> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xhuoapi.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Google 搜尋 MCP 對接指南

> serp MCP 服务器集成

[MCP（Model Context Protocol）](https://modelcontextprotocol.io) 是由 Anthropic 推出的模型上下文協議，允許 AI 模型（如 Claude、GPT 等）通過標準化介面調用外部工具。通過 XHuoAPI 提供的 SERP MCP Server，你可以在 Claude Desktop、VS Code、Cursor 等 AI 客戶端中直接進行 Google 搜尋，獲取網頁、圖片、新聞、視頻、地點等搜尋結果。

## 功能概覽

SERP MCP Server 提供以下核心功能：

* **網頁搜尋** — 搜尋 Google 網頁結果
* **圖片搜尋** — 搜尋 Google 圖片
* **新聞搜尋** — 搜尋 Google 新聞
* **視頻搜尋** — 搜尋 Google 視頻
* **地點搜尋** — 搜尋 Google 地點資訊
* **地圖搜尋** — 搜尋 Google 地圖
* **多語言多地區** — 支援自訂國家和語言參數
* **時間範圍篩選** — 按天、週、月、年篩選結果

## 前置準備

使用前，你需要獲取 XHuoAPI API Token：

1. 註冊或登入 [XHuoAPI 平台](https://api.xhuoapi.ai)
2. 前往 [Google SERP API](https://api.xhuoapi.ai/documents/serp-google) 頁面
3. 點擊「Acquire」獲取 API Token（首次申請贈送免費額度）

## 安裝配置

### 方式一：pip 安裝（推薦）

```bash theme={null}
pip install mcp-serp
```

### 方式二：原始碼安裝

```bash theme={null}
git clone https://github.com/XHuoAPI/SerpMCP.git
cd SerpMCP
pip install -e .
```

安裝完成後，即可使用 `mcp-serp` 命令啟動服務。

## 在 Claude Desktop 中使用

編輯 Claude Desktop 配置檔：

* **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
* **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`

添加以下配置：

```json theme={null}
{
  "mcpServers": {
    "serp": {
      "command": "mcp-serp",
      "env": {
        "XHuoAPI_API_TOKEN": "你的API Token"
      }
    }
  }
}
```

如果使用 `uvx`（無需提前安裝包）：

```json theme={null}
{
  "mcpServers": {
    "serp": {
      "command": "uvx",
      "args": ["mcp-serp"],
      "env": {
        "XHuoAPI_API_TOKEN": "你的API Token"
      }
    }
  }
}
```

保存配置後重啟 Claude Desktop，即可在對話中使用 Google 搜尋相關工具。

## 在 VS Code / Cursor 中使用

在專案根目錄創建 `.vscode/mcp.json`：

```json theme={null}
{
  "servers": {
    "serp": {
      "command": "mcp-serp",
      "env": {
        "XHuoAPI_API_TOKEN": "你的API Token"
      }
    }
  }
}
```

或者使用 `uvx`：

```json theme={null}
{
  "servers": {
    "serp": {
      "command": "uvx",
      "args": ["mcp-serp"],
      "env": {
        "XHuoAPI_API_TOKEN": "你的API Token"
      }
    }
  }
}
```

## 可用工具列表

| 工具名                  | 說明          |
| -------------------- | ----------- |
| `serp_google_search` | Google 網頁搜尋 |
| `serp_google_images` | Google 圖片搜尋 |
| `serp_google_news`   | Google 新聞搜尋 |
| `serp_google_videos` | Google 視頻搜尋 |
| `serp_google_places` | Google 地點搜尋 |
| `serp_google_maps`   | Google 地圖搜尋 |

## 使用示例

配置完成後，你可以在 AI 客戶端中直接用自然語言調用這些功能，例如：

* 「幫我搜尋一下最新的 AI 論文」
* 「搜尋北京好吃的火鍋店」
* 「查找關於 Python 非同步編程的圖片」
* 「搜尋今天的科技新聞」
* 「在地圖上查找附近的咖啡廳」

## 更多信息

* GitHub 倉庫：[XHuoAPI/SerpMCP](https://github.com/XHuoAPI/SerpMCP)
* PyPI 包：[mcp-serp](https://pypi.org/project/mcp-serp/)
* API 文檔：[搜尋引擎 API](https://api.xhuoapi.ai/documents/serp)
