Token导航 LogoToken导航TokenDH.com
Gemini Pro logo
运维云端stdio官方级别未说明来源级核验

Gemini Pro

MCP Server

一个先进的模型上下文协议(MCP)服务器,提供与Google Gemini AI模型的无缝集成,支持复杂推理、JSON模式输出和实时网络信息整合等功能。

工具数

0

提示词数

0

GitHub Stars

14

资源数

0
TypeScriptClaude云端部署Claude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

gurveeer

提供方

gurveeer

最后核验

2026/5/17 20:22

运行时

Docker

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

docker run -d \

详细介绍

🤖 MCP服务器Gemini

![License: MIT](https://opensource.org/licenses/MIT) ![TypeScript](https://www.typescriptlang.org/) ](https://nodejs.org/)

A. 最先进的模型上下文协议(MCP)服务器 它提供了与谷歌Gemini人工智能模型的无缝集成。该服务器使Claude Desktop和其他兼容MCP的客户端能够充分利用Gemini先进的人工智能功能。

✨ 特性

🧠 最新Gemini型号

  • 双子座2.5 Pro -最有能力的复杂推理思维模型
  • 双子座2.5闪光灯 -具有最佳性价比的快速思维模型
  • Gemini 2.0系列 -具有先进功能的最新一代型号
  • Gemini 1.5系列 -经过验证的可靠模型,适用于生产使用

🚀 高性能

  • 🧠 思维模型 -Gemini 2.5系列,逐步推理
  • 🔍 谷歌搜索暂停 -实时网络信息集成
  • 📊 JSON模式 -带模式验证的结构化输出
  • 🎯 系统说明 -行为定制和控制
  • 👁️ 视觉支持 -图像分析和多模式功能
  • 💬 对话记忆 -跨交互的上下文保护

🛠️ 生产就绪

  • TypeScript -全型安全与现代化发展
  • 全面的错误处理 -强大的错误管理和恢复
  • 速率限制 -防止API滥用的内置保护
  • 详细日志记录 -全面监控与调试
  • 输入验证 -使用Zod进行安全参数验证
  • 重试逻辑 -指数回退自动重试

🚀 快速开始

先决条件

安装

选项1:全局安装(推荐)

npm install -g mcp-server-gemini

方案2:地方发展

git clone https://github.com/gurr-i/mcp-server-gemini-pro.git
cd mcp-server-gemini-pro
npm install
npm run build

配置

1.设置API密钥

选项A:环境变量

export GEMINI_API_KEY="your_api_key_here"

选项B:.env文件

echo "GEMINI_API_KEY=your_api_key_here" > .env

2.配置克劳德桌面

添加到您的 claude_desktop_config.json:

对于全局安装:

{
  "mcpServers": {
    "gemini": {
      "command": "mcp-server-gemini",
      "env": {
        "GEMINI_API_KEY": "your_api_key_here"
      }
    }
  }
}

对于本地安装:

{
  "mcpServers": {
    "gemini": {
      "command": "node",
      "args": ["/path/to/mcp-server-gemini-pro/dist/enhanced-stdio-server.js"],
      "env": {
        "GEMINI_API_KEY": "your_api_key_here"
      }
    }
  }
}

3.重新启动克劳德桌面

完全关闭并重新启动Claude Desktop以使更改生效。

💡 使用示例

配置后,您可以使用自然语言通过Claude Desktop使用Gemini:

基本文本生成

"Use Gemini to explain quantum computing in simple terms"
"Generate a creative story about AI using Gemini 2.5 Pro"

高级功能

"Use Gemini with JSON mode to extract key points from this text"
"Use Gemini with grounding to get the latest news about AI"
"Generate a Python function using Gemini's thinking capabilities"

图像分析

"Analyze this image with Gemini" (attach image)
"What's in this screenshot using Gemini vision?"

开发任务

"Use Gemini to review this code and suggest improvements"
"Generate comprehensive tests for this function using Gemini"

⚙️ 配置

环境变量

服务器可以使用环境变量或 .env 文件:

所需配置

# Google AI Studio API Key (required)
GEMINI_API_KEY=your_api_key_here

可选配置

# Logging level (default: info)
# Options: error, warn, info, debug
LOG_LEVEL=info

# Enable performance metrics (default: false)
ENABLE_METRICS=false

# Rate limiting configuration
RATE_LIMIT_ENABLED=true        # Enable/disable rate limiting (default: true)
RATE_LIMIT_REQUESTS=100        # Max requests per window (default: 100)
RATE_LIMIT_WINDOW=60000        # Time window in ms (default: 60000 = 1 minute)

# Request timeout in milliseconds (default: 30000 = 30 seconds)
REQUEST_TIMEOUT=30000

# Environment mode (default: production)
NODE_ENV=production

环境设置

开发环境

# .env for development
GEMINI_API_KEY=your_api_key_here
NODE_ENV=development
LOG_LEVEL=debug
RATE_LIMIT_ENABLED=false
REQUEST_TIMEOUT=60000

生产环境

# .env for production
GEMINI_API_KEY=your_api_key_here
NODE_ENV=production
LOG_LEVEL=warn
RATE_LIMIT_ENABLED=true
RATE_LIMIT_REQUESTS=100
RATE_LIMIT_WINDOW=60000
REQUEST_TIMEOUT=30000
ENABLE_METRICS=true

Claude桌面配置

配置文件位置

操作系统路径
macOS~/Library/Application Support/Claude/claude_desktop_config.json
视窗%APPDATA%\Claude\claude_desktop_config.json
Linux~/.config/Claude/claude_desktop_config.json

基本配置

{
  "mcpServers": {
    "gemini": {
      "command": "mcp-server-gemini",
      "env": {
        "GEMINI_API_KEY": "your_api_key_here"
      }
    }
  }
}

高级配置

{
  "mcpServers": {
    "gemini": {
      "command": "mcp-server-gemini",
      "env": {
        "GEMINI_API_KEY": "your_api_key_here",
        "LOG_LEVEL": "info",
        "RATE_LIMIT_REQUESTS": "200",
        "REQUEST_TIMEOUT": "45000"
      }
    }
  }
}

本地开发配置

{
  "mcpServers": {
    "gemini": {
      "command": "node",
      "args": ["/path/to/mcp-server-gemini-pro/dist/enhanced-stdio-server.js"],
      "cwd": "/path/to/mcp-server-gemini-pro",
      "env": {
        "GEMINI_API_KEY": "your_api_key_here",
        "NODE_ENV": "development",
        "LOG_LEVEL": "debug"
      }
    }
  }
}

🛠️ 可用工具

工具描述主要功能
generate_text生成具有高级功能的文本思维模型、JSON模式、基础
分析图像使用视觉模型分析图像多模态理解,详细分析
count_tokes计算代币以进行成本估算所有型号的准确代币计数
list_models列出所有可用的Gemini型号实时型号可用性和功能
embed_text生成文本嵌入高质量矢量表示
获取帮助获取使用帮助和文档通过示例进行自我记录

📊 模型比较

模型上下文窗口功能最佳选择速度
双子座-2.5-pro2M令牌思考、JSON、接地复杂推理、编码较慢
双子座-2.5-flash1M代币思考、JSON、接地通用快速
双晶-2.5-长石1M令牌思考,JSON高吞吐量任务最快
双子座2.0闪光1M令牌JSON,接地标准任务快速
双子座-2.0-flash-lite1M令牌JSON简单任务最快
gemini-2.0-实验2M令牌JSON,接地实验功能中等
双子座-1.5-pro2M令牌JSON传统支持中等
双子座-1.5-flash1M令牌JSON传统支持快速

🔧 发展

先决条件

设置

# Clone the repository
git clone https://github.com/gurr-i/mcp-server-gemini-pro.git
cd mcp-server-gemini-pro

# Install dependencies
npm install

# Set up environment variables
cp .env.example .env
# Edit .env and add your GEMINI_API_KEY

可用脚本

发展

npm run dev          # Start development server with hot reload
npm run dev:watch    # Start with file watching (nodemon)
npm run build        # Build for production
npm run build:watch  # Build with watch mode
npm run clean        # Clean build directory

测试

npm test             # Run all tests
npm run test:watch   # Run tests in watch mode
npm run test:coverage # Run tests with coverage report
npm run test:integration # Run integration tests (requires API key)

代码质量

npm run lint         # Lint TypeScript code
npm run lint:fix     # Fix linting issues automatically
npm run format       # Format code with Prettier
npm run format:check # Check code formatting
npm run type-check   # Run TypeScript type checking
npm run validate     # Run all quality checks (lint + test + type-check)

发布与分发

npm run prepack      # Prepare package for publishing
npm run release      # Build, validate, and publish to npm

项目结构

mcp-server-gemini/
├── src/                          # Source code
│   ├── config/                   # Configuration management
│   │   └── index.ts             # Environment config with Zod validation
│   ├── utils/                   # Utility modules
│   │   ├── logger.ts           # Structured logging system
│   │   ├── errors.ts           # Custom error classes & handling
│   │   ├── validation.ts       # Input validation with Zod
│   │   └── rateLimiter.ts      # Rate limiting implementation
│   ├── enhanced-stdio-server.ts # Main MCP server implementation
│   └── types.ts                # TypeScript type definitions
├── tests/                       # Test suite
│   ├── unit/                   # Unit tests
│   │   ├── config.test.ts      # Configuration tests
│   │   ├── validation.test.ts  # Validation tests
│   │   └── errors.test.ts      # Error handling tests
│   ├── integration/            # Integration tests
│   │   └── gemini-api.test.ts  # Real API integration tests
│   └── setup.ts               # Test setup and utilities
├── docs/                       # Documentation
│   ├── api.md                 # API reference
│   ├── configuration.md       # Configuration guide
│   └── troubleshooting.md     # Troubleshooting guide
├── scripts/                    # Build and utility scripts
│   ├── build.sh              # Production build script
│   ├── dev.sh                # Development script
│   └── test.sh               # Test execution script
├── .github/workflows/         # GitHub Actions CI/CD
│   ├── ci.yml                # Continuous integration
│   └── release.yml           # Automated releases
├── dist/                      # Built output (generated)
├── coverage/                  # Test coverage reports (generated)
└── node_modules/             # Dependencies (generated)

🧪 测试

测试套件概述

该项目包括全面的测试,包括单元测试、集成测试和代码覆盖率报告。

运行测试

所有测试

npm test                    # Run all tests (unit tests only by default)
npm run test:watch         # Run tests in watch mode for development
npm run test:coverage      # Run tests with coverage report

单元测试

npm test -- --testPathPattern=unit    # Run only unit tests
npm test -- --testNamePattern="config" # Run specific test suites

集成测试

集成测试需要有效的 GEMINI_API_KEY 并进行真正的API调用:

# Set API key and run integration tests
GEMINI_API_KEY=your_api_key_here npm run test:integration

# Or set in .env file and run
npm run test:integration

测试覆盖率

npm run test:coverage      # Generate coverage report
open coverage/lcov-report/index.html  # View coverage report (macOS)

测试结构

单元测试(tests/unit/)

  • 配置测试:环境变量验证、配置加载
  • 验证测试:输入验证、模式验证、净化
  • 错误处理测试:自定义错误类、错误恢复、重试逻辑
  • 公用设施测试:记录器、速率限制器、辅助功能

集成测试(tests/integration/)

  • Gemini API测试:用于测试连接和功能的真实API调用
  • 模型测试:验证所有支持的模型是否正常工作
  • 特性测试:JSON模式、基础、嵌入、令牌计数

写作测试

测试文件结构

// tests/unit/example.test.ts
import { describe, it, expect, beforeEach, afterEach } from '@jest/globals';
import { YourModule } from '../../src/your-module.js';

describe('YourModule', () => {
  beforeEach(() => {
    // Setup before each test
  });

  afterEach(() => {
    // Cleanup after each test
  });

  it('should do something', () => {
    // Test implementation
    expect(result).toBe(expected);
  });
});

定制配对器

测试套件包括自定义Jest匹配器:

expect(response).toBeValidMCPResponse(); // Validates MCP response format

测试配置

测试配置在 jest.config.js 与:

  • TypeScript支持:完整的ES模块和TypeScript编译
  • 覆盖阈值:要求最低70%的覆盖率
  • 测试超时:30秒用于集成测试
  • 安装文件:自动测试环境设置

🐳 Docker部署

使用Docker

构建并运行

# Build the Docker image
docker build -t mcp-server-gemini .

# Run the container
docker run -d \
  --name mcp-server-gemini \
  -e GEMINI_API_KEY=your_api_key_here \
  -e LOG_LEVEL=info \
  mcp-server-gemini

使用Docker Compose

# Create .env file with your API key
echo "GEMINI_API_KEY=your_api_key_here" > .env

# Start the service
docker-compose up -d

# View logs
docker-compose logs -f

# Stop the service
docker-compose down

Docker开发

# Start development environment
docker-compose --profile dev up

# This mounts source code for live reloading

特定于环境的部署

生产部署

# Production build
docker build --target production -t mcp-server-gemini:prod .

# Run with production settings
docker run -d \
  --name mcp-server-gemini-prod \
  --restart unless-stopped \
  -e GEMINI_API_KEY=your_api_key_here \
  -e NODE_ENV=production \
  -e LOG_LEVEL=warn \
  -e RATE_LIMIT_ENABLED=true \
  -e ENABLE_METRICS=true \
  mcp-server-gemini:prod

健康检查

# Check container health
docker ps
docker logs mcp-server-gemini

# Manual health check
docker exec mcp-server-gemini node -e "console.log('Health check passed')"

🚀 部署选项

1.npm全局安装

# Install globally
npm install -g mcp-server-gemini

# Run directly
GEMINI_API_KEY=your_key mcp-server-gemini

2.本地安装

# Clone and build
git clone https://github.com/gurr-i/mcp-server-gemini-pro.git
cd mcp-server-gemini-pro
npm install
npm run build

# Run locally
GEMINI_API_KEY=your_key npm start

3.Docker部署

# Using Docker Hub (when published)
docker run -e GEMINI_API_KEY=your_key mcp-server-gemini-pro:latest

# Using local build
docker build -t mcp-server-gemini-pro .
docker run -e GEMINI_API_KEY=your_key mcp-server-gemini-pro

4.流程经理(PM2)

# Install PM2
npm install -g pm2

# Create ecosystem file
cat > ecosystem.config.js Made with ❤️ By Gurveer for the AI development community

目录标签

目录标签

TypeScriptClaude云端部署AI模型服务本地部署复杂推理JSON模式多模态分析生产级部署

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

api-key

运行时(runtime,运行环境)

Docker

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdioapi-key部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP