Skip to content

MCP server

The reference fleet ships an MCP server: templates/fleet/mcp/yen-mcp.sh. It answers agents over stdio (JSON-RPC 2.0, one message per line) by running yen queries on the fleet. It serves the fleet in its directory.

Terminal window
cd templates/fleet
nix run .#yen-mcp

This table is read from the server script itself (14 tools):

ToolWhat it answers
yen_schemaEvery kind, aspect and invariant of the fleet.
yen_checkInvariants: violations, incomplete, ok, and the why rules of each violation.
yen_contextOne scope: parent, children, aspects, elements given and received, errors.
yen_explainWhy an aspect is active, inactive or undefined at a scope.
yen_errorsError records, optionally only one code.
yen_declared_inThe files that answer a declaration path.
yen_exportThe fleet as sorted N-Triples with sha256 and count. The agent decides whether to store it.
yen_stageEvaluate a change (a module as JSON) without applying it: ok, errors, violations, diff, refused, sha.
yen_queriesThe stored-query catalog: each query with its required and optional parameters.
yen_askRun a stored query by name with an args object. Errors (missing-param, unknown query) come back as the result.
yen_impactThe scopes an element of a scope reaches over routed elements, by depth.
yen_labelsTrust labels per aspect; with floor n, the edges whose aspect has trust below n.
yen_why_notWhether an invariant atom is violated, and the why/whyNot rules for it.
yen_programDry-run a change program (list of op objects): valid, errors, ok, violations, diff.

Each answer is { complete; result }, or { complete = false; error }. A timeout is never an empty answer. Arguments reach Nix through a file and builtins.fromJSON, never through string interpolation.

Any MCP client that starts a stdio server can use it. For example, in an mcpServers config:

{ "mcpServers": { "yen": { "command": "nix", "args": [ "run", "/path/to/fleet#yen-mcp" ] } } }
VariableMeaning
YEN_FLEETthe fleet directory (default: the parent of mcp/)
YEN_FLAKEits flake ref (default: from the git top)
YEN_TIMEOUTseconds per nix call (default 120)
Contribute Community Sponsor