crayon-c4-mcp

v1.56.10
io.github.SQUORA-NL/crayon-c4-mcp Checked 4 hours ago Published 3 days ago

Author, validate and maintain a CRAYON-C4 architecture model — never write an invalid file.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

validate_model Validate a CRAYON-C4 model

Check a model against BOTH the published Draft 2020-12 schema (shape) and the app's own semantic validator (meaning — dangling relationship endpoints, illegal containment, a container-drop naming a C4 id that is gone). Returns path-precise errors with the rule behind each one. With no arguments it checks the model THIS SESSION is building; pass `model` to check a draft you have not committed anywhere, or `path` to check a file on disk. Hard violations are `errors`; soft ones are `warnings` — a model with only warnings still imports and renders.

ParameterTypeDescription
modelThe model object to validate. Takes precedence over `path`.
pathstringWorkspace-relative path to a model FILE. Omit both arguments to validate the model this session is building, which is usually what you want before `write_model`.

create_model Create a new model

Scaffold a new, valid CRAYON-C4 model in this session. Nothing is written to disk until `write_model`. Choose the slices you will actually use: an ABSENT deployment or behavioral slice says "this project does not model that", an EMPTY one says "it does, and nothing is in it yet" — both are legal.

ParameterTypeDescription
name *stringProject name, as a person would say it.
overwritebooleanReplace the model already open in this session. Refuses without it, so an in-progress model is never lost to a stray call.
slicesarraySlices to scaffold. `c4` is always included.
titlestringTitle on the diagram set. Defaults to `name`.

read_model Open a model and summarise it

Load a model file into this session and report what is in it: element counts by type, relationships, every diagram with its subject and how many lines it actually draws, elements that appear on no diagram, and the validation state. It deliberately does NOT return the whole file — read `crayon-c4://model/current` when you genuinely need the JSON.

ParameterTypeDescription
pathstringWorkspace-relative path. Defaults to the session model file.
reloadbooleanRe-read from disk, discarding unsaved session edits.

upsert_nodes Create or update elements

Create or update C4 elements by id. Ids are YOURS and stable — use meaningful ones (`sys-shop`, `cnt-api`) so re-running the same call updates rather than duplicates. Containment is enforced: a Container lives in a Software System, a Component in a Container, Code in a Component; Person / External System / Software System are root-only. Parents named in the SAME call are applied first, so a system and its containers can go in one batch. Per-element outcome is reported; a rejected element does not stop the others, but if any element is rejected the whole batch is left unapplied.

ParameterTypeDescription
nodes *array

upsert_relationships Create or update relationships

Create or update entries in the ONE central relationship list. A relationship is identified by its endpoint pair, so re-running the same call updates rather than duplicates. Point it at the DEEPEST elements that actually talk — coarser diagrams roll it up automatically, and pointing it at a system "because that is the diagram I am drawing" throws the detail away for good. DIRECTION = WHO INITIATES: a relationship goes from the element that starts the interaction at runtime to the element it acts on (calls, sends to, reads from, writes to). It is activation, not data flow. One line per intera…

ParameterTypeDescription
relationships *array

upsert_layer Create or update a diagram

Create or update a diagram: which elements it shows, what it is ABOUT (`subject`), where it sits in the tree (`parent`), and how it draws its lines. The subject renders as the BOUNDARY FRAME around its children, never as a card — so it is dropped from the node list if you include it, and you are told. You never list relationships on a diagram: every line is derived by projecting the central list onto the elements shown.

ParameterTypeDescription
addNodesarray
descriptionstring
diagramTypestringThe C4 level. `landscape` is level 0 (several systems, no subject). Behaviour and sequences are not a C4 diagram type — use F4.
edgeStylestring
idstringStable diagram id. Derived from the label when omitted.
labelstringRequired when creating — what the reader sees in the diagram list.
nodesarrayReplaces the element list.
parentThe diagram above this one.
removeNodesarrayTakes elements off THIS diagram only (they stay in the model). The diagram remembers them as manually removed so the wand never adds them back; listing one in `nodes`/`addNodes` later clears that.
subjectThe element this diagram is about. `null` = explicitly none (a landscape diagram, which REFUSES a subject); omit to leave it alone.

