This MCP server provides web search capabilities through Perplexity's API, offering automatic model selection based on your query intent. It analyzes what you're asking for and chooses the most appropriate Perplexity model to deliver better search results.
Clone the repository:
git clone https://github.com/RossH121/perplexity-mcp.git
cd perplexity-mcp
Install dependencies:
npm install
Build the server:
npm run build
Get your Perplexity API key from Perplexity's settings page
Add the server to Claude's config file at ~/Library/Application Support/Claude/claude_desktop_config.json
:
{
"mcpServers": {
"perplexity-server": {
"command": "node",
"args": [
"/absolute/path/to/perplexity-mcp/build/index.js"
],
"env": {
"PERPLEXITY_API_KEY": "your-api-key-here",
"PERPLEXITY_MODEL": "sonar"
}
}
}
}
Be sure to replace /absolute/path/to
with the actual path to where you cloned the repository.
The server supports automatic model selection based on query intent, but you can specify a default model using the PERPLEXITY_MODEL
environment variable:
sonar-deep-research
- For extensive research and expert-level analysissonar-reasoning-pro
- For advanced logical reasoning and complex problem-solvingsonar-reasoning
- For reasoning tasks with balanced performancesonar-pro
- General-purpose model with excellent search capabilitiessonar
- Fast and efficient for straightforward queriesFor current model pricing and availability, visit: Perplexity Pricing
After configuring the server and restarting Claude, simply ask questions that require web search:
If Claude doesn't automatically use the search tool, try prepending "Search the web" to your prompt.
The server automatically selects the most appropriate Perplexity model based on your query:
Each search response includes information about which model was used and why.
You can customize your search experience by allowing or blocking specific domains:
Note: Perplexity API supports up to 3 domains total with priority given to allowed domains.
Limit search results to a specific time window:
This is particularly useful for time-sensitive queries like current events.
Manually control which model is used:
Example workflow:
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "perplexity-server" '{"command":"node","args":["/absolute/path/to/perplexity-mcp/build/index.js"],"env":{"PERPLEXITY_API_KEY":"your-api-key-here","PERPLEXITY_MODEL":"sonar"}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"perplexity-server": {
"command": "node",
"args": [
"/absolute/path/to/perplexity-mcp/build/index.js"
],
"env": {
"PERPLEXITY_API_KEY": "your-api-key-here",
"PERPLEXITY_MODEL": "sonar"
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"perplexity-server": {
"command": "node",
"args": [
"/absolute/path/to/perplexity-mcp/build/index.js"
],
"env": {
"PERPLEXITY_API_KEY": "your-api-key-here",
"PERPLEXITY_MODEL": "sonar"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect