MCP Google Custom Search Server

MCP Google Custom Search Server

site icon
2024.12.27 1
TypeScript网页搜索语言学习模型支持搜索工具
MCP Google Custom Search Server 是一个基于模型上下文协议(MCP)的服务器,通过Google的Custom Search API提供网页搜索功能。该服务器使语言学习模型(LLMs)能够使用标准化接口执行网页搜索。
View on GitHub

Overview

基本能力

产品定位

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:
...

常见问题解答

  1. 如何获取Google API密钥和搜索引擎ID?
  2. 访问Google Cloud Console启用Custom Search API并创建API凭证
  3. 访问Programmable Search Engine创建新的搜索引擎并获取搜索引擎ID

  4. 如何与Claude Desktop集成?

  5. 将服务器配置添加到Claude Desktop配置文件中

使用教程

使用依赖

  1. 一个启用了Custom Search API的Google Cloud项目
  2. 一个自定义搜索引擎ID
  3. 本地开发要求:
  4. Node.js(v18或更高版本)
  5. npm(随Node.js一起安装)

安装教程

  1. 克隆仓库: bash git clone https://github.com/yourusername/mcp-google-custom-search-server.git cd mcp-google-custom-search-server
  2. 安装依赖: bash npm install
  3. 创建.env文件: bash GOOGLE_API_KEY=your-api-key GOOGLE_SEARCH_ENGINE_ID=your-search-engine-id
  4. 构建服务器: bash npm run build
  5. 启动服务器: bash npm start

调试方式

  1. 使用MCP Inspector: bash npx @modelcontextprotocol/inspector node build/index.js
  2. 使用示例查询进行手动测试: bash {"jsonrpc":"2.0","id":1,"method":"callTool","params":{"name":"search","arguments":{"query":"example search"}}}

许可证

该项目遵循 MIT 开源许可条款,请参阅 MIT 了解完整条款。