Perplexity Web MCP & CLIのロゴ

Perplexity Web MCP & CLI

コミュニティ
jacob-bd

MCP server and Anthropic API-compatible interface for Perplexity AI web interface

公開者jacob-bd
リポジトリperplexity-web-mcp
言語Python
フォーク
31
スター
187
利用可能なツール
0
通信方式stdio
カテゴリ
ライセンスMIT
リンク
  • ツールをAIワークフローに接続

    Perplexity Web MCP & CLIは、対応するAIクライアントやAIエージェントから利用できるMCP機能を提供します。

  • 0個の利用可能なツール

    呼び出し可能なアクションを以下で確認できます。サーバーから提供されている場合は、名前や説明も表示されます。

  • コピーして使える設定

    セットアップ用の設定例を使って、お好みのMCPクライアントにこのサーバーを設定できます。

  • オープンソースの注目度

    リンク先のリポジトリには187件のスターと31件のフォークがあります。

Perplexity Web MCP & CLI

PyPI version PyPI downloads Total downloads Python License

MCP server, CLI, and API-compatible interface for Perplexity AI's web interface.

Use your Perplexity Pro/Max subscription to access premium models (Sonar 2, GPT-5.6 Terra, GPT-5.6 Sol, Gemini 3.1 Pro, Claude Sonnet 5, Claude Opus 4.8, GLM 5.2, Kimi K2.6, Grok 4.5, and Nemotron 3 Ultra) from the terminal, through MCP tools, or as an API endpoint.

Features

  • CLI: Query Perplexity models directly from the terminal (pwm ask, pwm council, pwm research, pwm chat)
  • MCP Server: MCP tools for AI agents with citations, rate limit checking, and multi-turn context
  • API Server: Drop-in Anthropic Messages API and OpenAI Chat Completions API
  • 10 Models: Sonar 2, GPT-5.6 Terra, GPT-5.6 Sol, Gemini 3.1 Pro, Claude Sonnet 5, Claude Opus 4.8, GLM 5.2, Kimi K2.6, Grok 4.5, and Nemotron 3 Ultra
  • Thinking Mode: Extended thinking support for all compatible models
  • Deep Research: Full support for Perplexity's Deep Research mode
  • Multi-Turn Conversations: State-preserved threaded conversations for both MCP and CLI REPL
  • Model Council: Query multiple models in parallel and get a synthesized consensus
  • Setup & Skill Management: Auto-configure MCP for Claude Code, Cursor, Windsurf, Gemini CLI, Codex, Cline, Antigravity; install Agent Skills across 9 platforms
  • Doctor: Diagnose installation, auth, config, rate limits, and skill status

Vibe Coding Alert

Full transparency: this project was built by a non-developer using AI coding assistants. If you're an experienced Python developer, you might look at this codebase and wince. That's okay.

The goal here was to learn — both about building CLI tools in Python and about how modern web applications work under the hood. The code works, but it's very much a learning project released solely for the purpose of research and education, not a polished product.

[!WARNING] Unofficial & Unsupported — This project is not affiliated with, endorsed by, or supported by Perplexity AI. It interacts with Perplexity's web interface through unofficial, undocumented methods that may break at any time without notice if Perplexity changes their internal APIs or RPCs. Use at your own risk. The author(s) accept no responsibility for any consequences to your Perplexity account, including but not limited to rate limiting, suspension, or termination. This project is released strictly for educational and research purposes only.

If you know better, teach us. PRs, issues, and architectural advice are all welcome. This is open source specifically because human expertise is irreplaceable.


Installation

From PyPI (recommended)

Using uv:

bash
uv tool install perplexity-web-mcp-cli

Using pipx:

bash
pipx install perplexity-web-mcp-cli

Using pip:

bash
pip install perplexity-web-mcp-cli

Note: Requires Python 3.10-3.13.

From source (for development)

bash
git clone https://github.com/jacob-bd/perplexity-web-mcp.git
cd perplexity-web-mcp
uv venv && source .venv/bin/activate
uv pip install -e .

Upgrading

bash
pip install --upgrade perplexity-web-mcp-cli

After upgrading, restart your MCP client (Claude Code, Cursor, etc.) to reload the server.


Quick Start

bash
# 1. Authenticate
pwm login

