Perplexity MCP Server
local-only server
The server can only run on the client’s local machine because it depends on local resources.
Integrations
Enables interaction with Perplexity AI's language models, providing capabilities to generate chat completions with full message history support and send simple queries for quick answers using various Llama-based models.
Perplexity MCP Server
Overview
The Perplexity MCP Server is a Node.js implementation of Anthropic's Model Context Protocol (MCP) that enables Claude to interact with Perplexity's language models. This server provides a secure bridge between Claude and Perplexity AI's capabilities, allowing for enhanced AI interactions through tool use.
Available Tools
The server currently implements two main tools:
1. perplexity_chat
Advanced chat completion tool with full message history support.
2. perplexity_ask
Simplified single-query interface for quick questions.
Installation
- Clone the repository:Copy
- Install dependencies:Copy
- Create
.env
file:Copy - Build the project:Copy
Claude Desktop Configuration
To add this server to Claude Desktop, update your claude_desktop_config.json
:
The configuration file is typically located at:
- Windows:
%APPDATA%/Claude/config/claude_desktop_config.json
- macOS:
~/Library/Application Support/Claude/config/claude_desktop_config.json
- Linux:
~/.config/Claude/config/claude_desktop_config.json
Development
Start the development server with automatic recompilation:
The server uses TypeScript and implements the MCP protocol using the @modelcontextprotocol/sdk
package.
Architecture
Core Components
- PerplexityServer Class
- Implements MCP server protocol
- Handles tool registration and execution
- Manages error handling and server lifecycle
- Tools System
- Modular tool definitions
- Type-safe tool handlers
- Structured input validation
Technical Details
- Built with TypeScript for type safety
- Uses
@modelcontextprotocol/sdk
for MCP implementation - Communicates via stdio transport
- Environment-based configuration
Error Handling
The server implements comprehensive error handling:
- API error reporting
- Invalid tool requests handling
- Connection error management
- Process signal handling
Dependencies
@modelcontextprotocol/sdk
: ^1.0.3dotenv
: ^16.4.7isomorphic-fetch
: ^3.0.0
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Security
- API keys are managed through environment variables
- Input validation for all tool parameters
- Error messages are sanitized before output
- Process isolation through MCP protocol
License
This project is licensed under the ISC License.
Troubleshooting
Common issues and solutions:
- Server Not Found
- Verify the path in
claude_desktop_config.json
is correct - Ensure the server is built (
npm run build
) - Check if Node.js is in your PATH
- Verify the path in
- Authentication Errors
- Verify your Perplexity API key in .env
- Check if the API key has the required permissions
- Tool Execution Errors
- Verify the tool parameters match the schema
- Check network connectivity
- Review server logs for detailed error messages
You must be authenticated.
A Node.js implementation that enables Claude to interact with Perplexity AI's language models through Anthropic's Model Context Protocol, providing tools for advanced chat completions and quick queries.
- Overview
- Available Tools
- Installation
- Claude Desktop Configuration
- Development
- Architecture
- Error Handling
- Dependencies
- Contributing
- Security
- License
- Troubleshooting