mcpField
M
MCP Google Custom Search Server

MCP Google Custom Search Server

本地服务
github.com/alexatnordnet搜索与检索4754 周前更新

关于 MCP Google Custom Search Server

MCP Google Custom Search Server 是一个基于 Google Custom Search API 的网页搜索 MCP 服务。它让 大模型 通过统一接口执行搜索,适合需要在 LLM 应用中获取网页结果的开发者。

主要功能

  1. 01调用 Google Custom Search API 进行搜索
  2. 02可配置返回结果数量,最多 10 条
  3. 03结果包含标题、URL 和描述
  4. 04使用 TypeScript 实现并通过 Zod 校验输入

适用场景

  1. 01在 Claude Desktop 等客户端中进行网页搜索
  2. 02为 LLM 应用补充最新的网页信息

MCP 相关

该项目是 MCP 服务,向 MCP 客户端暴露名为 search 的工具,用于执行 Google 自定义搜索。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"google-custom-search-server": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/inspector"
]
}
}
}
启动命令npx -y @modelcontextprotocol/inspector

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
npm@modelcontextprotocol/inspector

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

MCP Google Custom Search Server

一个通过 Google Custom Search API 提供网络搜索功能的 Model Context Protocol(MCP)服务。此服务可让大语言模型(LLM)通过标准化接口执行网络搜索。

🌟 功能

  • 与 Google Custom Search API 无缝集成
  • 符合 Model Context Protocol(MCP)的服务实现
  • 使用 TypeScript 实现类型安全
  • 通过环境变量进行配置
  • 使用 Zod 进行输入验证
  • 可配置搜索结果数量(每次查询最多 10 条)
  • 格式化搜索结果,包括标题、URL 和描述
  • 错误处理与验证
  • 兼容 Claude Desktop 和其他 MCP 客户端

📋 先决条件

开始之前,请确保你已准备好:

  1. 已启用 Custom Search API 的 Google Cloud 项目

  2. Custom Search Engine ID

  3. 本地开发环境要求:

    • Node.js(v18 或更高版本)
    • npm(随 Node.js 一同安装)

🚀 快速开始

  1. 克隆代码库:

    git clone https://github.com/limklister/mcp-google-custom-search-server.git
    cd mcp-google-custom-search-server
    
  2. 安装依赖:

    npm install
    
  3. 创建 .env 文件:

    GOOGLE_API_KEY=your-api-key
    GOOGLE_SEARCH_ENGINE_ID=your-search-engine-id
    
  4. 构建服务:

    npm run build
    
  5. 启动服务:

    npm start
    

🔧 配置

环境变量
变量描述必填
GOOGLE_API_KEY你的 Google Custom Search API 密钥是
GOOGLE_SEARCH_ENGINE_ID你的 Custom Search Engine ID是
Claude Desktop 集成

将此配置添加到 Claude Desktop 配置文件中(通常位于 ~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "google-search": {
      "command": "node",
      "args": [
        "/absolute/path/to/mcp-google-custom-search-server/build/index.js"
      ],
      "env": {
        "GOOGLE_API_KEY": "your-api-key",
        "GOOGLE_SEARCH_ENGINE_ID": "your-search-engine-id"
      }
    }
  }
}

📖 API 参考

可用工具
search

使用 Google Custom Search API 执行网络搜索。

参数:

  • query(字符串,必填):要执行的搜索查询
  • numResults(数字,可选):要返回的结果数量
    • 默认值:5
    • 最大值:10

响应示例:

Result 1:
Title: Example Search Result
URL: https://example.com
Description: This is an example search result description
---

Result 2:
...

🛠️ 开发

项目结构
mcp-google-custom-search-server/
├── src/
│   └── index.ts          # Main server implementation
├── build/                # Compiled JavaScript output
├── .env                  # Environment variables
├── package.json          # Project dependencies and scripts
├── tsconfig.json         # TypeScript configuration
└── README.md            # Project documentation
可用脚本
  • npm run build:将 TypeScript 编译为 JavaScript
  • npm start:启动 MCP 服务
  • npm run dev:开发监视模式
测试
  1. 使用 MCP Inspector:

    npx @modelcontextprotocol/inspector node build/index.js
    
  2. 使用示例查询进行手动测试:

    # After starting the server
    {"jsonrpc":"2.0","id":1,"method":"callTool","params":{"name":"search","arguments":{"query":"example search"}}}
    
Google Custom Search Server MCP server

MseeP.ai Security Assessment Badge

📝 许可证

本项目采用 MIT 许可证授权,详情请参阅 LICENSE 文件。

🙏 致谢

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。