Skip to main content
Glama

SerpApi MCP Server

SerpApi MCP 服务器

构建一个 MCP 服务器:

  • 使用 API 密钥通过 SerpApi快速获取已解析的搜索引擎结果页面

此 MCP(模型上下文协议)服务器与SerpApi集成,可在各种搜索引擎中执行搜索,并检索实时和已归档结果。它提供工具和资源,以便与 MCP 客户端或主机(例如 Grok 或 Claude for Desktop)进行无缝交互。


安装

要设置 SerpApi MCP 服务器,请安装所需的 Python 库:

pip install mcp serpapi python-dotenv

您还需要一个SerpApi API 密钥。在 SerpApi 注册即可获取。

快速入门

  1. 保存服务器代码:将服务器代码放在文件中,例如 server.py。
  2. 配置 API 密钥:在与 SerpApi API 密钥相同的目录中创建一个 .env 文件:
SERPAPI_API_KEY=your_api_key_here
  1. 运行服务器:使用以下命令启动服务器:
python server.py
  1. 与 MCP 客户端集成:将服务器连接到 MCP 客户端或主机(例如 Claude for Desktop)。对于 Claude,请更新 Claude_desktop_config.json 文件:
{ "mcpServers": { "serpapi": { "command": "python", "args": ["path/to/server.py"] } } }

重新启动客户端以加载服务器。

特征

  • 支持的引擎:Google、Google Light、Bing、沃尔玛、雅虎、eBay、YouTube、DuckDuckGo、Yandex、百度
  • 工具
  • 搜索:使用查询和可选参数在指定引擎上执行搜索。
  • 资源
  • 位置:查找 Google 位置。

使用示例

这些示例假设 MCP 客户端(例如,使用 MCP 客户端 SDK 以 Python 编写)已连接到服务器。列出支持的引擎检索支持的搜索引擎列表:

engines = await session.read_resource("locations") print(engines)

执行搜索使用位置过滤器在 Google 上搜索“咖啡”:

result = await session.call_tool("search", { "query": "coffee", "engine": "google", "location": "Austin, TX" })

打印(结果)

配置

API 密钥:在.env文件中将您的 SerpApi API 密钥设置为SERPAPI_API_KEY

运行服务器

生产模式:使用以下命令启动服务器:

python server.py

开发模式:使用 MCP Inspector 进行调试:

mcp dev server.py

测试

使用 MCP 检查器或 MCP 客户端测试服务器。对于 Claude 桌面版,请在Claude_desktop_config.json中配置服务器,重启应用,然后使用锤子图标探索和测试可用的工具。

-
security - not tested
F
license - not found
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

MCP 服务器与 SerpApi 集成,可从 Google、Bing、Yahoo 等多个搜索引擎检索搜索结果,从而可以快速访问实时和存档的搜索数据。

  1. 安装
    1. 快速入门
      1. 特征
        1. 使用示例
          1. 配置
            1. 运行服务器
          2. 测试

            Related MCP Servers

            • A
              security
              F
              license
              A
              quality
              Enables integration of Google search functionality into MCP-enabled applications using the Serper API, providing rich search results, configurable parameters, and efficient response handling.
              Last updated -
              1
              12
              TypeScript
              • Apple
            • A
              security
              A
              license
              A
              quality
              A headless browser MCP server that allows AI agents to fetch web content and perform Google searches without API keys, supporting various output formats like Markdown, JSON, HTML, and text.
              Last updated -
              2
              4
              TypeScript
              MIT License
            • A
              security
              F
              license
              A
              quality
              An MCP protocol server that enables web search functionality using the Tavily API, allowing AI assistants to perform internet searches in real-time.
              Last updated -
              4
              2
              Python
            • -
              security
              A
              license
              -
              quality
              MCP server for using various search tools like Tavily API. Planning to support various search tools (i.e. wiki search, searxng, etc)
              Last updated -
              1
              Python
              MIT License
              • Apple
              • Linux

            View all related MCP servers

            MCP directory API

            We provide all the information about MCP servers via our MCP API.

            curl -X GET 'https://glama.ai/api/mcp/v1/servers/ilyazub/serpapi-mcp-server'

            If you have feedback or need assistance with the MCP directory API, please join our Discord server