Provides AI-powered search, research, and reasoning capabilities through three specialized tools: perplexity_ask for general conversational AI, perplexity_research for deep research with citations, and perplexity_reason for advanced reasoning
MCP Perplexity Server
MCP server for Perplexity.ai that provides AI-powered search, research, and reasoning capabilities.
🚀 Features
Perplexity AI Integration: Three specialized tools for different use cases
perplexity_ask
: General conversational AI using sonar-pro modelperplexity_research
: Deep research with citations using sonar-deep-research modelperplexity_reason
: Advanced reasoning using sonar-reasoning-pro model
TypeScript: Full type safety with modern TypeScript patterns
HTTP Transport: RESTful API with Express.js server
Session Management: Stateful connections with proper session handling
Configuration Management: Environment-based configuration with validation
Error Handling: Comprehensive error handling and logging
Health Checks: Built-in health monitoring endpoints
Docker Support: Production-ready containerization
Development Tools: ESLint, Prettier, and testing setup
Production Ready: Optimized for scalability and security
📋 Prerequisites
Node.js 20+
npm or yarn
Docker (optional, for containerization)
🛠️ Quick Start
Option 1: Use the Project Generator (Recommended)
Generator Options:
--description <desc>
: Project description--author <name>
: Author name--target-dir <dir>
: Target directory (default: mcp-)--install-deps
: Install npm dependencies automatically--no-git
: Skip git repository initialization
Option 2: Manual Setup
2. Environment Configuration
Create a .env
file in the root directory:
3. Development
🏗️ Project Structure
🔧 Project Generator
This template includes powerful project generation tools to quickly create new MCP servers:
Features:
Automatic Name Conversion: Converts kebab-case names to all required formats (camelCase, PascalCase, etc.)
File Templating: Updates all files with the new project name and details
Git Integration: Optionally initializes a new git repository
Dependency Management: Can automatically install npm dependencies
Smart Copy Logic: Excludes development files and prevents infinite recursion
Usage Examples:
🔧 Architecture
Core Components
McpServerApp: Main application class that orchestrates the MCP server
Configuration: Environment-based configuration with type safety
Session Management: HTTP-based stateful sessions with cleanup
Transport Layer: StreamableHTTPServerTransport for MCP communication
Error Handling: Comprehensive error handling with proper HTTP responses
HTTP Endpoints
GET /health
- Health check endpointPOST /mcp
- Main MCP communication endpointGET /mcp
- Server-to-client notifications via SSEDELETE /mcp
- Session termination
🛠️ Customization Guide
Using Perplexity Tools
The server provides three Perplexity AI tools:
1. perplexity_ask
General conversational AI using the sonar-pro model.
2. perplexity_research
Deep research with citations using the sonar-deep-research model.
3. perplexity_reason
Advanced reasoning using the sonar-reasoning-pro model.
Adding New Tools
To add a new MCP tool, modify the createServer()
method in src/index.ts
:
Configuration Management
Add new configuration options in src/config/index.ts
:
Adding Middleware
Add Express middleware in the run()
method:
🐳 Docker Deployment
Build and Run
Docker Compose (Recommended)
Create a docker-compose.yml
:
Run with:
🔒 Security Best Practices
This template implements several security measures:
Input Validation: Zod schema validation for all tool parameters
Error Handling: Safe error responses without information leakage
Session Management: Proper session cleanup and validation
HTTP Security: Ready for security headers and CORS configuration
Environment Variables: Secure configuration management
Recommended Additional Security
📊 Monitoring and Logging
The template includes basic logging setup. For production, consider adding:
Structured Logging: Winston with JSON format
Metrics Collection: Prometheus metrics
Health Checks: Comprehensive health endpoints
APM Integration: Application Performance Monitoring
🧪 Testing
Writing Tests
Create test files in src/**/*.test.ts
:
🚀 Production Deployment
Environment Variables
Performance Optimization
Enable gzip compression
Implement proper caching headers
Use connection pooling for databases
Monitor memory usage and implement limits
Set up log rotation
Scaling Considerations
Load balancing across multiple instances
Database connection pooling
Session store externalization (Redis)
Horizontal pod autoscaling in Kubernetes
📚 References
🤝 Contributing
Fork the repository
Create a feature branch
Make your changes
Add tests for new functionality
Run the test suite
Submit a pull request
📝 License
This project is licensed under the MIT License - see the LICENSE file for details.
🆘 Support
For questions and support:
Check the MCP Documentation
Review existing issues
Create a new issue with detailed information
Happy coding! 🎉
This server cannot be installed
Provides AI-powered search, research, and reasoning capabilities through integration with Perplexity.ai, offering three specialized tools: general conversational AI, deep research with citations, and advanced reasoning.
Related MCP Servers
- AsecurityFlicenseAqualityThis server allows users to perform web searches using Perplexity AI, providing a tool for retrieving search results through a simple API interface.Last updated -11613
- -securityAlicense-qualityProvides access to Perplexity AI models through two tools: ask\_perplexity for expert programming assistance and chat\_perplexity for maintaining ongoing conversations with context preservation.Last updated -MIT License
- AsecurityAlicenseAqualityProvides AI assistants with enhanced reasoning capabilities through structured thinking, persistent knowledge graph memory, and intelligent tool orchestration for complex problem-solving.Last updated -203051MIT License
- -securityAlicense-qualityProvides specialized AI-powered comprehensive research and analysis capabilities by integrating with advanced deep research agents, offering unlimited queries with no rate limits and faster performance than comparable services.Last updated -13158MIT License