diagram-forge
Generates professional architecture diagrams from natural language descriptions using template-driven prompts and swappable AI image providers.
README
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
Quick Start
1. Install
pip install diagram-forge
Or 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 Image
3. 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_diagram |
Generate a diagram from a text prompt with template and style support |
edit_diagram |
Edit an existing diagram with natural language instructions |
list_templates |
List available diagram templates and their variables |
list_providers |
Show configured providers, API key status, and supported features |
list_styles |
List available style reference images |
get_usage_report |
View generation costs and usage stats by provider, type, or day |
configure_provider |
Set up an API key for a provider (session-only) |
Diagram Types
| Type | Template | Best For |
|---|---|---|
architecture |
Enterprise Architecture (TOGAF) | System architecture, layered designs |
c4_container |
C4 Container Diagram | Software system internals, C4 Level 2 |
exec_infographic |
Executive Infographic | Stakeholder presentations, semantic colors + icons |
data_flow |
Data Flow / Pipeline | ETL pipelines, data movement |
component |
Component Detail View | Service internals, module structure |
sequence |
Sequence Diagram | Request flows, protocol interactions |
integration |
Integration / Connection Map | System connections, API landscape |
infographic |
Infographic / Learning Card | Concept explanations, overviews |
product_roadmap |
Product Roadmap | Phase pipelines, gate icons, status badges |
workstreams |
Workstreams / Priority Lanes | Swimlane planning with status and dependencies |
kanban |
Kanban Board | Three-column task boards with category color bars |
brand_infographic |
Brand Infographic | Investor/marketing slides with brand aesthetic |
generic |
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 templates- Context-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 5
Benchmark 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 templates
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 模型以安全和受控的方式获取实时的网络信息。