内容
# Google Search MCP Server
[](https://smithery.ai/server/@gradusnikov/google-search-mcp-server)
一个提供 Google 自定义搜索功能的模型上下文协议 (MCP) 服务器。
## 安装
### 通过 Smithery 安装
要通过 [Smithery](https://smithery.ai/server/@gradusnikov/google-search-mcp-server) 自动安装 google-search-mcp-server 到 Claude Desktop:
```bash
npx -y @smithery/cli install @gradusnikov/google-search-mcp-server --client claude
```
### 手动安装
1. 克隆仓库:
```bash
git clone https://github.com/gradusnikov/google-search-mpc-server.git
cd google-search-mpc-server
```
2. 安装依赖:
```bash
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
```
要获取这些凭据:
1. 创建一个 Google Cloud 项目并启用自定义搜索 API
2. 从 Google Cloud 控制台生成一个 API 密钥
3. 在 https://cse.google.com/cse/all 创建一个自定义搜索引擎并获取其 ID
## 使用
使用 MCP 启动服务器:
```bash
mcp run google_search_mcp_server.py
```
或者将服务器添加到 Claude Desktop 应用的 *CLAUDE_DIRECTORY/claude_desktop_config.json* 中。例如,如果您使用的是 Windows 子系统 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"
]
},
```