MCP Gemini API 服务器
适用于 Cursor 和 Claude 的 Google Gemini API 服务器。 Gemini 提供多种功能,包括文本生成、图像分析和视频分析。
主要特点
- 文本生成(使用gemini-2.0-flash模型)
- 图像创建和分析
- YouTube 视频分析
- 网络搜索
开始
基本要求
- Node.js 18.0.0 或更高版本
- npm 或 yarn
- Google API 密钥(用于访问 Gemini API)
安装
偏好设置
- 在
config.ts
文件中设置您的 Google API 密钥:
构建并运行
PM2 服务器管理
服务器通过 PM2 自动管理。您可以使用以下命令管理您的服务器:
Cursor/Claude 集成
MCP 设置
将以下设置添加到您的~/.cursor/mcp.json
文件:
API 端点
/gem-generate
:生成文本/gem-generate-image
:图像生成/分析/gem-analyze-video
:分析 YouTube 视频/gem-search
:网页搜索
重大更新
最新版本(2024-03)
- 通过 PM2 实现服务器自动化
- 统一到 gemini-2.0-flash 模型
- 增加了自动重启和错误恢复功能
- 改善您的设置
先前版本
- 添加了 YouTube 视频分析功能
- 改进的图像创建/分析能力
- 添加网页搜索功能
故障排除
常见问题
- 如果服务器没有启动
- API 密钥错误
- 确保您的 API 密钥在
config.ts
文件中设置正确。 - 检查 Gemini API 配额和权限
- 确保您的 API 密钥在
- 内存使用问题
- 检查
ecosystem.config.js
中的内存限制设置 - 使用 PM2 监控跟踪内存使用情况
- 检查
贡献
- 分叉项目
- 创建你的功能分支(
git checkout -b feature/AmazingFeature
) - 提交您的更改(
git commit -m 'Add some AmazingFeature'
) - 推送到分支(
git push origin feature/AmazingFeature
) - 打开拉取请求
执照
该项目遵循 MIT 许可证。请参阅LICENSE文件以了解详细信息。
接触
项目经理:techkwon 电子邮件: techkwon@example.com项目链接: https://github.com/techkwon/mcp-gemini
关键依赖关系
- @google/generative-ai:^0.1.3(Gemini API SDK)
- @fastify/cors:^8.5.0(CORS 支持)
- fastify:^4.29.0(Web 服务器框架)
- googleapis:^148.0.0(Google API 支持)
- 打字稿:^5.0.0
- zod:^3.24.2(数据验证)
- pino: ^8.21.0 (日志记录)
Claude 桌面应用程序集成指南
设置文件位置
Claude 桌面应用程序的设置文件位于以下路径:
- Windows:
%APPDATA%/Claude/config.json
- macOS:
~/Library/Application Support/Claude/config.json
JSON 设置示例
变量描述
{uuid}
:自动生成的唯一请求ID。{input}
:输入到 Claude 聊天窗口的文本
如何使用
- 打开 Claude 桌面应用程序的设置文件。
- 将上面的 JSON 设置添加到您现有的设置中。
- 重新启动 Claude 桌面应用程序。
- 您可以在聊天窗口中使用它,如下所示:
响应格式
所有 API 响应都遵循以下格式:
错误响应
如果发生错误,请按照以下格式进行响应:
错误处理
在以下情况下,服务器将返回适当的错误响应:
- 400:错误的请求格式
- 401:身份验证错误(API 密钥相关)
- 500:内部服务器错误
安全注意事项
- 确保将您的 API 密钥作为环境变量进行管理。
- 在生产环境中,添加适当的安全设置。
- 注意不要记录敏感信息。
故障排除
端口冲突
如果端口 8000 已被使用:
服务器稳定性
如果服务器意外终止:
- 考虑使用 PM2 或其他进程管理器。
- 检查日志以确定终止的原因。
开发指南
日志记录
- 使用 Pino logger 实现结构化日志记录
- 在开发环境中,通过 pino-pretty 输出可读的日志。
类型安全
- 使用 TypeScript 和 Zod 确保运行时类型安全
- 已实现 API 请求/响应的模式验证。
CLINE MCP 市场注册指南
前期准备
- 您的 GitHub 存储库必须是公开的
- README.md 文件应包含清晰的安装和设置说明。
- (可选)您可以通过
llms-install.md
文件为您的 AI 代理提供额外的安装说明。
注册程序
- 在CLINE MCP Marketplace 存储库中创建新问题
- 该问题包含以下信息:
- GitHub 仓库网址: https://github.com/techkwon/mcp-gemini
- 徽标图像: PNG文件,尺寸为400×400
- **附加原因:**此 MCP 服务器可以为 CLINE 用户提供的价值示例:GXP12
- 测试 CLINE 是否能仅使用 README.md 成功安装服务器
审批流程
- CLINE 团队审查已提交的 MCP 服务器
- 我们正在进行安全性和稳定性验证
- 一旦获得批准,您将被列入市场并可供所有 CLINE 用户访问。
优化安装指南
您可以通过创建llms-install.md
文件为您的 AI 代理提供额外的安装说明:
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
通过 MCP 协议提供对 Google Gemini AI 功能(包括文本生成、图像分析、YouTube 视频分析和网络搜索功能)的访问的服务器。
Related MCP Servers
- -securityAlicense-qualityModel Context Protocol (MCP) server implementation that enables Claude Desktop to interact with Google's Gemini AI models.Last updated -53TypeScriptMIT License
- -securityAlicense-qualityA server that enables Claude Desktop to generate images using Google's Gemini AI models through the Model Context Protocol (MCP).Last updated -1JavaScriptMIT License
- -security-license-qualityAn MCP server implementation that allows using Google's Gemini AI models (specifically Gemini 1.5 Pro) through Claude or other MCP clients via the Model Context Protocol.Last updated -1JavaScript
- AsecurityAlicenseAqualityA dedicated server that wraps Google's Gemini AI models in a Model Context Protocol (MCP) interface, allowing other LLMs and MCP-compatible systems to access Gemini's capabilities like content generation, function calling, chat, and file handling through standardized tools.Last updated -1620TypeScriptMIT License