Skip to main content
Glama
Hanato238

Perplexity API MCP Server

by Hanato238

Perplexity APIプラットフォーム MCPサーバー

Install in Cursor

Install in VS Code

Add to Kiro

npm version

Perplexity APIプラットフォームの公式MCPサーバー実装です。SonarモデルとSearch APIを通じて、AIアシスタントにリアルタイムのウェブ検索、推論、リサーチ機能を提供します。

利用可能なツール

perplexity_search

Perplexity Search APIを使用した直接的なウェブ検索。メタデータ付きのランク付けされた検索結果を返し、最新情報の検索に最適です。

perplexity_ask

sonar-proモデルを使用した、リアルタイムウェブ検索対応の汎用会話型AI。簡単な質問や日常的な検索に最適です。

perplexity_research

sonar-deep-researchモデルを使用した、深く包括的なリサーチ。徹底的な分析や詳細なレポート作成に最適です。

perplexity_reason

sonar-reasoning-proモデルを使用した高度な推論と問題解決。複雑な分析タスクに最適です。

[!TIP] perplexity_reasonおよびperplexity_researchのオプションパラメータとしてstrip_thinkingが利用可能です。

trueに設定すると、レスポンスから<think>...</think>タグが削除され、コンテキストトークンを節約できます。デフォルトはfalseです。

設定

APIキーの取得

  1. APIポータルからPerplexity APIキーを取得します。

  2. 以下の設定内のyour_key_hereをAPIキーに置き換えます。

  3. (オプション) タイムアウトの設定: PERPLEXITY_TIMEOUT_MS=600000 (デフォルト: 5分)

  4. (オプション) カスタムベースURLの設定: PERPLEXITY_BASE_URL=https://your-custom-url.com (デフォルト: https://api.perplexity.ai)

  5. (オプション) ログレベルの設定: PERPLEXITY_LOG_LEVEL=DEBUG|INFO|WARN|ERROR (デフォルト: ERROR)

Claude Code

claude mcp add perplexity --env PERPLEXITY_API_KEY="your_key_here" -- npx -y @perplexity-ai/mcp-server

またはプラグイン経由でインストール:

export PERPLEXITY_API_KEY="your_key_here"
claude
# Then run: /plugin marketplace add perplexityai/modelcontextprotocol
# Then run: /plugin install perplexity

Codex

codex mcp add perplexity --env PERPLEXITY_API_KEY="your_key_here" -- npx -y @perplexity-ai/mcp-server

Cursor、Claude Desktop、Kiro、Windsurf、およびVS Code

ほとんどのクライアントは、クライアント設定内の同じmcpServersラッパーを使用して手動で設定できます(Cursorの例を参照)。クライアントのスキーマが異なる場合は、そのドキュメントで正確なラッパー形式を確認してください。

手動セットアップの場合、これらのクライアントはすべて同じmcpServers構造を使用します:

クライアント

設定ファイル

Cursor

~/.cursor/mcp.json

Claude Desktop

claude_desktop_config.json

Kiro

.kiro/settings/mcp.json

Windsurf

~/.codeium/windsurf/mcp_config.json

VS Code

.vscode/mcp.json

{
  "mcpServers": {
    "perplexity": {
      "command": "npx",
      "args": ["-y", "@perplexity-ai/mcp-server"],
      "env": {
        "PERPLEXITY_API_KEY": "your_key_here"
      }
    }
  }
}

プロキシ設定(企業ネットワーク向け)

職場でこのサーバーを実行する場合(特に企業のファイアウォールやプロキシの背後にある場合)、インターネットトラフィックをネットワークのプロキシ経由で送信する方法を指定する必要があるかもしれません。以下の手順に従ってください。

1. プロキシの詳細情報を取得する

  • IT部門にHTTPSプロキシのアドレスとポートを確認してください。

  • ユーザー名とパスワードが必要な場合もあります。

2. プロキシ環境変数を設定する

Perplexity MCPにとって最も簡単で信頼性の高い方法は、PERPLEXITY_PROXYを使用することです。例:

export PERPLEXITY_PROXY=https://your-proxy-host:8080

プロキシにユーザー名とパスワードが必要な場合は、以下を使用します:

export PERPLEXITY_PROXY=https://username:password@your-proxy-host:8080

3. 代替案: 標準環境変数

標準の変数を使用したい場合は、HTTPS_PROXYおよびHTTP_PROXYをサポートしています。

[!NOTE] サーバーはPERPLEXITY_PROXY → HTTPS_PROXY → HTTP_PROXYの順序でプロキシ設定を確認します。いずれも設定されていない場合は、直接インターネットに接続します。 URLにはhttps://を含める必要があります。一般的なポートは8080、3128、80です。

HTTPサーバーのデプロイ

クラウドや共有環境へのデプロイには、サーバーをHTTPモードで実行します。

環境変数

変数

説明

デフォルト

PERPLEXITY_API_KEY

Perplexity APIキー

必須

