Draxl Docs

Agents

Workspace-scoped MCP tools for semantic Draxl edits.

Draxl includes an agent-facing backend for .rs.dx files. The backend exposes inspection, semantic edit, raw patch, and conflict-check tools over stdio MCP.

Setup

Generate a Codex MCP configuration for the current workspace:

cargo run -p draxl-cli -- mcp setup --client codex --root .

Print the generated configuration:

cargo run -p draxl-cli -- mcp setup --client codex --root . --print

Run the server directly:

cargo run -p draxl-cli -- mcp serve --root .

The server restricts file access to the configured workspace root and resolves .rs.dx paths relative to that root.

Tool Flow

An agent should inspect the file first:

draxl_inspect_file

The response includes the source, a fingerprint, node summaries, node ids, node kinds, parent ids, slots, ranks, and compact summaries.

Use node lookup when a specific target needs legal edit affordances:

draxl_get_node

The response includes the node subtree plus legal ranked slots, single-child slots, and scalar paths for that node kind.

Edit Tools

The MCP server exposes higher-level edit tools:

ToolPurpose
draxl_replace_nodeReplace an existing node with a source fragment.
draxl_insert_after_stmtInsert a statement after a ranked statement id.
draxl_set_pathSet a scalar path such as a name, text, operator, or semicolon flag.
draxl_apply_patch_textApply raw Draxl patch text.
draxl_check_conflictsCompare two patch streams and return conflict JSON.

Most edit tools accept an expected_fingerprint. The server rejects the edit when the file has changed since inspection. That protects an agent from applying a patch to stale source.

Most edit tools also accept apply. With apply: false, the response returns preview_dx and leaves the file unchanged. With apply: true, the server writes canonical Draxl source after validation.

Raw Patch Escape Hatch

Prefer the higher-level edit tools when they fit the task. Use draxl_apply_patch_text for multi-op changes or operator families outside higher-level tool coverage:

set @f1.name = add_one_fast
insert @f1.body[ah]: @s4 @e4 trace();

The server runs the same patch parser, resolver, executor, validator, and canonical printer used by the CLI.

Conflict Checks

Agents can compare candidate streams before applying them:

draxl_check_conflicts

The result matches the CLI conflict JSON. Use the reported class, code, owner, left_regions, right_regions, left, and right fields to request targeted resolution.

On this page