remove_elements Remove elements and diagrams

Delete elements and/or diagrams safely. A delete CASCADES to the whole containment subtree — a child whose parent is gone is invalid and usually cannot be legally reparented — and drops every relationship touching anything removed. Child diagrams are re-hung on the deleted diagram's parent rather than deleted, unless you ask otherwise. Run it with `dryRun` first: the plan tells you exactly what would go.

ParameterTypeDescription
deleteChildDiagramsbooleanAlso delete diagrams below the ones named, instead of re-hanging them.
dryRunbooleanReport the plan and change nothing.
layersarrayDiagram ids to remove.
nodesarrayElement ids to remove.

set_layout Pin element positions on a diagram

Optionally pin where elements sit on one diagram. PRESENCE is what makes a position manual: an element with no entry is placed by the layout engine and follows every future change, one with an entry is pinned and stops following. Passing `null` for an element returns it to automatic. Most models should carry no layout at all — pin only when you have a real reason.

ParameterTypeDescription
layerId *string
clearbooleanDrop every pin on this diagram.
positionsobjectElement id → {x,y}, or null to return it to automatic.

write_model Write the model to disk

Validate, pretty-print and write the session model. It REFUSES to write anything invalid. By default it returns a DIFF and writes nothing — pass `confirm: true` to actually write. The output is JSON with two-space indent and a trailing newline, so re-writing produces a clean Git diff rather than a one-line blob. Also writes every decision in the model out to `adr/*.md` beside it, in the same Git-native format `merge_model` reads back in — the file a decision came from (or its new home, for one authored in this session) is always current after a write.

ParameterTypeDescription
confirmbooleanWrite. Without it you get a preview only.
pathstringWorkspace-relative target. Defaults to the session model file.

license_status License status

Report this session's tier, which capabilities it grants, where the key was found, and — when unlicensed — exactly why and what the free tier still allows. Call this when a tool says a capability is not included.

explain_c4 Explain C4 and what each diagram level is for

Explain the INTENT behind C4 and behind each diagram level — what question it answers, who reads it, what belongs on it and what does not. Ask for a `level` to get that level in depth, or a `topic` (relationships, subject, containment, deployment, flows, layout) for how that idea works here. Read this when you are deciding WHAT to model; read `crayon-c4://capabilities` for the rules and `crayon-c4://schema/model` for the shape.

ParameterTypeDescription
levelstringExplain one diagram level in depth.
topicstringExplain one idea in depth.

get_session_settings Report the settings in effect

Report the settings this session will author with, and — per field — whether the value came from the engine default, this repository's `.crayon/config.json`, or this session. Also returns the repo's prompt guidance for each AI pass.

set_session_settings Set this session's authoring preferences

Set preferences for THIS session. They override the repository's `.crayon/config.json` per FIELD — a field you do not mention keeps whatever the repo or the engine default says, so setting `language` never silently adopts a `granularity` you did not ask for. Nothing is written to disk: use `write_config` to make a preference the repository's. The effective settings are echoed back with their sources.

ParameterTypeDescription
descriptionStylestring
diagramBudgetintegerElements per diagram above which a diagram is reported as too big.
granularitystringComponent granularity for a scan. `folder` makes a folder the Component and demotes its files to Code.
languagestringBCP-47 tag for generated prose, e.g. "nl".
preferSubjectBoundarybooleanPrefer a diagram ABOUT an element (subject = boundary frame) over a flat landscape.
relationshipsobject
resetbooleanClear every session setting first, returning to the repo/default values.

read_config Read .crayon/config.json

Read this repository's `.crayon/config.json` and validate it against the published config schema. A missing file is reported, not an error — the config is optional.

write_config Write .crayon/config.json

