Image Beautifier MCP Server
Enables AI-powered image generation, icon creation, hero banner design, and UI beautification using Google's Gemini Nano Banana API.
README
Image Beautifier MCP Server
A Model Context Protocol (MCP) server that provides AI-powered image generation and UI beautification tools for agents and applications. Built with Node.js and TypeScript, this server enables Claude and other MCP-compatible clients to generate images, icons, hero banners, and beautify UI screenshots.
Powered by Google's Gemini Nano Banana - Uses the official Gemini 2.5 Flash Image API (codename "Nano Banana") for fast, high-quality image generation.
Features
- generate_image: Generate custom images from text prompts with style, size, and format options
- generate_icon: Create icons with different themes (minimal, playful, corporate)
- generate_hero: Generate hero/banner images for products and websites
- beautify_screenshot: Analyze and provide suggestions for UI improvements (stub implementation)
Architecture
- Provider-based design: Easily swap between different image generation backends (Gemini, OpenAI, Replicate, local Stable Diffusion)
- Security-first: Path validation, rate limiting, and safe file operations
- Stdio transport: Compatible with Claude Desktop, Claude Code, and other MCP hosts
- Type-safe: Full TypeScript implementation with Zod validation
Installation
Prerequisites
- Node.js 18.0.0 or higher
- npm or yarn
- A Gemini API key (or configure a different provider)
Setup
- Clone the repository:
git clone <repository-url>
cd banana-mcp
- Install dependencies:
npm install
- Configure environment variables:
cp .env.example .env
Edit .env and add your API credentials:
GEMINI_API_KEY=your_api_key_here
GEMINI_BASE_URL=https://generativelanguage.googleapis.com
GEMINI_MODEL=gemini-2.5-flash-image
LOG_LEVEL=info
RATE_LIMIT_PER_MINUTE=20
- Build the project:
npm run build
- Run the server:
npm start
Getting Your Gemini API Key
This server uses Google's Gemini 2.5 Flash Image (codename "Nano Banana") for image generation.
- Visit Google AI Studio
- Sign in with your Google account
- Click "Get API Key" or "Create API Key"
- Copy your API key
- Add it to your
.envfile asGEMINI_API_KEY
Available Models:
gemini-2.5-flash-image- Nano Banana (fast, optimized for speed)gemini-3-pro-image-preview- Nano Banana Pro (professional quality, enterprise)
API Documentation:
Configuration
Environment Variables
| Variable | Description | Default |
|---|---|---|
GEMINI_API_KEY |
Your Gemini API key | (required) |
GEMINI_BASE_URL |
Gemini API base URL | https://generativelanguage.googleapis.com |
GEMINI_MODEL |
Model name for image generation | gemini-2.5-flash-image |
LOG_LEVEL |
Logging level (debug, info, warn, error) | info |
RATE_LIMIT_PER_MINUTE |
Max requests per minute per tool | 20 |
OUTPUT_DIR |
Directory for generated images | ./outputs |
MCP Host Configuration
Claude Desktop
Add to your Claude Desktop config file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"image-beautifier": {
"command": "node",
"args": ["/absolute/path/to/banana-mcp/dist/index.js"],
"env": {
"GEMINI_API_KEY": "your_api_key_here"
}
}
}
}
Claude Code
Add to your MCP settings:
{
"mcpServers": {
"image-beautifier": {
"command": "node",
"args": ["/absolute/path/to/banana-mcp/dist/index.js"]
}
}
}
Make sure your .env file is properly configured in the project directory.
Tools Reference
generate_image
Generate an image from a text prompt with customizable options.
Input:
{
"prompt": "A cute cartoon banana wearing sunglasses",
"style": "illustration",
"size": "1024x1024",
"background": "solid",
"output_format": "png",
"output_path": "my_image.png"
}
Parameters:
prompt(required): Text description (1-2000 characters)style:illustration|3d|flat|photoreal|anime|pixel(default:illustration)size:1024x1024|1024x1536|1536x1024(default:1024x1024)background:transparent|solid(default:solid)output_format:png|webp(default:png)output_path(optional): Custom filename (must be in outputs/ directory)
Output:
{
"ok": true,
"file_path": "outputs/generate_image_2026-02-10T12-30-45_a1b2c3d4.png",
"mime_type": "image/png",
"width": 1024,
"height": 1024
}
generate_icon
Generate an icon from a concept with customizable theme.
Input:
{
"concept": "A rocket ship launching into space",
"theme": "minimal",
"size": "512x512",
"output_format": "png"
}
Parameters:
concept(required): Icon concept description (1-2000 characters)theme:minimal|playful|corporate(default:minimal)size:256x256|512x512(default:512x512)output_format:png|webp(default:png)
Output:
{
"ok": true,
"file_path": "outputs/generate_icon_2026-02-10T12-31-20_e5f6g7h8.png",
"mime_type": "image/png",
"width": 512,
"height": 512
}
generate_hero
Generate a hero/banner image for a product or website.
Input:
{
"product_name": "BananaMCP",
"tagline": "The sweetest MCP server for image generation",
"vibe": "modern",
"size": "1536x1024",
"output_format": "png"
}
Parameters:
product_name(required): Product or website name (1-200 characters)tagline(required): Product tagline (1-500 characters)vibe(optional): Mood/vibe description (max 200 characters)size:1024x1024|1024x1536|1536x1024(default:1536x1024)output_format:png|webp(default:png)
Output:
{
"ok": true,
"file_path": "outputs/generate_hero_2026-02-10T12-32-15_i9j0k1l2.png",
"mime_type": "image/png",
"width": 1536,
"height": 1024
}
If provider is not configured:
{
"ok": false,
"suggested_prompt": "Hero banner image for \"BananaMCP\"...",
"message": "Image provider not configured. Configure GEMINI_API_KEY to generate images."
}
beautify_screenshot
Analyze a screenshot and provide UI improvement suggestions (stub implementation).
Input:
{
"input_image_path": "outputs/screenshot.png",
"goal": "Make the UI more modern and clean",
"output_format": "png"
}
Parameters:
input_image_path(required): Path to screenshot (must be in outputs/ directory)goal(required): Beautification goal (1-1000 characters)output_format:png|webp(default:png)
Output:
{
"ok": true,
"message": "Beautify screenshot is currently a stub implementation",
"suggested_steps": [
"Increase whitespace and padding for a cleaner look",
"Use a consistent color palette throughout the UI",
"Improve typography hierarchy with varied font sizes",
"..."
],
"note": "To implement image editing, integrate an image manipulation API or library"
}
Testing
Run the test suite to verify the server is working:
npm run test
This will test all four tools and show example outputs. If GEMINI_API_KEY is not configured, tests will show what would happen with a configured provider.
Output Files
All generated images are saved to the outputs/ directory with automatically generated filenames:
outputs/
generate_image_2026-02-10T12-30-45_a1b2c3d4.png
generate_icon_2026-02-10T12-31-20_e5f6g7h8.png
generate_hero_2026-02-10T12-32-15_i9j0k1l2.png
To clean up generated files:
rm outputs/*.png outputs/*.webp
About the Gemini Nano Banana Provider
This server uses the official Gemini API format for image generation. The implementation is based on Google's documented API structure:
API Details:
- Endpoint:
/v1beta/models/{model}:generateContent - Authentication:
x-goog-api-keyheader - Request Format: Official
contents+generationConfigstructure - Response Format:
candidates[0].content.parts[].inline_data.data
Key Features:
- Automatic aspect ratio detection (1:1, 16:9, 3:2, etc.)
- Image size optimization (1K, 2K, 4K)
- Style enhancement via prompt engineering
- Base64 image data in responses
No customization needed - the provider works out-of-the-box with the official Gemini API. Just add your API key!
Advanced: Switching Models
To use Nano Banana Pro (higher quality):
GEMINI_MODEL=gemini-3-pro-image-preview
Troubleshooting API Issues
If you encounter API errors:
-
Enable debug logging:
LOG_LEVEL=debug -
Check your API key: Visit Google AI Studio
-
Verify model availability: Some models may require enterprise access
-
Review API quotas: Check your usage limits in Google AI Studio
Adding New Providers
To add support for OpenAI, Replicate, or other image generation services:
- Create a new provider file in
src/providers/:
// src/providers/openaiProvider.ts
import { ImageProvider, ImageGenerationOptions, ImageGenerationResult } from './imageProvider.js';
export class OpenAIProvider implements ImageProvider {
// Implement the interface methods
}
- Update
src/mcp/server.tsto use your provider:
const imageProvider: ImageProvider = new OpenAIProvider();
- Add necessary environment variables to
.env.example
Security Features
- Path validation: All file operations are restricted to the
outputs/directory - Rate limiting: Configurable per-minute request limits (default: 20)
- Input validation: Prompt length limits (max 2000 characters)
- Error sanitization: API keys and sensitive data are never exposed in error messages
- Safe filename generation: Automatic filename generation prevents path traversal attacks
Troubleshooting
"Provider not configured" error
Make sure GEMINI_API_KEY is set in your .env file or passed via environment variables in your MCP host configuration.
"Rate limit exceeded" error
Reduce the frequency of requests or increase RATE_LIMIT_PER_MINUTE in your .env file.
"Invalid output path" error
Ensure output_path (if provided) is a simple filename without directory separators. The file will automatically be saved to the outputs/ directory.
Images not generating
- Check your API key is valid
- Verify the
GEMINI_BASE_URLandGEMINI_MODELmatch your API setup - Enable debug logging:
LOG_LEVEL=debugin.env - Check the logs for API error messages
TypeScript compilation errors
Make sure you're using Node.js 18+ and have installed all dependencies:
node --version # Should be >= 18.0.0
npm install
npm run build
Development
Project Structure
banana-mcp/
├── src/
│ ├── index.ts # Server entry point
│ ├── mcp/
│ │ ├── server.ts # MCP server and tool handlers
│ │ └── schema.ts # Tool schemas
│ ├── providers/
│ │ ├── imageProvider.ts # Provider interface
│ │ └── geminiProvider.ts # Gemini implementation
│ └── utils/
│ ├── files.ts # File operations
│ ├── paths.ts # Path validation
│ ├── validate.ts # Input validation
│ └── log.ts # Logging
├── scripts/
│ └── test.ts # Test suite
├── outputs/ # Generated images
├── package.json
├── tsconfig.json
├── .env.example
└── README.md
Building
npm run build
Running in Development
npm run dev
Cleaning Build Artifacts
npm run clean
License
MIT
Contributing
Contributions are welcome! Please feel free to submit issues and pull requests.
Support
For issues and questions, please open an issue on the GitHub repository.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。