Provides Google Custom Search API integration, enabling AI agents to perform web searches and retrieve formatted search results with titles, links, and snippets.
Google Search MCP Server
一个基于FastMCP框架的Google搜索服务器,提供Google自定义搜索功能。支持Streamable HTTP传输协议,具备企业级安全认证机制。
✨ 主要特性
- 🔍 Google搜索集成: 使用Google Custom Search API提供强大的搜索功能
- 🚀 Streamable HTTP: 支持实时通信的高性能HTTP传输协议
- 🔐 企业级安全: 内置Bearer Token认证机制,支持生产环境安全部署
- ⚙️ 灵活配置: 通过环境变量轻松配置服务器参数
- 📦 现代化依赖管理: 支持UV和pip两种依赖管理方式
- 🛠️ 开发友好: 完整的开发工具链,包括测试、格式化、类型检查
- 📚 完整文档: 详细的服务器和客户端配置指南
🚀 快速开始
环境要求
- Python 3.8+
- Google API Key
- Google Custom Search Engine ID
安装
使用UV(推荐)
使用pip
配置
- 复制环境变量模板文件:
- 编辑
.env
文件,配置必要的环境变量:
运行服务器
服务器将在 http://127.0.0.1:9000/mcp/
启动。
🔧 配置选项
环境变量
变量名 | 描述 | 默认值 | 必需 |
---|---|---|---|
GOOGLE_API_KEY | Google API密钥 | - | ✅ |
GOOGLE_CSE_ID | Google自定义搜索引擎ID | - | ✅ |
HTTP_HOST | 服务器主机地址 | 127.0.0.1 | ❌ |
HTTP_PORT | 服务器端口 | 9000 | ❌ |
ENABLE_AUTH | 是否启用认证 | false | ❌ |
API_TOKEN | API认证令牌 | - | 认证启用时必需 |
认证配置
开发环境(无认证)
生产环境(启用认证)
📖 使用方法
服务器API
服务器提供一个搜索工具:
search_google
执行Google搜索并返回格式化结果。
参数:
query
(str): 搜索查询字符串num_results
(int, 可选): 返回结果数量,默认为5auth_token
(str, 可选): 认证令牌(启用认证时必需)
返回值:
客户端连接
基本连接(无认证)
带认证的连接
运行示例
项目提供了完整的客户端示例:
🛠️ 开发
安装开发依赖
代码格式化
类型检查
测试
代码检查
📁 项目结构
🔍 详细文档
🤝 贡献
欢迎贡献代码!请遵循以下步骤:
- Fork本项目
- 创建功能分支 (
git checkout -b feature/AmazingFeature
) - 提交更改 (
git commit -m 'Add some AmazingFeature'
) - 推送到分支 (
git push origin feature/AmazingFeature
) - 创建Pull Request
📄 许可证
本项目采用MIT许可证 - 查看 LICENSE 文件了解详情。
🙏 致谢
- FastMCP - 提供MCP服务器框架
- Google Custom Search API - 提供搜索功能
- UV - 现代化的Python包管理器
📞 支持
如果您遇到问题或有建议,请:
注意: 使用本服务器需要有效的Google API密钥和Custom Search Engine ID。请确保遵守Google API的使用条款和服务限制。
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Enables Google search functionality through the Google Custom Search API with enterprise-grade security authentication. Supports streamable HTTP transport protocol for real-time search operations with configurable result limits.