Skip to content

MCP server

GitHub →

ayida mcp starts an MCP server over stdio, so assistants can model an existing system from its code and infrastructure, or design a new one conversationally. It learns the language, reads the architecture, asks it questions, compares revisions, edits the HCL source and renders it, safely, through nine tools.

Setup

Install ayida, then add it to your client’s MCP configuration.

For Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json on macOS, %APPDATA%\Claude\claude_desktop_config.json on Windows):

{
  "mcpServers": {
    "ayida": {
      "command": "ayida",
      "args": ["mcp", "--project", "/path/to/your/architecture"]
    }
  }
}

For Claude Code:

claude mcp add ayida -- ayida mcp --project /path/to/your/architecture

If you used loko before, remove its server first with claude mcp remove loko.

Tools

The server registers nine tools:

ToolDirectionWhat it does
schemareadDescribes the language: every block, attribute and allowed value
describereadExplains the compiled architecture
queryreadAnswer graph questions (dependents, paths, coupling, flows) and list views, elements and relationships
validatereadCompile and report diagnostics
diffreadCompare two revisions, or a revision with the files on disk, with each change’s blast radius
apply_editwriteEdit the HCL source, compiling before anything is written
movewriteMove or rename elements, rewriting every reference
fmtwriteCanonically format every *.ayida.hcl file
buildwriteRender diagrams, markdown and a site into a directory in the project

schema, describe, query, validate and diff read; apply_edit, move and fmt edit the HCL source; build renders. Writes touch *.ayida.hcl files only (and build its output directory). Every edit compiles before it is written, and saves all-or-nothing, so a broken reference never reaches disk. Change the architecture through the tools rather than editing files directly.

Output defaults to TOON, which roughly halves the size of tabular answers such as query results. Pass format: "json" to any tool for JSON instead.

Working with the tools

  1. Learn the language, then read. Call schema once, then describe; every read returns a revision. In an empty directory, describe returns a bootstrap: the smallest valid project declaration and a ready-to-send apply_edit request that creates it.
  2. Quote the revision when you write. apply_edit, move and fmt take base_revision. If a file the write would change has been modified since that read, the write is refused as stale_revision and the newer change is kept — read again and retry. Each successful write returns the new revision.
  3. Preview when unsure. preview: true returns unified diffs and writes nothing.
  4. Batch related changes. apply_edit takes up to 100 edits; they apply in order, compile once, and save all-or-nothing.

Write results report only what the change caused: diagnostics_added, diagnostics_removed and a count of the unchanged ones. The diffs mark lines that changed only in whitespace separately. Pass diagnostics: "all" and diff: "exact" for the full lists.

Diagnostics in every result are compact by default (severity, code, detail, address and at); pass ranges: "full" for full source ranges. Every describe and schema result also carries server_version, and describe carries root and files, so an assistant can detect a stale server or a --project pointed somewhere unexpected before an edit lands.

Diffing revisions

diff gives the same changes as ayida diff. With no arguments it compares HEAD with the files on disk. from and to take a commit, branch or tag, and from_export takes a JSON export inside the project root. The compact result gives from, to and the counts per class, then one row per change:

→ diff {"from": "main"}
from: main (d33935a)
to: worktree
counts:
  added: 1
  removed: 0
  renamed: 1
  rewired: 1
  attribute_changed: 1
  rebound: 0
changes[#4]{class,address,old,summary,blast}:
  added,container.dlq_worker,"","",1
  renamed,container.payments_api,container.api,"",2
  rewired,container.payments_api.uses.orders,"","target: container.orders_db -> container.orders_aurora",2
  attribute_changed,container.worker,"","system: system.payments -> system.ledger",0

blast counts the elements that depend on the change. detail: "full" returns the ayida diff --format json shape, with the blast-radius addresses.

Refusals

A refusal is a normal tool result with ok: false, and nothing is written. The reasons are compile_errors, stale_revision, dangling_references (consider cascade: true), address_in_use, not_found, invalid_edit, path_refused, project_exists and no_project.

Command options

ayida mcp --project /path/to/your/architecture
FlagTypeDefaultDescription
--project, -pstring.The architecture the tools read and edit. MCP clients usually start ayida from another directory, so set it
--envstring""Set an environment variable (KEY=VALUE) for the server