Validate and write this repository's `.crayon/config.json`. It REFUSES to write anything the published config schema rejects. By default it MERGES your keys over what is there — pass `replace: true` to write the object verbatim. Like `write_model`, it previews unless you pass `confirm: true`.

ParameterTypeDescription
config *objectThe config object, or the keys to merge.
confirmbooleanWrite. Without it you get a preview only.
replacebooleanReplace the file instead of merging over it.

detect_stack Detect what this repository is built with

Report the stacks found in this workspace — Next.js, React, .NET, Java (Maven or Gradle), or a generic fallback — with the root each was found at. Cheap: it reads manifests, not sources. Run it first to know whether a scan will find anything.

scan_repo Derive a C4 model from the code

Walk the repository and derive a C4 model, honouring `.crayon/config.json` (roots, exclusions, bundles, granularity). It NEVER writes: by default it reports what it found and changes nothing. Pass `adopt: true` to make the result this session's model — use `merge_model` instead when a model already exists, so hand-written curation survives. The report always names any diagram over budget: an unreadable diagram is a config problem, and nothing is truncated silently.

ParameterTypeDescription
adoptbooleanReplace this session's model with the scan result. Refused when unsaved changes exist.
depthstringDeepest level to emit. `component` is the usual choice; `code` emits a class per file and is rarely readable.
excludearrayProject names to leave out, on top of the config's own.
granularitystringComponent granularity. `folder` makes a folder the Component; `file` is the legacy one-per-file shape.
rootsarrayScope the scan to these app/solution roots (workspace-relative). Omit for the whole repo.

extract_deployment Derive a deployment view from the container definitions

Parse `Dockerfile*` and `docker-compose*.yml` into a deployment canvas linked to the C4 containers, and DECLARE every deployment source it did not read — Kubernetes manifests, Helm charts, Terraform, CI workflows. That declaration matters: a deployment view built from compose while a Helm chart sits beside it is not incomplete, it is wrong, and you should read those yourself before trusting this.

ParameterTypeDescription
adoptbooleanWrite the derived canvas into this session's model, replacing any existing deployCanvas.
depthstringDeepest level to emit. `component` is the usual choice; `code` emits a class per file and is rarely readable.
excludearrayProject names to leave out, on top of the config's own.
granularitystringComponent granularity. `folder` makes a folder the Component; `file` is the legacy one-per-file shape.
rootsarrayScope the scan to these app/solution roots (workspace-relative). Omit for the whole repo.

extract_flows Trace behavioral flows from the configured entry points

Build F4 flow diagrams by tracing call sites from the entry points declared in `.crayon/config.json` under `flows.entryPoints`. With no entry points configured it produces nothing and says so — this tool traces what you point it at, it does not guess what matters. Lanes are bound to the C4 elements that perform each step, and a synchronous call is one `call` connection with no reverse line.

ParameterTypeDescription
adoptbooleanFold the derived flows into this session's model. Hand-authored flows (`upsert_flow`) and curation on derived ones are kept.
depthstringDeepest level to emit. `component` is the usual choice; `code` emits a class per file and is rarely readable.
excludearrayProject names to leave out, on top of the config's own.
granularitystringComponent granularity. `folder` makes a folder the Component; `file` is the legacy one-per-file shape.
rootsarrayScope the scan to these app/solution roots (workspace-relative). Omit for the whole repo.

merge_model Fold a fresh scan into the existing model

Re-scan the repository and reconcile it against the model, using provenance to tell CODE-DERIVED facts from hand-written curation. THE GUARANTEE: a re-run never silently discards curation. Descriptions and names a person wrote are kept; a name that changed on BOTH sides is reported as a conflict and left alone until you pick; and an element the code no longer has is only removed if you opt in, and only when it was code-derived in the first place. Also reconciles the repository's own `adr/*.md` decision records against the model's `adr` slice — matched by id, never removed however you opt in…

