基本能力
产品定位
MCP Google Custom Search Server 是一个提供网页搜索功能的MCP服务器,主要用于增强语言学习模型(LLMs)的搜索能力。
核心功能
- 无缝集成Google Custom Search API
- 符合模型上下文协议(MCP)的服务器实现
- 使用TypeScript进行类型安全实现
- 环境变量配置
- 使用Zod进行输入验证
- 可配置的搜索结果(每次查询最多10个)
- 格式化的搜索结果,包括标题、URL和描述
- 错误处理和验证
- 兼容Claude Desktop和其他MCP客户端
适用场景
- 语言学习模型(LLMs)需要执行网页搜索的场景
- 需要标准化接口进行网页搜索的应用程序
- 需要可配置搜索结果的应用程序
工具列表
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:
...
```
常见问题解答
- 如何获取Google API密钥和搜索引擎ID?
- 访问Google Cloud Console启用Custom Search API并创建API凭证
-
访问Programmable Search Engine创建新的搜索引擎并获取搜索引擎ID
-
如何与Claude Desktop集成?
- 将服务器配置添加到Claude Desktop配置文件中
使用教程
使用依赖
- 一个启用了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"}}}