
Perplexity MCP Server
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.
laodev1
Tools
perplexity_ask
Send a simple query to Perplexity AI
perplexity_chat
Generate a chat completion using Perplexity AI
README
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.
{
"name": "perplexity_chat",
"description": "Generate a chat completion using Perplexity AI",
"parameters": {
"model": "string (optional) - One of: llama-3.1-sonar-small-128k-online, llama-3.1-sonar-large-128k-online, llama-3.1-sonar-huge-128k-online",
"messages": "array of {role, content} objects - The conversation history",
"temperature": "number (optional) - Sampling temperature between 0-2"
}
}
2. perplexity_ask
Simplified single-query interface for quick questions.
{
"name": "perplexity_ask",
"description": "Send a simple query to Perplexity AI",
"parameters": {
"query": "string - The question or prompt to send",
"model": "string (optional) - One of: llama-3.1-sonar-small-128k-online, llama-3.1-sonar-large-128k-online, llama-3.1-sonar-huge-128k-online"
}
}
Installation
-
Clone the repository:
git clone https://github.com/yourusername/perplexity-mcp-server.git cd perplexity-mcp-server
-
Install dependencies:
npm install
-
Create
.env
file:PERPLEXITY_API_KEY=your-api-key-here
-
Build the project:
npm run build
Claude Desktop Configuration
To add this server to Claude Desktop, update your claude_desktop_config.json
:
{
"mcpServers": {
//more servers...
"perplexity": {
"command": "node",
"args": ["path\\to\\perplexity-mcp-server\\dist\\index.js"],
"env": {
"PERPLEXITY_API_KEY": "YOUR_PERPLEXITY_API_KEY"
}
}
//more servers...
}
}
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:
npm run dev
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
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
MCP Package Docs Server
Facilitates LLMs to efficiently access and fetch structured documentation for packages in Go, Python, and NPM, enhancing software development with multi-language support and performance optimization.
Claude Code MCP
An implementation of Claude Code as a Model Context Protocol server that enables using Claude's software engineering capabilities (code generation, editing, reviewing, and file operations) through the standardized MCP interface.
@kazuph/mcp-taskmanager
Model Context Protocol server for Task Management. This allows Claude Desktop (or any MCP client) to manage and execute tasks in a queue-based system.
Linear MCP Server
Enables interaction with Linear's API for managing issues, teams, and projects programmatically through the Model Context Protocol.
serper-search-scrape-mcp-server
This Serper MCP Server supports search and webpage scraping, and all the most recent parameters introduced by the Serper API, like location.
mermaid-mcp-server
A Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.