ParameterTypeDescription
acceptRemovalsarrayIds to actually remove. Removal is opt-in per id; a hand-authored element is never removed whatever you list.
applybooleanApply the change set. Without it you get the report only.
depthstringDeepest level to emit. `component` is the usual choice; `code` emits a class per file and is rarely readable.
excludearrayProject names to leave out, on top of the config's own.
granularitystringComponent granularity. `folder` makes a folder the Component; `file` is the legacy one-per-file shape.
resolveConflictsobjectPer `<id>.<field>` key: keep `mine` (the model) or take `theirs` (the code).
rootsarrayScope the scan to these app/solution roots (workspace-relative). Omit for the whole repo.

propose_config Measure the repository and propose a config

Scan, measure how big each diagram comes out, and propose a `.crayon/config.json` that makes them readable — a granularity, the test/sample projects worth excluding, and every project you COULD exclude with its child count. It measures first and writes nothing: a diagram of 12 elements needs no tuning, and one of 240 is not fixed by trimming three. Pass the proposal to `write_config` when you agree with it.

ParameterTypeDescription
depthstringDeepest level to emit. `component` is the usual choice; `code` emits a class per file and is rarely readable.
excludearrayProject names to leave out, on top of the config's own.
excludeProjectsarrayProject names to put in the proposal's exclude list.
granularitystringComponent granularity. `folder` makes a folder the Component; `file` is the legacy one-per-file shape.
rootsarrayScope the scan to these app/solution roots (workspace-relative). Omit for the whole repo.

list_enrichment_tasks What still needs a description

List every element field still waiting for prose — derived from the MODEL itself (a field is waiting iff it is empty or still holds an ⟦enrich:…⟧ placeholder), so it is exact and a re-run never re-lists what somebody already wrote. Each entry names the source file to read it FROM, when the scan recorded one. Also returns the style rules in effect, from this repo's settings.

ParameterTypeDescription
limitintegerReturn at most this many, in stable order. Use it to work in batches.
nodeIdsarrayOnly these elements.

apply_enrichment Write the descriptions you found

Write descriptions into the model. It REFUSES to overwrite a field that already holds text somebody wrote — an enrichment pass fills what is missing, it never replaces prose — and it refuses an empty or placeholder value rather than storing one, so a gap stays visible instead of looking filled. Omit any element you could not determine; it stays on the task list. Nothing reaches disk until `write_model`.

ParameterTypeDescription
fills *array

list_decisions Find decisions

List the architecture decisions (ADRs) in the session model, filtered and ordered. Use `element` to ask "which decisions are about this?" — an element id, a name, "from>to" for a connection, or a key like `c4-node:<id>` — and `includeChildren` / `includeParents` to widen that to everything inside it or what contains it. Returns summaries; call `get_decision` for the full text.

ParameterTypeDescription
categoriesarrayA decision must carry ALL of these.
dateFromstringInclusive YYYY-MM-DD.
dateTostringInclusive YYYY-MM-DD.
descendingboolean
elementstringOnly decisions linked to this element or connection.
includeChildrenboolean
includeParentsboolean
sortstring
statusstringA status, `needs-review` (a linked element was removed), or `all`.
textstringMatches id, title, category or the name of a linked element.

get_decision Read one decision

One decision in full: its context, decision and consequences, the elements it links to (with whether each still exists), its categories and its supersede chain.

ParameterTypeDescription
id *stringe.g. `adr-0003`.

create_decision Record a decision

Record a new architecture decision. It is created `proposed` unless you say otherwise, and gets the next free `adr-NNNN` id. Link it to the elements it is about with `links` (ids, names, "from>to" for a connection, or `c4-node:<id>` keys) — a link to something that does not exist is refused.

ParameterTypeDescription
title *string
categoriesarray
consequencesstringWhat follows from it. Markdown.
contextstringWhy a decision was needed. Markdown.
datestringYYYY-MM-DD. Defaults to today.
decisionstringWhat was decided. Markdown.
linksarray
statusstring

update_decision Edit a decision

Change a decision. While it is `proposed` any field can change. Once it is accepted (or later) it is a RECORD: title, date and prose are refused — supersede it with `supersede_decision` instead. Links and categories can always be changed.

