Concepts
Write boundary
The guarded state machine behind structural and text-file changes.
A requested edit is not enough to authorize a write. ast-mcp requires a route that matches the target's capabilities and proves the caller is operating on current state.
Route selection
| Target | Required route |
|---|---|
| New file | file_write |
| Parseable rewrite-supported source | file_patch with patchStrategy: "ast" |
| Unsupported, unparseable, or inspection-only file | file_patch with patchStrategy: "aider_block" |
| Rename | file_rename |
| Metadata-only change | file_chattr |
| Deletion | file_delete |
Commit sequence
- Resolve the path under an allowed root.
- Confirm the requested route matches the file's capabilities.
- Compare the supplied SHA-256 with current state.
- Build candidate content from reviewed operations.
- Assert that dprint can format the candidate.
- Acquire cooperating locks in deterministic path order.
- Recheck the hash inside the lock.
- Format and atomically replace the file.
- Release locks on success or failure.
A stale hash, ambiguous Aider block, unexpected AST match count, capped preview, formatter rejection, or lost MCP connection is a safe stop.
Concurrency
In-process queues coordinate calls inside one server. Filesystem lock files coordinate cooperating processes. Sorting multi-file lock acquisition prevents lock-order inversions, and the hash recheck inside the lock closes the race between preview and commit.