MCP Google Custom Search Server
镜像
概述
MCP Google 自定义搜索服务器是一个符合模型上下文协议(MCP)的服务器,让语言模型能够通过 Google 自定义搜索 API 执行网络搜索。
前提条件
- Google Cloud 项目(启用了自定义搜索 API)
- Google 自定义搜索引擎 ID
- Node.js v18+
快速安装
-
克隆仓库
git clone https://github.com/yourusername/mcp-google-custom-search-server.git cd mcp-google-custom-search-server
-
安装依赖
npm install
-
配置环境变量
# 创建.env文件 GOOGLE_API_KEY=your-api-key GOOGLE_SEARCH_ENGINE_ID=your-search-engine-id
-
构建并启动服务器
npm run build npm start
Claude Desktop 集成
将以下配置添加到 Claude Desktop 配置文件:
{
"mcpServers": {
"google-search": {
"command": "node",
"args": [
"/absolute/path/to/mcp-google-custom-search-server/build/index.js"
],
"env": {
"GOOGLE_API_KEY": "your-api-key",
"GOOGLE_SEARCH_ENGINE_ID": "your-search-engine-id"
}
}
}
}
可用工具
search
参数:
query
(必需): 搜索查询numResults
(可选): 结果数量 (默认: 5, 最大: 10)
示例:
{"jsonrpc":"2.0","id":1,"method":"callTool","params":{"name":"search","arguments":{"query":"example search"}}}
测试
使用 MCP Inspector:
npx @modelcontextprotocol/inspector node build/index.js
其他信息
- 环境变量:
GOOGLE_API_KEY
,GOOGLE_SEARCH_ENGINE_ID
- 开发:
npm run dev
用于开发模式 - 许可证: MIT
完整文档请参见项目 README.md 文件。