打开自定义搜索API MCP服务器
 ](https://www.npmjs.com/package/open-custom-search-api-mcp-server) ](https://www.npmjs.com/package/open-custom-search-api-mcp-server) ](https://github.com/naoto24kawa/open-custom-search-api-mcp-server)
一个模型上下文协议(MCP)服务器,提供对谷歌的自定义搜索API的访问。
特性
- 谷歌搜索:使用Google自定义搜索API搜索网页
- 可配置的结果限制(1-10个结果)
- API凭据的环境变量配置
- 全面的错误处理
安装
使用npx(推荐)
# Run directly without installation
npx open-custom-search-api-mcp-server本地安装
npm install -g open-custom-search-api-mcp-server先决条件
用法
使用npx运行
npx open-custom-search-api-mcp-server在本地运行
# After global installation
open-custom-search-api-mcp-server可用工具
谷歌搜索
使用Google自定义搜索API搜索网页。
参数:
query(必填):搜索查询limit(可选):返回的最大结果数(1-10,默认值:10)
例子:
{
"name": "google_search",
"arguments": {
"query": "MCP server development",
"limit": 5
}
}答复:
{
"query": "MCP server development",
"totalResults": "1000000",
"searchTime": 0.123,
"results": [
{
"title": "Example Result",
"link": "https://example.com",
"snippet": "This is an example search result...",
"displayLink": "example.com"
}
]
}配置
MCP客户端配置
要将此服务器与Claude Desktop或其他MCP客户端一起使用,请将以下配置添加到您的MCP客户端设置中(例如。, .mcp.json 或克劳德桌面配置):
{
"mcpServers": {
"custom-search": {
"command": "npx",
"args": ["open-custom-search-api-mcp-server"],
"env": {
"GOOGLE_API_KEY": "your-google-api-key",
"GOOGLE_SEARCH_ENGINE_ID": "your-custom-search-engine-id"
}
}
}
}对于本地开发或全球安装:
{
"mcpServers": {
"custom-search": {
"command": "open-custom-search-api-mcp-server",
"env": {
"GOOGLE_API_KEY": "your-google-api-key",
"GOOGLE_SEARCH_ENGINE_ID": "your-custom-search-engine-id"
}
}
}
}环境变量
服务器需要以下环境变量:
GOOGLE_API_KEY:来自Google云控制台的Google API密钥GOOGLE_SEARCH_ENGINE_ID:您在谷歌自定义搜索中的自定义搜索引擎ID
建筑
所有搜索操作都在MCP服务器上本地执行,以尽量减少AI令牌的消耗。服务器处理:
- 对Google自定义搜索API的HTTP/HTTPS请求
- JSON响应解析和格式化
- API故障的错误处理
- 环境变量验证
- 输入参数验证
许可证
麻省理工学院
