MCP Hub
Back to servers

Perplexity MCP Server (Python)

A Python port of the official Perplexity MCP server that enables web-grounded Q\&A, deep research, and step-by-step reasoning via Perplexity AI's models. It supports both STDIO and HTTP interfaces for seamless integration with tools like Claude Desktop and Cursor.

glama
Updated
Mar 30, 2026

Perplexity MCP Server — Python Port

Python conversion of the official perplexityai/modelcontextprotocol Node.js/TypeScript server.

File mapping

TypeScript (original)Python (this port)Notes
src/types.tstypes.pyDataclasses replace TS interfaces
src/validation.tsvalidation.pyPydantic models replace Zod schemas
src/logger.tslogger.pyDirect translation
src/server.tsserver.pyCore MCP tools + API logic
src/index.ts__main__.pySTDIO entry point
src/http.tshttp_server.pyHTTP entry point (FastAPI + uvicorn)

Dependencies

Node.jsPython
@modelcontextprotocol/sdkmcp
axios / undici (fetch)httpx
zodpydantic
express + corsfastapi + CORSMiddleware
Node.js built-insPython stdlib (asyncio, re, json, …)

Installation

pip install -e .

Usage

STDIO (for Claude Desktop, Cursor, VS Code…)

export PERPLEXITY_API_KEY=your_key_here
python -m perplexity_mcp
# or after pip install:
perplexity-mcp

Claude Desktop / Cursor mcpServers config:

{
  "mcpServers": {
    "perplexity": {
      "command": "perplexity-mcp",
      "env": { "PERPLEXITY_API_KEY": "your_key_here" }
    }
  }
}

HTTP server

export PERPLEXITY_API_KEY=your_key_here
python -m perplexity_mcp.http_server
# or after pip install:
perplexity-mcp-http

The server listens on http://0.0.0.0:8080/mcp by default.

Environment variables

VariableDescriptionDefault
PERPLEXITY_API_KEYPerplexity API key (required)
PERPLEXITY_BASE_URLCustom API base URLhttps://api.perplexity.ai
PERPLEXITY_TIMEOUT_MSRequest timeout in ms300000
PERPLEXITY_PROXYProxy URL
HTTPS_PROXY / HTTP_PROXYFallback proxy env vars
PERPLEXITY_LOG_LEVELDEBUG|INFO|WARN|ERRORERROR
PORTHTTP server port8080
BIND_ADDRESSHTTP bind address0.0.0.0
ALLOWED_ORIGINSCORS origins (comma-separated)*

Available tools

ToolModelDescription
perplexity_asksonar-proQuick Q&A with web grounding
perplexity_researchsonar-deep-researchDeep multi-source research (30s+)
perplexity_reasonsonar-reasoning-proStep-by-step reasoning + web
perplexity_searchSearch APIRaw ranked URL results

Reviews

No reviews yet

Sign in to write a review