FerryCat
FerryCat is a local MCP server for contract-driven cross-host AI-agent handoff and verification over a shared SQLite WAL mesh.
Dispatch tasks/code reviews to another local agent with file SHA-256 baselines, TTLs, schemas, and optional proposal-mode patches.
Atomically poll and claim assigned tasks, then fulfill with structured outputs, summaries, artifacts, and schema validation.
Inspect mesh state and verify on-disk pointer files without mutating state.
Manage claimed work by extending TTLs, releasing it back to the queue, or marking it failed.
Apply worker-submitted unified patches only when baseline hashes match and
git applysucceeds.
Supports Google Antigravity as a target desktop AI agent host, enabling cross-host handoff and code-review contracts to be dispatched to and fulfilled by Antigravity agents.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@FerryCat dispatch a review of src/api.ts to WorkBuddy"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
FerryCat: Contract-Driven Cross-Host AI Agent Handoff Bus
FerryCat (
ferrycat) is a lightweight, deterministic cross-host AI agent handoff, code review, and verification harness built on the Model Context Protocol (MCP) and Node.js built-innode:sqlite(WAL mode).
Purpose-built to safely bridge isolated desktop IDE agent hosts (such as Google Antigravity, WorkBuddy, Claude Code, and Cursor) across separate OS processesβenabling Actor-Critic evaluation loops, static analysis gates, and SWE-bench-style patch verification without context drift or blind reviews on stale files.
π Deep Dive: Why I Started Building FerryCat: When Two AI Coding Hosts Live on the Same Desktop
Quick Glance (See It in 60s)
No IDE setup or config file edits required. Watch the entire deterministic loop execute inside an isolated sandbox in ~2 seconds:
npx ferrycat demoβ‘ FerryCat Zero-Config Sandbox Demo β‘
β [1/4] Contract Dispatched Locked: src/calc.ts (sha256: ce3ba9a5...bc5d)
β [2/4] Contract Claimed Lease: 7424261d-9a3f-4a86-a7ff-de278c273e96
β [3/4] Execution & Check Heartbeat 1 renewal | CHANGES_REQUESTED (loose equality caught)
β [4/4] Contract Completed TOCTOU: 0 dirty files | Status: COMPLETED (elapsed: 2.1s)
π End-to-end multi-agent handoff verified successfully!π‘ Real benchmark: spins up an isolated child-process sandbox, triggers 1 real lease renewal, and runs a static analysis & verification gate that catches loose equality at
src/calc.ts:6. Options (--keep/--json/--no-color) detailed in Quickstart Β§0.
Related MCP server: AgentMesh MCP
Core Pain Points & Engineering Solutions
While the official MCP Tasks specification (2025-11 / 2026-07) addresses long-running operations within a single Client β Server connection, it does not solve cross-host collaboration on a developer workstation:
stdioProcess Isolation: Desktop IDEs spawn local MCP servers as independent child processes with isolated memory spaces and distinct Node.js runtimes.Silent Blind Reviews on Stale Code (
Stale Context): When handing off a task from Host A to Host B, unushed IDE buffers, branch switches, or mid-review edits cause the receiving agent to audit outdated code and produce plausible but invalid conclusions.Context Window Bloat: Pasting hundreds of lines of source code across chat windows duplicates token consumption on both ends.
Unstructured Handoff Outputs: Free-form prose responses lack deterministic schema enforcement, making downstream consumption unreliable and prone to infinite retry loops.
FerryCat resolves these failure modes through a human-scheduled, contract-driven SQLite WAL bus:
[Developer] [Host A: Antigravity] [~/.ferrycat/mesh.db] [Host B: WorkBuddy]
| | | |
|-- 1. "Dispatch review" --->| | |
| |-- dispatch_contract() -------->| Write status = SUBMITTED |
| | (Full SHA-256 + Line Bounds) | Store size / sha256 snapshot |
| | | |
|-- 2. Switch IDE: "Poll" ---|--------------------------------|------------------------------>|
| | |<-- poll_next_task() ----------|
| | | (Atomic claim changes===1 |
| | | + Verify disk SHA-256) |
| | | |-- Read local files
| | |<-- fulfill_contract() --------|-- Re-verify SHA-256
| | | (Validate Ajv JSON Schema | & submit JSON
| | | -> status = COMPLETED) |
| | | |
|-- 3. Switch IDE: "Inspect" | | |
| |-- inspect_mesh_state() ------->| Read-only query of COMPLETED |
|<-- Present structured res -| | |Key Architectural Pillars
1. Deterministic 7-State Machine
Every state transition is bound to an explicit SQL transaction with optimistic concurrency control (changes === 1), eliminating phantom or dangling states:
dispatch_contract()
β
βΌ
βββββββββββββ
β SUBMITTED β (Queue TTL: default 1800s)
βββββββ¬ββββββ
β
poll_next_task()
ββββββββββββββββββΌβββββββββββββββββ
β (Queue TTL) β (Hash Match) β (Missing / Size Diff / SHA-256 Mismatch)
βΌ βΌ βΌ
βββββββββββββ βββββββββββββ βββββββββββββββββ
β TIMED_OUT β β CLAIMED β β POINTER_STALE β (Terminal: Rejects blind review)
βββββββββββββ βββββββ¬ββββββ βββββββββββββββββ
β² β (Exec TTL: default 300s)
β fulfill_contract()
β ββββββββββββββββββΌβββββββββββββββββ¬βββββββββββββββββ
ββββ€ (Exec TTL) β (Schema Valid) β (Retries > 2) β (Mid-Review File Edit)
β βΌ βΌ βΌ
β βββββββββββββ βββββββββββββββββββββ βββββββββββββββββ
ββββββββββββ COMPLETED β β VALIDATION_FAILED β β POINTER_STALE β
βββββββββββββ βββββββββββββββββββββ βββββββββββββββββNote on
POINTER_STALEvs.SELF_CONTAINEDPatch Mode (FC-202):POINTER_STALEis terminal whenever on-disk pointer files mismatch the dispatched SHA-256 baseline, except when a read-only contract (code_review/architecture_audit) attaches a verified unifiedgit_patch(--patch-file) that satisfies all three gates: every declared file block carries at least one@@hunk with real+/-content (EMPTY_PATCH_HUNKS/EMPTY_PATCH_CONTENTotherwise), and the touched paths cover every pointer file (PATCH_DOES_NOT_COVER_POINTERSotherwise). In thatSELF_CONTAINEDmode,poll_next_taskreturnspatch_mode: "SELF_CONTAINED"with an explicitworkspace_warninginstructing the reviewer to inspectgit_patchrather than stale on-disk files.
Holder-side lifecycle controls on a CLAIMED contract (all require agent_id === target_agent):
Call | Transition | Guard rails |
|
| Resets |
|
| Must be called inside the active window; max 5 renewals per holder; refused once |
|
| Requires a |
2. Full-File SHA-256 Fingerprinting, Pre-Flight Verify & TOCTOU Soft-Failure Buffering (ADR-0004)
Dispatch Snapshot:
dispatch_contractreads target files on disk, recording bytesize, full-filesha256(64 hex chars),first_line, andlast_line. If a file was modified within the last 3 seconds, awarningis emitted to alert the requester of potential unsaved IDE buffers.Claim Verification:
poll_next_taskverifiesExistence -> Byte Size -> Full-File SHA-256(never rejecting onmtime_msalone to tolerate no-op IDE saves). On mismatch, it waits150msasynchronously (non-blocking, FC-203) and retries once to rule out transient IDE flushes before marking the contractPOINTER_STALEβ unless the contract is a read-only review/audit carrying a verified unifiedgit_patchcovering all pointer files (SELF_CONTAINEDpatch mode, FC-202), in which case it claims with an explicitworkspace_warningand records__verified_on_disk__: "NO"and__unverified_pointers__inverified_sha256.Pre-Flight Verify (
verify_contract): A strictly read-only check allowing workers or scripts to audit pointer health (valid: truevsvalid: falsewith dirty files list) before submitting.TOCTOU Soft-Failure Buffering:
fulfill_contractchecks on-disk pointer fingerprints. If dirty pointers are detected:Strike 1 returns
RETRY_NEEDED, leaves the contractCLAIMED, renews the execution window, and lists dirty files with recovery instructions (git stash/git checkout -- <file>).Strike 2 transitions to terminal
POINTER_STALEand saves the full submitted review payload intosalvaged_result_jsonso review effort is never lost.
TOCTOU Race Narrowing: While no file-based system can eliminate the microsecond race between reading disk bytes and committing a database row, FerryCat's dual-verification (at
polland atfulfill) drastically narrows the TOCTOU window from minutes of blind review down to the sub-millisecond atomic SQL transition boundary.
3. Bounded Schema Validation (RETRY_NEEDED $\le 2$)
Outputs are validated against the contract's JSON Schema via cached Ajv validators, with errors flattened into concise single-line paths (e.g.,
["/passed: must be boolean"]).Up to 2 validation failures return
RETRY_NEEDEDwhile keeping the contractCLAIMEDfor immediate self-correction (each rejection also renews the execution window); a 3rd failure transitions the contract to terminalVALIDATION_FAILED.
4. Dual-Stage TTL & Read-Before-Write Sweeping
Separates
queue_ttl_sec(default 1800s forSUBMITTED) fromexec_ttl_sec(measured fromclaimed_at), preventing tasks claimed late in the queue window from timing out prematurely during execution.exec_ttl_secdefaults are tiered bytask_type:code_review/architecture_auditβ 1800s (deep reasoning or human-in-the-loop),implementation/test_generationβ 300s. An explicitexec_ttl_secalways wins.poll_next_taskexecutes a lock-freeSELECT COUNT(*)probe before attempting anyUPDATEon expired rows;inspect_mesh_stateis strictly read-only.
5. Defense-in-Depth Path Security
Enforces path containment within
workspace_rootand blocks sensitive file patterns (.env*,*.pem,*.key,id_rsa*,*credentials*,*secret*,.npmrc,.git/config) on bothdispatchandworkerverification paths.Path Resolution:
workspace_rootis strongly recommended to be passed as an absolute path. If a relative path is provided, it is deterministically resolved againstprocess.cwd()viapath.resolve.
6. Threat Model & Security Assumptions (Local Workstation IPC)
Assumed Trust Environment: FerryCat is intentionally designed as a Trusted Local Workstation Bus bridging isolated IDE hosts operating under the same OS user account. Callers and workers share the local file system (
workspace_root) and SQLite database (~/.ferrycat/mesh.db).Defense Scope: Path containment (
assertSafePointerPath) and sensitive file pattern filters prevent unintentional workspace escapes, symlink traversals, or accidental leakage of credentials/secret files during handoffs.Daemon Execution Surface: In daemon mode (
ferrycat-cli daemon), handler scripts are invoked directly viaexecFile. Write permissions toferrycat.config.jsonor handler script paths are equivalent to host execution privileges (ADR-0005 Β§2.2). Keep configurations local and version-controlled.Out of Scope (Non-Goals): FerryCat does not provide adversarial sandboxing, multi-tenant isolation, or network authorization against malicious local processes or adversarial agents spoofing
AGENT_NAME.
Applicability Boundaries (When NOT to Use FerryCat)
Disjoint File Systems: FerryCat offloads context by file reference; both hosts must share access to the same local
workspace_root.Trivial Single-Turn Queries: Each cross-host handoff involves 3 explicit human window switches (~15β25s overhead).
Multi-Step Dynamic DAG Pipelines: FerryCat's background daemon (
ferrycat-cli daemon, ADR-0005) manages single-step contract dispatch and supervised worker lifecycles; for complex multi-step branching DAG orchestrations, use dedicated DAG workflow engines such as PatchCat.
Controlled Daemon & Declarative Handlers (ADR-0005)
FerryCat provides a controlled daemon mode governed by SQLite microsecond CAS leases on daemon_locks and declarative scripts defined in ferrycat.config.json (ideal for binding static analysis gates like tsc / eslint / AST checks or automated test suites like Jest / Vitest / Pytest as deterministic verification workers):
# Run a single dispatch cycle with declared handlers
ferrycat-cli daemon --config ./ferrycat.config.json --once
# Start continuous daemon loop
ferrycat-cli daemon --config ./ferrycat.config.json
# Inspect lease ownership + write-ahead journal health (read-only)
ferrycat-cli daemon --statusdaemon --status reports journal_degraded / last_journal_error / journal_path / journal_entries alongside lease ownership, so a silently unwritable write-ahead journal (which would disarm crash recovery) is visible instead of failing mute.
Example ferrycat.config.json:
{
"version": 1,
"daemon": {
"poll_interval_ms": 1000,
"lease_ttl_sec": 30,
"heartbeat_interval_ms": 10000,
"notify": true
},
"agents": {
"workbuddy": {
"handlers": {
"code_review": {
"exec_file": "./scripts/review-handler.js",
"pass_env": ["CUSTOM_ANALYZER_PATH"]
}
}
}
}
}Quickstart
0. See what it actually does first (ferrycat demo)
Before configuring any MCP server, watch the whole loop in ~3 seconds:
npx ferrycat demo(or npx -p ferrycat ferrycat-cli demo)
It spins up a fully isolated sandbox under the OS temp dir (dedicated SQLite database,
sample source file, sample handler), runs dispatch β claim β supervised execution β TOCTOU re-verification β COMPLETED, then deletes the sandbox.
Your real workspace and ~/.ferrycat/mesh.db are never read or written.
β‘ FerryCat Zero-Config Sandbox Demo β‘
Sandbox: /tmp/ferrycat-demo-c5iK6V
β [1/4] Contract Dispatched
Locked src/calc.ts (sha256: ce3ba9a5...bc5d)
β [2/4] Contract Claimed
Lease 7424261d-9a3f-4a86-a7ff-de278c273e96
β [3/4] Execution & Schema Check
Heartbeat 1 lease renewal(s)
β [4/4] Contract Completed
TOCTOU fingerprints matched (0 dirty files)
π End-to-end multi-agent handoff verified successfully!Option | Effect |
| Run the 5-step zero-write patch proposal + baseline-locked |
| Emit a structured result for CI / upstream assertions |
| Keep the sandbox and print its path for manual |
| Disable ANSI colors (auto-off when not a TTY or |
1. Recommended: Zero-Install MCP Mounting (via npx)
No local clone or manual compilation required. Run npx ferrycat init --yes (or scope per host with --client antigravity --role requester / --client workbuddy --role worker, ADR-0007) to auto-detect installed hosts (Antigravity, WorkBuddy, Cursor, VS Code, Windsurf, Claude Desktop, Claude Code) and safely merge the ferrycat server entry (with backup and JSONC protection), or mount manually into your IDE's MCP configuration using npx -y ferrycat:
Antigravity Configuration
Edit %USERPROFILE%\.gemini\antigravity\mcp_config.json (or ~/.gemini/antigravity/mcp_config.json on macOS/Linux):
{
"mcpServers": {
"ferrycat": {
"command": "npx",
"args": ["-y", "ferrycat"],
"env": {
"AGENT_NAME": "antigravity"
}
}
}
}WorkBuddy / Claude Code / Cursor / Codex Configuration
Configure the target host's MCP settings with its respective AGENT_NAME:
{
"mcpServers": {
"ferrycat": {
"command": "npx",
"args": ["-y", "ferrycat"],
"env": {
"AGENT_NAME": "workbuddy"
}
}
}
}2. Global Installation & Source Build
Global CLI Installation:
npm install -g ferrycatThen simply set
"command": "ferrycat"in your MCP config.Local Source Build (For Contributors):
git clone https://github.com/GuoBug/FerryCat.git cd FerryCat npm install npm run build npm testMount using your local path:
"command": "node","args": ["--experimental-sqlite", "/path/to/FerryCat/dist/index.js"].
First-Class CLI Experience (ferrycat-cli)
Beyond serving as an in-IDE MCP Server, FerryCat provides a first-class CLI utility (ferrycat-cli). The single ferrycat executable dispatches on its first argument: no argv starts the MCP stdio server, a known subcommand routes to the CLI. So you can run npx ferrycat <command> with zero install (or ferrycat-cli <command> once installed globally). Sharing the same ~/.ferrycat/mesh.db SQLite WAL database and Zod validation contracts, the CLI allows developers to inspect mesh health, verify working tree safety, and hook into automated CI/Git scripts without leaving their terminal:
1. Terminal Visual Inspection (ASCII Status Table)
Inspect all cross-host handoffs and error reasons formatted as an ASCII table:
# View all contracts in an ASCII table
npx ferrycat inspect
# Filter by target agent (e.g., only tasks for antigravity)
npx ferrycat inspect --target antigravity2. Pre-Flight Verification (Auditing Before Mutation)
Audit on-disk pointer file integrity against the contract's baseline SHA-256 before committing review work (ADR-0004), eliminating false-positive deliveries:
npx ferrycat verify --id <CONTRACT_ID>3. Local CI & Headless Worker Execution
Poll the queue, claim tasks, and execute local review/test scripts with automatic failure closure:
# Safely run a script upon task arrival (no shell quotation hazards)
npx ferrycat worker --agent codex --mode=exec --exec-file ./scripts/review.sh --delivery envelope
# See docs/examples/ for dispatch.example.json, fulfill.example.json, and handler.example.cjs templates.4. Zero-Config Sandbox Walkthrough (demo)
Run the self-contained multi-agent lifecycle simulation without configuring an MCP server:
npx ferrycat demoOptions (--keep to retain SQLite for manual inspection, --json for CI assertions) detailed in Quickstart Β§0.
5. Production Controlled Daemon (daemon, ADR-0005)
Run the headless orchestration daemon coordinating background workers via atomic CAS leases and declarative script bindings:
# Launch daemon using project-local declarative configuration
npx ferrycat daemon --config ./ferrycat.config.json
# Run single poll/dispatch iteration for a targeted agent and exit
npx ferrycat daemon --agent workbuddy --once6. Storage Pruning, Conflict Export & Isolated Git Worktrees (ADR-0008)
# Reclaim patch/salvage blobs on terminal contracts older than 14 days (never touches SUBMITTED/CLAIMED)
npx ferrycat prune --older-than 14d --strip-blobs --vacuum
# Safely export a conflicted proposal patch for manual 3-way review
npx ferrycat apply --id <CONTRACT_ID> --export-patch ./pending.patch
# Run automated worker inside an ephemeral detached git worktree (>512KB / binary / build-and-test safe)
npx ferrycat worker --agent workbuddy --mode=exec --once --isolation worktree --exec-file ./handler.cjsExposed MCP Tools & Role-Scoped Governance (ADR-0007)
All MCP tools declare native ToolAnnotations (openWorldHint: false across the board; readOnlyHint: true & idempotentHint: true on read-only tools; destructiveHint: true on fail_contract and apply_contract_patch) to minimize IDE approval friction. You can also trim the exposed toolset per host via FERRYCAT_ROLE=full|requester|worker (or ferrycat --role <role>) to save context tokens and prevent role confusion:
Tool Name | Scoped Roles | Transactional Behavior |
|
| Enforces path blacklist $\to$ computes full-file SHA-256 & line bounds, checks active pointer overlaps ( |
|
| Sweeps expired TTLs (read-before-write) $\to$ claims via |
|
| Dual-Track TOCTOU guard: Track A (read-only) & Track B2 ( |
|
| Verifies exact baseline SHA-256 lock ( |
|
| Hands a |
|
| Heartbeat: restarts the execution window ( |
|
| Marks a |
|
| Read-only pre-flight & post-completion check ( |
|
| Pure read-only query ( |
Note on
write_mode: 'proposal'Boundaries & Structuredremediation(ADR-0007):
When to use
proposalvs.direct:write_modedefaults to'direct'(in-place worker edits per ADR-0006). Opt intowrite_mode: 'proposal'(ferrycat-cli dispatch --write-mode proposal$\to$fulfill --proposed-patch-file$\to$ferrycat-cli apply --id <ID> [--dry-run]) when multiple IDE agents share the sameworkspace_rootconcurrently.Trade-offs & Limits:
apply_contract_patchrequiresgitonPATHto executegit apply, boundsproposed_patchto512KBUTF-8 unified text diffs (no binary patches or120000symlink modes), and enforces a strict full-file SHA-256 baseline lock rather than 3-way fuzzy merging.Structured Self-Healing: Non-
COMPLETEDresponses includeremediation: { action, retryable, hint }so agents and scripts can branch deterministically without parsing prose messages.
π‘ Architecture Decision Records & Engineering Verification:
ADR-0001: Cross-Host SQLite WAL Bus & Human-Scheduled Poll Model (Why
node:sqliteWAL +poll_next_taskinstead of 60s Blocking Hold or single-connection MCP Tasks)ADR-0002: Full-File SHA-256 Fingerprinting, TOCTOU Guard & Cross-Model Audit (Stale-context prevention and real-world cross-host verification records)
ADR-0003: GUI Sandbox vs CLI Process Hybrid Layering Architecture & Wake-Up Boundaries (Desktop HITL approval vs in-house CLI dual-channel autonomy)
ADR-0004: Separation of Review and Mutation (SRM), TOCTOU Soft-Failure Buffering & Immutable Baseline Protocol (How to prevent review abortion from concurrent or well-intended reviewer edits; live mesh case: contract
fc_1793098036393_aea8bb9b)ADR-0005: Controlled Daemon, Atomic CAS Micro-Leases & Safe Execution Boundaries (Microsecond atomic CAS leases on
daemon_locksand declarative whitelist handler enforcement)ADR-0006: Dual-Track TOCTOU Semantics & Post-Mutation SHA-256 Fulfillment (Why
implementation/test_generationtasks commit post-mutation SHA-256 intoverified_sha256while preserving pre-mutation baselines inpointers; live mesh case:fc_1793100801409_4eedf544)ADR-0007: Role-Scoped MCP Surface, Overlap Detection, Zero-Write Proposal Mode & Remediation Envelopes (
ToolAnnotations,FERRYCAT_ROLEscoping, active pointer overlap warnings,write_mode: 'proposal'+apply_contract_patch, and machine-branchableremediation)ADR-0008: Terminal Storage Pruning, Conflict Patch Export & Ephemeral Git Worktree Isolation (
ferrycat prune,apply --export-patch, and crash-resilientisolation: 'worktree'for >512KB / binary / build-verified mutations)
About the Author
Guo Qiang (GuoBug), Product Engineer specializing in platform engineering and growth. Currently focused on AI workflow orchestration, DAG state machines, and deterministic system architectures.
Open Source & Homepage: https://github.com/GuoBug Β· https://guobug.github.io
Inquiries and discussions on workflow engine architecture, topological scheduling, and developer experience are warmly welcomed.
Available Tools
9 toolsapply_contract_patchApply Contract Proposal PatchADestructive
Verify the cryptographic dispatch baseline SHA-256 lock and atomically apply a COMPLETED contract's proposed_patch to workspace_root via git apply (ADR-0007).
Purpose
Completes the zero-write proposal loop (write_mode="proposal") by allowing the requester host to dry-run or atomically land a worker's unified diff only when the local baseline has not drifted.
Strict Preconditions & Safety Gates
Contract must be in COMPLETED status with write_mode="proposal", non-empty proposed_patch, and proposal_applied_at === null (refuses duplicate application with ALREADY_APPLIED).
Baseline Drift Lock: Every existing pointer file touched by proposed_patch must currently match its exact dispatched SHA-256 in pointers_json, and newly created files must not already exist on disk. Any drift immediately aborts with status="PROPOSAL_CONFLICT" (zero fuzzy merging, zero overwrites).
Runs "git apply --check" in workspace_root; when dry_run is false, executes "git apply", computes post-apply SHA-256 hashes into verified_sha256, and records proposal_applied_at.
Return Value
Returns { ok, contract_id, status: 'APPLIED' | 'DRY_RUN_OK' | 'ALREADY_APPLIED' | 'PROPOSAL_CONFLICT' | 'PRECONDITION_FAILED', dry_run, proposed_patch_sha256?, proposal_applied_at?, touched_files?, verified_sha256?, drifted_files?, git_check_error?, remediation?, message }.
Inputs: contract_id (required), dry_run, agent_id.
dispatch_contractDispatch ContractA
Dispatch a task or code review contract to another local AI agent host via the shared SQLite WAL mesh.
Purpose
Registers a new contract in SUBMITTED status with full-file SHA-256 fingerprint snapshots of all target files, establishing an immutable baseline for cross-host verification and emitting active pointer overlap warnings.
Usage Guidelines
When to use: Use when requesting code reviews, architecture audits, implementation, or test generation from a target agent (e.g., target_agent="workbuddy" or "antigravity").
Mutation Write Modes (ADR-0006 / ADR-0007):
write_mode="direct" (default for implementation / test_generation): Worker edits pointer files directly on disk and commits post-mutation SHA-256 hashes at fulfill time.
write_mode="proposal": Worker is forbidden from editing disk files and must deliver a unified git diff in proposed_patch; requester reviews and atomically applies it via apply_contract_patch. Recommended when concurrent agents share workspace_root.
When NOT to use:
Do NOT use to claim or execute tasks (use poll_next_task).
Do NOT use to check task status or inspect outputs (use inspect_mesh_state).
Do NOT pass write_mode on read-only tasks (code_review / architecture_audit).
Behavior & Side Effects
Mutates local SQLite database (~/.ferrycat/mesh.db) only; makes zero network requests.
Active Pointer Overlap Detection (ADR-0007): Checks non-expired SUBMITTED / CLAIMED contracts in the same workspace_root and populates overlapping_contracts + warning if pointer files intersect.
Return Value
Returns { contract_id, status: 'SUBMITTED', created_at, write_mode?, files, patch_sha256?, patch_bytes?, overlapping_contracts?, warning? }.
Inputs: title (required), pointers (required), task_type (required), target_agent (required), +8 more.
extend_ttlExtend Execution TTLA
Heartbeat renewal for long-running execution: restarts the active execution window of a CLAIMED contract.
Behavior & Side Effects
Mutates database: Resets claimed_at=nowMs and increments extend_count (max 5 renewals per holder, bounded by created_at + 4 * queue_ttl_sec).
Return Value
Returns { ok, contract_id, status: 'CLAIMED' | 'TIMED_OUT', claimed_at?, expires_at?, extend_count, max_extends, remediation?, message }.
Inputs: contract_id (required), agent_id, claim_token.
fail_contractFail ContractADestructive
Explicitly mark a CLAIMED contract as terminal FAILED with a mandatory failure reason.
Behavior & Side Effects
Destructive terminal transition: Sets status='FAILED', error_reason='WORKER_FAILED: ', and completed_at=nowMs.
Return Value
Returns { ok, contract_id, status: 'FAILED' | 'TIMED_OUT', remediation?, message }.
Inputs: reason (required), contract_id (required), agent_id, claim_token.
fulfill_contractFulfill ContractA
Submit execution or review deliverables for a CLAIMED contract under Dual-Track TOCTOU verification (ADR-0004 / ADR-0006 / ADR-0007) and Ajv JSON Schema validation.
Purpose
Delivers task outputs, enforces track-specific workspace integrity and cryptographic SHA-256 auditing, validates structured payloads, and transitions the contract to terminal COMPLETED.
Track-Specific Fulfillment Rules
Track A β Read-Only Audit (code_review | architecture_audit, ADR-0004):
Pointer files on disk MUST remain 100% unchanged (verifyAllPointers). Pass suggested code fixes in structured_output.fixes.
Accidental disk edits trigger a 1-strike recoverable RETRY_NEEDED buffer (restore via git checkout/stash, call verify_contract, then retry); a 2nd dirty attempt transitions to terminal POINTER_STALE while salvaging your output.
Track B1 β Direct Mutation (implementation | test_generation with write_mode="direct", default, ADR-0006):
Editing pointer files on disk and creating declared artifacts_pointers files is expected and permitted (SECURITY_REJECTED and FILE_MISSING remain hard blockers).
Post-mutation full-file SHA-256 hashes are committed into verified_sha256 while pointers preserves the pre-mutation baseline.
Track B2 β Zero-Write Proposal Mode (implementation | test_generation with write_mode="proposal", ADR-0007):
Pointer files on disk MUST remain 100% unchanged (enforced by the same 1-strike TOCTOU guard as Track A).
You MUST provide a valid non-empty unified git diff (<= 512KB) in proposed_patch touching only safe workspace paths and declared existing pointer files (or new files from /dev/null). Missing or invalid patches return recoverable RETRY_NEEDED (remediation.action="FIX_PATCH_AND_RESUBMIT").
Return Value
Returns { ok, contract_id, status: 'COMPLETED' | 'RETRY_NEEDED' | 'POINTER_STALE' | 'VALIDATION_FAILED' | 'TIMED_OUT', retry_count, max_retries, toctou_strike?, max_toctou_strikes?, dirty_files?, validation_errors?, no_op?, proposed_patch_sha256?, proposed_patch_bytes?, remediation?, message }.
Inputs: contract_id (required), result_summary (required), agent_id, claim_token, +3 more.
inspect_mesh_stateInspect Mesh StateARead-onlyIdempotent
Strictly read-only query of contracts, execution progress, outputs, proposal patches, diagnostic counters, and failure causes.
Purpose
Provides comprehensive observability into the multi-agent mesh state without acquiring database write locks or mutating rows.
Behavior & Side Effects
Zero side effects: Pure read-only SELECT query against local SQLite WAL. Never alters rows or triggers sweeps.
Pass include_patch=true to expand raw git_patch and proposed_patch payloads (omitted by default to conserve context tokens).
Return Value
Returns { total_returned, contracts: Array<{ contract_id, requester_agent, target_agent, task_type, write_mode, title, status, is_logically_expired, created_at, claimed_at, completed_at, proposal_applied_at, retry_count, extend_count, release_count, toctou_strike, result_summary, structured_output, artifacts_pointers, proposed_patch_sha256, proposed_patch_bytes, proposed_patch?, error_reason, salvaged_result, verified_sha256 }> }.
Inputs: limit, status, contract_id, target_agent, +1 more.
poll_next_taskPoll Next TaskA
Atomically claim the oldest pending SUBMITTED contract assigned to this agent and verify local file fingerprints.
Purpose
Retrieves and claims next available contract work for the current agent, transitioning it from SUBMITTED to CLAIMED.
Usage Guidelines
When to use: Call to discover and atomically take ownership of pending tasks assigned to your agent_id.
When NOT to use:
Do NOT use to non-destructively inspect queue depth or monitor status without claiming (use inspect_mesh_state).
Do NOT use to create contracts (use dispatch_contract).
Delivery Track Rules (check contract.task_type & contract.write_mode):
Read-only tasks (code_review / architecture_audit): NEVER edit pointer files on disk; place suggested diffs in structured_output.fixes (ADR-0004).
Mutation tasks with write_mode="direct": Edit target files on disk; post-mutation SHA-256 hashes are snapshotted at fulfill_contract (ADR-0006).
Mutation tasks with write_mode="proposal": NEVER edit pointer files on disk; deliver a unified diff via proposed_patch in fulfill_contract (ADR-0007).
Return Value
When work is claimed: { has_task: true, status: 'CLAIMED', contract: { contract_id, requester_agent, target_agent, task_type, write_mode, title, context_summary, workspace_root, pointers, contract_schema, claimed_at, exec_ttl_sec, claim_token } }.
When stale or empty: { has_task: false, status?, stale_error?, remediation?, message? }.
Inputs: agent_id.
release_contractRelease Contract to QueueA
Hand a CLAIMED contract back to the queue tail as SUBMITTED with a fresh queue window.
Behavior & Side Effects
Mutates database: Resets claimed_at=NULL, claim_token=NULL, updates queued_at=nowMs, resets extend_count=0 and toctou_strike=0, and increments release_count.
Preserves contract-level retry_count so schema validation retries cannot be laundered across releases.
Limits: Maximum 3 releases per contract; refused once past created_at + 4 * queue_ttl_sec.
Return Value
Returns { ok, contract_id, status: 'SUBMITTED' | 'CLAIMED' | 'TIMED_OUT', release_count, max_releases, remediation?, message }.
Inputs: contract_id (required), reason, agent_id, claim_token.
verify_contractVerify Contract BaselineARead-onlyIdempotent
Read-only pre-flight and post-completion consistency check (ADR-0004 / ADR-0006 / ADR-0007): audits on-disk pointer files against the contract's SHA-256 baseline or committed post-mutation snapshot.
Behavior & Side Effects
Zero side effects: Pure read-only operation. Never updates SQLite state and never consumes a TOCTOU strike.
Track-aware verification:
Read-only tasks & CLAIMED write_mode="proposal" contracts: checks immutable baseline SHA-256.
CLAIMED write_mode="direct" mutation contracts: checks path safety & file existence while reporting modified files.
COMPLETED mutation contracts: verifies on-disk files against committed verified_sha256.
Return Value
Returns { ok: true, valid, fulfillable, contract_id, status, target_agent, toctou_strike, max_toctou_strikes, dirty_files, remediation?, message }.
Inputs: contract_id (required), agent_id, claim_token.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
TDQS
Scored across 9 tools
Each tool owns a distinct lifecycle step (dispatch, poll/claim, fulfill, release, extend, fail, verify, inspect, apply patch), and the descriptions explicitly add 'when NOT to use, use tool X instead' cross-references, which sharply separates the read-only pairs (inspect_mesh_state vs verify_contract) and the queue-management pairs (release_contract vs fail_contract).
All nine names are snake_case verb-first constructions (dispatch_contract, fulfill_contract, apply_contract_patch, verify_contract, etc.), with the noun consistently identifying the subject (contract/task/ttl/mesh_state). The only variation is poll_next_task, which is still clearly verb-first and readable.
Nine tools map cleanly onto one contract's full lifecycle plus two read-only observability operations β no padding and nothing feels missing from the set. The count sits comfortably in the well-scoped 3-15 range.
The surface covers dispatch β claim β fulfill/verify β apply/discard β terminal outcomes with retry, TTL, and failure paths well. The one gap is that a SUBMITTED (unclaimed) contract has no cancel/withdraw operation, so a requester who dispatched in error must wait for it to time out.
Maintenance
Related MCP Connectors
Control plane for autonomous software labor. Agents claim objectives over MCP with audit trail.
Public MCP for agent verification, work discovery and governed interoperability.
Project management shared by people and AI agents, with persistent project state through MCP.
Team memory for AI coding agents and code reviews, reviewed by humans and served over MCP.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables MCP-capable coding agents to coordinate via authenticated task creation, claiming, messaging, and review approval over a secure local event log.-
- AlicenseCqualityDmaintenanceEnables coding agents to coordinate around shared project context, durable tasks, messages, artifacts, multimodal analysis requests, design-system checks, change proposals, and review requests through a compact MCP interface. It persists state locally in JSON and exposes tools, resources, and prompts for agent-to-agent workflows.9MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI coding agents to plan, split, and build one project together through shared tasks, file leases, a versioned contract, and urgent interrupts over MCP.MIT
- AlicenseNot gradedqualityCmaintenanceEnables Claude and Codex agents to delegate implementation, testing, research, or review tasks to each other through local MCP tools, while supporting persistent sessions, isolated editing workspaces, and reviewed integration. It also allows progress tracking, cancellation, model selection, and management handoff between providers.2MIT