Image Generation MCP
Generates blog and social media images using Google's Gemini AI with pre-configured platform presets for Ghost, Medium, Instagram, Twitter, LinkedIn, YouTube, and more.
README
image-generation-mcp
An MCP (Model Context Protocol) server for generating blog and social media images using AI. Currently supports Google's Gemini/Nano Banana image generation models with a provider architecture designed for easy extension.
Install: npx -y image-generation-mcp
Features
- Platform Presets: Pre-configured dimensions for Ghost, Medium, Instagram, Twitter, LinkedIn, YouTube, and more
- Multiple Quality Levels: Standard (fast) or High (uses Gemini Pro for better quality)
- Auto-Save: Images are always saved to disk (never lost as base64-only responses)
- PNG Metadata: Prompt, model, style, and generation info embedded in every image
- Provider Architecture: Extensible design to support multiple AI providers
- Security First: Input validation, prompt sanitization, safe error handling
Quick Start
Environment Variables
| Variable | Required | Description |
|---|---|---|
GOOGLE_API_KEY |
Yes | Your Google AI API key for Gemini |
IMAGE_OUTPUT_DIR |
No | Default directory for saved images (defaults to ./generated-images) |
Get your API key from Google AI Studio.
Claude Code Setup
Option 1: Published Package (Recommended)
# Add to Claude Code (user scope - available in all projects)
claude mcp add image-gen --scope user -e GOOGLE_API_KEY=your-api-key -- npx -y image-generation-mcp
# Or add to current project only
claude mcp add image-gen -e GOOGLE_API_KEY=your-api-key -- npx -y image-generation-mcp
Option 2: Local Development
# From the project directory, build first
npm run build
# Add local server to Claude Code
claude mcp add image-gen -e GOOGLE_API_KEY=your-api-key -- node /absolute/path/to/image-generation-mcp/dist/index.js
Option 3: Manual Configuration
Add to ~/.claude.json (user scope) or .mcp.json (project scope):
{
"mcpServers": {
"image-gen": {
"type": "stdio",
"command": "npx",
"args": ["-y", "image-generation-mcp"],
"env": {
"GOOGLE_API_KEY": "your-api-key-here"
}
}
}
}
For local development:
{
"mcpServers": {
"image-gen": {
"type": "stdio",
"command": "node",
"args": ["/absolute/path/to/image-generation-mcp/dist/index.js"],
"env": {
"GOOGLE_API_KEY": "your-api-key-here"
}
}
}
}
Verify Installation
# List configured MCP servers
claude mcp list
# Check status within Claude Code
/mcp
Claude Desktop Setup
Add to your claude_desktop_config.json:
{
"mcpServers": {
"image-gen": {
"command": "npx",
"args": ["-y", "image-generation-mcp"],
"env": {
"GOOGLE_API_KEY": "your-api-key-here"
}
}
}
}
Config file locations:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
Tools
generate_blog_image
Generate an image for blog posts or social media.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
prompt |
string | Yes | Description of the image to generate |
format |
string | No | Platform preset (default: ghost-banner) |
quality |
string | No | standard or high (default: standard) |
style |
string | No | Style hint (e.g., "photorealistic", "illustration") |
title |
string | No | Blog post title for context |
outputPath |
string | No | Path to save the image (defaults to ./generated-images/ with timestamp) |
provider |
string | No | Provider to use (default: gemini) |
Example:
Generate a blog banner for my post about TypeScript best practices.
Use format: medium-ghost-spooky, style: modern minimalist
list_image_formats
List all available image format presets.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
category |
string | No | Filter by category: blog, social, video, generic |
Available Formats
Blog Platforms
| Format | Dimensions | Ratio | Description |
|---|---|---|---|
ghost-banner |
1200x675 | 16:9 | Featured image for Ghost blog posts |
ghost-feature |
2000x1125 | 16:9 | High-resolution feature image for Ghost |
medium-ghost-spooky |
2560x1440 | 16:9 | Premium high-resolution blog banner (QHD) |
medium-banner |
1400x788 | 16:9 | Banner image for Medium articles |
substack-header |
1456x816 | 16:9 | Header image for Substack posts |
wordpress-featured |
1200x675 | 16:9 | Featured image for WordPress posts |
Social Media
| Format | Dimensions | Ratio | Description |
|---|---|---|---|
instagram-post |
1080x1080 | 1:1 | Square post for Instagram feed |
instagram-story |
1080x1920 | 9:16 | Vertical story/reel for Instagram |
twitter-post |
1200x675 | 16:9 | Image for Twitter/X posts |
linkedin-post |
1200x628 | ~1.91:1 | Image for LinkedIn posts |
facebook-post |
1200x630 | ~1.91:1 | Image for Facebook posts |
Video Platforms
| Format | Dimensions | Ratio | Description |
|---|---|---|---|
youtube-thumbnail |
1280x720 | 16:9 | Thumbnail for YouTube videos |
youtube-banner |
2560x1440 | 16:9 | Channel banner for YouTube |
Generic
| Format | Dimensions | Ratio | Description |
|---|---|---|---|
square |
1024x1024 | 1:1 | Generic square image |
landscape |
1920x1080 | 16:9 | Standard landscape (1080p) |
landscape-4k |
3840x2160 | 16:9 | 4K landscape image |
portrait |
1080x1920 | 9:16 | Standard portrait/vertical image |
PNG Metadata
Every generated PNG image includes embedded metadata:
| Field | Description |
|---|---|
Description |
The original prompt |
AI-Model |
Model used (e.g., gemini-2.5-flash-image) |
AI-Provider |
Provider name (gemini) |
Image-Format |
Preset used (e.g., twitter-post) |
AI-Style |
Style hint if specified |
Title |
Blog post title if specified |
Creation-Time |
ISO timestamp |
Software |
image-generation-mcp |
View metadata:
# macOS/Linux
strings your-image.png | grep -E "^(Description|AI-|Title|Creation)"
# Or use exiftool
exiftool your-image.png
Security
This MCP server implements several security measures:
- Input Validation: Prompts are validated for length and sanitized
- Prompt Injection Protection: Suspicious patterns are blocked
- Path Traversal Prevention: Output paths are validated
- Safe Error Messages: API keys and sensitive data are never exposed in errors
- No Logging of Secrets: API keys are never logged
⚠️ Disclaimer
This is a simple, vibe-coded MCP server for generating images. It is provided as-is for convenience and educational purposes.
What You Should Know
-
API Key Security: Your
GOOGLE_API_KEYis as safe as you make it. We do not store, log, or transmit your API key anywhere except to Google's API. You are responsible for:- Keeping your API key secure
- Not committing it to version control
- Rotating it if you suspect it has been compromised
-
Data Transmission: Your prompts and generated images are sent to/from Google's Gemini API. Review Google's AI Terms of Service for their data handling policies.
-
No Warranty: This software is provided "AS IS", without warranty of any kind. The authors are not liable for any damages, data loss, API costs, or other issues arising from use of this software.
-
API Costs: Image generation may incur costs on your Google Cloud account. Monitor your usage and set up billing alerts.
-
Content Responsibility: You are responsible for the prompts you submit and the images you generate. Do not use this tool to generate harmful, illegal, or policy-violating content.
License
MIT License - see LICENSE for full terms.
By using this software, you acknowledge that you have read and understood these terms.
Adding New Providers
The server uses a provider interface pattern. To add a new provider:
- Create a new file in
src/providers/implementingImageProvider - Register it in
src/providers/index.ts
// src/providers/my-provider.ts
import { ImageProvider, ImageGenerationOptions, GeneratedImage } from "./types.js";
export class MyProvider implements ImageProvider {
readonly name = "my-provider";
isConfigured(): boolean { /* ... */ }
generateImage(options: ImageGenerationOptions): Promise<GeneratedImage> { /* ... */ }
getSupportedAspectRatios(): string[] { /* ... */ }
getMaxResolution(): { width: number; height: number } { /* ... */ }
}
Development
# Install dependencies
npm install
# Build
npm run build
# Run locally
GOOGLE_API_KEY=your-key node dist/index.js
# Watch mode
npm run dev
# Run tests
npm test
# Lint and format
npm run lint
npm run format
Publishing to npm
# 1. Make sure you're logged in to npm
npm login
# 2. Update version in package.json (if needed)
npm version patch # or minor, major
# 3. Run all checks
npm run check
# 4. Publish
npm publish
# 5. After publishing, users can install with:
# npx image-generation-mcp
# or: npm install -g image-generation-mcp
License
MIT
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。