mcp
v0.28.0MCP server for Modudraft - create and edit system-design diagrams via AI (cloud edition)
Model Context Protocol (MCP) server for Modudraft - the system-design diagramming tool. Connect your AI assistant (Claude, Cursor, Copilot, etc.) to your Modudraft diagrams and let it build and edit architecture, sequence, DB schema, API, cloud, network, data-flow and state machine diagrams for you. Go to your Modudraft account → API Keys → Create new key.
Summary extracted from the README.
@modudraft/mcp
Model Context Protocol (MCP) server for Modudraft - the system-design diagramming tool.
Connect your AI assistant (Claude, Cursor, Copilot, etc.) to your Modudraft diagrams and let it build and edit architecture, sequence, DB schema, API, cloud, network, data-flow and state machine diagrams for you.
Requirements
- Modudraft Pro account - API access is a Pro feature
- Node.js 18+
- An API key from your Modudraft dashboard
Setup
1. Create an API key
Go to your Modudraft account → API Keys → Create new key.
Copy the key - you'll only see it once.
2. Add to your MCP config
Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"modudraft": {
"command": "npx",
"args": ["-y", "@modudraft/mcp"],
"env": {
"MODUDRAFT_API_KEY": "mdft_your_key_here",
"MODUDRAFT_PROJECT_ROOTS": "/Users/you/code/your-repo"
}
}
}
}
MODUDRAFT_PROJECT_ROOTS is optional. You only need it if you want the agent to import from, or write files to, your code. It is the folder with your source code: the repo, or the git worktree, you want diagrams built from. The import tools read your docker-compose.yml, k8s manifests, OpenAPI specs, SQL and .env files from there, and export (with output_path) / generate_docs write their output there. The MCP reads and writes files only inside it, in its own ~/.modudraft folder, and in the system temp folder (on Linux that folder is shared with other users of the machine). Credential files such as .env, .dev.vars, *.tfstate and its backups (*.tfstate.backup, *.tfstate.<timestamp>.backup), *.tfvars, .envrc and .envrc.*, kubeconfig, any *.json whose name contains service-account (or service_account, serviceaccount) and private keys are never returned by read_file, in any folder and in any letter case; .env and .dev.vars files can be imported with import_file, which redacts secret values. List several repos with : (; on Windows). Your diagrams themselves are saved to your Modudraft account, not to this folder.
Without it, all diagram tools work as usual. The file tools fall back to your client's workspace folders, or the folder the server was started in. Claude Desktop starts the server from /, so there the file tools stay off until you set it.
Cursor (.cursor/mcp.json in your project or ~/.cursor/mcp.json globally):
{
"mcpServers": {
"modudraft": {
"command": "npx",
"args": ["-y", "@modudraft/mcp"],
"env": {
"MODUDRAFT_API_KEY": "mdft_your_key_here"
}
}
}
}
Environment variables
| Variable | Required | Description |
|---|---|---|
MODUDRAFT_API_KEY |
Yes | Your mdft_… API key |
MODUDRAFT_API_URL |
No | Override API base URL (default: https://api.modudraft.com) |
MODUDRAFT_PROJECT_ROOTS |
No | Your source-code folder(s): the repo or git worktree the file tools (scan_project, read_file, import_file, export, ...) may read from and write to. Separate several with : (; on Windows); ~ is allowed. Used when your MCP client doesn't share its workspace folders. Your home directory or / is never accepted, so point it at the repo itself. |
MODUDRAFT_AUTO_TIDY_MS |
No | Quiet period, in milliseconds, before the architecture tab is auto-tidied after nodes or edges are added or removed (default 8000; 0 turns auto-tidy off). See Auto-tidy |
MODUDRAFT_TOOLSETS |
No | Which tool groups to list: unset lists core + modeling, import, analysis (the default), all lists every tool, core lists only the core tools, "sequences,api" lists core plus those groups. See Toolsets |
Toolsets
The default lists the core tools and the modeling, import and analysis groups; every other group is one load_toolset call away. Set MODUDRAFT_TOOLSETS=all to list everything, or core for the smallest set. The core group covers diagram management, nodes and edges, rendering, discovery, org context and search_diagrams. The core tools are: list_diagrams, create_diagram, get_diagram, rename_diagram, delete_diagram, clear_diagram, layout_diagram, get_share_link, add_node, get_node, update_node, delete_node, add_edge, update_edge, delete_edge, add_boundary, add_note, move_to_level, render_diagram_text, list_archetypes, list_tools, list_protocols, get_node_schema, get_org_context, refresh_org_context, search_diagrams.
| Toolset | Purpose | Tools |
|---|---|---|
modeling |
Bulk create and node metadata | apply_architecture, bulk_add_nodes, bulk_add_edges, set_node_metadata, suggest_metadata |
sequences |
Sequence diagrams: sequences, lanes, messages, fragments | list_sequences, add_sequence, update_sequence, delete_sequence, add_sequence_participant, add_sequence_message, bulk_add_sequence_messages, update_sequence_message, delete_sequence_message, get_sequence, clear_sequence, add_sequence_fragment, update_sequence_fragment, delete_sequence_fragment |
database |
DB tables and ER export | add_db_table, update_db_table, delete_db_table, export_er_diagram |
api |
API endpoints, contracts, OpenAPI and AsyncAPI export | add_api_endpoint, bulk_add_api_endpoints, update_api_endpoint, delete_api_endpoint, export_openapi, export_asyncapi |
infra |
Cloud resources and network devices | add_cloud_resource, update_cloud_resource, delete_cloud_resource, add_network_device, update_network_device, delete_network_device |
data_flows |
Data-flow pipelines and stages | list_data_flows, add_data_flow, add_data_flow_stage, update_data_flow_stage, delete_data_flow_stage, reorder_data_flow_stages |
views |
Show and hide tabs, the Notes tab | get_enabled_tabs, enable_tab, disable_tab, get_notes, set_notes, append_to_notes, replace_in_notes |
import |
Read and scan the repo, import files, apply env values | read_file, scan_project, import_file, import_directory, apply_env_to_nodes |
export |
Mermaid, PlantUML, draw.io, Terraform, K8s, Structurizr, write files, generate docs and runbooks | export, generate_docs, generate_runbook |
analysis |
Validate, diff, review, cross-diagram suggestions, clone | validate_diagram, diff_diagram, review_diagram, get_review, get_ai_usage, find_shared_services, suggest_connections, clone_diagram, suggest_architecture |
project |
Watch a repo for drift, sync a diagram with the repo, generate sequences from the API | watch_project, check_project_drift, unwatch_project, sync_project, generate_sequence_from_api |
history |
Server version history (snapshots) and the edit log | snapshot_diagram, list_snapshots, restore_snapshot, get_edit_log |
security |
Threat model: trust zones, data classes, STRIDE threats, the Markdown report | get_security_view, suggest_threats, add_threat, update_threat, delete_threat, set_trust_zone, set_data_class, export_threat_model |
states |
State machines per component, event consumers, Mermaid, XState and PlantUML export | list_state_machines, get_state_machine, create_state_machine, update_state_machine, delete_state_machine, apply_state_machine, add_state, update_state, delete_state, add_transition, update_transition, delete_transition, set_event_consumers, export_state_machine |
MODUDRAFT_TOOLSETS="core"lists the core tools only;"sequences,api"lists core plus those groups;"all"lists everything; unset lists the default groups (core,modeling,import,analysis).- A value made only of unknown names keeps the default groups and prints a warning on stderr.
load_toolset(name)adds a group at runtime and sends a tools-changed notification. If your client doesn't refresh tools afterload_toolset, setMODUDRAFT_TOOLSETSinstead.- Calling a tool by name works even when it isn't listed, if your client lets the agent call a tool it was not shown: the server loads its group and runs it. Otherwise use
load_toolsetorMODUDRAFT_TOOLSETS.
Upgrading to 0.28.0
No API change. Agents spend much less context on Modudraft; these things behave differently:
get_diagramreturns a summary by default: the tabs and their sizes, node and edge counts, per-tab outlines with ids, names and types (capped: a tab that is cut saysoutline_omitted, andincludereturns the full data), and the first 3 hints. Passincludefor full data:["diagram"]for nodes, edges and levels, section names (sequence,db-schema,api,cloud,network,data-flow,hints), or["all"]for the exact shape 0.27 returned. Scripts that readnodesoredgesfromget_diagrammust passinclude.- The default toolset is smaller: the core tools plus
modeling,importandanalysis. SetMODUDRAFT_TOOLSETS=allto list every group (it lists the mergedexporttool, and the old export names stay callable for one release, see below), or callload_toolset(name). A client that ignorestools/list_changedsees only the lean set afterload_toolset: there, call a tool by name (it loads its group where the client lets the agent call a tool it was not shown), or setMODUDRAFT_TOOLSETS=all. - The
export_*tools of theexportgroup (export_mermaid,export_plantuml,export_drawio,export_terraform,export_k8s_yaml,export_to_file,export_structurizr) are now oneexport(format)tool (mermaid,plantuml,drawio,terraform,k8s,sql,openapi,structurizr_dsl,structurizr_json;output_pathwrites a file). The old names still work in 0.28, return what they returned before plus adeprecatedfield, and are not listed. They are removed in 0.29. A file written byexportholds exactly what the same call returns inline, sodiagram_type,tab_type,sequence_idandlevelapply to files too. list_diagramsreturns its documented six fields:id,name,updatedAt,workspaceId,workspaceName,workspaceKind. The other fields of the API row (createdAt,createdBy,creatorName,lastEditorName,updatedVia,description,folderId,folderName,readOnlySince) are no longer returned.- Replies are compact JSON. Write replies (
bulk_add_nodes,apply_architecture) send at most 3 tips about missing fields and say how many were left out; passall_hints: truefor all of them. scan_project,import_file,read_file,import_directory,watch_projectandcheck_project_driftgive paths relative to the project root, and the file tools accept them back.import_directoryfinds or creates the Database and API nodes its SQL and OpenAPI files attach to, and says which innodes.dbandnodes.api(always lists). It never guesses between several candidates: those files go tonot_importedwith the reason, andimport_filewithnode_idtakes them.resultslists only the imported files: failed files are no longer in it (they are innot_importedwith theirerror), theokfield is gone, andpathis relative to the project root (it was relative to the scanned folder). A script that filteredresultsonr.okshould readresultsas the imported files andnot_importedas the failures. Nodes it creates are tidied only when the diagram was empty and no file brought its own layout.- The drift-check Action releases a new minor with default 0.28.0 after npm serves it.
modudraft-mcp checkoutput is unchanged.
Upgrading to 0.27.1
No API change; upgrade at any time.
validate_diagramno longer fails on a diagram that has a tab without a database, API or other list. The web app does not save empty lists, so the tool threw "Cannot read properties of undefined" on most diagrams saved there. A missing list is now treated as empty.
Upgrading to 0.27.0
Deploy the API first: the refusals below come from the API of the same release. Against an older API this version behaves like 0.26.3.
- Plans now apply whatever the billing switch says. Free keeps 3 active diagrams, records no versions and has no AI; the Pro trial and Pro keep 50 versions per diagram, with 30 (trial) or 100 AI credits a month; Team keeps 100 and Enterprise 200.
list_snapshotsshows the plan's cap. Storage follows the plan too: 20 MB of diagram data and 200 MB of Notes images on Free, 100 MB and 1 GB on the Pro trial and Pro, and one org pool of 300 MB and 3 GB on Team, 500 MB and 5 GB on Enterprise; a person on Team or Enterprise keeps that plan's version cap in their personal workspace, with 100 MB and 1 GB of storage there.storage_fullrefusals now name the plan. - Every account that is not on a paid or assigned plan gets a Pro trial of at least 14 days on the day this release goes live, and AI Architect and the MCP work during it. Free has no MCP after the trial. When the trial ends, the API keys of a Free account stop working: every request with one is refused with
403("The MCP server needs a paid plan or the Pro trial."), and the keys work again as soon as the account has Pro, Team, Enterprise or an assigned plan. Each person has one plan: a member of an organization on a Team or Enterprise plan (Team and Enterprise come with an organization) is on that plan everywhere, gets no trial and keeps the MCP, while a member of an organization with no plan has only their own plan. - A Free account with more than 3 diagrams chooses 3 active ones in the web app; the others are read-only until they move to the Bin. Every write to a read-only diagram (the edit lock, saves, uploads) is refused with
403 read_only_free, and the tool says so in plain words instead of a raw status line: "This diagram is read-only on the Free plan. Choose which 3 diagrams stay active, or get a paid plan. Nothing from this call was saved; ask the user to choose which diagrams stay active in the web app, or to get a paid plan." Reading, exporting and deleting still work. review_diagramon a Free account is refused withtrial_requiredwhatever the billing switch says; the text names Pro, and says when the Pro trial has ended. There is no free review on Free any more.- New
get_review(diagram_id)in theanalysistoolset reads the latest saved review of a diagram. It runs nothing and costs no credits. It returns the free Quick checks inquickChecks, the AI'sfindings, thesummary, thekindand sizetier, when (createdAt) and by whom (createdBy) it ran, andstale: truewhen the diagram changed since. With no saved review it returnsreview: nulland says so. If an organization turned the AI Architect off, the tool says so instead of returning findings. After your client cancelled areview_diagramcall, it adds anotewhile that run may still be going, because the saved review is replaced only when the run finishes: comparecreatedAtwith when the run started. review_diagramnow sends a progress notification every 15 seconds while it waits, when your client asks for progress (it sends aprogressToken). A client that resets its request timeout on progress then waits for the whole run (a Deep review can take up to 4 minutes) instead of giving up at its default timeout.- When the agent stops waiting first, the run still finishes on the server and is saved and charged. If your client cancels the call,
get_reviewsays the run may still be going (above). If the tool's own wait of 5 minutes runs out, the server's limit has passed, so the run is over, and the tool says so and points toget_review: "The review took longer than this tool waits, so the server has finished it by now: it was saved, or it failed and its credits were given back. Call get_review with this diagram_id to read it. Running review_diagram again would be charged again." - The refusals that named an upgrade now say what works while checkout is closed: on Free, the version tools say "Version history isn't available on the Free plan. It comes with the Pro trial and every paid plan.", and a new diagram past the Free limit says to delete one "or get a paid plan" with the billing page's link.
- When an organization's plan ends, the organization is suspended: its workspaces and its teams' workspaces are read-only at once. Every write there (the edit lock, saves, new diagrams, clones, imports, uploads, snapshots, reviews) is refused with
403 org_suspended, and the tool says so in plain words: "This organization's plan has ended, so it is read-only. Its owner can contact us to renew it. Nothing from this call was saved; the organization's diagrams can still be read and exported. Ask its owner to contact Modudraft to renew the plan." Reading and exporting still work. Its owner is emailed at the next daily run (a few organizations a day, the rest the next days) and again 7 days before the deletion; 30 days after the suspension the organization is deleted, and its owner can restore it within 90 days with a plan. A plan applied at any point lifts the suspension at once. Members keep their personal workspaces on their own plan.
Upgrading to 0.26.3
Deploy the API first: the refusals and prices below come from the API of the same release. Against an older API this version behaves like 0.26.2.
- Each workspace has a storage cap. A write that would add data past it is refused with
413 storage_full, nothing from that request is saved, and every tool shows the API's own message and adds that nothing was saved. Writes that do not add data always go through, so deleting nodes, tabs or diagrams still works on a full workspace. The caps now follow the plan (see "Upgrading to 0.27.0"). review_diagramon an account with no AI is refused withtrial_required, and the tool says so in plain words instead of a raw403.get_ai_usageshows the same state ascredits.trialOffer.- A chat message in the web app's AI panel now costs 1, 3 or 6 credits by diagram size (the same small, medium and large tiers as a Review). In
get_ai_usage,prices.chatis now an object,{ s, m, l }, likeprices.reviewandprices.deep, instead of a single number. The agent tools do not chat; only what the usage shows changes.
Upgrading to 0.26.2
Deploy the API first: this release calls the API's owner-checked lock release (DELETE /api/diagrams/:id/lock) and GET /api/diagrams/:id/version, which ship in the same API deploy.
- The edit lock is held only while a write is sent, and released right after it, whether the write succeeded or failed. A person editing the diagram in the web app, or another agent, is no longer blocked for 45 seconds after each agent change. The release is skipped once the lease may already have lapsed, so another writer's lock is never cleared.
- When another editor or agent holds the lock, a write waits for it once (at most 5 seconds) and tries again. If it is still held, the tool says the diagram is locked, that nothing was saved, and to try again in a few seconds.
- A diagram over 2 MB in total is refused before anything is written, with its size and how to split it, instead of a raw
413. The same message replaces the API's bare413: Payload too large. A single tab over the per-tab limits keeps its own message. - A write that times out is checked against the diagram's version. If the diagram changed, the tool says the change most likely saved and to check with
get_diagrambefore trying again; if not, it says most likely nothing was saved, and to check for a duplicate if you retry. A timed-outrestore_snapshotsays whether the restore may have been saved (checklist_snapshotsfirst) or that nothing was restored. create_diagramandclone_diagramon a Free workspace that is full say so in plain words, with the upgrade link, instead ofdiagram_limit_reached.clone_diagramkeeps the copy the API makes of every tab and no longer writes a second copy over it. A diagram with levels now clones in one step; before, the tool reported a failure for a complete copy, and a retry made a second one ("Copy of X 2").- An agent whose API key belongs to someone with an edit grant on the diagram (not a member of its workspace) can now write. Before, claiming the edit lock answered
404and the write failed. - A stricter write check: a level problem (a node whose
insideOfnames a missing container, one that is not a component, or a cycle) is now refused on every Architecture-entry tab type (sequence, DB schema and API schema tabs too, not only the canvas). An agent write that was accepted before can now get a400whose message names the node and says why; fix that node'sinsideOfand write again. - SQL imports now keep type precision (for example
varchar(255)anddecimal(10,2)instead ofvarcharanddecimal), so the first drift check after upgrading may report those columns as changed once. - Import and export fixes that ship inside this package:
- SQL imports read pg_dump files (constraints added by
ALTER TABLE,COPYdata blocks) and MySQL dumps with backslash escapes in strings without dropping tables. - Mermaid exports give every node, table, column, participant and stage its own id, so names that differ only in punctuation (
a-banda_b) stay separate. draw.io exports keep label text such as&and<exactly, and import it back unchanged. - Nodes inside a boundary keep their positions: a diagram whose boundary children were saved by the web app with positions relative to the boundary is now exported and laid out with them at the right place.
- SQL imports read pg_dump files (constraints added by
Upgrading to 0.26.1
A security release. The server changes are in this package; the clone rule below is enforced by the API, so it needs the API deploy of the same release.
- Diagram ids are checked before any request: a
diagram_id,source_diagram_id,diagram_idsentry or thediagraminmodudraft.jsonmust be letters, digits,-and_(every real id is). Anything else is refused with "is not a diagram id". read_filerefuses more credential files, matched on the file name in any folder and in any letter case:.dev.varsand.dev.vars.*,*.tfstateand its backups (*.tfstate.backup,*.tfstate.<timestamp>.backup),*.tfvarsand*.tfvars.json,.envrcand.envrc.*,kubeconfigandkubeconfig.*, any*.jsonwhose name containsservice-account(orservice_account,serviceaccount),*.p8keys,.vault-tokenand.htpasswd.import_filereads.dev.varslike a.envfile, with secret values redacted.- Env imports redact more:
PGPASSWORD, PINs, webhook and Sentry DSN URLs, and short Stripe keys. - YAML imports (OpenAPI, AsyncAPI, docker-compose, CloudFormation, Kubernetes, dbt) refuse a file that expands past 1,000,000 items through aliases, or refers to itself, instead of hanging.
- Copying an organization's diagram (
clone_diagram) now needs aworkspace_idin that organization; the API refuses a copy into a personal workspace. An organization's diagram can only be cloned within its organization. This is enforced by the API, so it takes effect with the API deploy, not with this package. - The drift-check Action now defaults to this exact MCP version instead of
latest.
Upgrading to 0.26.0
- New
review_diagramandget_ai_usagein theanalysistoolset, for the AI Architect. Deploy the API first: they callPOST /api/diagrams/:id/reviewandGET /api/ai/usage.review_diagramruns a Review (type: "review", the default) or a Deep review (type: "deep") and waits for the result, up to 5 minutes. An optionalfocustells it what to look at closely. It returns the free Quick checks inquickChecks, the AI'sfindings, asummary, the sizetierandcreditsLeft. Each finding's fixes list diagram edits (an update lists only the fields it changes); the tool never applies them, so ask before using the editing tools.get_ai_usagereturns the credits left this month, when they reset, this month's spending by type and the prices by diagram size. Check it before a Deep review.- Reviews need a paid plan or the Pro trial (Free has no AI) and spend credits. A failed run is refunded. A run the agent stops waiting for still finishes on the server and is saved and charged (0.27.0 adds
get_reviewto read it). An organization can turn the AI Architect off; the tool then says so.
- An admin can pause some features (AI Architect, API keys, share links and more) without a deploy. A paused feature answers
503 feature_disabled, and the tools andmodudraft-mcp checkshow the API's plain text, for example "AI Architect is temporarily turned off." - The
review_diagramprompt is nowstructure_review, so it no longer shares a name with thereview_diagramtool. It still validates a diagram and lists its structural issues.
Upgrading to 0.25.0
- New
statestoolset for state machines (file format 2.13.0). Deploy the API and the web app first: a diagram with state machines needs an API and a web app that read file format 2.13.0. Any component on the Architecture tab can own any number of machines, with nested, parallel, history and final states.list_state_machineslists the machines of a diagram or of one component, with state, transition and warning counts.get_state_machinereturns one machine as a tree of states and transitions, with linked endpoints resolved (orresolved: nullwhen the endpoint was removed) and its warnings.create_state_machinecreates a machine on a component with one initial state ("Idle" unless you name it).update_state_machinerenames a machine, changes its description or initial state, or moves it to another component.delete_state_machinedeletes a machine with its states and transitions.apply_state_machinebuilds a whole machine from one nested JSON shape in one write, all or nothing, at most 500 operations. It replaces an existing machine only when you passmachine_id; the same name on the same component without it is refused with the existing machine's id. A replace keeps the machine on its component (to move one, delete it and apply it on the new component) and cannot take another machine's name there. A change too large for one request is refused before anything is sent. Ambiguous targets, sibling-name clashes and a parallel state with one region are refused with the state path and the fix, and nothing is written.add_state,update_stateanddelete_stateedit states.add_statewith kindparallelcreates the state with two regions. A machine's last top-level state, and one of a parallel state's two regions, cannot be deleted: the message says what to do instead.add_transition,update_transitionanddelete_transitionedit transitions. A trigger is a plainevent, anapi_event(an event endpoint of the API tab), anendpoint(a non-event endpoint), a timer (after_ms) oralways.set_event_consumerssets the components that consume an event endpoint.export_state_machinereturns Mermaid, XState or PlantUML text, or writes it to a file under your project folders withpath.
- New
export_asyncapiin theapitoolset: the event endpoints as an AsyncAPI 3.0.0 document, with a channel per topic, a send operation per publisher and a receive operation per consumer. YAML text by default, JSON text withformat: json, or a file withoutput_path. - The file argument differs between the two new exports:
export_state_machine(statestoolset) takespath, likeexport_structurizrandexport_threat_model, andexport_asyncapi(apitoolset) takesoutput_path, likeexport_to_file. - State refs take an id, a dotted name path from the machine root (
Box.Inner) or a name unique in the machine; machine refs take an id or a name unique in the diagram; component refs take an id or an exact label. - State-machine edits are sent as targeted ops, so they don't overwrite concurrent edits in the web app. When someone else changes the diagram first, the edit is planned again on the new version; if its state is gone, it says so and writes nothing.
delete_nodeandclear_diagramalso remove the state machines a removed component owns, andimport_file/import_directoryreport the machines removed with a component the file no longer has.update_api_endpointdrops an endpoint's consumers when its protocol changes away fromevent.clone_diagrampoints cloned machines, transitions and consumers at the cloned items.- Update to 0.25.0. Clients below 0.25.0 save with a full-file write, so on a diagram that has state machines the API refuses any of their writes that removes a component owning a machine (
delete_node,clear_diagram, a re-import that drops the component,update_nodeturning an owner into something that is not a component), and it refuses theirclone_diagramof such a diagram, because a machine would lose its owner. - State-machine text is capped: names, guards and each action 200 characters, descriptions 2000. The tools refuse longer text with a message naming the field, before anything is sent.
Upgrading to 0.24.0
- New
securitytoolset for threat modeling the Architecture tab (file format 2.12.0). Deploy the web app and API first: a diagram with threats needs a web app that reads file format 2.12.0.set_trust_zonesets a boundary's trust zone (internet,dmz,internal,restricted,third-party). Items inside take its zone.set_data_classsets the data class (public,internal,pii,credentials,payment) of an arrow or a data store, plusencrypted(arrows, in transit) orencrypted_at_rest(data stores). These fields are set only here;update_edgeandupdate_nodeare unchanged.get_security_viewreturns the zones, each component's tool, archetype and zone, each arrow's protocol, data class and encryption, and the threats.suggest_threatsruns the same STRIDE rules as the web app's "Suggest threats" and adds the new suggestions. Running it again never adds a duplicate and never brings back a threat markednot-applicable.add_threat,update_threatanddelete_threatedit the threat list. Threats the agent adds are markedsource: agent.export_threat_modelreturns the Markdown report, or writes it to a.mdfile under your project folders withpath.
- The workflow the tools describe: set zones and data classes, run
suggest_threats, callget_security_viewand add threats specific to each component's tool and archetype (the rules are generic and don't know a technology's own weaknesses), then review each suggestion and fill in mitigations and owners, and export the report. - Threat edits are sent as targeted threat ops, so they don't overwrite concurrent canvas edits in the web app.
clone_diagramnow points a cloned diagram's threats at the cloned items. Clients below 0.24.0 keep threats on their writes, but theirclone_diagramcopies threats with the original target ids, so the copy's threats show "target removed". Upgrade before cloning a diagram that has a threat model.- Threat text is capped: title 200 characters, description and mitigation 2000, owner 100.
add_threatandupdate_threatrefuse longer text with a message naming the field. - With more than one Architecture tab, the first tab that gets a threat holds the model; the web app, the report and these tools all follow it.
Upgrading to 0.23.3
- The "MODUDRAFT_API_KEY is not set" message now links to the same API keys page as the expired and revoked key messages (
/account?section=api-keys) instead of/dashboard.
Upgrading to 0.23.2
- An expired or revoked API key now fails with a clear message ("Your Modudraft API key expired" or "was revoked") and a link to create a new one at https://app.modudraft.com/account?section=api-keys. A key revoked because your plan ended says so and links to billing instead. The
modudraft-mcp checkCLI shows the same messages. Other authentication errors are unchanged. - New keys default to a 1-year expiry (you can still pick 30 days, 90 days or no expiry when you create one); unused keys are revoked after 90 days; a warning email goes out 7 days before an expiry or auto-revoke; revoked keys stay in the key list for 30 days.
- Creating a key in the web app asks you to sign in again first if your session is older than 15 minutes. This applies to the web app only; the MCP server cannot create keys.
Upgrading to 0.23.1
- A write refused because a tab is too large (HTTP 413
tab_too_large) now shows the server's message, which names the tab and the limit, instead of a generic failure. import_fileandimport_directorycheck the built diagram against the tab size and item limits before writing, and report the problem without saving anything.snapshot_diagram,list_snapshotsand the other version tools say "Version history isn't available on the Free plan. Upgrade to Pro to keep versions." when your plan has no version history.clone_diagramasks the server to copy the source diagram's Notes images to the clone. A.modudraftfile exported from a diagram keeps absolute image URLs, and so do copied image URLs. They work only while the source diagram's Notes or versions still reference the image; after that the daily sweep removes it.
Upgrading to 0.23.0
- New tool
export_structurizr(export toolset) writes a diagram back out as a Structurizr workspace:format: "dsl"or"json", with an optionalpathunder your project folders andoverwrite. It returns{ format, summary, text }, or{ format, path, summary }when it wrote a file.export_structurizrcan write.dslfiles; the other file-writing tools cannot. No other tool changed.
Upgrading to 0.22.1
write_confignow adds the$schemaline tomodudraft.json, so editors validate and autocomplete the file.- A diagram that was imported on the web is only adopted by a Structurizr re-import when the workspace matches (the same entry file and most element names). Otherwise the web-imported items are left as they are, the workspace is imported beside them in the same diagram, and a warning says so.
Upgrading to 0.22.0
- Adds Structurizr import:
import_fileandimport_directoryread aworkspace.dsl(with its!included files) or a Structurizrworkspace.json, and re-importing updates the diagram in place.sync_project,watch_projectand themodudraft-mcp checkcommand also compare aworkspace.dslsource. Nothing is removed.
Upgrading to 0.21.0
- Architecture diagrams have levels: a component can contain other items. New optional inputs:
inside(a component id or label; empty ornullmeans the top level) onadd_node,bulk_add_nodes,add_boundary,add_noteandupdate_node;c4_kindanddescriptiononupdate_node;inside: "delete" | "lift"ondelete_node;levelonrender_diagram_text,layout_diagram,export_mermaid,export_plantuml,export_drawioandexport_to_file. - New tool
move_to_level(core) moves components into another component or back to the top level. delete_nodenow asks before deleting a component that has items inside: passinside: "delete"to delete them too orinside: "lift"to move them up one level.get_diagramreturns alevelsfield (for exampleTop: 2 items; Orders: 1; since 0.28.0 withinclude: ["diagram"]or["all"]).render_diagram_textand the exports show the top level unless you passlevel; items outside the level appear marked as outside, with arrows to them shown as implied.validate_diagramreports broken levels as errors and C4 rule breaks as warnings.- Diagrams without levels behave as before. Deploy the web app and API first: a level written by this version needs a web app that reads file format 2.11.0.
- More on levels and the C4 look: https://modudraft.com/docs/c4
Upgrading to 0.20.0
- Adds the
sync_projecttool and themodudraft-mcp checkcommand. Nothing is removed. See Repo sync and CI drift check.
Upgrading to 0.19.0
- Snapshots are now server versions.
snapshot_diagramsaves a named version in the diagram's Version history (visible to teammates in the web app),list_snapshotslists the versions, andrestore_snapshotrestores one (snapshot_idis a version id or a version number). Parameter names are unchanged. The restore is saved as a new version and the state before it stays in the history (the previous version), so it can be undone. - Versions are pruned oldest first by plan: 50 per diagram on Pro, 100 on Team and 200 on Enterprise; Free has no version history. Pending edits from this MCP are saved before a snapshot or restore.
delete_snapshotis removed (versions are pruned automatically by plan); calling it returns an explanatory error.- Snapshots saved by older versions in
~/.modudraft/snapshots.v2.jsonare still listed (withsource: "local") and can be restored, but are read-only: no new local snapshots are written. - Requires a Modudraft API with version history.
Upgrading to 0.18.0
- New
load_toolsettool and theMODUDRAFT_TOOLSETSenvironment variable (see Toolsets). Nothing was removed or renamed, and the default is unchanged: every tool is listed. - New MCP resources and prompts (see Resources and prompts).
Resources and prompts
Besides tools, the server offers MCP resources and prompts, for clients that support them.
- Resources: each diagram is readable as plain-text line art at
modudraft://diagram/<id>(the architecture tab, the same output asrender_diagram_text).resources/listreturns your 50 most recently edited diagrams; any diagram id you can reach can be read by URI. - Prompts:
map_repo(optionalpath) scans a repository and imports what it finds;check_drift(diagram_id) checks a diagram against the project code;structure_review(diagram_id) validates a diagram and lists its structural issues;threat_model(diagram_id) builds a STRIDE threat model and exports the report. Each is one message that names the toolset to load.
Upgrading to 0.17.0
- More importers now report a
warningslist for what they skipped or could not map (most formats already did; dbml, schema-rb, typeorm, sqlalchemy, dbt, cloudformation and asyncapi return none).import_filerefuses a SQL file that only hasALTER TABLEstatements (noCREATE TABLE) with a reason. export_terraformandexport_k8s_yaml(andexport_to_filefor those formats) returnwarnings(in the response only; nothing is written into the exported file). Terraform names, values and comments are escaped, and unmappable resource types become commented-out blocks. The Kubernetes YAML no longer carries# TODOcomments.- The SQL export is now quoted. Mermaid output (flowchart, ER, sequence) differs in places: edge labels are escaped, boundaries become subgraphs, and the Mermaid importer handles
&, dotted and thick links,:::cls, quoted labels and subgraphs. - The Postman and Insomnia importers now keep
HEADandOPTIONSrequests too, without a request body (TRACEand other methods are still skipped with a warning). - Table-level
PRIMARY KEYmakes its columns non-nullable on SQL import.
Upgrading to 0.16.0
HEADandOPTIONSare supported HTTP methods for API endpoints and OpenAPI imports (TRACEis still skipped with a warning). The Postman and Insomnia importers still keep only GET, POST, PUT, PATCH and DELETE.add_api_endpoint,bulk_add_api_endpoints, andadd_db_tablereject duplicates, for every protocol: an http endpoint with the same method and path (placeholders are normalized, so/orders/:id,/orders/{id}and/orders/{orderId}are the same path), an endpoint of another protocol with the same protocol and name, and a table with the same schema and name (case-insensitive; no schema meanspublic).export_openapihoists$defsintocomponents.schemas(identical definitions share one component), rewrites:namepath segments to{name}, synthesizes undeclared path parameters, and lists undeclared or unused path parameters and duplicate operations underx-modudraft-warnings.
Upgrading to 0.14.2
- File tools (
read_file,import_file,import_directory,scan_project,export, ...) only read and write inside your source-code folder (your repo or git worktree). The server takes it from your MCP client's workspace folders, thenMODUDRAFT_PROJECT_ROOTS, then the folder the server was started in. Your home directory itself is never accepted, so Claude Desktop users who want the file tools should set the optionalMODUDRAFT_PROJECT_ROOTSto their repo. Relative paths resolve against the first folder, and a leading~is expanded. export(withoutput_path),generate_docsandgenerate_runbookrefuse to overwrite an existing file unless you passoverwrite: true.
Tools
Diagram management
(toolset: core)
| Tool | Description |
|---|---|
list_diagrams |
List your diagrams from every workspace you belong to: id, name, updatedAt, workspaceId, workspaceName, workspaceKind |
create_diagram |
Create a new diagram (optional workspace_id) |
get_diagram |
Read a diagram. By default a summary: the tabs and their sizes, node and edge counts, per-tab outlines (ids, names, types) and the first 3 hints. include adds full data: ["diagram"] (nodes, edges, levels), section names (sequence, db-schema, api, cloud, network, data-flow, hints) or ["all"] (everything, as 0.27 returned). Large results are paged: pass tab_id, offset and limit to read one tab in slices |
delete_diagram |
Move diagram to Bin |
clear_diagram |
Remove all content from a diagram |
layout_diagram |
Auto-arrange the architecture tab now, with the same layout as the editor's Tidy button (LR/TB/RL/BT); boundaries are refitted around their nodes. Pinned nodes keep their place; pass include_pinned: true to lay out everything and clear all pins |
get_share_link |
Get or create a share link. If a link exists with a different permission it is returned as is; pass replace: true to rotate it (the old link stops working) |
Architecture nodes & edges
(toolset: core)
| Tool | Description |
|---|---|
add_node |
Add a component (compute, database, queue, gateway, etc.). tool takes a catalog key or a common name and is resolved to the catalog key (see Tool names). Optional runs_on links the node to a Cloud-tab resource (its id or name; a bad value is refused with the valid names) |
update_node |
Update label, tool, or archetype (a tool name is resolved the same way; the archetype is left alone). runs_on sets the cloud resource the node runs on; pass an empty string or null to clear it |
delete_node |
Remove a node and its connections. Data-flow stages linked to it keep existing; only their node_id link is cleared |
add_edge |
Connect two nodes with optional label and protocol |
update_edge |
Update edge label or protocol |
delete_edge |
Remove a connection |
add_boundary |
Add a grouping boundary box |
add_note |
Add a sticky note annotation |
move_to_level |
Move items (items: ids, or labels for components) into another component (inside: id or label) or back to the top level (inside: null); refused when it would put a component inside itself |
Node metadata
(toolset: modeling, except get_node_schema, which is in core)
| Tool | Description |
|---|---|
set_node_metadata |
Set a configuration property on a node (host, port, framework, region, etc.) |
suggest_metadata |
Find nodes with missing configuration and suggest what to fill in |
get_node_schema |
Get expected metadata fields for an archetype |
Sequence diagram
(toolset: sequences)
A diagram can hold many named sequences. Each has its own lanes (architecture nodes, in order), messages and fragments. Message and fragment tools take sequence_id, which may be left out only when the diagram has exactly one sequence.
| Tool | Description |
|---|---|
list_sequences |
List the sequences: id, name, lanes and message/fragment counts |
add_sequence |
Create a sequence; path: ["Web", "API", "DB"] builds lanes Web, API, DB and messages Web→API, API→DB |
update_sequence |
Rename a sequence, change its description, or reorder/replace its lanes |
delete_sequence |
Delete a sequence with its messages and fragments |
add_sequence_participant |
Add a lane (an architecture node) to a sequence |
add_sequence_message |
Add a message between two lanes (pass a node id or exact node label) |
bulk_add_sequence_messages |
Add many messages (and optional fragments) to one sequence in one call |
get_sequence |
Read one sequence: lanes, messages (ids, node labels, whether the tab draws them) and fragments; far smaller than get_diagram |
update_sequence_message |
Edit one message in place (sender, receiver, label, type) and/or move it to a new position |
delete_sequence_message |
Delete one message and renumber the rest; fragments that included it are trimmed (or removed if left empty) |
clear_sequence |
Remove all messages and fragments from one sequence (keeps its lanes) |
add_sequence_fragment |
Wrap messages of one sequence in a loop / alt / opt / par fragment |
update_sequence_fragment |
Change a fragment's kind, condition, or message list |
delete_sequence_fragment |
Remove a fragment |
DB schema (ER diagram)
(toolset: database)
| Tool | Description |
|---|---|
add_db_table |
Add a database table with columns; rejects duplicate table names (case-insensitive) |
update_db_table |
Replace a table's columns |
delete_db_table |
Remove a table |
export_er_diagram |
Export schema as SQL DDL |
API schema (OpenAPI)
(toolset: api)
| Tool | Description |
|---|---|
add_api_endpoint |
Add an http (including HEAD and OPTIONS), graphql, grpc, websocket or event endpoint; rejects duplicate endpoints. Its request and response shapes go in contract: per-protocol slots holding JSON Schema (as an object or YAML), where fields are required unless marked optional: true. Omit contract to start from an empty one |
bulk_add_api_endpoints |
Add many endpoints in one call, each with its own contract; rejects duplicates within the batch or diagram; one invalid endpoint rejects the whole batch |
update_api_endpoint |
Update endpoint details; contract replaces the slots it names and keeps the rest; changing protocol converts the contract and lists anything that could not be kept in dropped |
delete_api_endpoint |
Remove an endpoint |
export_openapi |
Export the http endpoints as OpenAPI 3.1 (JSON, or YAML with format: yaml); hoists $defs into components.schemas, synthesizes undeclared path params, and reports warnings under x-modudraft-warnings |
The old request_body, request_format, body, body_format and top-level responses arguments were removed; they now return an error naming their replacement in contract.
Notes
(toolset: views)
| Tool | Description |
|---|---|
get_notes |
Return the diagram's Markdown notes |
set_notes |
Replace the notes |
append_to_notes |
Add content to the end of the notes |
replace_in_notes |
Literal find-and-replace inside the notes (must match exactly once unless replace_all), so one checkbox or sentence can change without resending everything |
Cloud diagram
(toolset: infra)
| Tool | Description |
|---|---|
add_cloud_resource |
Add a cloud resource (cluster, VPC, service, database, queue, etc.) |
update_cloud_resource |
Rename or change the type of a cloud resource |
delete_cloud_resource |
Remove a cloud resource. Nodes that ran on it (or a child) keep existing; only their runs_on link is cleared |
Network diagram
(toolset: infra)
| Tool | Description |
|---|---|
add_network_device |
Add a network device (router, switch, firewall, etc.) |
update_network_device |
Rename or change the type of a network device |
delete_network_device |
Remove a network device |
Data flow diagram
(toolset: data_flows)
| Tool | Description |
|---|---|
add_data_flow_stage |
Add a pipeline stage (source, transform, sink, etc.). Optional node_id links it to an Architecture-tab node (its id or label; a bad value is refused with the valid names) |
update_data_flow_stage |
Rename or change the type of a data flow stage, or set its node_id link (empty string or null clears it) |
delete_data_flow_stage |
Remove a data flow stage |
reorder_data_flow_stages |
Set the order of all stages in a data flow diagram |
File import
(toolset: import)
| Tool | Description |
|---|---|
scan_project |
Scan a directory and list all importable files (docker-compose, K8s, Terraform, SQL, Prisma, OpenAPI, etc.) |
read_file |
Read any file from the filesystem |
import_file |
Import a file into a diagram - auto-detects format. Re-importing the same file updates it in place (see Re-import) |
Supported import formats:
- Architecture:
docker-compose.yml→ nodes + edges; a Structurizr workspace (workspace.dslwith its!included files, orworkspace.json) → levels, groups, relationships and dynamic views as sequences, with deployment on the cloud tab and docs/ADRs in the notes - Cloud: Kubernetes YAML, Terraform
.tf, AWS CloudFormation YAML/JSON - DB schema: SQL DDL,
schema.prisma, DBML,schema.rb(Rails), TypeORM entities, SQLAlchemy models, dbtschema.yml - API: OpenAPI 2.x/3.x, GraphQL SDL, Protocol Buffers
.proto, Postman collection, Insomnia export v4, AsyncAPI - Context (no diagram change):
.envfiles (sensitive values always redacted),package.json,go.mod,requirements.txt,Gemfile,pom.xml,Cargo.toml
Export
(toolset: export, except render_diagram_text, which is in core)
| Tool | Description |
|---|---|
export |
Export a diagram. format: mermaid (flowchart, sequence or er via diagram_type), plantuml (component, sequence, er or api), drawio (architecture or db-schema via tab_type), terraform or k8s (from the cloud tab, with warnings), sql (DDL) or openapi (these two only write a file), structurizr_dsl or structurizr_json (with a summary of what was exported, left out or changed). Returns the text, or with output_path writes the file under your project folders and returns the path and size (overwrite: true replaces an existing file). level exports one level of the architecture |
render_diagram_text |
Draw the architecture (level shows one level; outside items are marked "(outside)"), sequence, DB schema (ER), cloud, network or data-flow tab as plain-text line art, the whole tab or a part of it (see Viewing diagrams as text) |
The 0.27 names (export_mermaid, export_plantuml, export_drawio, export_terraform, export_k8s_yaml, export_to_file, export_structurizr) still work in 0.28: they return what they returned before, plus a deprecated field, and they are not listed. They are removed in 0.29.
Validation & diff
(toolset: analysis)
| Tool | Description |
|---|---|
validate_diagram |
Check a diagram for issues: dangling edges, orphaned nodes, FK integrity, missing PKs, duplicate routes, broken levels (errors) and C4 rule breaks (warnings), etc. |
diff_diagram |
Compare two diagrams and return a structured list of what changed (added/removed/modified) |
review_diagram |
Ask the AI Architect to review a design for single points of failure, scaling, bottlenecks, data and consistency, resilience, security basics and patterns. type is review (default) or deep; focus narrows it. Costs credits. Returns quickChecks (free rule checks), findings (each fix lists diagram edits), summary, tier and creditsLeft |
get_review |
Read the latest saved AI Architect review of a diagram, free: quickChecks, findings, summary, kind, tier, createdAt, createdBy, and stale when the diagram changed since. Use it when review_diagram timed out instead of running it again |
get_ai_usage |
Show the AI Architect credits left this month, when they reset, this month's spending by type, and the price of a Review, a Deep review or a chat message by diagram size |
Cross-diagram intelligence
(toolset: analysis)
| Tool | Description |
|---|---|
find_shared_services |
Find nodes that appear in multiple diagrams - useful for shared infrastructure audits |
suggest_connections |
Detect likely missing edges based on archetype pairs |
suggest_architecture |
Generate a suggested node/edge structure from a text description |
clone_diagram |
Deep-copy a diagram as a starting template |
Discovery (static, no API call)
(toolset: core)
| Tool | Description |
|---|---|
list_archetypes |
All component archetypes with metadata field schemas |
list_tools |
Available tech tools per archetype (postgresql, redis, kafka, etc.) |
list_protocols |
Valid edge protocol values |
Org context
(toolset: core)
| Tool | Description |
|---|---|
get_org_context |
Get cached org context - existing tools, protocols, naming patterns |
refresh_org_context |
Force a refresh of the org context cache |
Threat model
(toolset: security)
Threats live on the Architecture tab (one threat model per diagram). Run suggest_threats first, then add threats specific to each component's tool and archetype, then fill in mitigations.
| Tool | Description |
|---|---|
get_security_view |
Boundaries with their trust zones; each component's tool, archetype, effective zone and (data stores) data class and encryption at rest; each arrow's protocol, data class and encryption in transit; the threats (targetRemoved: true when the item was deleted) |
suggest_threats |
Run the Modudraft STRIDE rules and add the new suggestions (status suggested). Returns the count and titles. Safe to re-run: no duplicates, and a not-applicable threat never comes back |
add_threat |
Add a threat (source: agent): title, stride (S T R I D E), target ({ kind: "node" | "edge" | "boundary" | "diagram", id }), optional severity, status, description, mitigation, owner |
update_threat |
Change any field of a threat; an empty string clears description, mitigation or owner |
delete_threat |
Delete a threat (for a rule suggestion that doesn't apply, prefer status not-applicable) |
set_trust_zone |
Set or clear a boundary's trust zone: internet, dmz, internal, restricted, third-party |
set_data_class |
Set data_class on an arrow or a data store, plus encrypted (arrows) or encrypted_at_rest (data stores) |
export_threat_model |
The Markdown threat-model report (same as the web app's download), or write it to a .md file with path |
Example prompts
"Scan my project at ~/code/myapp and import everything you find into diagram X."
"Import our docker-compose.yml and create an architecture diagram."
"Import schema.prisma and generate the DB schema tab."
"Export the architecture as a Mermaid diagram and save it to ./docs/architecture.md."
"Generate Terraform stubs for everything in the cloud tab and save to ./infra/main.tf."
"Validate diagram X - are there any issues with the schema or missing connections?"
"Compare diagram A and diagram B - what changed between the two designs?"
"What services appear in more than one of our diagrams?"
"Suggest an architecture for a checkout service with Stripe, Postgres, Redis, and an event queue."
"Create a diagram of a typical e-commerce backend with a React frontend, API gateway, user service, product service, order service, PostgreSQL databases, Redis cache, and Kafka queue. Connect them and layout the diagram."
"Add the DB schema for the order service - orders, order_items, and payments tables."
"Add a Login sequence that goes Web App → API Server → Postgres."
"What metadata is missing from the diagram nodes? Fill in the hosts and ports based on our .env file."
How it works
Each tool call requires a diagram_id. The server reads the current diagram from the Modudraft API, applies the change in memory, and writes it back - with a 150ms debounce batch so rapid sequential edits (add 10 nodes, add edges) result in a single API round trip. Changes appear instantly in the Modudraft web app.
The get_diagram summary includes the first few hints (structural problems and nodes with empty metadata fields) so your AI assistant knows what context to ask you for; include: ["hints"] returns all of them.
Security
- API keys are hashed (SHA-256) server-side and never stored in plain text
- Keys can be revoked at any time from the dashboard
- All requests use HTTPS
.envfile imports redact all secrets - only topology metadata (host, port, database name, region) is ever extracted; passwords, tokens, and API keys are always replaced with[REDACTED]
License
Proprietary software. Copyright © 2026 Modudraft. All rights reserved.
You may install and run this package to connect your own AI tools to the Modudraft service under a valid Modudraft account. Copying, modifying, redistributing, and reverse-engineering it are not permitted. The full terms are in the LICENSE file included in this package, and use of the service is governed by the Terms of Service. Questions: security@modudraft.com.
Where agent edits go
Agent edits (add_node, add_edge, ...) target the architecture tab. The exporters (Terraform, Kubernetes, Mermaid, ...) read the cloud, network and data-flow tabs, so build those with their own tools or import into them with target_tab (db-schema, api, cloud or network).
Concurrent edits
Every write sends the diagram version it was based on in the x-modudraft-base-version header. If someone edits the same diagram in the web app meanwhile, the server refuses the stale write instead of overwriting their edit; the MCP then re-reads the diagram, re-applies the agent's change and retries (at most 3 attempts). If the diagram keeps changing, the call fails with a clear message and nothing from that call is saved, so just try again. This needs a Modudraft API that supports the precondition; against an older API the header is ignored.
Pinned nodes
A node with an explicit x/y (add_node, add_boundary) is pinned. Nodes that people drag or nudge in the web editor are pinned too. The editor's Tidy button and the node menu's "Unpin" clear pins. Auto-tidy and layout_diagram keep pinned nodes where they are; layout_diagram with include_pinned: true lays out every node and clears all pins.
Re-import
import_file and import_directory remember where each imported item came from: the repository (its origin remote without credentials, such as github.com/acme/shop, or else the repo folder's name) plus the file path relative to the git root, scoped to the target node for DB and API imports. Two repos that both have a root docker-compose.yml therefore never overwrite each other's items. Importing the same file again:
- updates items that came from that file (columns, labels and types are replaced by the file's content),
- adds new items,
- removes items the importer created earlier that no longer exist in the file.
Items from other files are never touched. Existing items without import history whose name matches an item in the file (a table, endpoint, service or resource of the same name) are adopted and from then on kept in sync with the file; the response lists them under adopted in changes. Other items you made by hand are never touched. import_directory reports each file's changes, also_removed and warnings, plus a removed total. A parse that finds nothing is refused unless you pass allow_empty: true, so an empty or broken file cannot wipe a diagram. target_tab accepts db-schema, api, cloud or network. Terraform dependencies are recorded as config.dependsOn.
Structurizr workspaces. Items are matched by their Structurizr canonical names (for example Container://Shop.Web Store), so matched items keep their id, position and pin. A few things follow from that:
- Renaming a software system or container in the DSL gives it, and everything inside it, a new name: they are imported again as new items (the positions inside it start fresh) and the old ones are removed. Items you made by hand inside a removed system or container are moved up a level, not deleted.
- A
runsOnlink stays when you remove thecontainerInstancethat set it, as long as its deployment node still exists. Links you set by hand are kept too. - The workspace's documentation and ADRs go into one marked block of the notes per workspace, replaced on re-import. Changes to docs, ADRs or dynamic views only are not reported as drift by
sync_projector the CI check (applying a sync still updates the notes block and the sequences). - A colour the workspace sets wins on re-import; a colour you set by hand on an item the workspace gives no colour stays, and is not drift.
- A diagram made by importing the workspace on the web is picked up by the first
import_fileof the same workspace: its items are matched, not added a second time. - Only the files the workspace uses (
!include,!docsand!adrstargets, and the.jsonfiles beside it, checked for a layout) are read from its folder, up to 50 MB in all;node_modulesand.gitare skipped. A Structurizrworkspace.jsonmay be up to 20 MB; other entry files are limited to 2 MB, and the files a workspace includes count toward the 50 MB total. watch_project/check_project_drifttrack the workspace file itself (workspace.dsl), not the files it includes. After editing an included file, runsync_project(or the CI check), which reads the whole workspace, to see the change.
More on importing a workspace: https://modudraft.com/docs/migrations/structurizr
Project drift
check_project_drift only reports; it no longer consumes the drift. Drift stays reported until you pass acknowledge: true. Re-importing a modified file with import_file also clears it for that file; a new file stays reported as added until you acknowledge. A truncated scan (too many files) is flagged in the result.
Repo sync and CI drift check
sync_project compares the files in your repo with a diagram and brings the diagram up to date. It previews by default; the same engine powers the check command and the GitHub Action, so CI can tell you when the diagram has drifted from the code.
CI drift check. The same engine powers npx @modudraft/mcp check and the modudraft/drift-check GitHub Action, which compare docker-compose, Kubernetes, Terraform, OpenAPI, Prisma, SQL and more with a diagram on every pull request (exit 0 in sync, 1 drift with --on-drift fail, 2 error). A file that fails to parse is reported and removes nothing. Supported files, modudraft.json, flags, keys and example workflows: https://modudraft.com/docs/ci
sync_project inputs: diagram_id, dir, files, dry_run (default true), remove_missing, write_config. With dry_run: false it writes once through the normal save path, so the change is recorded in version history (it may merge with an earlier version from the same key within 10 minutes). Applying is refused when the sources came only from a scan. write_config: true writes modudraft.json (also during a preview), keeps existing entries, writes { path, node } when a node was used, and skips files that errored. It also adds "$schema": "https://modudraft.com/schema/modudraft.json" as the first key (kept if already present), which gives autocomplete and validation in VS Code and JetBrains. With no diagram id and no config the tool answers: "Pass diagram_id, or add modudraft.json (sync_project with write_config: true)".
Workspaces and local files
list_diagrams, search_diagrams and get_org_context cover every workspace you belong to; create_diagram and clone_diagram accept workspace_id. The API lists at most 500 diagrams (newest first); when list_diagrams hits that cap it returns { diagrams, truncated: true, note }.
Local state lives in ~/.modudraft: snapshots.v2.json, edit-log.v2.json, watch.v2.json and org-context-v2.v2.json (the org context cache, which holds org and team labels). These files are private to you (files 0600, folder 0700), locked against concurrent MCP processes, and kept separately per API key. The first write imports the data of an older MCP's snapshots.json, edit-log.json or watch.json; those older files are never written again, so an older MCP still running cannot wipe the new ones.
Auto-tidy
Agents build a diagram with many small calls, and the layout only makes sense once the nodes and the edges between them exist. So adding or removing a node or an edge (add_node, add_edge, delete_node, delete_edge, bulk_add_nodes, bulk_add_edges) does not tidy immediately. Each change restarts a per-diagram timer, and the diagram is tidied once, after the changes stop - never between the ten adds of a ten-element build. It is the same layout as the editor's Tidy button.
- Editing a property (
update_node,update_edge, metadata) never triggers it, only a change in the number of elements does. add_nodewith an explicitx/ykeeps that position and does not schedule a tidy.- Calling
layout_diagramyourself tidies right away and cancels the pending one. - The tidy is best-effort: if the diagram is locked by someone editing, it is skipped, and the next add or remove schedules another.
- Set
MODUDRAFT_AUTO_TIDY_MSto change the quiet period, or0to turn it off.
Tool names
A node's tool is a catalog key (better-auth, postgresql, google-oauth), and the app shows an initials badge with an "unknown tool" warning for anything else. Agents rarely use the exact key, so add_node, update_node, bulk_add_nodes and apply_architecture resolve what they are given:
- an exact catalog key (any case);
- an alias listed on the tool in the catalog (
postgres,pg,k8s,NextAuth,entra id,sign in with Google,GitHub login); - the key or display label with case, spaces, punctuation and underscores ignored (
Better Auth,betterauth,better_auth,Auth.js).
- The resolved catalog key is stored. If you did not pass an
archetype, the tool's own is used, sotool: "Better Auth"is anauthnode, notcompute. An explicitarchetypealways wins, andupdate_nodenever changes the archetype. - Nothing is guessed: an ambiguous name (a bare
google,microsoftorapple) stays unresolved. - An unknown tool is kept exactly as typed (custom technologies are fine) and the response carries a
tool_hint(tool_hintsfor the bulk tools) naming the closest catalog tools. Uselist_toolsto browse valid values. suggest_architecturealso recognises these names when it looks for an auth component in a description, and the nodes it proposes now carry real catalog archetypes (client,gateway,auth,notification,search,database,cache,queue,storage,observability,compute).- Aliases are part of the catalog itself (an
aliaseslist on each tool in@modudraft/core), so the editor's palette search finds a tool by them too: typingentra,next authorsign in with googlefinds Azure AD, Auth.js and Google OAuth. - Importing a dependency manifest (
import_fileonpackage.json,requirements.txt,Gemfile,go.mod,composer.json,pom.xml) now also reports anauthlist of the authentication libraries it finds, under their catalog names (Better Auth,Auth.js,Clerk,Keycloak,Microsoft OAuth...), ready to pass straight toadd_node. Bare@supabase/supabase-jsandfirebaseare not counted as auth.
Viewing diagrams as text
render_diagram_text draws a tab as plain-text line art, so any agent or terminal can see a diagram without a Mermaid or PlantUML renderer. Print the returned text inside a code fence. It is read-only.
It draws the full tab or a part of it. diagram_type is architecture (default), sequence, er (the DB schema), cloud, network or data_flow.
| Selector | Applies to | Example | Shows |
|---|---|---|---|
focus + hops + direction |
architecture | focus: "Auth", hops: 2, direction: "out" |
that node and everything within N edges (out = downstream, in = callers, both = default) |
nodes |
architecture | nodes: ["Auth", "Postgres DB"] |
exactly those nodes and the edges between them |
boundary |
architecture | boundary: "VPC" |
the nodes inside that boundary |
archetype |
architecture | archetype: "database" |
only nodes of that archetype |
from_message / to_message |
sequence | from_message: 13, to_message: 15 |
messages 13 to 15 (0-based, inclusive) |
sequence_id |
sequence | sequence_id: "a1b2c3" |
which sequence (needed when there are several) |
participants |
sequence | participants: ["Web App", "API Server"] |
only messages between them |
focus + hops + direction |
er | focus: "orders", hops: 1 |
that table and the tables related to it (out = the tables it references, in = the tables that reference it) |
tables / name_prefix / schema |
er | tables: ["users", "orders"], name_prefix: "order", schema: "audit" |
exactly those tables / tables whose name starts with it / tables of one schema |
detail |
er | detail: "keys" |
full (default, every column), keys (only PK / FK / unique columns) or names (just the table names) |
root |
cloud, network | root: "main-vpc" |
that resource and everything inside it |
depth |
cloud, network | depth: 1 |
this many levels below the root(s); 0 = only the roots. Boxes with hidden children show (+N) |
type |
cloud, network | type: "ec2" |
resources of that type plus the chain of ancestors above them, marked as context |
config / style |
cloud, network | config: "all", style: "tree" |
how much config to show (none, summary = first 3 entries, all); nested boxes, an indented tree, or auto (nested, falling back to a tree when too wide or deeper than 4 levels) |
flow / descriptions |
data_flow | flow: "Orders pipeline", descriptions: true |
one flow / each stage's description under its name |
Selectors combine (each narrows the view). Nodes, boundaries, participants, tables, resources and flows are given by id or exact name, case-insensitive; an unknown or ambiguous one is an error that lists the choices. A partial view says what it leaves out: a box that still has hidden neighbours shows (+N) and they are listed below the diagram, and omitted messages are counted.
Options: layout (LR or TB, architecture and er), max_width (default 120; the renderer switches layout, moves edge labels to a numbered legend, or falls back to a tree, to fit), and charset (unicode or ascii for terminals and agents that cannot show box-drawing characters). The result also carries structured shown, hidden and warnings.
focus: "Auth", hops: 2, direction: "out":
┌─────────────────┐
┌►│ Microsoft OAuth │
│ │ external │
│ └─────────────────┘
│
│
┌───────────┐ OAuth 2.0 │ ┌──────────────┐
│ Auth │─────────────┘ ┌►│ GitHub OAuth │
│ auth (+1) │── OAuth 2.0 ──┘ │ external │
│ │───────────────┐ └──────────────┘
└───────────┘ OAuth 2.0 │
│
│ ┌──────────────┐
└►│ Google OAuth │
│ external │
└──────────────┘
Partial view: 4 of 12 nodes, 3 of 11 edges shown (focus "Auth", 2 hops out).
Hidden neighbours:
Auth: <- API Server
diagram_type: "sequence", from_message: 13, to_message: 15, participants: ["Web App", "API Server"]:
Web App API
│ │
│ │ ... 13 earlier messages omitted
│ │ ┏ loop: on each edit (autosave)
│──────►│ ┃ 13 PATCH /api/diagrams/:id/ops {seq, ops}
│◄┄┄┄┄┄┄│ ┃ 15 200 { ok, seq }
│ │ ┗
│ │ ... 15 later messages omitted
│ │ ... 1 message with other participants hidden
Columns: API = API Server
The ER view draws each table as a box of columns (PK, FK, UK; ? marks a nullable column) and each relation as a line from the table that holds the foreign key, labelled with the column and N:1, 1:1 or N:M. Relations come from foreign-key columns and from stored relations, merged. Tables with no relations are packed into a grid. diagram_type: "er", focus: "orders":
┌─────────────────────────┐
│ order_items │
│ (+1) │
│ PK id uuid │
│ FK order_id uuid │
│ FK,UK product_id uuid │
│ quantity integer │
└─────────────────────────┘
│
│ order_id N:1
┌┘
▼
┌──────────────────────────────┐
│ orders │
│ PK id uuid │
│ FK user_id uuid │
│ FK billing_address_id uuid │
│ FK shipping_address_id uuid │
│ total numeric(10, 2) │
└──────────────────────────────┘
│ │ │
│ │ user_id N:1 │
[1] │ [2] │ ┌──┘
┌────┘ ┌────┘ ▼
▼ ▼ ┌────────────────┐
┌────────────────┐ │ users │
│ addresses │ │ (+2) │
│ PK id uuid │ │ PK id uuid │
│ line1 text │ │ UK email text │
│ city text │ │ name? text │
└────────────────┘ └────────────────┘
Legend:
[1] orders -> addresses: billing_address_id N:1
[2] orders -> addresses: shipping_address_id N:1
Partial view: 4 of 10 tables, 4 of 9 relations shown (focus "orders", 1 hop).
Hidden neighbours:
users: <- profiles, <- audit.events
order_items: -> products
Cloud and network are containment hierarchies (a VPC contains subnets), not graphs, so they are drawn as boxes nested inside their parent, or as an indented tree. diagram_type: "cloud", style: "tree", config: "none":
prod-account (aws-account)
· account_id: 123456789012
· region: eu-west-1
├── main-vpc (vpc)
│ · cidr: 10.0.0.0/16
│ ├── public-a (subnet)
│ │ · cidr: 10.0.1.0/24
│ │ · az: eu-west-1a
│ │ ├── web-alb (load-balancer)
│ │ │ · scheme: internet-facing
│ │ ├── web-1 (ec2)
│ │ │ · instance_type: t3.small
│ │ │ · ami: ami-0abc
│ │ │ · key_pair: prod
│ │ │ · +1 more
│ │ └── web-2 (ec2)
│ │ · instance_type: t3.small
│ └── private-a (subnet)
│ · cidr: 10.0.2.0/24
│ └── orders-db (rds)
│ · engine: postgres
│ · size: db.t3.medium
└── assets (s3-bucket)
A data flow is drawn as one lane per flow, sources to transforms to sinks: all sources feed all transforms, and all transforms feed all sinks (a column with several stages joins the next through a shared bus). The flow's notes sit on the arrows, or in a numbered legend when they are long. diagram_type: "data_flow", flow: "Orders pipeline", descriptions: true:
Flow: Orders pipeline
Sources Transforms Sinks
┌────────────────────────────────┐ ┌────────────────────────────┐ ┌──────────────────────┐
│ Orders API │ raw events │ Deduplicate │ [1] │ Warehouse │
│ source · postgresql │ ┌──────►│ transform · spark │───┬──►│ sink · snowflake │
│ Orders written by the checkout │──────┤ │ Drop repeated events by id │ │ └──────────────────────┘
│ service │ │ └────────────────────────────┘ │
└────────────────────────────────┘ │ │ ┌──────────────────────┐
│ │ │ Search index │
┌────────────────────────────────┐ │ └──►│ sink · elasticsearch │
│ Web events │ │ └──────────────────────┘
│ source · kafka │──────┘
└────────────────────────────────┘
Legend:
[1] Orders pipeline: transforms -> sinks: cleaned, deduplicated rows ready for analytics and search