Skip to main content
Glama

image-generation-mcp

npm version License: MIT

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

Related MCP server: Gemini Image MCP Server

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

# 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

  1. API Key Security: Your GOOGLE_API_KEY is 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

  2. 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.

  3. 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.

  4. API Costs: Image generation may incur costs on your Google Cloud account. Monitor your usage and set up billing alerts.

  5. 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:

  1. Create a new file in src/providers/ implementing ImageProvider

  2. 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

Available Tools

2 tools
generate_blog_imageA

Generate images for blog posts and social media using AI.

Available formats:

  • ghost-banner: Ghost Blog Banner (1200x675)

  • ghost-feature: Ghost Feature Image (HD) (2000x1125)

  • medium-ghost-spooky: Medium Ghost Spooky (2560x1440)

  • medium-banner: Medium Banner (1400x788)

  • substack-header: Substack Header (1456x816)

  • wordpress-featured: WordPress Featured (1200x675)

  • instagram-post: Instagram Post (1080x1080)

  • instagram-story: Instagram Story (1080x1920)

  • instagram-landscape: Instagram Landscape (1080x608)

  • twitter-post: Twitter/X Post (1200x675)

  • twitter-header: Twitter/X Header (1500x500)

  • linkedin-post: LinkedIn Post (1200x628)

  • linkedin-banner: LinkedIn Banner (1584x396)

  • facebook-post: Facebook Post (1200x630)

  • facebook-cover: Facebook Cover (820x312)

  • youtube-thumbnail: YouTube Thumbnail (1280x720)

  • youtube-banner: YouTube Banner (2560x1440)

  • square: Square (1024x1024)

  • square-hd: Square HD (2048x2048)

  • landscape: Landscape (1920x1080)

  • landscape-4k: Landscape 4K (3840x2160)

  • portrait: Portrait (1080x1920)

Examples:

  • Generate a Ghost blog banner: { "prompt": "A serene mountain landscape at sunset", "format": "ghost-banner" }

  • High quality Instagram post: { "prompt": "Minimalist coffee cup on marble", "format": "instagram-post", "quality": "high" }

  • YouTube thumbnail with title: { "prompt": "Exciting tech reveal", "format": "youtube-thumbnail", "title": "New iPhone 17 Review" }

IMPORTANT: Always specify an outputPath to save the image to a meaningful location. If omitted, images are saved to a generated-images/ directory in the current working directory with a timestamped filename.

ParametersJSON Schema
NameRequiredDescriptionDefault
promptYesDescription of the image to generate
formatNoPlatform preset: ghost-banner, ghost-feature, medium-ghost-spooky, medium-banner, substack-header, wordpress-featured, instagram-post, instagram-story, instagram-landscape, twitter-post, twitter-header, linkedin-post, linkedin-banner, facebook-post, facebook-cover, youtube-thumbnail, youtube-banner, square, square-hd, landscape, landscape-4k, portraitghost-banner
qualityNoQuality levelstandard
styleNoOptional style hint (e.g., 'photorealistic', 'illustration')
titleNoOptional blog post title for context
outputPathNoOptional path to save the image file
providerNoImage generation providergemini

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, description discloses default save behavior and outputPath importance. Does not mention auth, rate limits, or side effects beyond file creation, but cover key behavioral aspects adequately.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Well-organized with headings, bullet list, examples, and a note. Every section serves a purpose, though the format list could be condensed. Front-loaded with purpose, then details.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 7-param tool with no output schema or annotations, the description explains all inputs, default behaviors, and provides examples. Lacks return value details but that falls on schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, baseline 3. Description adds dimensions to each format, examples for quality/title, and clarifies outputPath purpose. Adds meaningful context beyond schema definitions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states 'Generate images for blog posts and social media using AI' - a specific verb and resource. Sibling tool 'list_image_formats' lists formats, while this generates images, making the distinction obvious.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Examples show typical use cases and the IMPORTANT note guides outputPath usage. Lacks explicit when-not-to-use or alternative tools, but the sibling count is small and context is clear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_image_formatsA

List all available image format presets with their dimensions and use cases.

ParametersJSON Schema
NameRequiredDescriptionDefault
categoryNoFilter by category

TDQS

A3.8/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden. It clearly indicates a read-only listing operation and describes the content of the output (dimensions and use cases). It does not discuss permissions or side effects, but for a simple listing tool, this is sufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, concise sentence that front-loads the action ('List all...') and specifies what the output contains. Every word adds value, and there is no redundancy or filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the low complexity (1 optional parameter, no output schema), the description adequately covers the tool's purpose and output content. It could explicitly state that all presets are returned when no category is provided, but the word 'all' implies that. Sibling context is clear.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% coverage with descriptions for the 'category' parameter, including an enum. The description does not add additional meaning to the parameter beyond what the schema provides, so baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool lists all available image format presets and what they include (dimensions and use cases). It is distinct from the sibling 'generate_blog_image' which likely generates an image. However, it does not explicitly differentiate from siblings, missing a chance for clarity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies the tool is used to view available presets before generating an image, but provides no explicit guidance on when to use or not use it, nor any alternatives. The context of a single sibling suggests usage, but lacks direct instruction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 2 tool updates
    • First observedgenerate_blog_image
    • First observedlist_image_formats

TDQS

A4.1/5.0

Scored across 2 tools

Disambiguation5/5

The two tools have clearly distinct purposes: one generates images with various format options, the other lists available formats. No overlap or ambiguity between them.

Naming Consistency5/5

Both tools follow a consistent verb_noun pattern (generate_blog_image, list_image_formats), making it easy to understand their function at a glance.

Tool Count3/5

With only two tools, the server feels slightly thin for its domain. While the generation tool is comprehensive, a few additional tools (e.g., for image editing or batch generation) could better match the scope.

Completeness5/5

The server's stated purpose is generating images for blogs and social media, and listing formats. The generation tool supports a wide variety of formats and options, and the format listing tool provides necessary metadata. No critical gaps are apparent.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers