Google Search MCP Server

Google Search MCP Server

为与 VS Code / Cline / Anthropic 使用而构建的MCP Server - 启用谷歌搜索并能够跟随链接和研究网站。

简介

这是一个为 AI 模型提供 Google 搜索和网页分析能力的 MCP 服务器,兼容 VS Code、Cline 和 Anthropic 工具。

前提条件

  • Node.js ≥ 16
  • Python ≥ 3.8
  • Google Cloud Platform 账户
  • 自定义搜索引擎 ID 和 API 密钥

快速设置

  1. 克隆并安装依赖

    git clone [repository-url]
    cd google-search-server
    npm install
    pip install flask google-api-python-client flask-cors
    
  2. 配置 API 凭证

    创建 api-keys.json 文件:

    {
        "api_key": "your-google-api-key",
        "search_engine_id": "your-custom-search-engine-id"
    }
    
  3. 设置 MCP 配置

    添加到 cline_mcp_settings.json

    {
      "mcpServers": {
        "google-search": {
          "command": "npm",
          "args": ["run", "start:all"],
          "cwd": "/path/to/google-search-server"
        }
      }
    }
    
  4. 构建并启动服务器

    npm run build
    npm run start:all
    

可用工具

search

{
  "name": "search",
  "arguments": {
    "query": "your search query",
    "num_results": 5
  }
}

analyze_webpage

{
  "name": "analyze_webpage",
  "arguments": {
    "url": "https://example.com"
  }
}

batch_analyze_webpages

{
  "name": "batch_analyze_webpages",
  "arguments": {
    "urls": [
      "https://example1.com",
      "https://example2.com"
    ]
  }
}

获取 Google API 凭证

  1. 访问 Google Cloud 控制台
  2. 创建/选择项目并启用自定义搜索 API
  3. 创建 API 密钥
  4. 自定义搜索引擎页面创建搜索引擎
  5. 获取引擎 ID 并添加到配置文件

疑难解答

如遇问题,检查:

  • API 凭证是否正确
  • 网络连接状态
  • 服务器日志中的错误信息