
Google AI Studio MCP 服务器——强大的 Gemini API 集成,支持模型上下文协议,支持多模态文件处理、PDF 转 Markdown 转换、图像分析和音频转录......
概览
一个与 Google AI Studio / Gemini API 集成的模型上下文协议(MCP)服务器,提供内容生成功能,支持文件、对话历史和系统提示。 - Node.js 20.0.0 或更高版本 - Google AI Studio API 密钥 将你的 Google AI Studio API 密钥设置为环境变量: - GEMINI_MODEL:采用Gemini型号(默认:gemini-2.5-flash)- GEMINI_TIMEOUT:请求超时(毫秒)(默认:300000 = 5分钟)- GEMINI_MAX_OUTPUT_TOKENS:最大输出令牌数(默认:8192)- GEMINI_MAX_FILES:每次请求最大文件数(默认:10)- GEMINI_MAX_TOTAL_FILE_SIZE:最大文件大小(MB)(默认:50)- GEMINI_TEMPERATURE:生成温度(0-2,默认:0.2) 使用Gemini生成内容,全面支持文件、对话历史和系统提示。支持多种文件类型,包括图片、PDF、Office文档和文本文件。
概述(AI 翻译)
一个与 Google AI Studio / Gemini API 集成的模型上下文协议(MCP)服务器,提供内容生成功能,支持文件、对话历史和系统提示。
安装与使用
先决条件
- Node.js 20.0.0 或更高
- Google AI Studio API 密钥
使用 NPX(推荐)
本地安装
配置
将你的 Google AI Studio API 密钥设置为环境变量:
可选配置
GEMINI_MODEL:拟用Gemini型号(默认:gemini-2.5闪光灯)GEMINI_TIMEOUT:请求超时(毫秒)(默认:300000 = 5分钟)GEMINI_MAX_OUTPUT_TOKENS:最大输出令牌数(默认:8192)GEMINI_MAX_FILES:每个请求的最大文件数(默认:10)GEMINI_MAX_TOTAL_FILE_SIZE:最大总文件大小(MB)(默认:50)GEMINI_TEMPERATURE:生成温度(0-2,默认:0.2)
示例:
可用工具
generate_content
使用Gemini生成内容,全面支持文件、对话历史和系统提示。支持多种文件类型,包括图片、PDF、Office文档和文本文件。
参数:
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
AI Studio MCP Server
A Model Context Protocol (MCP) server that integrates with Google AI Studio / Gemini API, providing content generation capabilities with support for files, conversation history, and system prompts.
Installation and Usage
Prerequisites
- Node.js 20.0.0 or higher
- Google AI Studio API key
Using npx (Recommended)
GEMINI_API_KEY=your_api_key npx -y aistudio-mcp-server
Local Installation
npm install -g aistudio-mcp-server
GEMINI_API_KEY=your_api_key aistudio-mcp-server
Configuration
Set your Google AI Studio API key as an environment variable:
export GEMINI_API_KEY=your_api_key_here
Optional Configuration
GEMINI_MODEL: Gemini model to use (default: gemini-2.5-flash)GEMINI_TIMEOUT: Request timeout in milliseconds (default: 300000 = 5 minutes)GEMINI_MAX_OUTPUT_TOKENS: Maximum output tokens (default: 8192)GEMINI_MAX_FILES: Maximum number of files per request (default: 10)GEMINI_MAX_TOTAL_FILE_SIZE: Maximum total file size in MB (default: 50)GEMINI_TEMPERATURE: Temperature for generation (0-2, default: 0.2)
Example:
export GEMINI_API_KEY=your_api_key_here
export GEMINI_MODEL=gemini-2.5-flash
export GEMINI_TIMEOUT=600000 # 10 minutes
export GEMINI_MAX_OUTPUT_TOKENS=16384 # More output tokens
export GEMINI_MAX_FILES=5 # Limit to 5 files per request
export GEMINI_MAX_TOTAL_FILE_SIZE=100 # 100MB limit
export GEMINI_TEMPERATURE=0.7 # More creative responses
Available Tools
generate_content
Generates content using Gemini with comprehensive support for files, conversation history, and system prompts. Supports various file types including images, PDFs, Office documents, and text files.
Parameters:
user_prompt(string, required): User prompt for generationsystem_prompt(string, optional): System prompt to guide AI behaviorfiles(array, optional): Array of files to include in generation- Each file object must have either
pathorcontent path(string): Path to filecontent(string): Base64 encoded file contenttype(string, optional): MIME type (auto-detected from file extension)
- Each file object must have either
model(string, optional): Gemini model to use (default: gemini-2.5-flash)temperature(number, optional): Temperature for generation (0-2, default: 0.2). Lower values produce more focused responses, higher values more creative ones
Supported file types (Gemini 2.5 models):
- Images: JPG, JPEG, PNG, GIF, WebP, SVG, BMP, TIFF
- Video: MP4, AVI, MOV, WEBM, FLV, MPG, WMV (up to 10 files per request)
- Audio: MP3, WAV, AIFF, AAC, OGG, FLAC (up to 15MB per file)
- Documents: PDF (treated as images, one page = one image)
- Text: TXT, MD, JSON, XML, CSV, HTML
File limitations:
- Maximum file size: 15MB per audio/video/document file
- Maximum total request size: 20MB (2GB when using Cloud Storage)
- Video files: Up to 10 per request
安装
npx -y aistudio-mcp-server配置
{
"mcpServers": {
"aistudio": {
"command": "npx",
"args": ["-y", "aistudio-mcp-server"],
"env": {
"GEMINI_API_KEY": "your_api_key_here",
"GEMINI_MODEL": "gemini-2.5-flash",
"GEMINI_TIMEOUT": "600000",
"GEMINI_MAX_OUTPUT_TOKENS": "16384",
"GEMINI_MAX_FILES": "10",
"GEMINI_MAX_TOTAL_FILE_SIZE": "50",
"GEMINI_TEMPERATURE": "0.2"
}
}
}
}