# 2. Ask a question
pwm ask "What is quantum computing?"

# 3. Deep research
pwm research "agentic AI trends 2026"

# 4. Check your remaining quotas
pwm usage

# 5. Set up MCP for your AI tools
pwm setup add all           # Interactive setup for all detected tools
pwm setup add cursor        # Or add individually

# 6. Install the Agent Skill
pwm skill install claude-code

# 7. Diagnose any issues
pwm doctor

CLI Reference

Querying

Ask Perplexity a question. By default, Perplexity auto-selects the best model.

bash
pwm ask "What is quantum computing?"

Choose a specific model with -m (see Models for the full list):

bash
pwm ask "Compare React and Vue" -m gpt56_terra
bash
pwm ask "Explain the attention mechanism" -m claude_sonnet

Enable extended thinking with -t for deeper reasoning (available on models with Toggle thinking):

bash
pwm ask "Prove that the square root of 2 is irrational" -m claude_sonnet --thinking

Focus on specific sources with -s to control where Perplexity searches:

bash
# Search only academic papers and scholarly articles
pwm ask "transformer architecture improvements 2025" -s academic

# Search only social media (Reddit, Twitter, etc.)
pwm ask "best mechanical keyboard 2026" -s social

# Search SEC EDGAR financial filings
pwm ask "Apple revenue Q4 2025" -s finance

# Search all source types at once
pwm ask "latest AI news" -s all

# Search an account connector source, when your Perplexity account exposes one
pwm connectors list
pwm ask "recent funding for Stripe" -s pitchbook_mcp_cashmere

Output options:

bash
# JSON output (for piping to other tools)
pwm ask "What is Rust?" --json

# Suppress citation URLs (answer text only)
pwm ask "What is Rust?" --no-citations

Combine flags for full control:

bash
pwm ask "recent advances in protein folding" -m gemini_pro -s academic --json

Deep Research

Run Perplexity's Deep Research mode for in-depth reports with extensive sources. Uses a separate monthly quota.

bash
pwm research "agentic AI trends 2026"
bash
pwm research "climate policy impact on renewable energy" -s academic
bash
pwm research "NVIDIA competitive landscape" -s finance --json

Model Council

Query multiple models in parallel and get a synthesized consensus. Each model costs 1 Pro Search. Default synthesis uses Sonar 2 (also 1 Pro Search).

bash
# Default: GPT-5.6 Terra, Claude Sonnet, Gemini Pro + Sonar 2 synthesis (4 Pro Searches)
pwm council "What are best practices for microservices?"
bash
# Custom model selection
pwm council "Compare Rust and Go" -m gpt56_terra,claude_sonnet
bash
# Enable extended thinking for all council models
pwm council "Prove the Pythagorean theorem" --thinking
bash
# Skip synthesis, output as JSON
pwm council "React vs Vue" --no-synthesis --json

Authentication

bash
pwm login                                    # Interactive login (email + OTP)
pwm login --check                            # Check if authenticated
pwm login --email user@example.com           # Send verification code (non-interactive)
pwm login --email user@example.com --code 123456  # Complete auth with code
pwm login --email user@example.com --code 123456 --totp-code 654321  # Account with TOTP enabled

Set PWM_SAVE_TO_LIBRARY=1 to save shared CLI and MCP queries to the Perplexity thread library. Queries are incognito by default.

Usage & Limits

bash
pwm usage                  # Check remaining rate limits
pwm usage --refresh        # Force-refresh from Perplexity servers

Hack

Seamlessly launch external AI tools connected to the Perplexity API server. This automatically starts the local pwm api server in the background, sets the required environment variables, and launches the tool.

bash
pwm hack claude            # Launch Claude Code
pwm hack claude -m gpt56_terra   # Launch Claude Code with a specific model

MCP Setup

bash
pwm setup list             # Show supported tools and MCP configuration status
pwm setup add all          # Interactive: detect and configure all tools
pwm setup add claude-code  # Add MCP server to Claude Code
pwm setup add cursor       # Add MCP server to Cursor
pwm setup add codex        # Add MCP server to Codex CLI
pwm setup add gemini       # Add MCP server to Gemini CLI
pwm setup add windsurf     # Add MCP server to Windsurf
pwm setup add cline        # Add MCP server to Cline CLI
pwm setup add antigravity  # Add MCP server to Antigravity
pwm setup remove all       # Remove from all configured tools
pwm setup remove cursor    # Remove MCP server from a tool

