谷歌搜索与网页读取服务器

一个提供谷歌自定义搜索API和网页内容提取功能的模型上下文协议服务器。

  • by pgzhang
  • JavaScript
  • 本地部署
  • 更新于

使用说明

mcp谷歌服务器用于谷歌自定义搜索和网页阅读的mcp服务器

模型上下文协议服务器,使用Google自定义搜索API和网页内容提取功能提供网络搜索功能。

设置

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

  1. 创建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 Custom Search API执行web搜索:

  • 搜索整个网站或特定网站
  • 控制结果数量(1-10)
  • 使用标题、链接和代码片段获取结构化结果

网页阅读器工具

从任何网页提取内容:

  • 获取并解析网页内容
  • 提取页面标题和正文
  • 通过删除脚本和样式来清理内容
  • 返回带有标题、文本和URL的结构化数据

安装

通过Smithery安装

通过以下方式自动安装适用于Claude Desktop的Google自定义搜索服务器 史密瑟里:

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

要与Claude Desktop一起使用,请使用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": {
        "SMARTSEARCH_ENDPOINT": "your-endpoint-here",
        "SMARTSEARCH_AK": "your-ak-here"
      }
    }
  }
}

用法

搜索工具

{
  "name": "search",
  "arguments": {
    "query": "your search query",
    "num": 5  // optional, default is 5, max is 10
  }
}

网页阅读器工具

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

网页阅读器的示例响应:

{
  "title": "Example Domain",
  "text": "Extracted and cleaned webpage content...",
  "url": "https://example.com"
}

调试

由于MCP服务器通过stdio进行通信,调试可能具有挑战性。我们建议使用 MCP检查员,可作为包脚本使用:

npm run inspector

检查器将提供一个URL,用于访问浏览器中的调试工具。