返回市场
谷歌搜索服务

谷歌搜索服务

作者:adenot55 星标更新:2025-09-24

项目介绍

mcp-google-server 使用Google自定义搜索和网页阅读功能的MCP服务器

smithery 徽章

这是一个使用Google自定义搜索API提供网络搜索功能并具备网页内容提取功能的Model Context Protocol服务器。

配置

获取Google API密钥和搜索引擎ID

  1. 创建一个Google Cloud项目:

    • 访问 Google Cloud控制台
    • 创建一个新的项目或选择一个现有的项目
    • 为您的项目启用计费
  2. 启用自定义搜索API:

    • 访问 API库
    • 搜索“自定义搜索API”
    • 点击“启用”
  3. 获取API密钥:

    • 访问 凭据
    • 点击“创建凭据” > “API密钥”
    • 复制您的API密钥
    • (可选)限制API密钥仅用于自定义搜索API
  4. 创建自定义搜索引擎:

    • 访问 可编程搜索引擎
    • 输入您想要搜索的网站(使用www.google.com进行通用网络搜索)
    • 点击“创建”
    • 在下一页点击“自定义”
    • 在设置中启用“搜索整个网络”
    • 复制您的搜索引擎ID(cx)

开发

安装依赖项:

npm install

构建服务器:

npm run build

开发时自动重建:

npm run watch

功能

搜索工具

使用Google自定义搜索API执行网络搜索:

  • 搜索整个网络或特定网站
  • 控制结果数量(1-10)
  • 获取包含标题、链接和摘要的结构化结果

网页阅读工具

从任何网页提取内容:

  • 获取并解析网页内容
  • 提取页面标题和主要内容
  • 清理内容,移除脚本和样式
  • 返回包含标题、文本和URL的结构化数据

安装

通过Smithery安装

要通过Smithery自动安装Google自定义搜索服务器到Claude桌面:

npx -y @smithery/cli install @adenot/mcp-google-search --client claude

要在Claude桌面中使用,请添加包含Google API凭证的服务器配置:

在MacOS上:~/Library/Application Support/Claude/claude_desktop_config.json 在Windows上:%APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "google-search": {
      "command": "npx",
      "args": [
        "-y",
        "@adenot/mcp-google-search"
      ],
      "env": {
        "GOOGLE_API_KEY": "your-api-key-here",
        "GOOGLE_SEARCH_ENGINE_ID": "your-search-engine-id-here"
      }
    }
  }
}

使用

搜索工具

{
  "name": "search",
  "arguments": {
    "query": "您的搜索查询",
    "num": 5  // 可选,默认值为5,最大值为1
  }
}

网页阅读工具

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

网页阅读器示例响应:

{
  "title": "示例域名",
  "text": "提取并清理的网页内容...",
  "url": "https://example.com"
}

调试

由于MCP服务器通过标准I/O通信,调试可能会比较困难。我们推荐使用作为包脚本提供的MCP Inspector

npm run inspector

Inspector会提供一个URL,以便您可以在浏览器中访问调试工具。