Skip to main content
Glama

MCP Perplexity Pro

index.ts1.61 kB
#!/usr/bin/env node import { createHTTPStreamingServer } from './http-streaming-server.js'; import { configSchema } from './types.js'; // Default port let PORT = 8125; // Parse command-line arguments for --port=XXXX for (let i = 2; i < process.argv.length; i++) { const arg = process.argv[i]; if (arg.startsWith('--port=')) { const value = parseInt(arg.split('=')[1], 10); if (!isNaN(value)) { PORT = value; } else { console.error('Invalid value for --port'); process.exit(1); } } } // Load configuration - try multiple sources for API key const apiKey = process.env.PERPLEXITY_API_KEY || process.env.API_KEY || process.env.PERPLEXITY_API_TOKEN || ''; const config = { api_key: apiKey, default_model: 'sonar-reasoning-pro', project_root: process.cwd(), storage_path: '.perplexity', }; // Debug API key - only log to stdout in debug mode, otherwise stderr const debugMode = process.env.MCP_DEBUG_MODE === 'true'; const debugLog = debugMode ? console.log : console.error; debugLog( `API key loaded: ${config.api_key ? 'YES (' + config.api_key.substring(0, 10) + '...)' : 'NO'}` ); // Validate configuration const validatedConfig = configSchema.parse(config); const app = createHTTPStreamingServer(validatedConfig); app.listen(PORT, () => { debugLog(`MCP Perplexity HTTP Streaming Server listening on port ${PORT}`); debugLog( `Claude Code can connect using: claude mcp add --transport http perplexity-http http://localhost:${PORT}` ); }); process.on('SIGINT', () => { debugLog('Shutting down HTTP streaming server...'); process.exit(0); });

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cfdude/mcp-perplexity-pro'

If you have feedback or need assistance with the MCP directory API, please join our Discord server