For clients that support HTTP/SSE, or when multiple sessions should share one MCP process, run the local daemon:

bash
pwm serve-mcp --transport streamable-http  # Start HTTP MCP on 127.0.0.1:8000/mcp
pwm serve-mcp --status                # Check daemon status
pwm serve-mcp --stop                  # Stop the daemon
pwm setup add codex --http            # Configure Codex for Streamable HTTP
pwm serve-mcp --transport sse         # Start the legacy SSE transport

The HTTP transports bind to loopback by default. Keep the daemon on a loopback address unless you put an authenticated reverse proxy in front of it.

Skill Management

bash
pwm skill list                            # Show installation status per platform
pwm skill install claude-code             # Install skill for Claude Code
pwm skill install cursor --level project  # Install at project level
pwm skill uninstall gemini-cli            # Remove skill
pwm skill update                          # Update all outdated skills
pwm skill show                            # Display skill content

Doctor

bash
pwm doctor                 # Diagnose installation, auth, config, limits
pwm doctor -v              # Verbose (includes security + per-platform skill status)

AI Documentation

bash
pwm --ai                   # Print comprehensive AI-optimized reference

Models

CLI NameProviderThinkingNotes
autoPerplexityNoAuto-selects best model
sonarPerplexityNoSonar 2 (latest in-house; API id experimental)
deep_researchPerplexityNoMonthly quota, in-depth reports
gpt56_terraOpenAIToggleGPT-5.6 Terra
gpt56_solOpenAIToggleGPT-5.6 Sol (Max tier required)
grok45xAIToggleGrok 4.5
claude_sonnetAnthropicToggleClaude Sonnet 5
claude_opusAnthropicToggleClaude Opus 4.8 (Max tier required)
gemini_proGoogleAlwaysGemini 3.1 Pro
nemotronNVIDIAAlwaysNemotron 3 Ultra 550B
glm52Z.aiAlwaysGLM 5.2
kimi_k26MoonshotToggleKimi K2.6

Source Focus

Control where Perplexity searches using -s (CLI) or source_focus (MCP):

OptionDescriptionExample Use Case
webGeneral web search (default)News, general questions
academicAcademic papers, journalsResearch, citations, scientific topics
socialReddit, Twitter, forumsOpinions, recommendations, community sentiment
financeSEC EDGAR filingsCompany financials, regulatory filings
allWeb + Academic + Social combinedBroad coverage across all sources

Account Connector Sources

Accounts with Perplexity connectors may expose additional source IDs such as pitchbook_mcp_cashmere or cbinsights_mcp_cashmere. List IDs before using them:

bash
pwm connectors list
pwm ask "recent funding for Stripe" -s pitchbook_mcp_cashmere

MCP clients should call pplx_connectors() first, then pass the returned ID as source_focus.

Connector access inherits the authenticated Perplexity account's permissions and may expose private organization or cloud data to whichever local agent can call this tool. Unknown and unreported connector values fail instead of falling back to web search. Administrators can set PWM_CONNECTORS_ENABLED=0 to disable connector queries or set PWM_CONNECTOR_ALLOWLIST to a comma-separated list of exact connector IDs. When these variables are unset, reported connectors remain available for backward compatibility. See Account Connector Sources for the full trust-boundary guidance.


MCP Server

Setup

The easiest way to configure MCP:

bash
pwm setup add claude-code

Or configure manually for any MCP client:

Claude Code CLI:

bash
claude mcp add perplexity pwm-mcp

Claude Desktop — Download the .mcpb extension from the latest release and open it with Claude Desktop. Or configure manually:

json
{
  "mcpServers": {
    "perplexity": {
      "command": "pwm-mcp"
    }
  }
}

Cursor (~/.cursor/mcp.json):

json
{
  "mcpServers": {
    "perplexity": {
      "command": "pwm-mcp"
    }
  }
}

Available MCP Tools

Query tools:

