LedgerGate
by yuanweize
README.md
# LedgerGate for ERPNext
**Governed financial automation for AI agents.** Typed MCP tools for customer and supplier master data, invoice drafts, PDF artifacts, accounting, bank reconciliation and approval-gated execution.
> **Alpha / 0.1.0.** The 34-tool catalog is implemented. Fixture-based regression and MCP protocol tests are available. Production read-only compatibility has been exercised; live write, submission, banking, SMTP and external approval-broker acceptance require a disposable ERPNext test company and operator validation before production use.
## Why LedgerGate?
Frappe's native MCP is an excellent general-purpose interface. LedgerGate complements it with financial intent, document-state checks, decimal arithmetic, duplicate protection, a durable operation journal, frozen approval payloads and private PDF artifacts. It does not replace ERPNext's accounting engine, tax determination or permissions.
- 34 typed domain tools; no arbitrary DocType, RPC, SQL or credential selection.
- Automatically create/update scoped routine drafts and party records with stable source IDs; never auto-submit.
- A separate privileged execution plane; local interactive approval by default, optional explicitly trusted external broker (e.g. Paperclip) for a single approval.
- Read-back verification, replay detection, unknown-outcome quarantine, manual reconciliation and auditable state transitions.
- Native ERPNext Print Formats/letterheads; visible DRAFT watermark; authenticated PDF resources and frozen attachments.
- Company configuration and ERP credentials injected at runtime. No customer data or secrets shipped.
```mermaid
flowchart TD
A[MCP client / Paperclip] --> R[Routine MCP: 34 tools]
R --> S[(Durable operation journal)]
R --> D[ERPNext draft-only identity]
A --> H[Native human approval]
H --> O[Separate privileged connector]
O --> S
O --> E[ERPNext operator identity]
D --> ERP[ERPNext]
E --> ERP
R --> P[Private PDF resources]
```
## Quick start
Python 3.12+; tested locally with Python 3.14 and MCP SDK 1.30.0. ERPNext/Frappe REST API v1 is used for portability; read-only checks have been run against an ERPNext/Frappe 17 development instance. ERPNext 15/16 compatibility is intended, not yet certified.
```bash
uv sync --locked --extra test
uv run pytest -q
cp .env.example .env.draft
chmod 600 .env.draft
# Edit .env.draft in your own secure editor; use a dedicated draft-only ERPNext user.
docker compose up -d draft
curl -fsS http://127.0.0.1:8080/health
```
The service exposes Streamable HTTP at `/mcp`, with a separate bearer credential. A reverse proxy must provide HTTPS for remote access. The default published port is loopback-only. For stdio clients, inject environment variables through the client's secret facility and use `ledgergate stdio`.
## Tool catalog
See [34 tools and permission policy](docs/tools.md), [generated machine-readable schemas](docs/tool-catalog.json), [deployment](docs/deployment.md), [Paperclip integration](docs/paperclip.md), [security model](docs/security-model.md), [ERPNext compatibility](docs/compatibility.md), and [comparison with alternatives](docs/comparison.md), [verification evidence](docs/verification.md) and [staging acceptance checklist](docs/staging-acceptance.md).
## Approval and execution
A routine action returns a durable operation ID and a verified ERP document ID. A high-risk action returns a frozen **PROPOSED** record, not a financial commitment. An operator must review the full payload and its hash. The default CLI path is `ledgergate approve-execute OPERATION_ID` in a trusted interactive terminal; see deployment instructions for separate credentials. The optional privileged MCP exposes only `execute_frozen_operation`, and only when a trusted broker mode is explicitly enabled. **An MCP client setting "Ask first" is not cryptographic proof of a human decision to this server.** Configure and test the actual trust boundary before enabling it.
Unknown outcomes stop further writes until reconciled; do not retry an uncertain operation with a fresh source ID.
## Costs and licensing
Apache-2.0 licensed software, self-hostable without a LedgerGate subscription. ERPNext, infrastructure, mail, hosted MCP clients and external providers retain their own licenses and charges. No commercial relationship or endorsement by ERPNext, Frappe, Paperclip or the MCP project is implied.
## Development
See [CONTRIBUTING](CONTRIBUTING.md) and [SECURITY](SECURITY.md). No live write tests in CI. Only synthetic fixtures belong in this repository. We welcome issues and contributions for version compatibility, ERPNext Workflow integration, transactional concurrency, multi-company authorization, e-invoicing and a signed approval-attestation protocol.
## Acknowledgments
Built on the Model Context Protocol Python SDK and Frappe/ERPNext REST and Print Format APIs. The design is informed by established safe-mode/immutable-plan patterns and MCP ecosystem projects described in [comparison](docs/comparison.md); third-party implementation code was not copied.
This server cannot be deployed
Maintenance
ActivityNo data
ResponsivenessNo recent community issues