PERPLEXITY_BASE_URL

APIリクエスト用のカスタムベースURL

https://api.perplexity.ai

PORT

HTTPサーバーポート

8080

BIND_ADDRESS

バインドするネットワークインターフェース

0.0.0.0

ALLOWED_ORIGINS

CORSオリジン(カンマ区切り)

*

Docker

docker build -t perplexity-mcp-server .
docker run -p 8080:8080 -e PERPLEXITY_API_KEY=your_key_here perplexity-mcp-server

Node.js

export PERPLEXITY_API_KEY=your_key_here
npm install && npm run build && npm run start:http

サーバーにはhttp://localhost:8080/mcpからアクセス可能になります。

トラブルシューティング

  • APIキーの問題: PERPLEXITY_API_KEYが正しく設定されていることを確認してください。

  • 接続エラー: インターネット接続とAPIキーの有効性を確認してください。

  • ツールが見つからない: パッケージがインストールされており、コマンドパスが正しいことを確認してください。

  • タイムアウトエラー: 長いリサーチクエリの場合は、PERPLEXITY_TIMEOUT_MSをより高い値に設定してください。

  • プロキシの問題: PERPLEXITY_PROXYまたはHTTPS_PROXYの設定を確認し、api.perplexity.aiがファイアウォールでブロックされていないことを確認してください。

  • EOF / Initializeエラー: 一部の厳格なMCPクライアントは、npxがインストールメッセージをstdoutに書き込むために失敗することがあります。この出力を抑制するには、npx -yの代わりにnpx -yqを使用してください。

サポートについては、community.perplexity.aiにアクセスするか、Issueを報告してください。


Available Tools

4 tools
perplexity_askAsk PerplexityA
Read-only

Answer a question using web-grounded AI (Sonar Pro model). Best for: quick factual questions, summaries, explanations, and general Q&A. Returns a text response with numbered citations. Fastest and cheapest option. Supports filtering by recency (hour/day/week/month/year), domain restrictions, and search context size. For in-depth multi-source research, use perplexity_research instead. For step-by-step reasoning and analysis, use perplexity_reason instead.

ParametersJSON Schema
NameRequiredDescriptionDefault
messagesYesArray of conversation messages
search_recency_filterNoFilter search results by recency. Use 'hour' for very recent news, 'day' for today's updates, 'week' for this week, etc.
search_domain_filterNoRestrict search results to specific domains (e.g., ['wikipedia.org', 'arxiv.org']). Use '-' prefix for exclusion (e.g., ['-reddit.com']).
search_context_sizeNoControls how much web context is retrieved. 'low' (default) is fastest, 'high' provides more comprehensive results.

Output Schema

ParametersJSON Schema
NameRequiredDescription
responseYesAI-generated text response with numbered citation references

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations indicate read-only, open-world, non-destructive behavior. The description adds context beyond annotations: returns numbered citations, supports specific filter types, and notes speed/cost trade-offs. It does not contradict annotations, and the added behavioral details are valuable for expectation-setting.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Every sentence earns its place: purpose, use cases, output format, performance, filters, and alternatives. It is front-loaded and clearly structured, with no wasted words despite covering multiple facets.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity, the presence of an output schema, and rich annotations, the description covers all essential aspects: operation, output, configuration, and tool differentiation. It is fully sufficient for an agent to select and invoke the tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the parameter semantics are already documented. The description restates filter types (recency, domain, context size) but does not meaningfully enrich beyond the schema's own descriptions. Baseline 3 is appropriate because the schema carries the burden.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource: 'Answer a question using web-grounded AI (Sonar Pro model).' It clearly contrasts with sibling tools by naming perplexity_research and perplexity_reason, making the tool's specific role unmistakable.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides explicit 'Best for' scenarios (quick factual questions, summaries, explanations, general Q&A), performance expectations ('Fastest and cheapest'), and direct alternatives ('For in-depth multi-source research, use perplexity_research instead'). This gives agents clear when-to-use and when-not-to-use guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

perplexity_reasonAdvanced ReasoningA
Read-only

Analyze a question using step-by-step reasoning with web grounding (Sonar Reasoning Pro model). Best for: math, logic, comparisons, complex arguments, and tasks requiring chain-of-thought. Returns a reasoned response with numbered citations. Supports filtering by recency (hour/day/week/month/year), domain restrictions, and search context size. For quick factual questions, use perplexity_ask instead. For comprehensive multi-source research, use perplexity_research instead.

ParametersJSON Schema
NameRequiredDescriptionDefault
messagesYesArray of conversation messages
strip_thinkingNoIf true, removes <think>...</think> tags and their content from the response to save context tokens. Default is false.
search_recency_filterNoFilter search results by recency. Use 'hour' for very recent news, 'day' for today's updates, 'week' for this week, etc.
search_domain_filterNoRestrict search results to specific domains (e.g., ['wikipedia.org', 'arxiv.org']). Use '-' prefix for exclusion (e.g., ['-reddit.com']).
search_context_sizeNoControls how much web context is retrieved. 'low' (default) is fastest, 'high' provides more comprehensive results.