ToolDescription
pplx_queryFlexible: model selection + thinking toggle
pplx_askQuick Q&A (auto-selects best model)
pplx_deep_researchIn-depth reports with sources
pplx_sonarPerplexity Sonar 2 (1 Pro Search)
pplx_gpt56_terra / pplx_gpt56_terra_thinkingGPT-5.6 Terra
pplx_gpt56_sol / pplx_gpt56_sol_thinkingGPT-5.6 Sol (Max tier)
pplx_grok45 / pplx_grok45_thinkingGrok 4.5
pplx_claude_sonnet / pplx_claude_sonnet_thinkClaude Sonnet 5
pplx_claude_opus / pplx_claude_opus_thinkClaude Opus 4.8 (Max tier)
pplx_gemini_pro_thinkGemini 3.1 Pro (thinking always on)
pplx_nemotron_thinkingNemotron 3 Ultra (thinking always on)
pplx_glm52GLM 5.2 (thinking always on)
pplx_kimi_k26 / pplx_kimi_k26_thinkingKimi K2.6

Smart routing (1):

ToolDescription
pplx_smart_queryQuota-aware routing — auto-selects best model based on limits

Council (1):

ToolDescription
pplx_councilQuery multiple models in parallel with optional synthesis

Usage, connectors & auth tools (5):

ToolDescription
pplx_usageCheck remaining quotas
pplx_connectorsList connector source IDs
pplx_auth_statusCheck authentication status
pplx_auth_request_codeSend verification code to email
pplx_auth_completeComplete email and TOTP authentication

All query tools support source_focus: none, web, academic, social, finance, all, or a connector source ID returned by pplx_connectors().


API Server

Use Perplexity models through Anthropic or OpenAI compatible API endpoints.

Start the server

bash
pwm api

The server binds to 127.0.0.1 by default. A non-loopback --host or HOST value is rejected unless PWM_API_KEY (or the legacy ANTHROPIC_API_KEY) contains a non-empty secret. Remote use should also be protected by a trusted TLS reverse proxy and firewall rules because the built-in server serves plain HTTP. Clients may send the configured secret as x-api-key or Authorization: Bearer <secret>.

When an API key is configured, the same authentication applies to every API endpoint, including the /v1/responses WebSocket route. The server rejects unauthenticated WebSocket connections before accepting the connection.

Anthropic API (Claude Code)

bash
export ANTHROPIC_BASE_URL=http://localhost:8080
export ANTHROPIC_API_KEY=perplexity
claude --model gpt-5.6-terra

Alternatively, launch Claude Code seamlessly using the hack command, which automatically starts the API server and configures the environment for you:

bash
pwm hack claude

OpenAI API

bash
export OPENAI_BASE_URL=http://localhost:8080/v1
export OPENAI_API_KEY=anything

Codex CLI Integration

Codex CLI performs strict client-side model validation. By default, it will reject any model name that isn't a recognized OpenAI ChatGPT account model (e.g., rejecting sonar).

To bypass this client-side block and use arbitrary Perplexity models natively, start Codex with the --local-provider lmstudio flag (or --oss). This instructs Codex to treat the backend as a local proxy:

bash
export OPENAI_API_BASE=http://localhost:8080/v1
export OPENAI_API_KEY=dummy

codex -m sonar --local-provider lmstudio

Our server's MODEL_MAP will seamlessly intercept sonar (or any other mapped names like gemini-pro, nemotron, glm-5.2, claude-sonnet-5) and correctly route it to Perplexity's API. You can also create an alias in your shell to make this easier: alias codex-pplx="codex --local-provider lmstudio".

API Model Names

API NamePerplexity ModelThinking
perplexity-autoBest (auto-select)No
gpt-5.6-terraGPT-5.6 TerraToggle
gpt-5.6-solGPT-5.6 SolToggle
grok-4.5Grok 4.5Toggle
claude-sonnet-5Claude Sonnet 5Toggle
claude-opus-4-8Claude Opus 4.8Toggle
gemini-3.1-proGemini 3.1 ProAlways
glm-5.2 / glm52GLM 5.2Always
nemotron-3-ultra / nemotronNemotron 3 UltraAlways

Legacy aliases (claude-3-5-sonnet, claude-3-opus) are supported for compatibility.


Python API

python
from perplexity_web_mcp import Perplexity, ConversationConfig, Models

