An MCP (Model Context Protocol) server implementation that integrates with Perplexity's AI-powered internet search API. This server enables AI assistants to perform internet searches and receive AI-enhanced answers with source citations.
- Internet search capabilities with AI-powered answers
- Source citations included with responses
- Optional domain filtering for search results
- Configurable API parameters
- Comprehensive logging system
- MCP protocol compliance
- Command line interface
pnpm install
The server can be configured through command line arguments or environment variables:
--api-key <key>
- Perplexity API key-h, --help
- Display help information
PERPLEXITY_API_KEY
- Perplexity API key (if not provided via command line)
To use this server with Claude Desktop, add the following to your Claude Desktop configuration file (usually located at ~/.claude-desktop/config.json
):
{
"mcpServers": {
"perplexity": {
"command": "node",
"args": [
"/path/to/your/dev/mcp-perplexity/dist/stdio-server.js",
"--api-key",
"your-perplexity-api-key"
]
}
}
}
Replace /path/to/your/dev/mcp-perplexity
with the actual path to your local development directory, and your-perplexity-api-key
with your actual Perplexity API key.
pnpm start
Or with direct API key:
pnpm start --api-key YOUR_API_KEY_HERE
The server exposes a single tool named perplexity_search
with the following input schema:
{
messages: {
role: 'system' | 'user',
content: string
}[],
searchDomainFilter?: string[] // Optional list of domains to restrict search results
}
Logs can be accessed through the MCP protocol at the resource URI logs://current
.
/src
/server
- Core server implementation/types
- TypeScript type definitionsindex.ts
- Main exportsstdio-server.ts
- Command line interface
pnpm build
pnpm test
Default configurations can be found in src/types/Constants.ts
:
- Default Model: llama-3.1-sonar-small-128k-online
- Default Temperature: 0.2
- Default Top P: 0.9
- Maximum Search Domains: 3
- Request Timeout: 30 seconds
The server implements comprehensive error handling:
- Input validation using Zod schemas
- API error handling with retry logic
- Clear error messages in MCP responses
- Detailed logging of all operations
- Fork the repository
- Create your feature branch:
git checkout -b feature/my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin feature/my-new-feature
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
Martin Bechard martin.bechard@DevConsult.ca
- Uses the Perplexity API for AI-powered internet search
- Built with the Anthropic MCP SDK