
Google Search MCP Server
一个 MCP (模型上下文协议) 服务器,提供 Google 搜索功能和网页内容分析工具。该服务器使 AI 模型能够以编程方式执行 Google 搜索并分析网页内容。
Tools
google_search
Search Google and return relevant results from the web. This tool finds web pages, articles, and information on specific topics using Google's search engine. Results include titles, snippets, and URLs that can be analyzed further using extract_webpage_content.
extract_webpage_content
Extract and analyze content from a webpage, converting it to readable text. This tool fetches the main content while removing ads, navigation elements, and other clutter. Use it to get detailed information from specific pages found via google_search. Works with most common webpage formats including articles, blogs, and documentation.
extract_multiple_webpages
Extract and analyze content from multiple webpages in a single request. This tool is ideal for comparing information across different sources or gathering comprehensive information on a topic. Limited to 5 URLs per request to maintain performance.
README
专为 Cline + VS Code 设计!
Google 搜索 MCP 服务器
一个 MCP (模型上下文协议) 服务器,提供 Google 搜索功能和网页内容分析工具。该服务器使 AI 模型能够以编程方式执行 Google 搜索和分析网页内容。
功能
- 具有过滤选项(日期、语言、国家/地区、安全搜索)的高级 Google 搜索
- 详细的网页内容提取和分析
- 用于比较多个来源的批量网页分析
- 环境变量支持 API 凭据
- 全面的错误处理和用户反馈
- 符合 MCP 的接口,可与 AI 助手无缝集成
前提条件
- Node.js (v16 或更高版本)
- Python (v3.8 或更高版本)
- Google Cloud Platform 帐户
- 自定义搜索引擎 ID
- Google API 密钥
安装
-
克隆存储库:
git clone https://github.com/your-username/google-search-mcp.git cd google-search-mcp
-
安装 Node.js 依赖项:
npm install
-
安装 Python 依赖项:
pip install flask google-api-python-client flask-cors beautifulsoup4 trafilatura markdownify
-
构建 TypeScript 代码:
npm run build
-
创建一个辅助脚本来启动 Python 服务器(Windows 示例):
# 创建 start-python-servers.cmd @echo off echo Starting Python servers for Google Search MCP... REM Start Python search server start "Google Search API" cmd /k "python google_search.py" REM Start Python link viewer start "Link Viewer" cmd /k "python link_view.py" echo Python servers started. You can close this window.
配置
API 凭据
您可以通过两种方式提供 Google API 凭据:
-
环境变量(推荐):
- 在您的环境中设置
GOOGLE_API_KEY
和GOOGLE_SEARCH_ENGINE_ID
- 服务器将自动使用这些值
- 在您的环境中设置
-
配置文件:
- 在根目录中创建一个
api-keys.json
文件:
{ "api_key": "your-google-api-key", "search_engine_id": "your-custom-search-engine-id" }
- 在根目录中创建一个
MCP 设置配置
将服务器配置添加到您的 MCP 设置文件:
对于 Cline (VS Code 扩展)
文件位置:%APPDATA%\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json
{
"mcpServers": {
"google-search": {
"command": "C:\\Program Files\\nodejs\\node.exe",
"args": ["C:\\path\\to\\google-search-mcp\\dist\\google-search.js"],
"cwd": "C:\\path\\to\\google-search-mcp",
"env": {
"GOOGLE_API_KEY": "your-google-api-key",
"GOOGLE_SEARCH_ENGINE_ID": "your-custom-search-engine-id"
},
"disabled": false,
"autoApprove": []
}
}
}
对于 Claude 桌面应用程序
文件位置:%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"google-search": {
"command": "C:\\Program Files\\nodejs\\node.exe",
"args": ["C:\\path\\to\\google-search-mcp\\dist\\google-search.js"],
"cwd": "C:\\path\\to\\google-search-mcp",
"env": {
"GOOGLE_API_KEY": "your-google-api-key",
"GOOGLE_SEARCH_ENGINE_ID": "your-custom-search-engine-id"
},
"disabled": false,
"autoApprove": []
}
}
}
运行服务器
方法 1:单独启动 Python 服务器(推荐)
-
首先,使用辅助脚本启动 Python 服务器:
start-python-servers.cmd
-
配置 MCP 设置以仅运行 Node.js 服务器:
{ "command": "C:\\Program Files\\nodejs\\node.exe", "args": ["C:\\path\\to\\google-search-mcp\\dist\\google-search.js"] }
方法 2:一体化脚本
使用单个命令启动 TypeScript 和 Python 服务器:
npm run start:all
可用工具
1. google_search
搜索 Google 并返回来自网络的相关结果。此工具使用 Google 搜索引擎查找有关特定主题的网页、文章和信息。
{
"name": "google_search",
"arguments": {
"query": "your search query",
"num_results": 5, // optional, default: 5, max: 10
"date_restrict": "w1", // optional, restrict to past day (d1), week (w1), month (m1), year (y1)
"language": "en", // optional, ISO 639-1 language code (en, es, fr, de, ja, etc.)
"country": "us", // optional, ISO 3166-1 alpha-2 country code (us, uk, ca, au, etc.)
"safe_search": "medium" // optional, safe search level: "off", "medium", "high"
}
}
2. extract_webpage_content
提取和分析网页内容,将其转换为可读文本。此工具获取主要内容,同时删除广告、导航元素和其他杂乱内容。
{
"name": "extract_webpage_content",
"arguments": {
"url": "https://example.com"
}
}
3. extract_multiple_webpages
从单个请求中的多个网页提取和分析内容。非常适合比较不同来源的信息或收集有关某个主题的全面信息。
{
"name": "extract_multiple_webpages",
"arguments": {
"urls": [
"https://example1.com",
"https://example2.com"
]
}
}
使用示例
以下是一些如何使用 Google 搜索 MCP 工具的示例:
基本搜索
搜索有关人工智能的信息
带有过滤器的高级搜索
搜索过去一周内有关西班牙语气候变化的最新消息
内容提取
从 https://example.com/article 提取内容
多重内容比较
比较来自以下网站的信息:
- https://site1.com/topic
- https://site2.com/topic
- https://site3.com/topic
获取 Google API 凭据
- 转到 Google Cloud Console
- 创建一个新项目或选择一个现有项目
- 启用 Custom Search API
- 创建 API 凭据(API 密钥)
- 转到 Custom Search Engine 页面
- 创建一个新的搜索引擎并获取您的搜索引擎 ID
- 将这些凭据添加到您的
api-keys.json
文件
错误处理
服务器提供详细的错误消息,用于:
- 缺少或无效的 API 凭据
- 搜索请求失败
- 无效的网页 URL
- 网络连接问题
架构
服务器由两个主要组件组成:
- TypeScript MCP 服务器:处理 MCP 协议通信并提供工具接口
- Python Flask 服务器:管理 Google API 交互和网页内容分析
许可证
MIT
推荐服务器
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。
Excel MCP Server
一个模型上下文协议服务器,使 AI 助手能够读取和写入 Microsoft Excel 文件,支持诸如 xlsx、xlsm、xltx 和 xltm 等格式。
Playwright MCP Server
提供一个利用模型上下文协议的服务器,以实现类人浏览器的自动化,该服务器使用 Playwright,允许控制浏览器行为,例如导航、元素交互和滚动。
@kazuph/mcp-fetch
用于获取网页内容和处理图像的模型上下文协议服务器。这使得 Claude Desktop(或任何 MCP 客户端)能够适当地获取网页内容和处理图像。
Claude Code MCP
一个实现了 Claude Code 作为模型上下文协议(Model Context Protocol, MCP)服务器的方案,它可以通过标准化的 MCP 接口来使用 Claude 的软件工程能力(代码生成、编辑、审查和文件操作)。
Apple MCP Server
通过 MCP 协议与 Apple 应用(如“信息”、“备忘录”和“通讯录”)进行交互,从而使用自然语言发送消息、搜索和打开应用内容。