umlforge 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
connector/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # UML Forge MCP Connector
2
+
3
+ **AI-powered UML diagram generation for coding agents.**
4
+
5
+ [UML Forge](https://umlforge.dev) gives Claude Code, Cursor, Windsurf, and any
6
+ MCP-compatible coding agent a suite of 13 specialised tools for producing
7
+ professional UML diagrams from your codebase, schema, or architecture
8
+ descriptions.
9
+
10
+ ## Quick start
11
+
12
+ **Claude Code:**
13
+ ```json
14
+ {
15
+ "mcpServers": {
16
+ "umlforge": {
17
+ "command": "uvx",
18
+ "args": ["umlforge"],
19
+ "env": { "UMLFORGE_API_KEY": "your-api-key" }
20
+ }
21
+ }
22
+ }
23
+ ```
24
+
25
+ **Cursor / Windsurf** — add the same block to your MCP settings.
26
+
27
+ Get your API key at [umlforge.dev](https://umlforge.dev).
28
+
29
+ ## Tools included
30
+
31
+ | Tool | Description |
32
+ |------|-------------|
33
+ | `umlforge_reverse_engineer` | Class, sequence, and state diagrams from a codebase or GitHub URL |
34
+ | `umlforge_api_sequence` | Sequence diagrams from OpenAPI / REST endpoints |
35
+ | `umlforge_erd_schema` | Entity-relationship diagrams from SQL schema or ORM models |
36
+ | `umlforge_state_machine` | State diagrams from business rules or UI flows |
37
+ | `umlforge_frontend_components` | Component hierarchy and data-flow diagrams |
38
+ | `umlforge_deployment` | Infrastructure and deployment diagrams |
39
+ | `umlforge_threat_model` | STRIDE threat model + attack surface diagram |
40
+ | `umlforge_event_driven` | Event flow and pub/sub architecture diagrams |
41
+ | `umlforge_ai_agent` | Agent topology and tool-call flow diagrams |
42
+ | `umlforge_stakeholder_arch` | C4 context diagrams for stakeholder communication |
43
+ | `umlforge_living_docs` | Living documentation diagrams synced to code |
44
+ | `umlforge_onboarding` | Onboarding maps for new team members |
45
+ | `umlforge_suggest` | Recommends the best diagram type for a description |
46
+
47
+ ## Requirements
48
+
49
+ - Python 3.11+
50
+ - An API key from [umlforge.dev](https://umlforge.dev) (free tier available)
51
+
52
+ ## License
53
+
54
+ Proprietary. The connector is open to install and use with a UML Forge account.
connector/__init__.py ADDED
File without changes
connector/__main__.py ADDED
@@ -0,0 +1,10 @@
1
+ """Entry point for `uvx umlforge` and `python -m connector`."""
2
+ from connector.server import mcp
3
+
4
+
5
+ def main() -> None:
6
+ mcp.run()
7
+
8
+
9
+ if __name__ == "__main__":
10
+ main()
@@ -0,0 +1,154 @@
1
+ """
2
+ UML Forge Connector — API Client
3
+
4
+ Thin HTTP client for the UML Forge hosted API.
5
+ ZERO business logic. ZERO prompt text.
6
+ All diagram generation happens server-side.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import httpx
12
+
13
+ from connector.config import load_config
14
+
15
+ # Timeout for diagram generation — Anthropic calls can take up to ~60s
16
+ _GENERATE_TIMEOUT = 210.0
17
+ _SUGGEST_TIMEOUT = 30.0
18
+
19
+
20
+ async def generate(
21
+ tool: str,
22
+ params: dict,
23
+ guided_mode: bool = False,
24
+ ) -> str:
25
+ """
26
+ Call POST /v1/generate on the UML Forge API.
27
+ Returns a formatted Markdown string ready for display in a coding agent.
28
+ """
29
+ config = load_config()
30
+
31
+ async with httpx.AsyncClient(timeout=_GENERATE_TIMEOUT) as client:
32
+ response = await client.post(
33
+ f"{config.api_base_url}/v1/generate",
34
+ json={
35
+ "tool": tool,
36
+ "params": params,
37
+ "guided_mode": guided_mode and config.guided_mode,
38
+ },
39
+ headers={
40
+ "Authorization": f"Bearer {config.api_key}",
41
+ "Content-Type": "application/json",
42
+ },
43
+ )
44
+
45
+ if response.status_code == 402:
46
+ body = response.json()
47
+ upgrade_url = body.get("upgrade_url", "https://umlforge.dev/billing")
48
+ return (
49
+ f"**Monthly diagram limit reached.**\n\n"
50
+ f"{body.get('error', 'Upgrade to Pro for unlimited diagrams.')}\n\n"
51
+ f"Upgrade at: {upgrade_url}"
52
+ )
53
+
54
+ if response.status_code == 401:
55
+ return (
56
+ "**Authentication failed.** Check that your API key in "
57
+ "your UMLFORGE_API_KEY is correct and active."
58
+ )
59
+
60
+ response.raise_for_status()
61
+ return _format_generate_response(response.json())
62
+
63
+
64
+ async def suggest(task_description: str) -> str:
65
+ """
66
+ Call POST /v1/suggest on the UML Forge API.
67
+ Returns a formatted recommendation string.
68
+ """
69
+ config = load_config()
70
+
71
+ async with httpx.AsyncClient(timeout=_SUGGEST_TIMEOUT) as client:
72
+ response = await client.post(
73
+ f"{config.api_base_url}/v1/suggest",
74
+ json={"task_description": task_description},
75
+ headers={
76
+ "Authorization": f"Bearer {config.api_key}",
77
+ "Content-Type": "application/json",
78
+ },
79
+ )
80
+
81
+ if response.status_code == 401:
82
+ return (
83
+ "**Authentication failed.** Check that your API key in "
84
+ "your UMLFORGE_API_KEY is correct and active."
85
+ )
86
+
87
+ if response.status_code == 402:
88
+ body = response.json()
89
+ upgrade_url = body.get("upgrade_url", "https://umlforge.dev/billing")
90
+ return (
91
+ f"**Monthly diagram limit reached.**\n\n"
92
+ f"{body.get('error', 'Upgrade to Pro for unlimited diagrams.')}\n\n"
93
+ f"Upgrade at: {upgrade_url}"
94
+ )
95
+
96
+ response.raise_for_status()
97
+ body = response.json()
98
+
99
+ return (
100
+ f"**Recommended tool:** `{body['recommended_tool']}`\n\n"
101
+ f"{body['reasoning']}\n\n"
102
+ f"**Alternative:** `{body['alternative_tool']}` \n"
103
+ f"{body['alternative_reasoning']}\n\n"
104
+ f"*Call the recommended tool with your task details to generate the diagram.*"
105
+ )
106
+
107
+
108
+ # ── Response formatter ────────────────────────────────────────────────────────
109
+
110
+ def _format_generate_response(body: dict) -> str:
111
+ """
112
+ Format a /v1/generate response body into readable Markdown.
113
+
114
+ Output shape:
115
+ ## Diagram Title [⚠️ if validation warning]
116
+
117
+ ```mermaid
118
+ [content]
119
+ ```
120
+
121
+ [supplementary tables / notes]
122
+
123
+ ---
124
+ *Generated by UML Forge | X diagrams remaining this month*
125
+ """
126
+ parts: list[str] = []
127
+
128
+ for diagram in body.get("diagrams", []):
129
+ title = diagram.get("title", "Diagram")
130
+ mermaid = diagram.get("mermaid", "").strip()
131
+ warning = " ⚠️ _validation warning — review before using_" \
132
+ if diagram.get("validation_warning") else ""
133
+
134
+ parts.append(f"## {title}{warning}\n\n```mermaid\n{mermaid}\n```")
135
+
136
+ # Supplementary sections (STRIDE table, implementation notes, etc.)
137
+ supplementary = body.get("supplementary", {})
138
+ for key, content in supplementary.items():
139
+ if isinstance(content, str) and content.strip():
140
+ parts.append(content.strip())
141
+
142
+ # Usage footer
143
+ usage = body.get("usage", {})
144
+ remaining = usage.get("diagrams_remaining")
145
+ tier = usage.get("tier", "free")
146
+
147
+ if remaining is not None:
148
+ footer = f"*Generated by UML Forge | {remaining} diagrams remaining this month*"
149
+ else:
150
+ footer = f"*Generated by UML Forge | {tier.title()} — unlimited diagrams*"
151
+
152
+ parts.append("---\n" + footer)
153
+
154
+ return "\n\n".join(parts)
connector/config.py ADDED
@@ -0,0 +1,94 @@
1
+ """
2
+ UML Forge Connector — Configuration
3
+
4
+ Resolution order (first match wins):
5
+ 1. Environment variables — set via .mcp.json "env" block (recommended)
6
+ UMLFORGE_API_KEY required
7
+ UMLFORGE_GUIDED_MODE optional, "true"/"false" (default: false)
8
+ UMLFORGE_API_BASE_URL optional (default: https://api.umlforge.dev)
9
+
10
+ 2. Config file fallback — ~/.umlforge/config.toml
11
+ api_key = "uf_live_your_key_here"
12
+ api_base_url = "https://api.umlforge.dev" # optional
13
+ guided_mode = false # optional, Pro tier only
14
+ """
15
+
16
+ import os
17
+ import sys
18
+ import tomllib
19
+ from dataclasses import dataclass
20
+ from pathlib import Path
21
+
22
+ CONFIG_PATH = Path.home() / ".umlforge" / "config.toml"
23
+
24
+ _SETUP_INSTRUCTIONS = """\
25
+ UML Forge: no API key found.
26
+
27
+ Add the key via your .mcp.json "env" block (recommended):
28
+
29
+ {
30
+ "mcpServers": {
31
+ "umlforge": {
32
+ "command": "uvx",
33
+ "args": ["umlforge"],
34
+ "env": {
35
+ "UMLFORGE_API_KEY": "uf_live_your_key_here"
36
+ }
37
+ }
38
+ }
39
+ }
40
+
41
+ Or create ~/.umlforge/config.toml:
42
+
43
+ api_key = "uf_live_your_key_here"
44
+ guided_mode = false
45
+
46
+ Get your key at https://umlforge.dev
47
+ """
48
+
49
+
50
+ @dataclass
51
+ class ConnectorConfig:
52
+ api_key: str
53
+ api_base_url: str = "https://api.umlforge.dev"
54
+ guided_mode: bool = False
55
+
56
+
57
+ def load_config() -> ConnectorConfig:
58
+ """
59
+ Load connector configuration from env vars (primary) or config file (fallback).
60
+ Exits with setup instructions if no API key is found.
61
+ """
62
+ # ── 1. Environment variables (set by MCP host via .mcp.json "env" block) ──
63
+ api_key = os.environ.get("UMLFORGE_API_KEY", "").strip()
64
+ if api_key:
65
+ return ConnectorConfig(
66
+ api_key=api_key,
67
+ api_base_url=os.environ.get(
68
+ "UMLFORGE_API_BASE_URL", "https://api.umlforge.dev"
69
+ ).rstrip("/"),
70
+ guided_mode=os.environ.get("UMLFORGE_GUIDED_MODE", "false").lower() == "true",
71
+ )
72
+
73
+ # ── 2. Config file fallback ────────────────────────────────────────────────
74
+ if CONFIG_PATH.exists():
75
+ with open(CONFIG_PATH, "rb") as fh:
76
+ data = tomllib.load(fh)
77
+
78
+ if "api_key" not in data:
79
+ print(
80
+ f"UML Forge: 'api_key' not found in {CONFIG_PATH}\n"
81
+ "Add: api_key = \"uf_live_your_key_here\"",
82
+ file=sys.stderr,
83
+ )
84
+ sys.exit(1)
85
+
86
+ return ConnectorConfig(
87
+ api_key=data["api_key"],
88
+ api_base_url=data.get("api_base_url", "https://api.umlforge.dev").rstrip("/"),
89
+ guided_mode=bool(data.get("guided_mode", False)),
90
+ )
91
+
92
+ # ── 3. Nothing found ───────────────────────────────────────────────────────
93
+ print(_SETUP_INSTRUCTIONS, file=sys.stderr)
94
+ sys.exit(1)
@@ -0,0 +1,12 @@
1
+ # UML Forge — MCP Connector Dependencies
2
+ # Installed on developer's machine
3
+ # Python 3.12.x required (tomllib is stdlib in 3.11+, no extra dep needed)
4
+
5
+ # ── MCP ────────────────────────────────────────────────
6
+ mcp[cli]>=1.27.0,<2.0.0
7
+
8
+ # ── HTTP Client ────────────────────────────────────────
9
+ httpx>=0.27.0,<1.0.0
10
+
11
+ # ── Data Validation ────────────────────────────────────
12
+ pydantic>=2.7.0,<3.0.0
connector/server.py ADDED
@@ -0,0 +1,33 @@
1
+ """
2
+ UML Forge Connector — MCP Server Entry Point
3
+
4
+ Starts the FastMCP stdio server with all 13 UML Forge tools registered.
5
+
6
+ Installation:
7
+ uvx umlforge # recommended — isolated, no pip install needed
8
+
9
+ Claude Code (.mcp.json):
10
+ {
11
+ "mcpServers": {
12
+ "umlforge": {
13
+ "command": "uvx",
14
+ "args": ["umlforge"],
15
+ "env": {
16
+ "UMLFORGE_API_KEY": "uf_live_your_key_here"
17
+ }
18
+ }
19
+ }
20
+ }
21
+
22
+ Cursor / other MCP hosts:
23
+ Same structure — set UMLFORGE_API_KEY in the "env" block.
24
+
25
+ Config fallback (power users): ~/.umlforge/config.toml
26
+ api_key = "uf_live_your_key_here"
27
+ guided_mode = false
28
+ """
29
+
30
+ from connector.tools import mcp
31
+
32
+ if __name__ == "__main__":
33
+ mcp.run()
connector/tools.py ADDED
@@ -0,0 +1,568 @@
1
+ """
2
+ UML Forge Connector — MCP Tool Definitions
3
+
4
+ Registers all 13 UML Forge tools with the FastMCP server.
5
+
6
+ CRITICAL CONSTRAINTS (enforced by architecture):
7
+ - ZERO business logic in this file
8
+ - ZERO prompt text in this file
9
+ - NO Anthropic API calls
10
+ - Every tool body is a single call to api_client.generate() or api_client.suggest()
11
+
12
+ The tool docstrings are what coding agents (Claude Code, Cursor, etc.) read
13
+ to decide which tool to call — write them clearly and specifically.
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ from mcp.server.fastmcp import FastMCP
19
+ from mcp.types import ToolAnnotations
20
+
21
+ from connector import api_client
22
+ from connector.config import load_config
23
+
24
+ mcp = FastMCP("umlforge_mcp")
25
+
26
+ _READ_ONLY = ToolAnnotations(
27
+ readOnlyHint=True,
28
+ destructiveHint=False,
29
+ idempotentHint=False,
30
+ openWorldHint=True,
31
+ )
32
+
33
+
34
+ # ── 1. Reverse Engineer ────────────────────────────────────────────────────────
35
+
36
+ @mcp.tool(annotations=_READ_ONLY)
37
+ async def umlforge_reverse_engineer(
38
+ codebase: str = "",
39
+ github_url: str | None = None,
40
+ max_nodes: int = 20,
41
+ ) -> str:
42
+ """
43
+ Reverse-engineer a codebase into UML class, sequence, and state diagrams.
44
+
45
+ Analyses the provided code and produces:
46
+ - Class diagram: entities, attributes, relationships, multiplicities
47
+ - Sequence diagram: primary execution flow or dominant use case
48
+ - State diagram: entity lifecycle (if stateful entities are found)
49
+ - Architectural smell flags: god classes, circular deps, anemic models
50
+
51
+ Best for: legacy system audits, onboarding, code review preparation,
52
+ technical debt assessment.
53
+
54
+ Provide EITHER codebase OR github_url — not required to supply both.
55
+
56
+ Args:
57
+ codebase: Code snippets, file contents, or structured description
58
+ of the codebase. Use this when you have code in context
59
+ or want to paste specific files.
60
+ github_url: Public GitHub URL — the server fetches the code for you.
61
+ Accepted formats:
62
+ github.com/owner/repo
63
+ github.com/owner/repo/tree/branch/path/to/dir
64
+ github.com/owner/repo/blob/branch/path/to/file.py
65
+ max_nodes: Maximum classes/components per diagram (default 20).
66
+ Increase for large codebases; decrease for readability.
67
+ """
68
+ config = load_config()
69
+ return await api_client.generate(
70
+ "umlforge_reverse_engineer",
71
+ {"codebase": codebase, "github_url": github_url, "max_nodes": max_nodes},
72
+ guided_mode=config.guided_mode,
73
+ )
74
+
75
+
76
+ # ── 2. Stakeholder Architecture ───────────────────────────────────────────────
77
+
78
+ @mcp.tool(annotations=_READ_ONLY)
79
+ async def umlforge_stakeholder_arch(
80
+ system_description: str,
81
+ audience_description: str,
82
+ ) -> str:
83
+ """
84
+ Generate a C4 architecture diagram (Context + Container + Component levels).
85
+
86
+ Produces three diagrams scaled for a mixed technical/non-technical audience:
87
+ - C4 Context: system boundary, external actors, primary integrations
88
+ - C4 Container: deployable units, tech stack labels, communication protocols
89
+ - C4 Component: internals of the most complex container
90
+
91
+ Best for: investor presentations, client onboarding, architecture review boards,
92
+ pre-demo documentation.
93
+
94
+ Args:
95
+ system_description: What the system does, who uses it, its major components.
96
+ audience_description: Who will read this (e.g. "CTO and backend engineers",
97
+ "non-technical investors").
98
+ """
99
+ config = load_config()
100
+ return await api_client.generate(
101
+ "umlforge_stakeholder_arch",
102
+ {
103
+ "system_description": system_description,
104
+ "audience_description": audience_description,
105
+ },
106
+ guided_mode=config.guided_mode,
107
+ )
108
+
109
+
110
+ # ── 3. API Sequence ───────────────────────────────────────────────────────────
111
+
112
+ @mcp.tool(annotations=_READ_ONLY)
113
+ async def umlforge_api_sequence(
114
+ services: str,
115
+ user_journey: str,
116
+ ) -> str:
117
+ """
118
+ Generate a detailed sequence diagram for an API or microservices interaction.
119
+
120
+ Produces:
121
+ - Sequence diagram: happy path + at least 2 failure/exception paths,
122
+ activation boxes, sync vs async arrows, performance boundary annotation
123
+ - Inter-service dependency table: caller, callee, protocol, failure mode, mitigation
124
+
125
+ Best for: new service integration design, API contract definition,
126
+ QA test planning, incident post-mortems.
127
+
128
+ Args:
129
+ services: Participants in the interaction, e.g.
130
+ "API Gateway, Auth Service, Order Service, Payment Provider, User DB".
131
+ user_journey: The user action or flow to diagram in plain English,
132
+ e.g. "User places an order through checkout".
133
+ """
134
+ config = load_config()
135
+ return await api_client.generate(
136
+ "umlforge_api_sequence",
137
+ {"services": services, "user_journey": user_journey},
138
+ guided_mode=config.guided_mode,
139
+ )
140
+
141
+
142
+ # ── 4. State Machine ──────────────────────────────────────────────────────────
143
+
144
+ @mcp.tool(annotations=_READ_ONLY)
145
+ async def umlforge_state_machine(
146
+ entity: str,
147
+ states: str,
148
+ events: str,
149
+ business_rules: str = "",
150
+ ) -> str:
151
+ """
152
+ Design a state machine diagram for a complex domain entity.
153
+
154
+ Produces:
155
+ - stateDiagram-v2: all states with entry/exit actions, transitions with
156
+ guard conditions, composite states, explicit ERROR and TERMINAL states
157
+ - State transition table: current state → event → guard → next state → action
158
+ - Implementation notes: which transitions need DB writes, domain events,
159
+ and race condition guards
160
+ - Assumption flags for any ambiguous business rules
161
+
162
+ Best for: domain-driven design, workflow/approval systems, order/job lifecycle,
163
+ IoT device management.
164
+
165
+ Args:
166
+ entity: Domain entity name (e.g. "Order", "Subscription", "JobApplication").
167
+ states: Known lifecycle states (e.g. "pending, active, suspended, cancelled").
168
+ events: Triggers that cause state transitions (e.g. "payment_received, user_cancels").
169
+ business_rules: Constraints on transitions (optional).
170
+ """
171
+ config = load_config()
172
+ return await api_client.generate(
173
+ "umlforge_state_machine",
174
+ {
175
+ "entity": entity,
176
+ "states": states,
177
+ "events": events,
178
+ "business_rules": business_rules,
179
+ },
180
+ guided_mode=config.guided_mode,
181
+ )
182
+
183
+
184
+ # ── 5. Living Docs ────────────────────────────────────────────────────────────
185
+
186
+ @mcp.tool(annotations=_READ_ONLY)
187
+ async def umlforge_living_docs(
188
+ current_diagrams: str,
189
+ sprint_changes: str,
190
+ affected_files: str = "",
191
+ ) -> str:
192
+ """
193
+ Update existing UML diagrams to reflect sprint or PR changes.
194
+
195
+ Diffs your current diagrams against described changes and produces:
196
+ - Updated diagrams only for affected sections (with %% changelog headers)
197
+ - New diagrams for any newly introduced architectural patterns
198
+ - Architecture evolution note suitable for pasting into a project wiki
199
+ - Explicit flags for intentionally removed nodes/relationships
200
+
201
+ Best for: sprint retrospectives, PR documentation, wiki maintenance,
202
+ architecture changelog management.
203
+
204
+ Args:
205
+ current_diagrams: Existing Mermaid diagram(s) to update — paste the
206
+ full content including ```mermaid fences.
207
+ sprint_changes: What changed: new components, removed flows, renamed
208
+ services, modified behaviour.
209
+ affected_files: Files or modules touched in this sprint/PR (optional).
210
+ """
211
+ config = load_config()
212
+ return await api_client.generate(
213
+ "umlforge_living_docs",
214
+ {
215
+ "current_diagrams": current_diagrams,
216
+ "sprint_changes": sprint_changes,
217
+ "affected_files": affected_files,
218
+ },
219
+ guided_mode=config.guided_mode,
220
+ )
221
+
222
+
223
+ # ── 6. ERD & Schema ───────────────────────────────────────────────────────────
224
+
225
+ @mcp.tool(annotations=_READ_ONLY)
226
+ async def umlforge_erd_schema(
227
+ domain_description: str,
228
+ entities: str,
229
+ access_patterns: str = "",
230
+ db_technology: str = "PostgreSQL",
231
+ ) -> str:
232
+ """
233
+ Design a database ERD with schema narrative and integrity checklist.
234
+
235
+ Produces:
236
+ - erDiagram: all entities with typed attributes, relationships, cardinality,
237
+ and foreign key labels
238
+ - Schema narrative: one paragraph per entity — business purpose, index
239
+ recommendations, denormalisation decisions
240
+ - Data integrity checklist: uniqueness, FK integrity, null policies, constraints
241
+ - Performance risk flags for N+1 query patterns
242
+
243
+ Best for: new feature schema design, migration planning, ORM model definition,
244
+ data architecture reviews.
245
+
246
+ Args:
247
+ domain_description: What the database stores (e.g. "E-commerce platform:
248
+ users, products, orders, payments").
249
+ entities: Known entities and key attributes (e.g. "User(id, email, tier),
250
+ Order(id, user_id, status, total)").
251
+ access_patterns: Most frequent read/write operations (optional, used
252
+ for index recommendations).
253
+ db_technology: Database technology — PostgreSQL, MySQL, MongoDB, etc.
254
+ (default: PostgreSQL).
255
+ """
256
+ config = load_config()
257
+ return await api_client.generate(
258
+ "umlforge_erd_schema",
259
+ {
260
+ "domain_description": domain_description,
261
+ "entities": entities,
262
+ "access_patterns": access_patterns,
263
+ "db_technology": db_technology,
264
+ },
265
+ guided_mode=config.guided_mode,
266
+ )
267
+
268
+
269
+ # ── 7. Threat Model ───────────────────────────────────────────────────────────
270
+
271
+ @mcp.tool(annotations=_READ_ONLY)
272
+ async def umlforge_threat_model(
273
+ system_description: str,
274
+ auth_mechanism: str,
275
+ trust_boundaries: list[str] | None = None,
276
+ sensitive_data: list[str] | None = None,
277
+ compliance_framework: str | None = None,
278
+ ) -> str:
279
+ """
280
+ Generate a security threat model with full STRIDE analysis.
281
+
282
+ Produces:
283
+ - Authentication flow sequence diagram with trust boundary annotations and
284
+ all failure paths (invalid creds, expired token, insufficient permissions)
285
+ - Data flow diagram with sensitivity labels (PUBLIC/INTERNAL/CONFIDENTIAL/SECRET)
286
+ - STRIDE threat table: all 6 categories with likelihood, mitigation, status
287
+ - Critical flags (🚨) for unencrypted sensitive data flows and high-risk gaps
288
+
289
+ Best for: pre-production security reviews, auth flow design,
290
+ compliance documentation (GDPR, NDPA 2023, SOC2, PCI-DSS),
291
+ penetration test preparation.
292
+
293
+ Pro users: set UMLFORGE_GUIDED_MODE=true in your .mcp.json env block.
294
+
295
+ Args:
296
+ system_description: What the system does, how users access it, main components.
297
+ auth_mechanism: Authentication in use (e.g. "JWT Bearer token", "API Key",
298
+ "OAuth2 + PKCE").
299
+ trust_boundaries: Trust boundary crossings (e.g. ["public internet → API",
300
+ "API → database"]).
301
+ sensitive_data: Sensitive data types (e.g. ["user emails", "payment tokens"]).
302
+ compliance_framework: Compliance scope (e.g. "GDPR", "NDPA 2023", "PCI-DSS").
303
+ """
304
+ config = load_config()
305
+ return await api_client.generate(
306
+ "umlforge_threat_model",
307
+ {
308
+ "system_description": system_description,
309
+ "auth_mechanism": auth_mechanism,
310
+ "trust_boundaries": trust_boundaries or [],
311
+ "sensitive_data": sensitive_data or [],
312
+ "compliance_framework": compliance_framework,
313
+ },
314
+ guided_mode=config.guided_mode,
315
+ )
316
+
317
+
318
+ # ── 8. Frontend Components ────────────────────────────────────────────────────
319
+
320
+ @mcp.tool(annotations=_READ_ONLY)
321
+ async def umlforge_frontend_components(
322
+ feature_description: str,
323
+ framework: str = "React",
324
+ state_management: str = "",
325
+ interactions: str = "",
326
+ ) -> str:
327
+ """
328
+ Generate a frontend component architecture diagram.
329
+
330
+ Produces:
331
+ - Component hierarchy graph: parent-child relationships, props (downward),
332
+ events/callbacks (upward), state store connections (dashed), API call origins
333
+ - Interaction sequence diagram: most complex user interaction — loading,
334
+ success, and error states
335
+ - Component responsibility table: responsibilities, state owned, reusability
336
+ - Accessibility note: ARIA roles needed, keyboard navigation, WCAG risks
337
+ - God component flags (⚠️) for components with too many responsibilities
338
+
339
+ Best for: new feature UI design, design system development,
340
+ component library documentation, frontend architecture reviews.
341
+
342
+ Args:
343
+ feature_description: The UI feature or page to diagram.
344
+ framework: Frontend framework — React, Vue, Angular, Svelte, Next.js, etc.
345
+ (default: React).
346
+ state_management: State approach — Redux, Zustand, Context API, Pinia, etc.
347
+ (optional).
348
+ interactions: Key user interactions (optional, improves diagram quality).
349
+ """
350
+ config = load_config()
351
+ return await api_client.generate(
352
+ "umlforge_frontend_components",
353
+ {
354
+ "feature_description": feature_description,
355
+ "framework": framework,
356
+ "state_management": state_management,
357
+ "interactions": interactions,
358
+ },
359
+ guided_mode=config.guided_mode,
360
+ )
361
+
362
+
363
+ # ── 9. Event-Driven ───────────────────────────────────────────────────────────
364
+
365
+ @mcp.tool(annotations=_READ_ONLY)
366
+ async def umlforge_event_driven(
367
+ system_context: str,
368
+ producers: str,
369
+ consumers: str,
370
+ broker: str = "",
371
+ events: str = "",
372
+ ) -> str:
373
+ """
374
+ Design an event-driven or async system architecture.
375
+
376
+ Produces:
377
+ - Event flow sequence diagram: producers → broker → consumers with ack,
378
+ retry loops, and dead-letter queue handling
379
+ - Event catalogue table: name, producer, consumers, payload, ordering,
380
+ idempotency, retention
381
+ - Choreography vs orchestration assessment with coupling risk flags
382
+ - Failure mode analysis table: scenario, impact, detection, recovery
383
+
384
+ Best for: event sourcing design, CQRS, microservices decoupling,
385
+ message broker integration, async workflow design.
386
+
387
+ Args:
388
+ system_context: What the event-driven system does and why it uses messaging.
389
+ producers: Services that emit events (e.g. "Order Service emits order.placed").
390
+ consumers: Services that consume events (e.g. "Notification, Inventory, Analytics").
391
+ broker: Message broker (e.g. "Kafka", "RabbitMQ", "AWS SQS/SNS") (optional).
392
+ events: Named domain events (e.g. "order.placed, payment.failed") (optional).
393
+ """
394
+ config = load_config()
395
+ return await api_client.generate(
396
+ "umlforge_event_driven",
397
+ {
398
+ "system_context": system_context,
399
+ "producers": producers,
400
+ "consumers": consumers,
401
+ "broker": broker,
402
+ "events": events,
403
+ },
404
+ guided_mode=config.guided_mode,
405
+ )
406
+
407
+
408
+ # ── 10. Team Onboarding ───────────────────────────────────────────────────────
409
+
410
+ @mcp.tool(annotations=_READ_ONLY)
411
+ async def umlforge_onboarding(
412
+ system_description: str,
413
+ tech_stack: str,
414
+ key_workflows: str,
415
+ pain_points: str = "",
416
+ ) -> str:
417
+ """
418
+ Generate a complete team onboarding and knowledge-transfer diagram package.
419
+
420
+ Produces four diagrams plus a gotchas table:
421
+ - System overview (C4 Container): the lay-of-the-land on day one
422
+ - Developer workflow sequence: local dev → test → CI → staging → production,
423
+ plus the most common debugging path
424
+ - Data lifecycle (activity diagram): how data enters, transforms, stores, deletes
425
+ - Module dependency map: internal modules + external deps, circular dep flags
426
+ - Gotchas & constraints table: what the code does, why it does it that way,
427
+ what breaks if you change it
428
+
429
+ Best for: developer onboarding, module handover, team scaling,
430
+ documentation-before-departure.
431
+
432
+ Args:
433
+ system_description: High-level description of the system being handed over.
434
+ tech_stack: Languages, frameworks, and infrastructure (e.g. "FastAPI,
435
+ PostgreSQL, React, Redis, Railway").
436
+ key_workflows: 2-3 most important flows a new developer must understand.
437
+ pain_points: Known gotchas, non-obvious decisions, workarounds (optional).
438
+ """
439
+ config = load_config()
440
+ return await api_client.generate(
441
+ "umlforge_onboarding",
442
+ {
443
+ "system_description": system_description,
444
+ "tech_stack": tech_stack,
445
+ "key_workflows": key_workflows,
446
+ "pain_points": pain_points,
447
+ },
448
+ guided_mode=config.guided_mode,
449
+ )
450
+
451
+
452
+ # ── 11. AI Agent ──────────────────────────────────────────────────────────────
453
+
454
+ @mcp.tool(annotations=_READ_ONLY)
455
+ async def umlforge_ai_agent(
456
+ pipeline_purpose: str,
457
+ agents: str,
458
+ tools_available: str = "",
459
+ orchestration_approach: str = "",
460
+ memory_strategy: str = "",
461
+ ) -> str:
462
+ """
463
+ Design an AI agent and orchestration pipeline architecture.
464
+
465
+ Produces:
466
+ - Agent pipeline sequence diagram: agents as participants with model names,
467
+ tool calls as self-calls, human-in-the-loop gates, retry/fallback logic
468
+ - Agent component map: agents, tool deps, memory components, external integrations
469
+ - Agent responsibility matrix: model, role, tools, inputs, outputs, failure behaviour
470
+ - Risk & observability note: hallucination hotspots, validation gates, logging points
471
+ - Tool overload flags (⚠️) for agents with more than 5 tools
472
+
473
+ Best for: multi-agent system design, LLM pipeline architecture,
474
+ AI product development, agentic workflow documentation.
475
+
476
+ Args:
477
+ pipeline_purpose: What the agent system does (e.g. "Research pipeline that
478
+ searches the web and drafts a report").
479
+ agents: Agents in the pipeline and their roles (e.g. "Planner Agent
480
+ [claude-opus-4], Research Agent [claude-sonnet-4]").
481
+ tools_available: Tools agents can call (e.g. "web_search, execute_code") (optional).
482
+ orchestration_approach: How agents coordinate — sequential, DAG, hierarchical,
483
+ parallel fan-out (optional).
484
+ memory_strategy: Memory approach — shared context, vector memory, Redis,
485
+ none (optional).
486
+ """
487
+ config = load_config()
488
+ return await api_client.generate(
489
+ "umlforge_ai_agent",
490
+ {
491
+ "pipeline_purpose": pipeline_purpose,
492
+ "agents": agents,
493
+ "tools_available": tools_available,
494
+ "orchestration_approach": orchestration_approach,
495
+ "memory_strategy": memory_strategy,
496
+ },
497
+ guided_mode=config.guided_mode,
498
+ )
499
+
500
+
501
+ # ── 12. Deployment ────────────────────────────────────────────────────────────
502
+
503
+ @mcp.tool(annotations=_READ_ONLY)
504
+ async def umlforge_deployment(
505
+ system_name: str,
506
+ cloud_provider: str,
507
+ environments: str,
508
+ services: str,
509
+ cicd_tool: str = "",
510
+ ) -> str:
511
+ """
512
+ Generate a deployment topology and CI/CD pipeline diagram.
513
+
514
+ Produces:
515
+ - Deployment diagram: nodes, artefacts, network paths with protocol/port labels,
516
+ internet-facing vs internal traffic distinction
517
+ - CI/CD pipeline flow: all stages from commit to production, automated gates,
518
+ manual approvals, rollback paths, environment promotion sequence
519
+ - Deployment environment table: infrastructure, triggers, data classification,
520
+ monitoring, rollback strategy per environment
521
+ - Infrastructure risk note: single points of failure, missing redundancy,
522
+ environment parity gaps
523
+ - Observability gap flags (⚠️) for services without /health endpoints
524
+
525
+ Best for: infrastructure provisioning, CI/CD pipeline design, cloud architecture
526
+ documentation, DevOps handover, disaster recovery planning.
527
+
528
+ Args:
529
+ system_name: Name of the system (e.g. "UML Forge API").
530
+ cloud_provider: Cloud provider(s) (e.g. "AWS", "Railway + Vercel", "GCP").
531
+ environments: Deployment environments (e.g. "development, staging, production").
532
+ services: Services and infrastructure to deploy (e.g. "FastAPI API, Next.js
533
+ frontend, PostgreSQL, Redis").
534
+ cicd_tool: CI/CD pipeline tool (e.g. "GitHub Actions", "GitLab CI") (optional).
535
+ """
536
+ config = load_config()
537
+ return await api_client.generate(
538
+ "umlforge_deployment",
539
+ {
540
+ "system_name": system_name,
541
+ "cloud_provider": cloud_provider,
542
+ "environments": environments,
543
+ "services": services,
544
+ "cicd_tool": cicd_tool,
545
+ },
546
+ guided_mode=config.guided_mode,
547
+ )
548
+
549
+
550
+ # ── 13. Suggest ───────────────────────────────────────────────────────────────
551
+
552
+ @mcp.tool(annotations=_READ_ONLY)
553
+ async def umlforge_suggest(task_description: str) -> str:
554
+ """
555
+ Recommend the best UML Forge tool for your task.
556
+
557
+ Given a plain-English description of what you want to diagram,
558
+ returns a ranked recommendation with reasoning and an alternative option.
559
+
560
+ Use this when you are not sure which of the 12 diagram tools fits
561
+ your task best.
562
+
563
+ Args:
564
+ task_description: Plain-English description of what you want to diagram
565
+ (e.g. "I want to document the lifecycle of an order"
566
+ or "I need to show how our auth service works").
567
+ """
568
+ return await api_client.suggest(task_description)
@@ -0,0 +1,76 @@
1
+ Metadata-Version: 2.4
2
+ Name: umlforge
3
+ Version: 0.1.0
4
+ Summary: UML Forge MCP connector — AI-powered UML diagram generation for coding agents
5
+ Project-URL: Homepage, https://umlforge.dev
6
+ Project-URL: Documentation, https://umlforge.dev/docs
7
+ License: Proprietary
8
+ Keywords: ai,architecture,class-diagram,claude,cursor,diagram,mcp,sequence-diagram,uml
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Topic :: Software Development :: Documentation
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Requires-Python: >=3.11
18
+ Requires-Dist: httpx<1.0.0,>=0.27.0
19
+ Requires-Dist: mcp[cli]<2.0.0,>=1.27.0
20
+ Requires-Dist: pydantic<3.0.0,>=2.7.0
21
+ Description-Content-Type: text/markdown
22
+
23
+ # UML Forge MCP Connector
24
+
25
+ **AI-powered UML diagram generation for coding agents.**
26
+
27
+ [UML Forge](https://umlforge.dev) gives Claude Code, Cursor, Windsurf, and any
28
+ MCP-compatible coding agent a suite of 13 specialised tools for producing
29
+ professional UML diagrams from your codebase, schema, or architecture
30
+ descriptions.
31
+
32
+ ## Quick start
33
+
34
+ **Claude Code:**
35
+ ```json
36
+ {
37
+ "mcpServers": {
38
+ "umlforge": {
39
+ "command": "uvx",
40
+ "args": ["umlforge"],
41
+ "env": { "UMLFORGE_API_KEY": "your-api-key" }
42
+ }
43
+ }
44
+ }
45
+ ```
46
+
47
+ **Cursor / Windsurf** — add the same block to your MCP settings.
48
+
49
+ Get your API key at [umlforge.dev](https://umlforge.dev).
50
+
51
+ ## Tools included
52
+
53
+ | Tool | Description |
54
+ |------|-------------|
55
+ | `umlforge_reverse_engineer` | Class, sequence, and state diagrams from a codebase or GitHub URL |
56
+ | `umlforge_api_sequence` | Sequence diagrams from OpenAPI / REST endpoints |
57
+ | `umlforge_erd_schema` | Entity-relationship diagrams from SQL schema or ORM models |
58
+ | `umlforge_state_machine` | State diagrams from business rules or UI flows |
59
+ | `umlforge_frontend_components` | Component hierarchy and data-flow diagrams |
60
+ | `umlforge_deployment` | Infrastructure and deployment diagrams |
61
+ | `umlforge_threat_model` | STRIDE threat model + attack surface diagram |
62
+ | `umlforge_event_driven` | Event flow and pub/sub architecture diagrams |
63
+ | `umlforge_ai_agent` | Agent topology and tool-call flow diagrams |
64
+ | `umlforge_stakeholder_arch` | C4 context diagrams for stakeholder communication |
65
+ | `umlforge_living_docs` | Living documentation diagrams synced to code |
66
+ | `umlforge_onboarding` | Onboarding maps for new team members |
67
+ | `umlforge_suggest` | Recommends the best diagram type for a description |
68
+
69
+ ## Requirements
70
+
71
+ - Python 3.11+
72
+ - An API key from [umlforge.dev](https://umlforge.dev) (free tier available)
73
+
74
+ ## License
75
+
76
+ Proprietary. The connector is open to install and use with a UML Forge account.
@@ -0,0 +1,12 @@
1
+ connector/README.md,sha256=e6kNXkutToRooOHh2RSBnUqq2cooamYt9xQduLQw4XM,1926
2
+ connector/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ connector/__main__.py,sha256=BKk-_KmGsvn0ZdXIV8YM6OBUSCah7jJ4ptugv4krIuQ,173
4
+ connector/api_client.py,sha256=7U4mUdiumopcyuzMWpv--VdSbLTa3Gpff4yak690ZvY,4899
5
+ connector/config.py,sha256=k4P_Kx8PyN4g1kcwp7xQXThfK_u-qvYyv8UjZwIP3-s,3034
6
+ connector/requirements.txt,sha256=MXi1U11guMwxSXMeE7TWtuZp06OHU289K5vxGwGkdMY,670
7
+ connector/server.py,sha256=sd3330HhQR2Ev4sVEyG_zwZo_6qst_pjuLR7gHE0Hsg,754
8
+ connector/tools.py,sha256=csIFkmOCe2GB5tXhyglu85TIc_YuRf5g029cRmI_MpU,23350
9
+ umlforge-0.1.0.dist-info/METADATA,sha256=UQfIhy5bo2-LW5fKMmiz0sLZ3XvkK30ybYGKqUhHUgc,2871
10
+ umlforge-0.1.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
11
+ umlforge-0.1.0.dist-info/entry_points.txt,sha256=0zs7k8SNUjC7-XB_Mj89GR8VAkEQqrXbodhDkxbVqUA,53
12
+ umlforge-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.30.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ umlforge = connector.__main__:main