Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

MCP Surface

The MCP surface is the agent-facing contract for l3dg3rr. It is intentionally smaller than the internal Rust API: agents see a compact set of capability families, each selected with a required action argument.

The source of truth is crates/ledgerr-mcp/src/contract.rs. Generated operator docs live in docs/mcp-capability-contract.md and docs/agent-mcp-runbook.md; regenerate them with cargo run -p xtask-mcpb -- generate-mcp-artifacts after changing the published surface.

There are two MCP layers in the roadmap:

LayerPrefixRole
Bookkeeping/domain MCPledgerr_*Existing financial document, workflow, audit, ontology, Xero, and workbook capabilities.
Desktop/controller MCPledgrrr_*Claude Desktop MCPB controller for install/status/service/tray/diagram/simulation/Office actions.

The ledgrrr_* controller surface must stay thin. It should inspect and orchestrate installed components, then delegate domain work to the existing ledgerr_* service layer.

Published Tool Families

ToolCapability familyTypical actions
ledgerr_documentsintake, filename validation, raw context, tags, filesystem metadataingest_pdf, ingest_rows, document_inventory, normalize_filename
ledgerr_reviewrule execution, classification, review flagsrun_rule, classify_ingested, query_flags, classify_transaction
ledgerr_reconciliationtotals and posting guardrailsvalidate, reconcile, commit
ledgerr_workflowlifecycle and plugin operationsstatus, transition, resume, plugin_info
ledgerr_auditevent history and audit replayevent_history, event_replay, query_audit_log
ledgerr_taxevidence, ambiguity review, workbook exportassist, evidence_chain, ambiguity_review, export_workbook
ledgerr_ontologygraph/ontology query and write operationsquery_path, export_snapshot, upsert_entities, upsert_edges
ledgerr_xerosupervised Xero catalog and entity linkageget_auth_url, fetch_contacts, link_entity, sync_catalog

Desktop Controller Tools

PRD-11 defines a Claude Desktop MCPB bundle that runs ledgrrr-mcp as the stdio controller. The controller is not the privileged installer. It exposes explicit tools that return plans, status, and local artifact outputs.

ToolResponsibility
ledgrrr_statusReport desktop, service, tray, model runtime, Office add-in, SharePoint, and b00t state.
ledgrrr_install_planReturn dry-run install/repair actions and required privilege level.
ledgrrr_install_desktopLaunch the native Windows installer.
ledgrrr_start_serviceStart the local ledgrrr service.
ledgrrr_stop_serviceStop the local ledgrrr service.
ledgrrr_open_trayLaunch or focus tray/taskbar UI.
ledgrrr_render_diagramRender typed playbook models into Mermaid/SVG/PNG/HTML.
ledgrrr_simulate_pipelineRun deterministic or local-CPU-model simulation and return evidence summary.
ledgrrr_export_office_artifactProduce OneNote/Office/SharePoint-safe playbook artifacts.
ledgrrr_repairRepair service, tray, model runtime, Office manifests, and b00t linkage.
ledgrrr_uninstallLaunch native uninstall or return exact removal steps.

Every mutating controller action must support a plan-first flow and emit audit evidence. Privileged Windows operations cross the native installer/UAC boundary.

Runtime Flow

fn initialize() -> tools_list
fn tools_list() -> choose_capability
fn choose_capability() -> call_action
fn call_action() -> service_dispatch
fn service_dispatch() -> audit_event
if action == commit -> approval_gate
if action == export_workbook -> workbook_projection
flowchart TD
    initialize["initialize"]
    tools_list["tools_list"]
    choose_capability["choose_capability"]
    call_action["call_action"]
    service_dispatch["service_dispatch"]
    audit_event["audit_event"]
    action____commit{"action == commit"}
    approval_gate["approval_gate"]
    action____export_workbook{"action == export_workbook"}
    workbook_projection["workbook_projection"]
    initialize --> tools_list
    tools_list --> choose_capability
    choose_capability --> call_action
    call_action --> service_dispatch
    service_dispatch --> audit_event
    action____commit -->|"true"|approval_gate
    action____export_workbook -->|"true"|workbook_projection

Layering

The transport adapter should not redefine business behavior. It parses the published shape, normalizes boundary variance, and dispatches to TurboLedgerService.

  1. ledgerr-mcp-server: stdio transport.
  2. contract: published tool families, actions, generated JSON Schema.
  3. mcp_adapter: request parsing, envelope shaping, compatibility aliases.
  4. TurboLedgerService: domain behavior, state, audit, lifecycle.
  5. ledger-core: deterministic financial primitives.

Compatibility Rule

Hidden legacy l3dg3rr_* and proxy names may continue to parse, but documentation and examples should use ledgerr_* only. Drift between contract.rs and generated docs is a test failure, not a manual documentation chore.