ParameterTypeDescription
id *string
addCategoriesarray
addLinksarray
categoriesarrayReplace the whole category list.
consequencesstring
contextstring
datestring
decisionstring
removeCategoriesarray
removeLinksarray
titlestring

set_decision_status Move a decision through its lifecycle

proposed → accepted → deprecated. Status only moves forward, and accepting a decision makes it a record whose content can no longer be edited, so confirm that is what is meant. A decision becomes `superseded` through `supersede_decision`, not here.

ParameterTypeDescription
id *string
status *string

supersede_decision Supersede a decision

Record that `newId` replaces `oldId`: the chain is linked and the old decision (and anything older in its chain) becomes superseded and locked. Refused if it would loop.

ParameterTypeDescription
newId *string
oldId *string

acknowledge_decision Confirm a decision is still valid

Clear the needs-review flag a decision gets when an element it links to is removed, and stamp the confirmation date. Re-link it (`update_decision`) or deprecate it instead if it no longer holds.

ParameterTypeDescription
id *string
datestring

delete_decision Delete a draft decision

Delete a `proposed` draft. An accepted decision is a record and is never deleted — deprecate or supersede it. The decision's file in `adr/` is removed by the next `write_model`.

ParameterTypeDescription
id *string

renumber_decision Renumber a decision

Renumber a decision and rewrite every mention of the old number across the project — links, the supersede chain, and prose in element descriptions. Returns the full list of places first; pass `confirm: true` to apply. Accepted records are rewritten too (only the number changes).

ParameterTypeDescription
id *string
number *e.g. 12 or `adr-0012`.
confirmboolean

check_decisions Check the decisions

Report what is wrong or stale about the decisions: invalid records, links to elements that have since been removed, supersede links that point nowhere, and decisions flagged for review.

import_decisions Import decisions from adr/

Fold the `adr/*.md` files beside the model — hand edits, or brand-new files with no id — into the session model, with the same rules a re-run of the extractor uses: an accepted decision keeps its content, status only moves forward, links and categories are added, and nothing is ever removed. Preview by default; pass `confirm: true` to apply.

ParameterTypeDescription
confirmboolean

upsert_flow Create or update one F4 flow diagram

Author ONE behavioral (F4) diagram by hand — a process, its diagram, sections, swimlanes, activities and connections — in a single batch, for a flow designed BEFORE code exists (use `extract_flows` for flows traced from code). Ids are YOURS and stable, so re-running the same call updates instead of duplicating and leaves `write_model` with an empty diff. A lane binds to a C4 element with `c4Ref` (must exist); its level and legal nesting derive from that element, and an illegal `parentLaneId` is rejected with the reason. Activities without `position` are placed by the editor's own placement…

ParameterTypeDescription
diagram *objectThe diagram. `name` is required when creating.
process *objectThe process the diagram belongs to. `name` is required when creating.
activitiesarray
connectionsarray
lanesarray
proposeMissingRelationshipsbooleanAdd the C4 relationships the connections need but the model lacks.
sectionsarrayBands of the board. Omit and one default section is created.

remove_flow_items Remove lanes, activities or connections from a flow

Remove items from one F4 diagram by id. Ids may be lanes (with their effective descendant lanes and all their steps — C4-nested lanes included), activities (with their connections and boundary events) or connections (id, or `fromActivity>toActivity`). A DRY RUN by default — it reports exactly what would go, computed by the same code that removes it; pass `confirm: true` to apply. Ids that match nothing, or match two kinds, are reported and skipped.

ParameterTypeDescription
diagramId *string
ids *array
confirmbooleanApply the removal. Without it nothing changes.

read_flow Summarise one F4 flow diagram

Summarise one F4 diagram without returning raw JSON: sections, the lane tree (with bound C4 element names and types), activities in reading order, connections with kind, labels and whether the C4 model covers them, unresolved `c4Ref`s, and C4 relationship gaps (with a route the model already describes, when there is one). Reads the session model.

ParameterTypeDescription
diagramId *string