MCP Google Custom Search Server
用于通过Google自定义搜索API进行搜索的MCP Server。
📋 简介
MCP Google 自定义搜索服务器是一个符合模型上下文协议(MCP)的服务器,允许语言模型通过Google自定义搜索API执行网络搜索。
🔍 前提条件
- Google Cloud 项目:启用自定义搜索API并创建API密钥
- 自定义搜索引擎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配置文件中(通常位于~/Library/Application Support/Claude/claude_desktop_config.json
):
{
"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"
}
}
}
}
🧪 测试服务器
使用MCP Inspector进行测试:
npx @modelcontextprotocol/inspector node build/index.js
示例查询:
{"jsonrpc":"2.0","id":1,"method":"callTool","params":{"name":"search","arguments":{"query":"example search"}}}
🛠️ 搜索工具参数
query
(字符串, 必需):搜索查询numResults
(数字, 可选):返回结果数 (默认: 5, 最大: 10)
📚 其他开发命令
npm run dev
: 开发监视模式