An MCP server implementation that provides access to Perplexity's Sonar models through OpenRouter.ai, offering AI assistants real-time web search, reasoning, and research capabilities.
This implementation uses the OpenRouter API endpoint to access Perplexity's models, providing unified access alongside other AI models available on OpenRouter.
General-purpose conversational AI with real-time web search using the perplexity/sonar-pro model via OpenRouter. Great for quick questions and everyday searches.
Deep, comprehensive research using the perplexity/sonar-deep-research model via OpenRouter. Ideal for thorough analysis and detailed reports.
Advanced reasoning and problem-solving using the perplexity/sonar-reasoning-pro model via OpenRouter. Perfect for complex analytical tasks.
Direct web search using the Perplexity Search API. Returns ranked search results with metadata, perfect for finding current information.
Note: This tool uses the direct Perplexity API endpoint (not OpenRouter) as OpenRouter does not currently support the Perplexity Search API. You'll need a separate PERPLEXITY_API_KEY to use this tool.
- Get your OpenRouter API Key from OpenRouter
- Set it as an environment variable:
OPENROUTER_API_KEY=your_key_here - (Optional) If you want to use the
perplexity_searchtool, get a Perplexity API Key from the API Portal and set:PERPLEXITY_API_KEY=your_key_here - (Optional) Set a timeout for requests:
OPENROUTER_TIMEOUT_MS=600000. The default is 5 minutes (300000ms). - (Optional) Set custom site identification:
OPENROUTER_SITE_URL=your_site_urlandOPENROUTER_SITE_NAME=your_site_name
Add to your claude.json or MCP configuration:
"mcpServers": {
"perplexity-openrouter": {
"type": "stdio",
"command": "node",
"args": ["/path/to/dist/index.js"],
"env": {
"OPENROUTER_API_KEY": "your_openrouter_key_here",
"OPENROUTER_TIMEOUT_MS": "300000",
"OPENROUTER_SITE_URL": "https://your-site-url.com",
"OPENROUTER_SITE_NAME": "Your Site Name"
}
}
}Add to your mcp.json:
{
"mcpServers": {
"perplexity-openrouter": {
"command": "node",
"args": ["/path/to/dist/index.js"],
"env": {
"OPENROUTER_API_KEY": "your_openrouter_key_here",
"OPENROUTER_TIMEOUT_MS": "300000"
}
}
}
}Add to your claude_desktop_config.json:
{
"mcpServers": {
"perplexity-openrouter": {
"command": "node",
"args": ["/path/to/dist/index.js"],
"env": {
"OPENROUTER_API_KEY": "your_openrouter_key_here",
"OPENROUTER_TIMEOUT_MS": "300000"
}
}
}
}To run the server locally:
- Clone this repository
- Install dependencies:
npm install - Build the project:
npm run build - Run with environment variables:
OPENROUTER_API_KEY=your_key node dist/index.js- API Key Issues: Ensure
OPENROUTER_API_KEYis set correctly - Connection Errors: Check your internet connection and API key validity at OpenRouter
- Tool Not Found: Make sure the project is built (
npm run build) and the path todist/index.jsis correct - Timeout Errors: For very long research queries, set
OPENROUTER_TIMEOUT_MSto a higher value (in milliseconds) - perplexity_search tool errors: This tool requires a separate
PERPLEXITY_API_KEYas it uses the direct Perplexity API
Using OpenRouter provides several benefits:
- Unified API for multiple AI models
- Automatic fallback to other providers
- Cost-effective routing
- Access to multiple Perplexity models and other AI models through a single API
- Built-in monitoring and usage tracking
For more information, visit OpenRouter.ai.