Google Search Mcp Server

Google Search Mcp Server

🚀 谷歌搜索 MCP 服务器

本项目是一个集成 Google 自定义搜索 JSON API 的 MCP 服务器实现,能够为用户提供强大的网络搜索功能,满足多样化的搜索需求。

🚀 快速开始

若想使用该服务器,你需要先完成 API 密钥和环境变量的配置,然后从本地仓库运行服务器。具体步骤如下:

  1. 获取 API 密钥
  2. 设置环境变量 在运行服务器之前设置这些变量:
export GOOGLE_API_KEY="your-api-key"
export GOOGLE_SEARCH_ENGINE_ID="your-search-engine-id"
  1. 从本地仓库运行服务器
    • 克隆仓库
git clone https://github.com/ayush-rudani/google-search-mcp-server.git
cd google-search-mcp-server
- **安装依赖项**
pnpm install
# 或者
npm install
- **构建项目**
pnpm run build
# 或者
npm run build
- **配置 Claude Desktop**

更新你的 claude_desktop_config.json:

{
"mcpServers": {
"google-search": {
"command": "/path/to/node", // <--- 在终端运行 `echo "$(which node)"` 以获取路径
"args": ["/full/path/to/google-search-mcp/index.js"],
"env": {
"GOOGLE_API_KEY": "your-api-key",
"GOOGLE_SEARCH_ENGINE_ID": "your-search-engine-id"
}
}
}
}

将 /path/to/node 替换为你系统中 Node.js 可执行文件的完整路径。 - 测试服务器

export GOOGLE_API_KEY=你的_api_key_here
export GOOGLE_SEARCH_ENGINE_ID=你的_engine_id_here
node dist/index.js

✨ 主要特性

  • 网页搜索:支持使用全面的查询选项搜索 Google,满足各种搜索需求。
  • 高级过滤:可通过日期、语言、国家和安全搜索级别控制搜索结果,精准定位所需信息。
  • 限流:内置限流功能,默认每分钟 10 次请求,有效防止超出 API 配额。
  • 结构化结果:返回格式化的搜索结果,包含标题、URL 和摘录,方便查看和使用。

📦 安装指南

若要从本地仓库运行该服务器,可按以下步骤操作:

  1. 克隆仓库
git clone https://github.com/ayush-rudani/google-search-mcp-server.git
cd google-search-mcp-server
  1. 安装依赖项
pnpm install
# 或者
npm install
  1. 构建项目
pnpm run build
# 或者
npm run build

📚 详细文档

工具

  • google_search
    • 功能:使用高级过滤选项执行 Google 搜索。
    • 输入参数: | 参数 | 类型 | 是否必填 | 详情 | |------|------|------|------| | query | 字符串 | 是 | 搜索词 | | num_results | 数字 | 否 | 结果数量(范围 1 - 10,默认值:5) | | date_restrict | 字符串 | 否 | 按日期筛选(例如,“d1”表示过去一天) | | language | 字符串 | 否 | 2 字符语言代码(例如,“en”) | | country | 字符串 | 否 | 2 字符国家代码(例如,“us”) | | safe_search | 字符串 | 否 | 安全级别(“off”,“medium”,“high”) |

配置

获取 API 密钥

  1. 在 Google Cloud Console 创建一个 Google Cloud 项目。
  2. 在 API Dashboard 激活 Custom Search JSON API。
  3. 通过 Credentials 部分或按照 Custom Search API 指南 生成一个 API 密钥。
  4. 通过设置自定义搜索引擎在 Google 的可编程搜索 获取搜索引擎 ID。

环境变量

在运行服务器之前设置这些变量:

export GOOGLE_API_KEY="your-api-key"
export GOOGLE_SEARCH_ENGINE_ID="your-search-engine-id"

从本地仓库运行

  1. 克隆仓库
git clone https://github.com/ayush-rudani/google-search-mcp-server.git
cd google-search-mcp-server
  1. 安装依赖项
pnpm install
# 或者
npm install
  1. 构建项目
pnpm run build
# 或者
npm run build
  1. 配置 Claude Desktop 更新你的 claude_desktop_config.json:
{
"mcpServers": {
"google-search": {
"command": "/path/to/node", // <--- 在终端运行 `echo "$(which node)"` 以获取路径
"args": ["/full/path/to/google-search-mcp/index.js"],
"env": {
"GOOGLE_API_KEY": "your-api-key",
"GOOGLE_SEARCH_ENGINE_ID": "your-search-engine-id"
}
}
}
}

将 /path/to/node 替换为你系统中 Node.js 可执行文件的完整路径。 5. 测试服务器

export GOOGLE_API_KEY=你的_api_key_here
export GOOGLE_SEARCH_ENGINE_ID=你的_engine_id_here
node dist/index.js

限流

该服务器默认启用每分钟 10 次请求的速率限制以防止超出 Google 的 API 配额。你可以在代码中调整此设置。

📄 许可证

此 MCP 服务器根据 MIT 许可证发布。有关详细信息,请参阅 LICENSE 文件。

  • 0 关注
  • 0 收藏,197 浏览
  • system 提出于 2025-09-23 10:45

相似服务问题

相关AI产品