SerpApi MCP 服务器
构建一个 MCP 服务器:
- 使用 API 密钥通过 SerpApi快速获取已解析的搜索引擎结果页面
此 MCP(模型上下文协议)服务器与SerpApi集成,可在各种搜索引擎中执行搜索,并检索实时和已归档结果。它提供工具和资源,以便与 MCP 客户端或主机(例如 Grok 或 Claude for Desktop)进行无缝交互。
安装
要设置 SerpApi MCP 服务器,请安装所需的 Python 库:
您还需要一个SerpApi API 密钥。在 SerpApi 注册即可获取。
快速入门
- 保存服务器代码:将服务器代码放在文件中,例如 server.py。
- 配置 API 密钥:在与 SerpApi API 密钥相同的目录中创建一个 .env 文件:
- 运行服务器:使用以下命令启动服务器:
- 与 MCP 客户端集成:将服务器连接到 MCP 客户端或主机(例如 Claude for Desktop)。对于 Claude,请更新 Claude_desktop_config.json 文件:
重新启动客户端以加载服务器。
特征
- 支持的引擎:Google、Google Light、Bing、沃尔玛、雅虎、eBay、YouTube、DuckDuckGo、Yandex、百度
- 工具:
- 搜索:使用查询和可选参数在指定引擎上执行搜索。
- 资源:
- 位置:查找 Google 位置。
使用示例
这些示例假设 MCP 客户端(例如,使用 MCP 客户端 SDK 以 Python 编写)已连接到服务器。列出支持的引擎检索支持的搜索引擎列表:
执行搜索使用位置过滤器在 Google 上搜索“咖啡”:
打印(结果)
配置
API 密钥:在.env
文件中将您的 SerpApi API 密钥设置为SERPAPI_API_KEY
。
运行服务器
生产模式:使用以下命令启动服务器:
开发模式:使用 MCP Inspector 进行调试:
测试
使用 MCP 检查器或 MCP 客户端测试服务器。对于 Claude 桌面版,请在Claude_desktop_config.json
中配置服务器,重启应用,然后使用锤子图标探索和测试可用的工具。
This server cannot be installed
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 等多个搜索引擎检索搜索结果,从而可以快速访问实时和存档的搜索数据。
Related Resources
Related MCP Servers
- AsecurityFlicenseAqualityEnables 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 -112TypeScript
- AsecurityAlicenseAqualityA 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 -24TypeScriptMIT License
- AsecurityFlicenseAqualityAn MCP protocol server that enables web search functionality using the Tavily API, allowing AI assistants to perform internet searches in real-time.Last updated -42Python
- -securityAlicense-qualityMCP server for using various search tools like Tavily API. Planning to support various search tools (i.e. wiki search, searxng, etc)Last updated -1PythonMIT License
Appeared in Searches
- Finding an LLM that integrates with MCP for precise calculations and accurate answers
- A resource for in-depth exploration of scientific topics
- Searching for web-based information or resources
- Using large language models to analyze and guide bid document preparation
- Using Google to search and generate answers