CLI, MCP server, and API-compatible interface for Perplexity AI's web interface.
# Install
uv venv && uv pip install -e .
# Authenticate
pwm login
# Query from terminal
pwm ask "What is quantum computing?"
# Run MCP server
pwm-mcpsrc/perplexity_web_mcp/
├── __init__.py # Package exports
├── shared.py # Shared query logic (MODEL_MAP, ask(), used by CLI + MCP)
├── council.py # Model Council (parallel multi-model queries + synthesis)
├── core.py # Perplexity client, Conversation class
├── sessions.py # Multi-turn context persistence and thread management
├── models.py # Model definitions (GPT, Claude, Gemini, Grok, etc.)
├── config.py # ClientConfig, ConversationConfig
├── enums.py # CitationMode, SearchFocus, SourceFocus
├── http.py # HTTP client with retry/rate limiting
├── rate_limits.py # Rate limit checking via /rest/rate-limit/all
├── token_store.py # Token persistence (~/.config/perplexity-web-mcp/token)
├── data/ # Bundled Agent Skill (SKILL.md + references/)
├── cli/
│ ├── main.py # Unified CLI entry point (pwm)
│ ├── auth.py # Authentication flow
│ ├── setup.py # MCP server setup for AI tools
│ ├── skill.py # Agent Skill management
│ ├── doctor.py # Diagnostic checks
│ └── ai_doc.py # --ai flag documentation
├── mcp/
│ └── server.py # MCP server (imports from shared.py)
└── api/
└── server.py # Anthropic/OpenAI API compatibility
pwm ask "query" [-m MODEL] [-t] [-s SOURCE] # Query Perplexity
pwm chat [-m MODEL] [-t] [-s SOURCE] # Multi-turn interactive chat
pwm council "query" [-m MODELS] [-t] [-s SOURCE] # Model Council (multi-model)
pwm research "query" [-s SOURCE] # Deep research
pwm login [--check] [--email E --code C] # Authentication
pwm usage [--refresh] # Rate limits
pwm setup [list|add|remove] CLIENT # MCP config
pwm skill [list|install|uninstall] TOOL # Skill management
pwm doctor [-v] # Diagnostics
pwm --ai # AI reference docauto/sonar(Sonar 2, API idexperimental) /deep_researchgpt56_terra(+ thinking)gpt56_sol(+ thinking, Max)grok45(+ thinking)claude_sonnet/claude_opus(+ thinking)gemini_pro(always thinking)nemotron(always thinking)glm52(always thinking)kimi_k26(+ thinking)
# Install with dev dependencies
uv pip install -e .
# Run the default offline test suite
uv run --group tests pytest tests/ -v
# Deliberately run only live integration tests
uv run --group tests pytest tests/ -v -m integration --run-live-testsBased on perplexity-webui-scraper by henrique-coder.