HomeCase StudiesAccounting AI — Deterministic Model Context Protocol (MCP) ERP Engine

Accounting AI — Deterministic Model Context Protocol (MCP) ERP Engine

High-performance Rust MCP daemon connecting LLM reasoning engines to enterprise ERP ledgers with strict double-entry mathematical invariants and token-gated commits.

By VertApp Engineering
Accounting AI — Deterministic Model Context Protocol (MCP) ERP Engine

Accounting AI: Deterministic MCP Financial Engine

Technical Specification

  • Core Language & Runtime: Rust (2021 edition), compiled to native machine binary.
  • Footprint & Performance: ~1.3 MB binary footprint, ~24 MB idle RAM, sub-120ms cold-start latency. Zero garbage collection pauses.
  • Transport & Protocol: Model Context Protocol (MCP specification) over standard input/output (stdio) with JSON-RPC 2.0 framing.
  • ERP Interface: Local loopback XML-over-HTTP interface (127.0.0.1:9000), zero third-party cloud intermediaries, zero external telemetry.
  • Serialization: Typed Abstract Syntax Tree (AST) serialization via quick-xml ensuring byte-exact UTF-16LE formatting with Byte Order Mark (BOM).

System Flow & Execution Pipeline

  1. Tool Invocation: The AI client issues structured JSON-RPC tool calls across read tools (trial balance, ledger lists, daybook, bill-wise outstandings) or draft tools (purchase, sales, payment, receipt, journal).
  2. Context Resolution & State Isolation: Active ledger and company parameters are validated against local schema definitions before querying the underlying accounting data store.
  3. Double-Entry Mathematical Assertion: Prior to staging any transaction, the engine computes: Σ Debits + Σ Credits == 0. Unbalanced entries or disallowed ledger patterns are rejected deterministically in Rust.
  4. Draft Staging (Zero Commit Authority): The MCP server creates an isolated XML draft in memory. No MCP tool possesses permission or capabilities to execute a write commit.
  5. Ephemeral Token-Gated Approval Gate: The daemon spawns a local, single-use, HMAC-SHA256 authenticated loopback URL.
  6. Physical Authorization Commit: The transaction is posted only when a human user reviews the raw XML diff and confirms via physical browser interaction.

AI / ML Architecture & Safety Invariants

  • Asymmetric Read/Write Privilege Separation: The LLM functions exclusively as a read-analyst and draft-synthesizer; direct database mutation is physically severed from model output.
  • Deterministic XML Generation: Eliminates string concatenation and prompt-injected payload tampering through typed Rust structs.
  • High-Throughput Concurrency: Processes high-density financial requests in milliseconds (bulk-staging 1,000 balanced vouchers in ~22 seconds).