a

adsfasdf

pgzhang/adsfasdf
0 Stars 15 次浏览 更新于 2026-08-23

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

MCP 服务配置

复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用

{
  "mcpServers": {
    "google-search": {
      "args": [
        "-y",
        "@adenot/mcp-google-search"
      ],
      "command": "npx",
      "env": {
        "SMARTSEARCH_AK": "your-ak-here",
        "SMARTSEARCH_ENDPOINT": "your-endpoint-here"
      }
    }
  }
}

该服务需要配置环境变量:SMARTSEARCH_AK、SMARTSEARCH_ENDPOINT

服务介绍

mcp-google-server 一个用于 Google 自定义搜索和网页阅读的 MCP 服务器

smithery 徽章

这是一个使用 Google 自定义搜索 API 和网页内容提取功能提供网络搜索能力的模型上下文协议(Model Context Protocol, MCP)服务器。

设置

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

  1. 创建一个 Google Cloud 项目:

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

    • 前往 API 库
    • 搜索“Custom Search API”
    • 点击“启用”
  3. 获取 API 密钥:

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

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

开发

安装依赖项:
bash
npm install

构建服务器:
bash
npm run build

开发时自动重建:
bash
npm run watch

功能

搜索工具

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

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

网页阅读工具

从任何网页中提取内容:

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

安装

通过 Smithery 安装

要通过 Smithery 自动为 Claude Desktop 安装 Google 自定义搜索服务器:

bash
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

json
{
"mcpServers": {
"google-search": {
"command": "npx",
"args": [
"-y",
"@adenot/mcp-google-search"
],
"env": {
"SMARTSEARCH_ENDPOINT": "your-endpoint-here",
"SMARTSEARCH_AK": "your-ak-here"
}
}
}
}

使用

搜索工具

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

网页阅读工具

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

来自网页阅读器的示例响应:
json
{
"title": "Example Domain",
"text": "已提取并清理的网页内容...",
"url": "https://example.com"
}

调试

由于 MCP 服务器通过 stdio 进行通信,调试可能会比较困难。我们推荐使用 MCP Inspector,它作为包脚本可用:

bash
npm run inspector

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

相关 MCP 服务