Perplexica MCP Server 标志

Perplexica MCP Server

社区
thetom42

MCP server for Perplexica

发布者thetom42
代码仓库perplexica-mcp
语言Python
复刻数
25
星标数
79
可用工具
0
传输类型stdio, streamable-http
分类
许可协议MIT
链接
  • 将工具接入 AI 工作流

    Perplexica MCP Server 提供 MCP 功能,可供兼容的 AI 客户端和智能体使用。

  • 0 个可用工具

    浏览下方可调用的操作;如果服务器提供了名称和描述,也会一并显示。

  • 可直接复制的配置

    使用安装配置片段,在您首选的 MCP 客户端中配置此服务器。

  • 开源社区热度

    关联的代码仓库有 79 个星标和 25 个复刻。

Perplexica MCP Server

A Model Context Protocol (MCP) server that provides search functionality using Perplexica's AI-powered search engine.

Features

  • Search Tool: AI-powered search with multiple source types (web, academic, discussions)
  • Multiple Transport Support: stdio, SSE, and Streamable HTTP transports
  • FastMCP Integration: Built using FastMCP for robust MCP protocol compliance
  • Unified Architecture: Single server implementation supporting all transport modes
  • Production Ready: Docker support with security best practices

Development Environment

For Claude Code Users

Important: If you are using Claude Code for development, this project requires the use of the container-use MCP server for all development operations. All file operations, code changes, and shell commands must be executed within container-use environments.

Working with Container-Use (Claude Code Only)

When contributing to this project using Claude Code, you must:

  1. Use Container-Use Only: All file operations, code editing, and shell commands must be performed using container-use environments
  2. View Your Work: After making changes, inform others how to access your work:
    • Use container-use log <env_id> to view the development log
    • Use container-use checkout <env_id> to check out your environment
  3. No Local Operations: Do not perform file operations directly on the local filesystem

Example Development Workflow (Claude Code)

bash
# Create a new environment for your work
container-use create --title "Your feature description"

# Make your changes using container-use tools
# (All file operations handled by container-use)

# Share your work with others
container-use log <your-env-id>
container-use checkout <your-env-id>

This ensures consistency, reproducibility, and proper version control for all development activities when using Claude Code.

For Other Development Environments

If you are not using Claude Code, you can develop normally using your preferred tools and IDE. The container-use requirement does not apply to regular development workflows.

Installation

From PyPI (Recommended)

bash
# Install directly from PyPI
pip install perplexica-mcp

# Or using uvx for isolated execution
uvx perplexica-mcp --help

From Source

bash
# Clone the repository
git clone https://github.com/thetom42/perplexica-mcp.git
cd perplexica-mcp

# Install dependencies
uv sync

MCP Client Configuration

To use this server with MCP clients, you need to configure the client to connect to the Perplexica MCP server. Below are configuration examples for popular MCP clients.

Important: All transport modes require proper environment variable configuration, especially:

  • PERPLEXICA_BACKEND_URL: URL to your Perplexica backend API
  • PERPLEXICA_CHAT_MODEL_PROVIDER and PERPLEXICA_CHAT_MODEL_NAME: Chat model configuration
  • PERPLEXICA_EMBEDDING_MODEL_PROVIDER and PERPLEXICA_EMBEDDING_MODEL_NAME: Embedding model configuration

These variables must be set either in your environment or provided in the MCP client configuration.

Claude Desktop

Stdio Transport (Recommended)

Add the following to your Claude Desktop configuration file:

Location: ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows)

json
{
  "mcpServers": {
    "perplexica": {
      "command": "uvx",
      "args": ["perplexica-mcp", "stdio"],
      "env": {
        "PERPLEXICA_BACKEND_URL": "http://localhost:3000/api/search",
        "PERPLEXICA_CHAT_MODEL_PROVIDER": "openai",
        "PERPLEXICA_CHAT_MODEL_NAME": "gpt-4o-mini",
        "PERPLEXICA_EMBEDDING_MODEL_PROVIDER": "openai",
        "PERPLEXICA_EMBEDDING_MODEL_NAME": "text-embedding-3-small"
      }
    }
  }
}

Alternative (from source):

