SerpMCP
](https://pypi.org/project/mcp-serp/) ](https://pypi.org/project/mcp-serp/)   
A. 模型上下文协议(MCP) 用于Google搜索的服务器 SERP API 通过 AceDataCloud API.
直接从Claude、VS Code或任何兼容MCP的客户端执行谷歌搜索并获得结构化结果。
特性
- 网络搜索 -常规谷歌网络搜索,结构化结果
- 图片搜索 -使用URL和缩略图搜索图像
- 新闻搜索 -获取任何主题的最新新闻文章
- 视频搜索 -从YouTube和其他来源查找视频
- 地点搜索 -搜索当地企业和地点
- 地图搜索 -查找位置和地理信息
- 知识图谱 -获取结构化实体信息
- 本地化 -支持多个国家和语言
- 时间过滤 -按时间范围筛选结果
工具参考
| 工具 | 说明 |
|---|---|
serp_google_search | 搜索谷歌并使用SERP API获得结构化结果。 |
serp_google_images | 搜索谷歌图片并获得图片结果。 |
serp_google_news | 搜索谷歌新闻,获取新闻文章结果。 |
serp_google_videos | 搜索谷歌视频并获取视频结果。 |
serp_google_places | 在谷歌上搜索当地的地方和企业。 |
serp_google_maps | 在谷歌地图上搜索位置。 |
serp_list_search_types | 列出所有可用的谷歌搜索类型。 |
serp_list_countries | 列出谷歌搜索中常用的国家代码。 |
serp_list_languages | 列出谷歌搜索中常用的语言代码。 |
serp_list_time_ranges | 列出谷歌搜索的可用时间范围过滤器。 |
serp_get_usage_guide | 获取使用Google SERP工具的全面指南。 |
快速开始
1.获取您的API代币
- 注册地址: AceDataCloud平台
- 去 API文档页
- 点击 “收购” 获取您的API令牌
- 复制令牌以在下面使用
2.使用托管服务器(推荐)
AceDataCloud托管托管MCP服务器-- 无需本地安装.
端点: https://serp.mcp.acedata.cloud/mcp
所有请求都需要一个Bearer令牌。使用步骤1中的API令牌。
Claude.ai
直接连接 Claude.ai 使用OAuth-- 不需要API令牌:
- 转到Claude.ai 设置→ 集成→ 添加更多
- 输入服务器URL:
https://serp.mcp.acedata.cloud/mcp - 完成OAuth登录流程
- 开始在对话中使用工具
克劳德桌面版
添加到您的配置(~/Library/Application Support/Claude/claude_desktop_config.json 在macOS上):
{
"mcpServers": {
"serp": {
"type": "streamable-http",
"url": "https://serp.mcp.acedata.cloud/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_TOKEN"
}
}
}
}光标/风帆
添加到MCP配置(.cursor/mcp.json 或 .windsurf/mcp.json):
{
"mcpServers": {
"serp": {
"type": "streamable-http",
"url": "https://serp.mcp.acedata.cloud/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_TOKEN"
}
}
}
}VS代码(副本)
添加到您的VS代码MCP配置中(.vscode/mcp.json):
{
"servers": {
"serp": {
"type": "streamable-http",
"url": "https://serp.mcp.acedata.cloud/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_TOKEN"
}
}
}
}或安装 Ace数据云MCP扩展 对于VS Code,它通过一键设置捆绑了所有15个MCP服务器。
JetBrains集成开发环境
- 首选 设置→ 工具→ AI助手→ 模型上下文协议(MCP)
- 点击 添加 → 超文本传输协议
- 粘贴:
{
"mcpServers": {
"serp": {
"url": "https://serp.mcp.acedata.cloud/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_TOKEN"
}
}
}
}克劳德代码
Claude Code原生支持MCP服务器:
claude mcp add serp --transport http https://serp.mcp.acedata.cloud/mcp \
-h "Authorization: Bearer YOUR_API_TOKEN"或添加到您的项目 .mcp.json:
{
"mcpServers": {
"serp": {
"type": "streamable-http",
"url": "https://serp.mcp.acedata.cloud/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_TOKEN"
}
}
}
}克莱恩
添加到Cline的MCP设置(.cline/mcp_settings.json):
{
"mcpServers": {
"serp": {
"type": "streamable-http",
"url": "https://serp.mcp.acedata.cloud/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_TOKEN"
}
}
}
}亚马逊Q开发者
添加到MCP配置中:
{
"mcpServers": {
"serp": {
"type": "streamable-http",
"url": "https://serp.mcp.acedata.cloud/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_TOKEN"
}
}
}
}Roo代码
添加到Roo Code MCP设置:
{
"mcpServers": {
"serp": {
"type": "streamable-http",
"url": "https://serp.mcp.acedata.cloud/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_TOKEN"
}
}
}
}Continue.dev
添加 .continue/config.yaml:
mcpServers:
- name: serp
type: streamable-http
url: https://serp.mcp.acedata.cloud/mcp
headers:
Authorization: "Bearer YOUR_API_TOKEN"泽德
添加到Zed的设置中(~/.config/zed/settings.json):
{
"language_models": {
"mcp_servers": {
"serp": {
"url": "https://serp.mcp.acedata.cloud/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_TOKEN"
}
}
}
}
}cURL测试
# Health check (no auth required)
curl https://serp.mcp.acedata.cloud/health
# MCP initialize
curl -X POST https://serp.mcp.acedata.cloud/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'3.或在本地运行(替代方案)
如果您更喜欢在自己的计算机上运行服务器:
# Install from PyPI
pip install mcp-serp
# or
uvx mcp-serp
# Set your API token
export ACEDATACLOUD_API_TOKEN="your_token_here"
# Run (stdio mode for Claude Desktop / local clients)
mcp-serp
# Run (HTTP mode for remote access)
mcp-serp --transport http --port 8000克劳德桌面(本地)
{
"mcpServers": {
"serp": {
"command": "uvx",
"args": ["mcp-serp"],
"env": {
"ACEDATACLOUD_API_TOKEN": "your_token_here"
}
}
}
}Docker(自托管)
docker pull ghcr.io/acedatacloud/mcp-serp:latest
docker run -p 8000:8000 ghcr.io/acedatacloud/mcp-serp:latest客户端使用自己的Bearer令牌进行连接——服务器从每个请求中提取令牌 Authorization 头球
可用工具
搜索工具
| 工具 | 说明 |
|---|---|
serp_google_search | 灵活的谷歌搜索,提供所有选项 |
serp_google_images | 搜索图片 |
serp_google_news | 搜索新闻文章 |
serp_google_videos | 搜索视频 |
serp_google_places | 搜索当地地点/企业 |
serp_google_maps | 搜索地图位置 |
信息工具
| 工具 | 说明 |
|---|---|
serp_list_search_types | 列出可用的搜索类型 |
serp_list_countries | 列出本地化的国家代码 |
serp_list_languages | 列出本地化语言代码 |
serp_list_time_ranges | 列出时间范围过滤器选项 |
serp_get_usage_guide | 获取全面的使用指南 |
用法示例
基本网络搜索
User: Search for information about artificial intelligence
Claude: I'll search for information about AI.
[Calls serp_google_search with query="artificial intelligence"]使用时间过滤器搜索新闻
User: What's the latest news about technology?
Claude: I'll search for recent tech news.
[Calls serp_google_news with query="technology", time_range="qdr:d"]本地化搜索
User: Find popular restaurants in Tokyo
Claude: I'll search for restaurants in Tokyo.
[Calls serp_google_places with query="popular restaurants Tokyo", country="jp"]图片搜索
User: Find images of the Northern Lights
Claude: I'll search for aurora borealis images.
[Calls serp_google_images with query="Northern Lights aurora borealis"]搜索参数
搜索类型
| 类型 | 描述 |
|---|---|
search | 常规网络搜索(默认) |
images | 图片搜索 |
news | 新闻文章 |
maps | 地图结果 |
places | 当地企业 |
videos | 视频结果 |
时间范围过滤器
| 代码 | 时间范围 |
|---|---|
qdr:h | 过去一小时 |
qdr:d | 过去一天 |
qdr:w | 上周 |
qdr:m | 上个月 |
常见国家代码
| 代码 | 国家 |
|---|---|
us | 美国 |
uk | 联合王国 |
cn 中国 | |
jp | 日本 |
de | 德国 |
fr | 法国 |
通用语言代码
| 代码 | 语言 |
|---|---|
en | 英语 |
zh-cn | 中文(简体) |
ja | 日语 |
es | 西班牙语 |
fr | 法语 |
de | 德语 |
响应结构
常规搜索结果
- 知识图:实体信息(公司、个人等)
- answer_box:直接回答
- 有机的:带有标题、链接、片段的常规搜索结果
- 人_也_问:相关问题
- 相关研究:相关查询
图片搜索结果
- 图像:带有URL和缩略图的图像结果
新闻搜索结果
- 新闻:带有来源和日期的新闻文章
配置
环境变量
| 变量 | 描述 | 默认值 |
|---|---|---|
ACEDATACLOUD_API_TOKEN | 来自AceDataCloud的API令牌 | 必需 |
ACEDATACLOUD_API_BASE_URL | API基本URL | https://api.acedata.cloud |
ACEDATACLOUD_OAUTH_CLIENT_ID | OAuth客户端ID(托管模式) | -- |
ACEDATACLOUD_PLATFORM_BASE_URL | 平台基础URL | https://platform.acedata.cloud |
SERP_REQUEST_TIMEOUT | 请求超时(秒) | 30 |
LOG_LEVEL | 日志记录级别 | INFO |
命令行选项
mcp-serp --help
Options:
--version Show version
--transport Transport mode: stdio (default) or http
--port Port for HTTP transport (default: 8000)发展
设置开发环境
# Clone repository
git clone https://github.com/AceDataCloud/SerpMCP.git
cd SerpMCP
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # or `.venv\Scripts\activate` on Windows
# Install with dev dependencies
pip install -e ".[dev,test]"运行测试
# Run unit tests
pytest
# Run with coverage
pytest --cov=core --cov=tools
# Run integration tests (requires API token)
pytest tests/test_integration.py -m integration代码质量
# Format code
ruff format .
# Lint code
ruff check .
# Type check
mypy core tools构建和发布
# Install build dependencies
pip install -e ".[release]"
# Build package
python -m build
# Upload to PyPI
twine upload dist/*项目结构
SerpMCP/
├── core/ # Core modules
│ ├── __init__.py
│ ├── client.py # HTTP client for SERP API
│ ├── config.py # Configuration management
│ ├── exceptions.py # Custom exceptions
│ └── server.py # MCP server initialization
├── tools/ # MCP tool definitions
│ ├── __init__.py
│ ├── search_tools.py # Search tools
│ └── info_tools.py # Information tools
├── prompts/ # MCP prompt templates
│ └── __init__.py
├── tests/ # Test suite
│ ├── conftest.py
│ ├── test_client.py
│ └── test_config.py
├── deploy/ # Deployment configs
│ └── production/
│ ├── deployment.yaml
│ ├── ingress.yaml
│ └── service.yaml
├── .env.example # Environment template
├── .gitignore
├── CHANGELOG.md
├── Dockerfile # Docker image for HTTP mode
├── docker-compose.yaml # Docker Compose config
├── LICENSE
├── main.py # Entry point
├── pyproject.toml # Project configuration
└── README.mdAPI 参考
此服务器包装 AceDataCloud谷歌SERP API:
贡献
欢迎投稿!拜托:
- 分叉存储库
- 创建要素分支(
git checkout -b feature/amazing) - 提交您的更改(
git commit -m 'Add amazing feature') - 推到分支(
git push origin feature/amazing) - 打开拉取请求
许可证
MIT许可证-请参阅 许可证 了解详情。
链接
______________________________________________________________________
用爱制作 AceDataCloud