client = Perplexity(session_token="your_token")
conversation = client.create_conversation(
    ConversationConfig(model=Models.CLAUDE_45_SONNET)
)

conversation.ask("What is quantum computing?")
print(conversation.answer)

for result in conversation.search_results:
    print(f"Source: {result.url}")

# Follow-up (context preserved)
conversation.ask("Explain it simpler")
print(conversation.answer)

Subscription Tiers & Rate Limits

TierCostPro SearchDeep ResearchLabs
Free$03/day1/monthNo
Pro$20/moWeekly poolMonthly poolMonthly pool
Max$200/moWeekly poolMonthly poolMonthly pool

The MCP server checks quotas before each query. Use pwm usage or pplx_usage to check your limits.


Troubleshooting

Authentication Errors (403)

Session tokens last ~30 days. Re-authenticate when expired:

bash
pwm login

Non-interactive (for AI agents):

bash
pwm login --email your@email.com
bash
pwm login --email your@email.com --code 123456

Via MCP tools (for AI agents without shell):

  1. Call pplx_auth_request_code(email="your@email.com")
  2. Check email for 6-digit code
  3. Call pplx_auth_complete(email="your@email.com", code="123456")

If the tool returns TOTP_REQUIRED, call it again with pplx_auth_complete(email="your@email.com", totp_code="654321").

Blank or Truncated Answers

Perplexity can return answer chunks without the older text field. If pwm ask returns No answer received or only part of the answer, upgrade to the latest patch release:

bash
uv tool upgrade perplexity-web-mcp-cli
pwm --version

Diagnose Issues

bash
pwm doctor

This checks installation, authentication, rate limits, MCP configuration, and skill installation -- with fix suggestions for every issue found.

Rate Limiting

  • CLI/MCP: Auto-checks quotas before each query, blocks if exhausted
  • API server: Enforces 5-second minimum between requests

Agent Skill

This project includes a portable Agent Skill (SKILL.md) that teaches AI agents how to use the CLI and MCP tools. Install it for your platform:

bash
pwm skill install all              # Install for all detected tools
pwm skill install claude-code      # Or install individually
pwm skill install cursor
pwm skill install codex
pwm skill install gemini-cli
pwm skill install antigravity
pwm skill install cline
pwm skill install opencode
pwm skill install openclaw
pwm skill install alef-agent

The skill follows Anthropic's Agent Skills open standard and works across any compliant AI platform.


Credits

Originally forked from perplexity-webui-scraper by henrique-coder.

Support

If Perplexity Web MCP saves you time or money, you can help cover the AI bills that go into building and testing it. Any support is hugely appreciated. 🙏

License

MIT

インストール

TypingMind
{
  "mcpServers": {
    "perplexity-web-mcp": {
      "command": "pwm-mcp",
      "args": []
    }
  }
}

Perplexity Web MCP & CLIのMCPを複数のAIモデルで活用

TypingMindはワークスペース単位でMCPツールに接続します。そのため、一度Perplexity Web MCP & CLIに接続すれば、モデルごとに個別に設定することなく、TypingMind内のさまざまなAIモデルで利用できます。 このMCPは、デバイス上のTypingMind MCPコネクタを通じてローカルで動作します。

ローカルコネクタのセットアップガイド

MCPサーバーが、お使いのコンピューター上のローカルファイル、アプリ、非公開リソースにアクセスする必要がある場合は、この方法を使います。

1

MCP設定を開く

TypingMindで「設定」、「詳細設定」、「MCP」の順に進み、「コネクタを設定」を選択してください。

  1. ブラウザでTypingMindを開いてください。
  2. 設定アイコンをクリックしてください。
  3. 「詳細設定」に移動してください。
  4. 「MCP」セクションを開いてください。
  5. 「コネクタを設定」をクリックし、「このデバイス」を選択してください。
「このデバイス」が選択されたTypingMindのMCPコネクタ設定画面
2

コネクタのコマンドを実行