json
{
  "mcpServers": {
    "perplexica": {
      "command": "uv",
      "args": ["run", "python", "-m", "perplexica_mcp", "stdio"],
      "cwd": "/path/to/perplexica-mcp",
      "env": {
        "PERPLEXICA_BACKEND_URL": "http://localhost:3000/api/search",
        "PERPLEXICA_CHAT_MODEL_PROVIDER": "openai",
        "PERPLEXICA_CHAT_MODEL_NAME": "gpt-4o-mini",
        "PERPLEXICA_EMBEDDING_MODEL_PROVIDER": "openai",
        "PERPLEXICA_EMBEDDING_MODEL_NAME": "text-embedding-3-small"
      }
    }
  }
}

Note: When running from source, ensure all required environment variables are set. The stdio transport requires proper model provider and model name configuration to communicate with the Perplexica backend.


#### SSE Transport

For SSE transport, first start the server:

```bash
uv run src/perplexica_mcp/server.py sse

Then configure Claude Desktop:

json
{
  "mcpServers": {
    "perplexica": {
      "url": "http://localhost:3001/sse"
    }
  }
}

Cursor IDE

Add to your Cursor MCP configuration:

json
{
  "servers": {
    "perplexica": {
      "command": "uvx",
      "args": ["perplexica-mcp", "stdio"],
      "env": {
        "PERPLEXICA_BACKEND_URL": "http://localhost:3000/api/search",
        "PERPLEXICA_CHAT_MODEL_PROVIDER": "openai",
        "PERPLEXICA_CHAT_MODEL_NAME": "gpt-4o-mini",
        "PERPLEXICA_EMBEDDING_MODEL_PROVIDER": "openai",
        "PERPLEXICA_EMBEDDING_MODEL_NAME": "text-embedding-3-small"
      }
    }
  }
}

Alternative (from source):

json
{
  "servers": {
    "perplexica": {
      "command": "uv",
      "args": ["run", "python", "-m", "perplexica_mcp", "stdio"],
      "cwd": "/path/to/perplexica-mcp",
      "env": {
        "PERPLEXICA_BACKEND_URL": "http://localhost:3000/api/search",
        "PERPLEXICA_CHAT_MODEL_PROVIDER": "openai",
        "PERPLEXICA_CHAT_MODEL_NAME": "gpt-4o-mini",
        "PERPLEXICA_EMBEDDING_MODEL_PROVIDER": "openai",
        "PERPLEXICA_EMBEDDING_MODEL_NAME": "text-embedding-3-small"
      }
    }
  }
}

VS Code (with MCP Extension)

Add to your VS Code MCP configuration file (.vscode/mcp.json):

json
{
  "servers": {
    "perplexica": {
      "type": "stdio",
      "command": "uv",
      "args": ["run", "python", "-m", "perplexica_mcp", "stdio"],
      "cwd": "/path/to/perplexica-mcp",
      "env": {
        "PERPLEXICA_BACKEND_URL": "http://localhost:3000/api/search",
        "PERPLEXICA_CHAT_MODEL_PROVIDER": "openai",
        "PERPLEXICA_CHAT_MODEL_NAME": "gpt-4o-mini",
        "PERPLEXICA_EMBEDDING_MODEL_PROVIDER": "openai",
        "PERPLEXICA_EMBEDDING_MODEL_NAME": "text-embedding-3-small"
      }
    }
  }
}

Generic MCP Client Configuration

For any MCP client supporting stdio transport:

bash
# Command to run the server (PyPI installation)
uvx perplexica-mcp stdio

# Command to run the server with .env file (PyPI installation)
uvx --env-file .env perplexica-mcp stdio

# Command to run the server (from source)
uv run python -m perplexica_mcp stdio

# Environment variables (can be exported or set inline)
export PERPLEXICA_BACKEND_URL=http://localhost:3000/api/search
export PERPLEXICA_CHAT_MODEL_PROVIDER=openai
export PERPLEXICA_CHAT_MODEL_NAME=gpt-4o-mini
export PERPLEXICA_EMBEDDING_MODEL_PROVIDER=openai
export PERPLEXICA_EMBEDDING_MODEL_NAME=text-embedding-3-small

# Or set inline for single execution (all required vars)
PERPLEXICA_BACKEND_URL=http://localhost:3000/api/search \
PERPLEXICA_CHAT_MODEL_PROVIDER=openai \
PERPLEXICA_CHAT_MODEL_NAME=gpt-4o-mini \
PERPLEXICA_EMBEDDING_MODEL_PROVIDER=openai \
PERPLEXICA_EMBEDDING_MODEL_NAME=text-embedding-3-small \
uvx perplexica-mcp stdio

For HTTP/SSE transport clients:

bash
# Start the server (PyPI installation)
uvx perplexica-mcp sse  # or 'http'

# Start the server (from source)
uv run /path/to/perplexica-mcp/src/perplexica_mcp/server.py sse  # or 'http'

# Connect to endpoints
SSE: http://localhost:3001/sse
HTTP: http://localhost:3002/mcp/

Configuration Notes

  1. Path Configuration: Replace /path/to/perplexica-mcp/ with the actual path to your installation
  2. Perplexica URL: Ensure PERPLEXICA_BACKEND_URL points to your running Perplexica instance
  3. Transport Selection:
    • Use stdio for most MCP clients (Claude Desktop, Cursor)
    • Use SSE for web-based clients or real-time applications
    • Use HTTP for REST API integrations
  4. Dependencies: Ensure uvx is installed and available in your PATH (or uv for source installations)

Troubleshooting

  • Server not starting: Check that uvx (or uv for source) is installed and the path is correct
  • Connection refused: Verify Perplexica is running and accessible at the configured URL
  • Permission errors: Ensure the MCP client has permission to execute the server command
  • Environment variables: Check that PERPLEXICA_BACKEND_URL is properly set

Server Configuration

Create a .env file in the project root with your Perplexica configuration:

env
# Perplexica Backend Configuration
PERPLEXICA_BACKEND_URL=http://localhost:3000/api/search

# Default Model Configuration (Optional)
# If set, these models will be used as defaults when no model is specified in the search request

# Chat Model Configuration
PERPLEXICA_CHAT_MODEL_PROVIDER=openai
PERPLEXICA_CHAT_MODEL_NAME=gpt-4o-mini

# Embedding Model Configuration  
PERPLEXICA_EMBEDDING_MODEL_PROVIDER=openai
PERPLEXICA_EMBEDDING_MODEL_NAME=text-embedding-3-small

Environment Variables

VariableDescriptionDefaultExample
PERPLEXICA_BACKEND_URLURL to Perplexica search APIhttp://localhost:3000/api/searchhttp://localhost:3000/api/search
PERPLEXICA_CHAT_MODEL_PROVIDERDefault chat model providerNoneopenai, ollama, anthropic
PERPLEXICA_CHAT_MODEL_NAMEDefault chat model nameNonegpt-4o-mini, claude-3-sonnet
PERPLEXICA_EMBEDDING_MODEL_PROVIDERDefault embedding model providerNoneopenai, ollama
PERPLEXICA_EMBEDDING_MODEL_NAMEDefault embedding model nameNonetext-embedding-3-small

Note: The model environment variables are optional. If not set, you'll need to specify models in each search request. When set, they provide convenient defaults that can still be overridden per request.

Usage

The server supports three transport modes:

1. Stdio Transport

bash
# PyPI installation
uvx perplexica-mcp stdio

# From source
uv run src/perplexica_mcp/server.py stdio

2. SSE Transport

bash
# PyPI installation
uvx perplexica-mcp sse [host] [port]

# From source
uv run src/perplexica_mcp/server.py sse [host] [port]
# Default: localhost:3001, endpoint: /sse

3. Streamable HTTP Transport

bash
# PyPI installation
uvx perplexica-mcp http [host] [port]

# From source
uv run src/perplexica_mcp/server.py http [host] [port]
# Default: localhost:3002, endpoint: /mcp

Docker Deployment

The server includes Docker support with multiple transport configurations for containerized deployments.

Prerequisites

  • Docker and Docker Compose installed
  • External Docker network named backend (for integration with Perplexica)

Create External Network

bash
docker network create backend

Build and Run

Option 1: HTTP Transport (Streamable HTTP)

bash
# Build and run with HTTP transport
docker-compose up -d

# Or build first, then run
docker-compose build
docker-compose up -d

Option 2: SSE Transport (Server-Sent Events)

bash
# Build and run with SSE transport
docker-compose -f docker-compose-sse.yml up -d

# Or build first, then run
docker-compose -f docker-compose-sse.yml build
docker-compose -f docker-compose-sse.yml up -d

Environment Configuration

Both Docker configurations support environment variables:

bash
# Create .env file for Docker
cat > .env << EOF
PERPLEXICA_BACKEND_URL=http://perplexica-app:3000/api/search
EOF

# Uncomment env_file in docker-compose.yml to use .env file

Or set environment variables directly in the compose file:

yaml
environment:
  - PERPLEXICA_BACKEND_URL=http://your-perplexica-host:3000/api/search

Container Details

TransportContainer NamePortEndpointHealth Check
HTTPperplexica-mcp-http3001/mcp/MCP initialize request
SSEperplexica-mcp-sse3001/sseSSE endpoint check

Health Monitoring

Both containers include health checks:

bash
# Check container health
docker ps
docker-compose ps

# View health check logs
docker logs perplexica-mcp-http
docker logs perplexica-mcp-sse

Integration with Perplexica

The Docker setup assumes Perplexica is running in the same Docker network:

yaml
# Example Perplexica service in the same compose file
services:
  perplexica-app:
    # ... your Perplexica configuration
    networks:
      - backend
  
  perplexica-mcp:
    # ... MCP server configuration
    environment:
      - PERPLEXICA_BACKEND_URL=http://perplexica-app:3000/api/search
    networks:
      - backend

Production Considerations

  • Both containers use restart: unless-stopped for reliability
  • Health checks ensure service availability
  • External network allows integration with existing Perplexica deployments
  • Security best practices implemented in Dockerfile

Available Tools

search

Performs AI-powered web search using Perplexica.

Parameters:

  • query (string, required): Search query
  • sources (array, required): Search sources to use. Valid values: "web", "academic", "discussions". Can combine multiple sources.
  • chat_model (object, optional): Chat model configuration
  • embedding_model (object, optional): Embedding model configuration
  • optimization_mode (string, optional): "speed", "balanced", or "quality"
  • history (array, optional): Conversation history as [["human", "text"], ["assistant", "text"]] pairs
  • system_instructions (string, optional): Custom instructions
  • stream (boolean, optional): Whether to stream responses

Testing

Run the comprehensive test suite to verify all transports:

bash
uv run src/test_transports.py

This will test:

  • ✓ Stdio transport with MCP protocol handshake
  • ✓ HTTP transport with Streamable HTTP compliance
  • ✓ SSE transport endpoint accessibility

Transport Details

Stdio Transport

  • Uses FastMCP's built-in stdio server
  • Supports full MCP protocol including initialization and tool listing
  • Ideal for MCP client integration

SSE Transport

  • Server-Sent Events for real-time communication
  • Endpoint: http://host:port/sse
  • Includes periodic ping messages for connection health

Streamable HTTP Transport

  • Compliant with MCP Streamable HTTP specification
  • Endpoint: http://host:port/mcp
  • Returns 307 redirect to /mcp/ as per protocol
  • Uses StreamableHTTPSessionManager for proper session handling

Development

The server is built using:

  • FastMCP: Modern MCP server framework with built-in transport support
  • Uvicorn: ASGI server for SSE and HTTP transports
  • httpx: HTTP client for Perplexica API communication
  • python-dotenv: Environment variable management

Architecture

none
┌─────────────────┐    ┌──────────────────┐    ┌─────────────────┐
│   MCP Client    │◄──►│ Perplexica MCP   │◄──►│   Perplexica    │
│                 │    │     Server       │    │   Search API    │
│  (stdio/SSE/    │    │   (FastMCP)      │    │                 │
│   HTTP)         │    │                  │    │                 │
└─────────────────┘    └──────────────────┘    └─────────────────┘
                              │
                              ▼
                       ┌──────────────┐
                       │   FastMCP    │
                       │  Framework   │
                       │ ┌──────────┐ │
                       │ │  stdio   │ │
                       │ │   SSE    │ │
                       │ │  HTTP    │ │
                       │ └──────────┘ │
                       └──────────────┘

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

  1. Fork the repository
  2. Create a feature branch (using container-use environments if using Claude Code)
  3. Make your changes (within container-use environment if using Claude Code)
  4. Add tests if applicable
  5. Submit a pull request
  6. If using Claude Code, provide access to your work via container-use log <env_id> and container-use checkout <env_id>

Support

For issues and questions:

  • Check the troubleshooting section
  • Review the Perplexica documentation
  • Open an issue on GitHub

安装

TypingMind
前提条件:

Node.js 18+

{
  "mcpServers": {
    "thetom42-perplexica-mcp": {
      "command": "uvx",
      "args": [
        "perplexica-mcp"
      ]
    }
  }
}

将 Perplexica MCP Server MCP 与多个 AI 模型配合使用

TypingMind 在工作区级别连接 MCP 工具,因此连接 Perplexica MCP Server 后,您就可以在 TypingMind 中搭配不同的 AI 模型使用,无需为每个模型单独设置。 您可以在自己的设备上本地运行 MCP,也可以通过 URL 连接远程 MCP 服务器。

方式 1:使用本地连接器

如果 MCP 服务器需要访问您电脑上的本地文件、应用或私有资源,请选择此方式。

1

打开 MCP 设置

在 TypingMind 中,依次前往“设置”、“高级设置”和“模型上下文协议”,然后选择“设置连接器”。

  1. 在您的浏览器中打开 TypingMind。
  2. 点击“设置”图标。
  3. 进入“高级设置”。
  4. 打开“模型上下文协议”部分。
  5. 点击“设置连接器”,然后选择“此设备”。
TypingMind MCP 连接器设置界面,已选择“此设备”
2

运行连接器命令

选择“此设备”,从 TypingMind 复制命令并在终端中运行。使用 MCP 时,请保持该进程运行。

  1. 复制 TypingMind 显示的设置命令。
  2. 在 macOS 上打开“终端”,或在 Windows 上打开 Windows Terminal。
  3. 粘贴并运行命令。
  4. 如果终端询问您是否继续,请确认安装软件包。
  5. 使用 MCP 工具时,请勿关闭终端窗口或停止其中的连接器进程。
3

将 Perplexica MCP Server 添加为服务器

当连接器状态为“就绪”时,点击“编辑服务器”,然后粘贴 MCP 服务器配置。

  1. 等待连接器状态显示为“就绪”。
  2. 点击“编辑服务器”。
  3. 粘贴 Perplexica MCP Server MCP 服务器配置。
  4. 保存服务器列表。
  5. 如需确认连接器是否仍处于就绪状态,请刷新。
TypingMind MCP 设置界面,显示正在运行的服务器和“编辑服务器”按钮
{
  "mcpServers": {
    "thetom42-perplexica-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "perplexica-mcp"
      ]
    }
  }
}
4

在不同模型中使用同一连接

保存服务器列表,打开“插件”,启用 Perplexica MCP Server MCP 工具,然后在 TypingMind 中选择任意受支持的 AI 模型,即可在聊天中使用这些工具,或将其分配给智能体。

  1. 在 TypingMind 中打开“插件”页面。
  2. 启用 Perplexica MCP Server MCP 工具。
  3. 开始聊天并选择您想使用的 AI 模型。
  4. 在聊天中使用 MCP 工具,或将其分配给 AI 智能体。
  5. 根据需要随时切换到其他 AI 模型,无需重新连接 MCP。
在 TypingMind 聊天中使用已启用的 MCP 工具和选定的 AI 模型
您能使用 Perplexica MCP Server 帮我完成这项任务吗?
Perplexica MCP Server
当然,我看过了。
以下是我使用 Perplexica MCP Server 得到的结果。

方式 2:添加 MCP 服务器 URL

如果 Perplexica MCP Server 已托管在远程服务器上,或您的团队希望让多个用户共用一个连接器,请选择此方式。

1

打开 MCP 连接器

在 TypingMind 中,前往“插件”,打开“MCP 连接器”,然后选择“添加 URL”。

  1. 在您的浏览器中打开 TypingMind。
  2. 进入“插件”。
  3. 打开“MCP 连接器”。
  4. 点击“添加 URL”。
TypingMind 的“添加自定义 MCP 服务器 URL”表单
2

粘贴服务器 URL

在“服务器 URL”字段中输入 您的服务器 URL。根据服务器要求,添加连接名称、描述、图标、自定义 HTTP 请求头或 OAuth 客户端设置。

  1. 将 您的服务器 URL 粘贴到“服务器 URL”字段中。
  2. 为 Perplexica MCP Server 输入连接名称。
  3. 您可以添加描述和图标,以便更容易识别此连接。
  4. 如果服务器需要身份验证,请添加自定义 HTTP 请求头或 OAuth 客户端信息。
3

创建连接

点击“创建连接”,然后返回插件列表,确认新的 MCP 连接处于可用状态。

  1. 点击“创建连接”。
  2. 返回 MCP 连接器列表。
  3. 确认列表中的 Perplexica MCP Server 连接显示为可用状态。
  4. 如果连接未立即出现,请刷新插件列表。
4

切换模型,无需重新连接

使用您偏好的模型开始聊天,在“插件”中启用 Perplexica MCP Server 工具,并根据需要随时切换到其他模型。该 MCP 连接在 TypingMind 工作区中仍然可用。

  1. 在 TypingMind 中开始新聊天。
  2. 选择您想使用的 AI 模型。
  3. 在“插件”中启用 Perplexica MCP Server 工具。
  4. 需要时,请让模型使用该工具。
  5. 切换到其他 AI 模型,继续使用同一个 MCP 连接。
在 TypingMind 聊天中使用已启用的 MCP 工具和选定的 AI 模型
您能使用 Perplexica MCP Server 帮我完成这项任务吗?
Perplexica MCP Server
当然,我看过了。
以下是我使用 Perplexica MCP Server 得到的结果。

常见问题

Perplexica MCP Server MCP 服务器有什么用途?

Perplexica MCP Server 是一个 MCP 服务器,可让兼容的 AI 客户端连接外部工具并获取上下文。在 TypingMind 中,只需添加一次此 MCP 服务器,即可在您的 AI 工作区中使用其工具。

可以在 TypingMind 中让多个 AI 模型使用 Perplexica MCP Server MCP 吗?

可以。TypingMind 在工作区层面连接 MCP 工具,因此您无需为每个模型单独配置 MCP 服务器,就能在 Claude、ChatGPT、Gemini 或您在 TypingMind 中配置的其他 AI 模型中使用 Perplexica MCP Server。

为什么在 TypingMind 中使用 Perplexica MCP Server MCP?

TypingMind 将多个 AI 模型、提示词、插件、AI 智能体、API 密钥和 MCP 工具整合到同一个工作区中,是最出色的大语言模型聊天前端之一。连接 Perplexica MCP Server 后,您可以在偏好的不同模型中使用其 MCP 工具,同时在 TypingMind 中井然有序地管理聊天工作流程。

如何将 Perplexica MCP Server MCP 连接到 TypingMind?

在 TypingMind 中,您可以使用本地 MCP 连接器或添加远程 MCP 服务器的 URL 来连接 Perplexica MCP Server。当服务器需要访问您设备上的文件、应用或私有资源时,请使用本地连接器;如果 MCP 服务器部署在远端,请使用服务器 URL。

Perplexica MCP Server MCP 在 TypingMind 中提供哪些工具?

Perplexica MCP Server 提供 MCP 功能,您可以在 TypingMind 的插件页面启用这些功能,然后在聊天中使用,或将其分配给 AI 智能体。

使用 Perplexica MCP Server MCP 需要向 TypingMind 提供我的 API 密钥吗?

不需要。TypingMind 采用本地优先的设计,让您自行选择模型提供商,并自行管理 API 密钥、提示词和 MCP 配置。如果 Perplexica MCP Server 需要身份验证,请在创建连接时,为该 MCP 服务器添加所需的请求头、OAuth 设置或本地配置。

相关 MCP 服务器

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