Gemini Flash MCP
by jezweb
This MCP server connects to Google's Gemini 2.0 Flash for image generation, designed for Roo Code and other MCP-compatible AI assistants. It allows AI assistants to generate images through the Model Context Protocol (MCP) with fine-grained control over the generation process.
Last updated: N/A
Gemini Flash MCP - Image Generation for Roo Code
This project provides a Model Context Protocol (MCP) server for connecting to Google's Gemini 2.0 Flash image generation model. It's specifically designed to work with Roo Code and other MCP-compatible AI assistants.
Currently working on issues with API connection
Currently testing and trying to resolve some issues with the Gemini API. Code may not be functional sorry!
Overview
This MCP server provides a tool for Gemini 2.0 Flash image generation with comprehensive support for all available API options. It allows AI assistants like Roo Code to generate images through the Model Context Protocol (MCP) with fine-grained control over the generation process.
Features
- Text-to-image generation using Google's Gemini 2.0 Flash model
- Full support for all available API parameters
- Simple web interface for testing and demonstration
- Easy installation for Roo Code and Claude Desktop
- Comprehensive documentation and examples
Installation
Prerequisites
- Node.js 18 or higher
- A Google AI Studio API key with access to the Gemini 2.0 Flash model
Global Installation
- Install the package globally:
npm install -g gemini-flash-mcp
- Run the setup command to configure Roo Code:
gemini-flash-mcp-install
- Set your Google AI API key in Roo Code settings:
- Open Roo Code
- Go to Settings
- Add the following environment variable to the MCP server configuration:
"gemini-flash-mcp": {
"env": {
"GEMINI_API_KEY": "your-google-ai-api-key"
}
}
- Restart Roo Code
Manual Installation
- Clone this repository:
git clone https://github.com/jezweb/gemini-image-generation-mcp.git
cd gemini-image-generation-mcp
- Install dependencies:
npm install
- Build the project:
npm run build
- Configure your MCP settings manually:
- For Roo Code: Edit
~/.config/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json
- For Claude Desktop: Edit
~/Library/Application Support/Claude/claude_desktop_config.json
(macOS) or appropriate path for your OS
Add the following configuration:
"gemini-flash-mcp": {
"command": "node",
"args": ["/path/to/gemini-flash-mcp/build/index.js"],
"env": {
"GEMINI_API_KEY": "your-google-ai-api-key"
}
}
- Restart Roo Code or Claude Desktop
Usage
Once installed, you can use the generate_image
tool in Roo Code or other MCP-compatible assistants:
Please generate an image of a sailing boat on Sydney Harbour
Available Parameters
The generate_image
tool supports the following parameters:
prompt
(required): Text description of the desired imagetemperature
: Controls randomness (0.0 to 1.0, default: 1.0)topP
: Controls diversity via nucleus sampling (0.0 to 1.0, default: 0.95)topK
: Controls diversity via top-k sampling (default: 40)maxOutputTokens
: Maximum number of tokens to generate (default: 8192)
Web Interface
A web interface is available for testing the image generation:
npm start
Then open your browser to http://localhost:3000
Development
Project Structure
src/
- Source code for the MCP serverindex.ts
- Main server file with the image generation toolgemini.ts
- Gemini API integrationinstall.ts
- Installation script for Roo Code and Claude Desktop
build/
- Compiled JavaScript filestest-gemini.html
- Web interface for testing image generationtest-gemini.js
- Direct test script for the Gemini API
Building
npm run build
Testing
npm test
Troubleshooting
API Key Issues
If you encounter authentication errors:
- Verify your API key is correct
- Ensure you have access to the Gemini 2.0 Flash model
- Check that the environment variable is properly set in your MCP configuration
Connection Issues
If the MCP server fails to connect:
- Check that the server is running
- Verify the path in your MCP configuration is correct
- Ensure the server has the correct permissions
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgements
- Google for providing the Gemini 2.0 Flash API
- The Model Context Protocol (MCP) team for enabling AI assistant extensibility