Skip to main content
Glama
exqlnet

perplexity-unofficial-mcp

by exqlnet

Perplexity Unofficial MCP(基于 Cookies)

非官方实现:本项目通过浏览器 Cookies 调用 Perplexity 的 Web 接口,稳定性与合规性不做保证。请确保你的使用方式符合你所在组织的安全要求与 Perplexity 的服务条款。

本项目目标是把非官方 perplexity-ai(Python SDK,Cookies 方式)包装成一个 MCP STDIO Server,让 MCP 客户端(Claude Desktop / Cursor / VS Code 等)能像使用官方 Perplexity MCP 一样使用它。

你会得到什么

  • 一个 Python MCP Server(STDIO + JSON-RPC 2.0),工具命名对齐官方:

    • perplexity_ask

    • perplexity_research

    • perplexity_reason

    • perplexity_search

  • 一份可直接用于 MCP 客户端的快速配置 JSON

Related MCP server: PPX-MCP

前置条件

  • Python >= 3.10

  • uv 已安装(https://docs.astral.sh/uv/)

  • 非官方 SDK 依赖:

    • 默认通过 pyproject.toml 里的 git pin 依赖安装(见 perplexity-api @ git+https://...@<commit>

    • 因此运行环境通常需要可用的 git 与网络访问(受限网络环境可考虑自行改为 vendoring)

  • (可选)你已在浏览器登录 Perplexity,并能获取 Cookies(提供后通常更稳定;未提供时可能走匿名访问/自动回退,取决于 Perplexity 侧策略)

重要:STDIO 模式下 stdout 只能输出 MCP 协议消息。本项目所有日志都输出到 stderr。建议使用 uv -q 并设置 UV_NO_PROGRESS=1 来尽量抑制 uv 自身输出。

Cookies 获取与配置

获取 Cookies(建议方式)

  1. 在浏览器登录 perplexity.ai

  2. 打开开发者工具 → Application/Storage → Cookies → https://www.perplexity.ai

  3. 找到并复制你当前会话的 Cookies(常见包含):

    • next-auth.csrf-token

    • next-auth.session-token

通过两个环境变量传入 Cookies(推荐方式)

本项目默认使用两个环境变量注入 Cookies:

  • PERPLEXITY_CSRF_TOKEN:对应 next-auth.csrf-token

  • PERPLEXITY_SESSION_TOKEN:对应 next-auth.session-token

如果上述变量缺失或为空,服务端会自动生成随机占位值用于满足上游 SDK 的参数形态(不会写入 stdout/stderr)。此时是否能成功调用取决于 Perplexity 是否允许匿名访问及其回退策略,本项目不做稳定性保证。

注意:不要把 token 写进仓库或公开渠道;建议通过本机环境变量或密钥管理注入。

安装与启动(推荐:uv)

本项目不再提供或依赖 npx 启动方式。推荐使用 uv 直接运行(由 uv 负责依赖解析与运行)。

如果你需要把它接入 MCP 客户端,推荐使用“从 GitHub 仓库地址启动”的形式(无需本地 clone)。

MCP 快速配置(JSON)

以下示例默认使用主分支 main。生产/团队环境建议 pin 到 tag 或 commit 以保证可复现。

Cursor / Claude Desktop / Windsurf(mcpServers 格式)

方式:使用 uv 从 GitHub 启动(推荐)

{
  "mcpServers": {
    "perplexity_unofficial": {
      "command": "uv",
      "args": [
        "-q",
        "tool",
        "run",
        "--from",
        "git+https://github.com/exqlnet/unofficial-perplexity-mcp.git@main",
        "perplexity-unofficial-mcp"
      ],
      "env": {
        "PERPLEXITY_CSRF_TOKEN": "<csrf>",
        "PERPLEXITY_SESSION_TOKEN": "<session>",
        "UV_NO_PROGRESS": "1",
        "UV_COLOR": "never"
      }
    }
  }
}

VS Code(.vscode/mcp.json,servers 格式)

方式:使用 uv 从 GitHub 启动(推荐)

{
  "servers": {
    "perplexity_unofficial": {
      "type": "stdio",
      "command": "uv",
      "args": [
        "-q",
        "tool",
        "run",
        "--from",
        "git+https://github.com/exqlnet/unofficial-perplexity-mcp.git@main",
        "perplexity-unofficial-mcp"
      ],
      "env": {
        "PERPLEXITY_CSRF_TOKEN": "<csrf>",
        "PERPLEXITY_SESSION_TOKEN": "<session>",
        "UV_NO_PROGRESS": "1",
        "UV_COLOR": "never"
      }
    }
  }
}

工具说明(与官方对齐)

perplexity_ask

  • 入参:query(字符串),可选 backend_uuid

  • 行为:

    • 为避免调用方误传导致行为不可预测:本 MCP 已禁用外部 mode / model 入参

    • 服务端会按内部默认策略选择模式(例如有 Cookies 时倾向使用 pro,并默认使用 gpt-5.2

    • 请避免频繁调用;尽量将多个子问题合并到一次 query / 一次 perplexity_search 中查清楚

  • 出参:content(文本)+ structuredContent.response(文本)+ 可选 structuredContent.chunks + 可选 structuredContent.backend_uuid

续问(同一对话线程继续问)

  • 每次调用若上游返回 backend_uuid,本 MCP 会在 structuredContent.backend_uuid 回传。

  • 下一次调用时,把该值作为入参 backend_uuid 传回,即可让 Perplexity 以同一对话上下文续问。

  • 注意:该能力依赖网页端私有接口与服务端策略,backend_uuid 可能缺失、过期或被忽略;本项目不保证稳定。

perplexity_research

  • 入参:query(字符串),可选 backend_uuidstrip_thinking

  • 行为:

    • 默认 deep research(专用语义)

    • 本 MCP 已禁用外部 mode / model 入参

    • 注意:这是重型调用,耗时更长;仅在必要时使用,优先 ask/search

perplexity_reason

  • 入参:query(字符串),可选 backend_uuidstrip_thinking

  • 行为:

    • 默认 reasoning(专用语义)

    • 本 MCP 已禁用外部 mode / model 入参

  • 入参:query(字符串),可选 backend_uuid

  • 行为:

    • 当前实现返回“回答文本”(并尽量在 structuredContent.chunks 附带结构化片段)

    • 本 MCP 已禁用外部 mode / model 入参;服务端会按内部默认策略选择模式

    • 请避免频繁调用;尽量把要查的点写进一次 query(例如用编号列出多个子问题),一次 search 查清楚

说明:官方 perplexity_search 语义是“返回搜索结果列表”;非官方 SDK 不一定稳定提供同等结构,因此本实现优先保证可用性与对齐接口形状。

重要:本 MCP 不再支持 messages[] 入参;如果你的调用方仍传 messages,会返回工具级错误并提示改用 query。 重要:本 MCP 不再支持 mode / model 入参;如果你的调用方仍传 mode / model,会返回工具级错误并提示移除该字段。

排错

  • 启动报错 未找到 uv:安装 uv 后重试。

  • 提示 Cookies 无效/请求失败:通常是会话过期,重新获取 Cookies 并更新 PERPLEXITY_CSRF_TOKEN / PERPLEXITY_SESSION_TOKEN

  • MCP 客户端初始化失败:检查是否有任何非协议输出写入 stdout;本项目日志写入 stderr,且推荐使用 uv -q 并设置 UV_NO_PROGRESS=1,仍失败时请检查你的外层启动命令是否会向 stdout 输出额外内容。

  • GitHub 拉取失败:检查网络与 git 可用性;受限环境可改为本地 clone 后再使用本地方式启动(见下文开发说明)。

开发说明

直接运行(不走 uv)

在仓库目录下:

  • 使用 PYTHONPATH=src python3 -m perplexity_unofficial_mcp.cli(适合不安装依赖时做协议层开发)

  • 使用 uv -q run --no-editable perplexity-unofficial-mcp(会按 pyproject.toml 安装依赖)

安全提示

  • 不要把真实 Cookies 提交到 git、截图或粘贴到公开渠道。

  • 建议通过密钥管理(或本机环境变量注入)提供 PERPLEXITY_CSRF_TOKEN / PERPLEXITY_SESSION_TOKEN

Available Tools

4 tools
perplexity_askAsk PerplexityB
Read-only

对齐官方 Perplexity MCP:输入 query 字符串并返回回答文本。请避免频繁调用;尽量将多个子问题合并到一次 query / 一次 perplexity_search 中查清楚。

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYes
backend_uuidNo续问用的会话标识。通常应直接使用上一轮工具返回的 structuredContent.backend_uuid;若不提供则视为新对话。

TDQS

B3.1/5.0
Behavior3/5

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

Annotations already declare readOnlyHint=true and openWorldHint=true, covering the safety profile. The description adds genuinely useful behavioral context beyond that — a rate/call-frequency caution and batching advice — but says nothing about latency, session behavior, or result limits. It adds some value over the annotations but not rich disclosure.

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

Conciseness4/5

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

Two sentences, front-loaded with the purpose and then the operational caveat, with no filler. It is efficient, though the purpose half is just a restatement of the obvious name.

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

Completeness3/5

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

There is no output schema, and the description does note that it returns answer text, which is the essential return contract. Combined with readOnly/openWorld annotations, the safety and shape are covered. However, for a tool with a sibling family and a session-continuation parameter, it does not fully explain return structure or when continuation via backend_uuid applies.

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 sits at 50%: backend_uuid is documented in the schema, while query is not. The description only restates that query is a string, adding no format, length, or example meaning beyond the schema. With coverage near the midpoint, baseline 3 is appropriate.

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

Purpose3/5

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

The description states the mechanics clearly — it takes a query string and returns answer text — which is a specific input/output contract. However, it never differentiates perplexity_ask from its three siblings (perplexity_research, perplexity_reason, perplexity_search); it only cites perplexity_search as an alternative batching target, not as a contrasting purpose. An agent cannot tell from this text why it would choose 'ask' over 'search' or 'reason'.

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

Usage Guidelines3/5

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

It gives real operational guidance: avoid frequent calls and consolidate multiple sub-questions into one query or one perplexity_search call. That is a useful when-to-batch rule. But it offers no explicit criteria for choosing this tool over the sibling research/reason/search tools, leaving the routing decision to inference.

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

perplexity_reasonAdvanced ReasoningC
Read-only

对齐官方 Perplexity MCP:推理(默认 reasoning)。请避免频繁调用;尽量将多个子问题合并到一次 query / 一次 perplexity_search 中查清楚。

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYes
backend_uuidNo续问用的会话标识。通常应直接使用上一轮工具返回的 structuredContent.backend_uuid;若不提供则视为新对话。
strip_thinkingNo

TDQS

C2.9/5.0
Behavior3/5

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

The annotations already declare readOnlyHint=true and openWorldHint=true, covering the safety profile. The description adds a behavioral constraint beyond those annotations: avoid frequent calls and merge sub-questions into one query or search. It does not disclose rate limits, authentication needs, or return behavior, but it does add relevant call-efficiency context.

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

Conciseness4/5

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

The description is two sentences and contains no obvious padding. It is reasonably front-loaded with the official-alignment and reasoning purpose, followed by the usage constraint, though the first clause is somewhat vague rather than maximally informative.

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

Completeness2/5

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

For a three-parameter tool with 33% schema description coverage, no output schema, and three sibling tools, the description leaves significant gaps. It does not explain when to prefer this reasoning tool over perplexity_ask or perplexity_research, nor does it define the query or strip_thinking parameters. The call-efficiency advice is present but insufficient for the definition to be complete.

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

Parameters2/5

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

Schema description coverage is only 33%, with backend_uuid described in the schema and query and strip_thinking undocumented. The description mentions query only as a container for merged sub-questions and adds no meaning to strip_thinking or the required query format, so it fails to compensate for the sparse schema coverage.

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

Purpose3/5

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

The description identifies the tool as the 'reasoning (default reasoning)' variant aligned with official Perplexity MCP, which gives a basic sense of purpose. However, it does not clearly state what kind of reasoning output the agent should expect or how it differs from siblings perplexity_ask and perplexity_research. The only sibling contrast is an indirect reference to merging sub-questions into perplexity_search.

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

Usage Guidelines3/5

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

It advises avoiding frequent calls and consolidating multiple sub-questions into one query or one perplexity_search call, which is useful operational guidance. Still, it does not explicitly say when to choose perplexity_reason over perplexity_ask or perplexity_research, so an agent must infer its place among siblings.

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

perplexity_researchDeep Research(重型)A
Read-only

对齐官方 Perplexity MCP:深度研究(重型调用,耗时更长;仅在必要时使用,优先 ask/search)。请避免频繁调用;尽量将多个子问题合并到一次 query / 一次 perplexity_search 中查清楚。

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYes
backend_uuidNo续问用的会话标识。通常应直接使用上一轮工具返回的 structuredContent.backend_uuid;若不提供则视为新对话。
strip_thinkingNo

TDQS

A4.1/5.0
Behavior4/5

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

Annotations only declare readOnlyHint and openWorldHint, so the description's disclosure that this is a slow, heavyweight call with cost/rate implications (避免频繁调用) is genuinely additive. It omits anything about result shape or session behavior beyond what the backend_uuid schema description already carries.

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?

Two compact sentences with the heavy-call warning and the preference for lighter siblings front-loaded; there is no filler and every clause carries an instruction.

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

Completeness3/5

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

With no output schema, the description should say something about what a research call returns, but it does not, and strip_thinking remains undocumented. The cost/latency framing and sibling routing are present, so it is adequate but incomplete for a 3-parameter tool.

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 only 33%: backend_uuid is documented in the schema, while query and strip_thinking are not. The description partially compensates by advising how to shape the query (merge sub-questions into one call), but says nothing about strip_thinking, leaving one parameter unexplained in both places.

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

Purpose4/5

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

The description states the resource and character of the operation (深度研究, 重型调用) and explicitly positions it against its siblings by naming ask/search. It is clear enough that an agent can distinguish it from perplexity_ask and perplexity_search without opening a schema, though the core verb is partly restated from the tool name itself.

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?

It gives an explicit use-only-when-necessary rule, names the preferred alternatives (优先 ask/search), warns against frequent invocation, and advises consolidating sub-questions into a single call. This is a complete when/when-not/alternative routing instruction.

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.1.3
    • First observedperplexity_ask
    • First observedperplexity_reason
    • First observedperplexity_research
    • First observedperplexity_search

TDQS

B3.4/5.0

Scored across 4 tools

Disambiguation2/5

All four tools take a query and return answer text, with nearly identical boilerplate warnings about avoiding frequent calls. The boundaries between perplexity_ask and perplexity_search are especially unclear since search also returns answer text, and only perplexity_research (heavy) and perplexity_reason (reasoning) are somewhat distinct.

Naming Consistency5/5

Every tool follows the exact same perplexity_<action> snake_case pattern with no deviations. The naming is fully predictable and consistent.

Tool Count5/5

Four tools align with the four Perplexity modes (ask, search, reason, research), which is a well-scoped set for a wrapper. No obvious missing or redundant tools based on the stated purpose.

Completeness4/5

The surface covers the main query modes, but perplexity_search returns answer text rather than fully structured search results, and there is no explicit conversational/session tool. These are minor gaps that agents can likely work around.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    D
    maintenance
    An unofficial MCP server for Perplexity AI that leverages Pro subscriptions and browser cookies to enable real-time web searches and model selection without an API key. It provides tools for performing queries, listing available models, and automating the login process to manage authentication.
    4
    13 npm
    MIT
  • A
    license
    Not graded
    quality
    Not graded
    maintenance
    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.
    MIT