展示 HN:SerpApi MCP 服务器
Show HN: SerpApi MCP Server

原始链接: https://github.com/serpapi/serpapi-mcp

## SerpApi MCP 服务器摘要 SerpApi MCP 服务器提供模型上下文协议 (MCP) 的实现,为 Claude 等大型语言模型提供强大的搜索和数据提取能力。它与 SerpApi 集成,以访问各种搜索引擎——包括 Google、Bing、YouTube 和 eBay——并提供实时数据,如天气和股票信息。 该服务器动态处理和格式化各种结果类型(新闻、图片、购物等),并提供灵活的 JSON 响应模式(“完整”或“紧凑”)。它作为一个托管服务可通过 `mcp.serpapi.com` 访问(需要 SerpApi API 密钥),或者可以通过 Git 克隆和 `uv run` 在本地运行。 连接可以通过 URL 中的基于路径的 API 密钥或通过 header 中的 Bearer token 建立。核心功能围绕一个“搜索工具”,利用 SerpApi 参数进行自定义查询。详细的 API 参考和参数选项可在 SerpApi 网站上找到。

SerpApi 在 GitHub 上发布了新的 MCP(机器学习内容解析器)服务器,引发了 Hacker News 的讨论。用户重点关注的一个功能是 SerpApi 提供的“美国法律保护”,该保护包含在其付费计划中(例如每月 150 美元的生产计划,包含 15,000 次搜索)。 该保护承诺涵盖与根据第一修正案抓取和解析公共搜索数据相关的法律责任——本质上保护用户免受诉讼。然而,一位评论员表示怀疑,将其与过去 SSL 证书提供商很少支付赔偿的保证进行了比较。他们还指出了一个重大漏洞:如果使用“以其他方式非法”,该保护将不适用。 讨论表明,一些公司可能会专门为了这种责任保护而订阅 SerpApi,尽管对其有效性存在疑问。
相关文章

原文

A Model Context Protocol (MCP) server implementation that integrates with SerpApi for comprehensive search engine results and data extraction.

Python 3.13+ MIT License

  • Multi-Engine Search: Google, Bing, Yahoo, DuckDuckGo, YouTube, eBay, and more
  • Real-time Weather Data: Location-based weather with forecasts via search queries
  • Stock Market Data: Company financials and market data through search integration
  • Dynamic Result Processing: Automatically detects and formats different result types
  • Flexible Response Modes: Complete or compact JSON responses
  • JSON Responses: Structured JSON output with complete or compact modes

SerpApi MCP Server is available as a hosted service at mcp.serpapi.com. In order to connect to it, you need to provide an API key. You can find your API key on your SerpApi dashboard.

You can configure Claude Desktop to use the hosted server:

{
  "mcpServers": {
    "serpapi": {
      "url": "https://mcp.serpapi.com/YOUR_SERPAPI_API_KEY/mcp"
    }
  }
}
git clone https://github.com/serpapi/serpapi-mcp.git
cd serpapi-mcp
uv sync && uv run src/server.py

Configure Claude Desktop:

{
  "mcpServers": {
    "serpapi": {
      "url": "http://localhost:8000/YOUR_SERPAPI_API_KEY/mcp"
    }
  }
}

Get your API key: serpapi.com/manage-api-key

Two methods are supported:

  • Path-based: /YOUR_API_KEY/mcp (recommended)
  • Header-based: Authorization: Bearer YOUR_API_KEY

Examples:

# Path-based
curl "https://mcp.serpapi.com/your_key/mcp" -d '...'

# Header-based  
curl "https://mcp.serpapi.com/mcp" -H "Authorization: Bearer your_key" -d '...'

The MCP server has one main Search Tool that supports all SerpApi engines and result types. You can find all available parameters on the SerpApi API reference.

The parameters you can provide are specific for each API engine. Some sample parameters are provided below:

  • params.q (required): Search query
  • params.engine: Search engine (default: "google_light")
  • params.location: Geographic filter
  • mode: Response mode - "complete" (default) or "compact"
  • ...see other parameters on the SerpApi API reference

Examples:

{"name": "search", "arguments": {"params": {"q": "coffee shops", "location": "Austin, TX"}}}
{"name": "search", "arguments": {"params": {"q": "weather in London"}}}
{"name": "search", "arguments": {"params": {"q": "AAPL stock"}}}
{"name": "search", "arguments": {"params": {"q": "news"}, "mode": "compact"}}
{"name": "search", "arguments": {"params": {"q": "detailed search"}, "mode": "complete"}}

Supported Engines: Google, Bing, Yahoo, DuckDuckGo, YouTube, eBay, and more.

Result Types: Answer boxes, organic results, news, images, shopping - automatically detected and formatted.

# Local development
uv sync && uv run src/server.py

# Docker
docker build -t serpapi-mcp . && docker run -p 8000:8000 serpapi-mcp

# Testing with MCP Inspector
npx @modelcontextprotocol/inspector
# Configure: URL mcp.serpapi.com/YOUR_KEY/mcp, Transport "Streamable HTTP transport"
  • "Missing API key": Include key in URL path /{YOUR_KEY}/mcp or header Bearer YOUR_KEY
  • "Invalid key": Verify at serpapi.com/dashboard
  • "Rate limit exceeded": Wait or upgrade your SerpApi plan
  • "No results": Try different query or engine
  1. Fork the repository
  2. Create your feature branch: git checkout -b feature/amazing-feature
  3. Install dependencies: uv install
  4. Make your changes
  5. Commit changes: git commit -m 'Add amazing feature'
  6. Push to branch: git push origin feature/amazing-feature
  7. Open a Pull Request

MIT License - see LICENSE file for details.

联系我们 contact @ memedata.com