
MCP Google Custom Search Server

Overview
基本能力
产品定位
MCP Google Custom Search Server 是一个为语言学习模型 (LLMs) 提供网页搜索能力的服务,通过 Google 的 Custom Search API 实现标准化搜索接口。
核心功能
- 与 Google Custom Search API 无缝集成
- 符合 Model Context Protocol (MCP) 的服务器实现
- 使用 TypeScript 的类型安全实现
- 通过环境变量配置
- 使用 Zod 进行输入验证
- 可配置的搜索结果(最多 10 条/查询)
- 格式化的搜索结果,包括标题、URL 和描述
- 错误处理和验证
- 与 Claude Desktop 和其他 MCP 客户端兼容
适用场景
- 语言学习模型 (LLMs) 需要执行网页搜索的场景
- 需要标准化搜索接口的应用
- 需要集成 Google 搜索能力的开发项目
工具列表
search
执行使用 Google Custom Search API 的网页搜索。
参数:
- query
(string, 必需): 要执行的搜索查询
- numResults
(number, 可选): 返回的结果数量
- 默认: 5
- 最大: 10
示例响应:
Result 1:
Title: Example Search Result
URL: https://example.com
Description: This is an example search result description
---
Result 2:
...
常见问题解答
- 如何获取 Google API 密钥和搜索引擎 ID?
- 访问 Google Cloud Console 启用 Custom Search API 并创建 API 凭证
-
访问 Programmable Search Engine 创建新的搜索引擎并获取搜索引擎 ID
-
如何与 Claude Desktop 集成?
- 在 Claude Desktop 配置文件中添加 MCP 服务器配置,指定服务器路径和环境变量
使用教程
使用依赖
- 一个启用了 Custom Search API 的 Google Cloud 项目
- 一个自定义搜索引擎 ID
- 本地开发要求:
- Node.js (v18 或更高版本)
- npm (随 Node.js 一起安装)
安装教程
-
克隆仓库:
bash git clone https://github.com/yourusername/mcp-google-custom-search-server.git cd mcp-google-custom-search-server
-
安装依赖:
bash npm install
-
创建 .env 文件:
bash GOOGLE_API_KEY=your-api-key GOOGLE_SEARCH_ENGINE_ID=your-search-engine-id
-
构建服务器:
bash npm run build
-
启动服务器:
bash npm start
调试方式
-
使用 MCP Inspector:
bash npx @modelcontextprotocol/inspector node build/index.js
-
使用示例查询手动测试:
bash {"jsonrpc":"2.0","id":1,"method":"callTool","params":{"name":"search","arguments":{"query":"example search"}}}