diagram-forge
Generates diagrams using Google Gemini's image generation capabilities, with support for style references via multi-image input.
Generates diagrams using OpenAI's GPT Image model for professional diagram outputs.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@diagram-forge Create an architecture diagram for a three-tier web app"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Diagram Forge
Turn natural language into enterprise-grade architecture diagrams. Diagram Forge is an MCP server that combines template-driven prompt engineering with swappable AI image providers to generate professional diagrams from any MCP-compatible client.
Instead of wrestling with diagramming tools or manually crafting image generation prompts, describe your system in plain English and let Diagram Forge handle the rest — template selection, prompt engineering, style application, and cost tracking.

Features
13 diagram templates — Architecture (TOGAF), C4 Container, Executive Infographic, data flow, component, sequence, integration, infographic, generic, product roadmap, workstreams, kanban, and brand infographic
2 image providers — Google Gemini (recommended), OpenAI (GPT Image)
Auto provider selection — Each template recommends the best provider/model for its diagram type
Template-driven prompts — YAML templates with hex-coded color systems, explicit rendering instructions, and layout rules
Style references — Feed a visual example to guide output consistency (Gemini)
Cost tracking — SQLite-backed usage and cost reporting
Cross-client — Works with Claude Code, Claude Desktop, Codex CLI, Gemini CLI via stdio transport
Related MCP server: Azure Diagram MCP Server
Quick Start
1. Install
pip install diagram-forgeOr from source:
git clone https://github.com/jessepike/diagram-forge.git
cd diagram-forge
pip install -e ".[dev]"2. Configure a provider
Set at least one API key:
export GEMINI_API_KEY="your-key" # Google Gemini (recommended)
export OPENAI_API_KEY="your-key" # OpenAI GPT Image3. Add to your MCP client
Claude Code (.mcp.json in your project):
{
"diagram-forge": {
"command": "python",
"args": ["-m", "diagram_forge.server"]
}
}Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"diagram-forge": {
"command": "python",
"args": ["-m", "diagram_forge.server"]
}
}
}Codex CLI / Gemini CLI — same .mcp.json format as Claude Code.
4. Generate a diagram
Ask your AI client naturally:
"Generate an architecture diagram of a three-tier web app with a React frontend, Node.js API layer, and PostgreSQL database"
Or be more specific:
"Create a TOGAF-style architecture diagram showing our microservices. Use the architecture template, Gemini provider, 16:9 aspect ratio."
MCP Tools
Tool | Description |
| Generate a diagram from a text prompt with template and style support |
| Edit an existing diagram with natural language instructions |
| List available diagram templates and their variables |
| Show configured providers, API key status, and supported features |
| List available style reference images |
| View generation costs and usage stats by provider, type, or day |
| Set up an API key for a provider (session-only) |
Diagram Types
Type | Template | Best For |
| Enterprise Architecture (TOGAF) | System architecture, layered designs |
| C4 Container Diagram | Software system internals, C4 Level 2 |
| Executive Infographic | Stakeholder presentations, semantic colors + icons |
| Data Flow / Pipeline | ETL pipelines, data movement |
| Component Detail View | Service internals, module structure |
| Sequence Diagram | Request flows, protocol interactions |
| Integration / Connection Map | System connections, API landscape |
| Infographic / Learning Card | Concept explanations, overviews |
| Product Roadmap | Phase pipelines, gate icons, status badges |
| Workstreams / Priority Lanes | Swimlane planning with status and dependencies |
| Kanban Board | Three-column task boards with category color bars |
| Brand Infographic | Investor/marketing slides with brand aesthetic |
| Custom / Freeform | Anything else |
Style References
Feed a visual example to guide output consistency. Gemini supports this natively via multi-image input.
generate_diagram(prompt="...", style_reference="c4-container")Save your own styles to ~/.diagram-forge/styles/<name>/reference.png with an optional style.yaml for metadata.
Auto Provider Selection
Set provider="auto" (the default) and Diagram Forge picks the best provider based on the diagram type. Each template includes a tested recommendation. Override with provider="openai" or provider="gemini" when you want a specific model.
Claude Code Plugin
This repo includes a Claude Code plugin in diagram-forge-plugin/ that adds a guided UX layer on top of the MCP server:
/diagram:create— Guided diagram creation with context gathering/diagram:iterate— Refine an existing diagram/diagram:usage— View cost report/diagram:templates— Browse available templatesContext-gatherer agent — Automatically explores your project to understand what to diagram
Diagram intelligence skill — Auto-triggers when you mention diagrams
To use, install the plugin or add the .mcp.json from the plugin directory.
How It Works
Template selection — Matches your request to one of 13 YAML templates, each encoding proven prompt patterns (color systems, layer organization, legibility rules)
Prompt rendering — Merges your description with the template, substituting variables and applying style defaults
Provider dispatch — Sends the engineered prompt to your chosen provider (Gemini or OpenAI)
Image handling — Saves the generated image, records cost and metadata to SQLite
Iteration — Edit existing diagrams with natural language instructions via providers that support image editing
Development
# Install dev dependencies
pip install -e ".[dev]"
# Run tests (52 tests)
python -m pytest tests/ -v --cov=diagram_forge
# Lint
ruff check src/ tests/
# Type check
mypy src/
# Test MCP tools interactively
npx @modelcontextprotocol/inspector python -m diagram_forge.server
# Run low-cost model benchmark (dry-run first)
python scripts/eval_diagram_models.py --dry-run --max-cost-usd 5
python scripts/eval_diagram_models.py --execute --providers gemini,openai --resolution 1K --max-cases 6 --max-cost-usd 5Benchmark and model-refresh docs:
docs/evaluation-runbook.mddocs/model-refresh-process.mdevals/benchmark_v1.yaml
Architecture
src/diagram_forge/
server.py # FastMCP server — 7 tools, stdio transport
models.py # Pydantic v2 models
config.py # YAML + env var config loading
template_engine.py # Template loading and prompt rendering
style_manager.py # Style reference image management
cost_tracker.py # SQLite usage/cost tracking
providers/
base.py # BaseImageProvider ABC
gemini.py # Google Gemini
openai_provider.py # OpenAI GPT Image
templates/ # 13 YAML prompt templatesLicense
MIT
Available Tools
7 toolsconfigure_providerA
Configure an API key for a provider (sets environment variable for current session).
Args: provider: Provider name (gemini|openai) api_key: The API key to set
Inputs: api_key (required), provider (required).
edit_diagramA
Edit an existing diagram based on instructions.
Args: image_path: Path to the existing diagram image prompt: Edit instructions provider: Image generation provider (gemini|openai) resolution: Output resolution (auto-detect if not specified) reference_images: Additional reference image paths output_path: Where to save the result
Inputs: prompt (required), image_path (required), provider, resolution, +2 more.
generate_diagramA
Generate an architecture diagram from a text prompt.
Args:
prompt: Description of what to generate
diagram_type: Type of diagram (architecture|data_flow|component|sequence|integration|infographic|c4_container|exec_infographic|generic)
theme: Background theme (light|dark). Default: light — the portfolio-wide
default (rep / marketing / CISO-facing output is the common case). Pass
theme="dark" for a dark charcoal canvas. This single switch governs the
background; you do NOT need to describe a background color in prompt.
provider: LEAVE AS DEFAULT ("auto"). The server is responsible for picking the right provider and model for the diagram type — callers should describe what to draw and let the server decide how. The current default chain is OpenAI gpt-image-2 (primary) → Gemini (fallback). Override only if you have a specific provider/model comparison need.
model: LEAVE UNSET unless you're explicitly benchmarking models. Server picks the right model for the chosen provider.
resolution: Output resolution (1K|2K|4K)
aspect_ratio: Output aspect ratio (16:9|1:1|9:16|4:3)
style_reference: Style name or path to reference image
output_path: Where to save the image (auto-generated if not provided)
temperature: Generation creativity (0.0 to 2.0)
quality: Output quality tier for OpenAI gpt-image-2 / gpt-image-1-mini (low|medium|high|auto).
Cost scales dramatically: at 1536x1024 on gpt-image-2, low=$0.005, medium=$0.041, high=$0.165.
Ignored by Gemini and legacy gpt-image-1.5. Default: auto.
Inputs: prompt (required), model, theme, quality, +7 more.
get_usage_reportA
Get usage and cost report for diagram generations.
Args: days: Number of days to report on (default: 30) group_by: Group results by 'provider', 'diagram_type', or 'day'
Inputs: days, group_by.
list_providersA
List configured providers with status, models, and health information.
Inputs: no named parameters.
list_stylesA
List all available style reference images.
Inputs: no named parameters.
list_templatesA
List all available diagram templates with descriptions.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Each tool has a clearly distinct purpose: generation, editing, listing resources, usage reporting, and provider configuration. No two tools overlap in a way that would cause misselection.
All tool names follow a consistent verb_noun pattern in snake_case (generate_diagram, edit_diagram, list_templates, configure_provider, etc.). The use of 'list' for multiple resource types and 'get' for a report is a reasonable variation within the same structural convention.
Seven tools is well-scoped for a diagram generation service, covering creation, editing, resource discovery, configuration, and reporting without unnecessary bloat.
The core lifecycle of diagram generation and editing is covered, along with resource discovery and provider management. The main gap is the lack of tools for managing previously generated diagrams (e.g., listing or deleting outputs), but this is a minor oversight since outputs are saved as files.
Maintenance
Related MCP Connectors
Generate cloud architecture diagrams, flowcharts, and sequence diagrams.
Create workflow, sequence, architecture, and mind map diagrams via AI assistants.
Create and edit architecture diagrams from your AI agent; get an SVG and a live editable canvas.
Generate, edit, and export data-architecture diagrams from your AI. Column lineage, PNG in chat.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProfessional AI-powered architecture diagram generator with multi-cloud support and MCP server integration. Generates beautiful, accurate diagrams with provider-specific icons for AWS, Azure, GCP, Kubernetes, and more.12MIT
- AlicenseNot gradedqualityDmaintenanceEnables creation of Azure architecture diagrams from natural language descriptions, generating PNG images automatically.MIT
- FlicenseNot gradedqualityAmaintenanceEnables AI assistants to turn plain-language descriptions of systems, flows, and data into 25 kinds of fully laid-out, hand-drawn Excalidraw diagrams — architecture, sequence, ER, swimlane, Gantt, charts and more — with auto-styling for 50+ technologies and revision in natural language. Runs fully offline, exports to SVG and PNG without a browser or Node.js, and can optionally persist the architecture as a queryable knowledge graph.-
- AlicenseNot gradedqualityBmaintenanceEnables AI assistants and coding tools to turn a few lines describing a system into clean, hand-sketched architecture diagrams in a consistent style, saving them as SVG or PNG files. Supports themes, automatic product icons, groups, sequence diagrams and cloud icon packs.1MIT