Output Schema

ParametersJSON Schema
NameRequiredDescription
responseYesAI-generated text response with numbered citation references

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true and destructiveHint=false, indicating a safe read operation. The description adds useful behavioral context beyond annotations, such as the reasoning model ('Sonar Reasoning Pro model'), the step-by-step nature of the analysis, and the presence of numbered citations in the output. These details help the agent anticipate response style and value. However, it doesn't explicitly mention potential latency or token usage, which could be relevant for a reasoning-heavy tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and well-structured, with four sentences covering purpose, usage cases, output features, and alternatives. It is front-loaded with the core function and uses no filler. Every sentence adds valuable information, making the description efficient and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (5 params, output schema, annotations), the description is complete: it covers what the tool does, when to use it, when not to use it, and what to expect in the response. The output schema exists, so return values need not be described. The combination of annotations, schema, and description provides a comprehensive picture.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with all 5 parameters thoroughly documented in the schema. The description mentions 'Supports filtering by recency (hour/day/week/month/year), domain restrictions, and search context size,' which echoes schema properties without adding new semantic depth. It does not explain parameter interactions or provide extra context beyond the schema, so a baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's function: 'Analyze a question using step-by-step reasoning with web grounding (Sonar Reasoning Pro model).' It distinguishes itself from siblings by specifying its niche: 'Best for: math, logic, comparisons, complex arguments, and tasks requiring chain-of-thought.' It also notes the return format: 'Returns a reasoned response with numbered citations.' This is a specific verb+resource+scope with clear differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit usage guidance, stating 'For quick factual questions, use perplexity_ask instead. For comprehensive multi-source research, use perplexity_research instead.' It also lists ideal use cases ('Best for: math, logic, comparisons...'), giving the agent clear criteria for when to choose this tool over alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

perplexity_researchDeep ResearchA
Read-only

Conduct deep, multi-source research on a topic (Sonar Deep Research model). Best for: literature reviews, comprehensive overviews, investigative queries needing many sources. Returns a detailed response with numbered citations. Significantly slower than other tools (30+ seconds). For quick factual questions, use perplexity_ask instead. For logical analysis and reasoning, use perplexity_reason instead.

ParametersJSON Schema
NameRequiredDescriptionDefault
messagesYesArray of conversation messages
strip_thinkingNoIf true, removes <think>...</think> tags and their content from the response to save context tokens. Default is false.
reasoning_effortNoControls depth of deep research reasoning. Higher values produce more thorough analysis.

Output Schema

ParametersJSON Schema
NameRequiredDescription
responseYesAI-generated text response with numbered citation references

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true, so the description's addition of 'Significantly slower than other tools (30+ seconds)' and 'Returns a detailed response with numbered citations' provides valuable behavioral context beyond the structured metadata. It does not contradict the read-only nature.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a compact set of five purposeful sentences. It front-loads the core action, then provides use cases, output format, a performance warning, and sibling alternatives—all without redundancy or filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With an output schema present and annotations providing read-only safety, the description gives sufficient context: purpose, use cases, speed, and alternatives. It is complete for a research tool, though it could mention specific limitations of the underlying model or cite that responses are not real-time.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3. The description does not describe parameters directly, but the schema already documents messages, strip_thinking, and reasoning_effort with their meanings. The description's reference to 'deep research' implicitly aligns with reasoning_effort, but adds no new parameter-level detail.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool conducts deep, multi-source research on a topic, and explicitly distinguishes it from siblings by naming alternatives for quick facts and logical reasoning. It also adds concrete output characteristics like numbered citations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit when-to-use guidance is provided: 'Best for literature reviews, comprehensive overviews, investigative queries needing many sources.' It also clearly states when NOT to use it ('quick factual questions' -> use perplexity_ask; logical analysis -> use perplexity_reason) and warns about the 30+ second latency.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 4 tool updatesv0.9.0
    • First observedperplexity_ask
    • First observedperplexity_reason
    • First observedperplexity_research
    • First observedperplexity_search

TDQS

A4.7/5.0

Scored across 4 tools

Disambiguation5/5

Each tool has a clearly delineated purpose (quick Q&A, step-by-step reasoning, deep research, raw search) and descriptions explicitly guide which tool to use for which scenario, eliminating ambiguity.

Naming Consistency5/5

All tools follow a consistent 'perplexity_verb' pattern in snake_case (ask, reason, research, search), making the naming predictable and easy for agents to infer functionality.

Tool Count5/5

Four tools is well-scoped for a search/QA server: covering quick answers, reasoning, deep research, and raw web search without redundancy or missing core functionality.

Completeness4/5

The tool set covers the primary workflows (factual Q&A, reasoning, multi-source research, raw search) with no major gaps; a potential minor addition could be a batch or follow-up tool, but not essential.

Related MCP Connectors