一个提供谷歌自定义搜索功能的模型上下文协议(MCP)服务器,能为相关应用集成谷歌搜索能力。
本服务器可提供谷歌自定义搜索功能,下面将为你介绍其安装、配置和使用方法。
要自动为Claude Desktop安装 google-search-mcp-server,请使用 Smithery:
npx -y @smithery/cli install @gradusnikov/google-search-mcp-server --client claude
git clone https://github.com/gradusnikov/google-search-mpc-server.git
cd google-search-mpc-server
pip install fastmcp google-api-python-client python-dotenv
在项目根目录中创建一个 .env 文件,包含以下变量:
GOOGLE_API_KEY=your_google_api_key
GOOGLE_CSE_ID=your_custom_search_engine_id
获取这些凭证的方法:
使用 MCP 运行服务器:
mcp run google_search_mcp_server.py
或在 Claude Desktop 应用的 CLAUDE_DIRECTORY/claude_desktop_config.json 中添加该服务器。例如,如果你使用的是 Windows Subsystem for Linux (WSL),配置可能如下所示:
"google-search": {
"command": "wsl.exe",
"args": [
"bash",
"-c",
"source /home/[user]/anaconda3/etc/profile.d/conda.sh && conda activate mcp && /home/[user]/anaconda3/bin/mcp run /home/[user]/google-search-mpc-server/google_search_mcp_server.py"
]
},