MCP server for Perplexity search
npm install mcp-perplexity-searchA Model Context Protocol (MCP) server for integrating Perplexity's AI
API with LLMs. This server provides advanced chat completion
capabilities with specialized prompt templates for various use cases.
- 🤖 Advanced chat completion using Perplexity's AI models
- 📝 Predefined prompt templates for common scenarios:
- Technical documentation generation
- Security best practices analysis
- Code review and improvements
- API documentation in structured format
- 🎯 Custom template support for specialized use cases
- 📊 Multiple output formats (text, markdown, JSON)
- 🔍 Optional source URL inclusion in responses
- ⚙️ Configurable model parameters (temperature, max tokens)
- 🚀 Support for various Perplexity models including Sonar and LLaMA
This server requires configuration through your MCP client. Here are
examples for different environments:
Add this to your Cline MCP settings:
``json`
{
"mcpServers": {
"mcp-perplexity-search": {
"command": "npx",
"args": ["-y", "mcp-perplexity-search"],
"env": {
"PERPLEXITY_API_KEY": "your-perplexity-api-key"
}
}
}
}
For WSL environments, add this to your Claude Desktop configuration:
`json`
{
"mcpServers": {
"mcp-perplexity-search": {
"command": "wsl.exe",
"args": [
"bash",
"-c",
"source ~/.nvm/nvm.sh && PERPLEXITY_API_KEY=your-perplexity-api-key /home/username/.nvm/versions/node/v20.12.1/bin/npx mcp-perplexity-search"
]
}
}
}
The server requires the following environment variable:
- PERPLEXITY_API_KEY: Your Perplexity API key (required)
The server implements a single MCP tool with configurable parameters:
Generate chat completions using the Perplexity API with support for
specialized prompt templates.
Parameters:
- messages (array, required): Array of message objects with:role
- (string): 'system', 'user', or 'assistant'content
- (string): The message contentprompt_template
- (string, optional): Predefined template to use:technical_docs
- : Technical documentation with code examplessecurity_practices
- : Security implementation guidelinescode_review
- : Code analysis and improvementsapi_docs
- : API documentation in JSON formatcustom_template
- (object, optional): Custom prompt template with:system
- (string): System message for assistant behaviourformat
- (string): Output format preferenceinclude_sources
- (boolean): Whether to include sourcesformat
- (string, optional): 'text', 'markdown', or 'json' (default:include_sources
'text')
- (boolean, optional): Include source URLs (default:model
false)
- (string, optional): Perplexity model to use (default:temperature
'sonar')
- (number, optional): Output randomness (0-1, default:max_tokens
0.7)
- (number, optional): Maximum response length
(default: 1024)
1. Clone the repository
2. Install dependencies:
`bash`
pnpm install
3. Build the project:
`bash`
pnpm build
4. Run in development mode:
`bash`
pnpm dev
The project uses changesets for version management. To publish:
1. Create a changeset:
`bash`
pnpm changeset
2. Version the package:
`bash`
pnpm changeset version
3. Publish to npm:
`bash``
pnpm release
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see the LICENSE file for details.
- Built on the
Model Context Protocol
- Powered by
Perplexity SONAR