「このデバイス」を選択し、TypingMindからコマンドをコピーしてターミナルで実行してください。MCPの使用中は、プロセスを実行したままにしてください。

  1. TypingMindに表示されるセットアップコマンドをコピーしてください。
  2. macOSではターミナルを、WindowsではWindows Terminalを開いてください。
  3. コマンドを貼り付けて実行してください。
  4. ターミナルで続行の確認を求められた場合は、パッケージのインストールを承認してください。
  5. MCPツールの使用中は、ターミナルウィンドウを開いたまま、プロセスの実行を継続してください。
3

Perplexity Web MCP & CLIをサーバーとして追加

コネクタのステータスが「準備完了」になったら、「サーバーを編集」をクリックし、MCPサーバーの設定を貼り付けてください。

  1. コネクタのステータスが「準備完了」になるまでお待ちください。
  2. 「サーバーを編集」をクリックしてください。
  3. Perplexity Web MCP & CLIのMCPサーバー設定を貼り付けてください。
  4. サーバー一覧を保存してください。
  5. コネクタが引き続き使用可能か確認するには、更新してください。
稼働中のサーバーと「サーバーを編集」ボタンが表示されたTypingMindのMCP設定画面
{
  "mcpServers": {
    "perplexity-web-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

複数のモデルで同じ接続を使用

サーバー一覧を保存し、「プラグイン」を開いてPerplexity Web MCP & CLIのMCPツールを有効にしてください。その後、TypingMindで対応するAIモデルを選択し、チャットでツールを使うか、AIエージェントに割り当ててください。

  1. TypingMindの「プラグイン」ページを開いてください。
  2. Perplexity Web MCP & CLIのMCPツールを有効にしてください。
  3. チャットを開始し、使用するAIモデルを選択してください。
  4. MCPツールをチャットで使うか、AIエージェントに割り当ててください。
  5. MCPに再接続することなく、必要に応じて別のAIモデルに切り替えられます。
選択したAIモデルと有効なMCPツールを使用したTypingMindのチャット
Perplexity Web MCP & CLIを使ってこのタスクを手伝ってもらえますか?
Perplexity Web MCP & CLI
はい、読みました。
Perplexity Web MCP & CLIで調べた結果をお伝えします。

よくある質問

Perplexity Web MCP & CLI MCPサーバーは何に使いますか?

Perplexity Web MCP & CLIは、対応するAIクライアントを外部ツールやコンテキストに接続するためのMCPサーバーです。TypingMindでは、このMCPサーバーを一度追加するだけで、AIワークスペース内でそのツールを利用できるようになります。

TypingMindでPerplexity Web MCP & CLI MCPを複数のAIモデルと併用できますか?

はい。TypingMindはワークスペース単位でMCPツールに接続するため、モデルごとにMCPサーバーを設定する必要はありません。Claude、ChatGPT、Geminiや、TypingMindで設定したその他のAIモデルでPerplexity Web MCP & CLIを利用できます。

TypingMindでPerplexity Web MCP & CLI MCPを使うメリットは何ですか?

TypingMindは、複数のAIモデル、プロンプト、プラグイン、AIエージェント、APIキー、MCPツールを1つのワークスペースにまとめられる、LLMチャット向けの優れたフロントエンドです。Perplexity Web MCP & CLIを接続すると、TypingMindでチャットのワークフローを整理しながら、お好みのモデルでそのMCPツールを利用できます。

Perplexity Web MCP & CLI MCPをTypingMindに接続するにはどうすればよいですか?

Perplexity Web MCP & CLIはTypingMindのローカルMCPコネクタ経由で動作します。MCPサーバーがコンピューター上のローカルファイル、デスクトップアプリ、コマンドラインツール、プライベートリソースにアクセスする必要がある場合に最適です。

TypingMindでPerplexity Web MCP & CLI MCPのどのようなツールを利用できますか?

Perplexity Web MCP & CLIはMCP機能を提供しています。TypingMindのプラグインページで有効にすると、チャットで使用したり、AIエージェントに割り当てたりできます。

Perplexity Web MCP & CLI MCPを使うには、APIキーをTypingMindと共有する必要がありますか?

いいえ。TypingMindはローカルファーストの設計で、モデルプロバイダー、APIキー、プロンプト、MCP設定をご自身で管理できます。Perplexity Web MCP & CLIで認証が必要な場合は、接続の作成時に、そのMCPサーバーに必要なヘッダー、OAuth設定、またはローカル設定を追加してください。

関連するMCPサーバー

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