ambrook-mcp-guardrail
Deterministic pre-flight ledger validator that treats AI agent proposed financial writes as untrusted input, validating them against ledger invariants before commit, ensuring invalid transactions result in zero ledger mutation.
README
<p align="center"> <img src="./assets/readme/hero.svg" width="100%" alt="ambrook-mcp-guardrail: deterministic pre-flight ledger validator — an AI agent's proposed financial write is treated as untrusted input and validated before the commit boundary. Real test run: 5/5 tests pass, 0 invalid mutations."> </p>
ambrook-mcp-guardrail
A deterministic pre-flight ledger validator proof-of-concept. An AI agent's proposed financial write is treated as untrusted input and validated against ledger invariants before it reaches a commit boundary.
Inspired by Ambrook's publicly described combination of hybrid AI + rule-based systems, MCP-based tooling, and a multidimensional general ledger (enterprise / project / location / funding dimensions).
This is an independent proof-of-concept inspired by those publicly documented design principles. It is NOT Ambrook's internal implementation.
The invariant
<p align="center"> <img src="./assets/readme/pipeline.svg" width="100%" alt="Pipeline: AI agent → mock MCP write_transaction tool call → deterministic pre-flight validator. VALID → commit; INVALID → structured rejection, no commit. Invariant: invalid transaction → zero ledger mutation."> </p>
INVALID TRANSACTION → ZERO LEDGER MUTATION. The commit branch is the only path that mutates the ledger.
How validation works
ledger-rules.ts is a pure, deterministic validator. All errors are collected; if any invariant fails, the entire write is rejected with structured errors ({ code, message }) — no partial writes.
| Rule | What it checks |
|---|---|
| L1 Double-entry balance | Total debits must equal total credits. |
| L2 Required structure | Transaction ID, ≥1 debit, ≥1 credit, valid positive amounts, currency. |
| L3 Multidimensional data | Declared enterprise/project/location/funding dimensions must carry structurally valid identifiers — no silent omission. |
| L4 No partial validation | One failing invariant rejects the whole write; every rejection returns structured errors. |
Proof — the actual run
Five simulated agent tool calls (agent-test-suite.ts), all asserted programmatically. No results are hand-written; everything below is generated from execution into results.json.
| # | Tool call | Result | Errors reported | Ledger size |
|---|---|---|---|---|
| 1 | agent-tool-call-001 — balanced pair |
ACCEPT | — | 0 → 1 |
| 2 | agent-tool-call-002 — balanced + 4 valid dimensions |
ACCEPT | — | 1 → 2 |
| 3 | agent-tool-call-003 — unbalanced 1000 / 900 |
REJECT | UNBALANCED_ENTRY |
2 → 2 |
| 4 | agent-tool-call-004 — missing debit, empty dimension ID |
REJECT | MISSING_TX_ID, MISSING_DEBIT, UNBALANCED_ENTRY, INVALID_DIMENSION |
2 → 2 |
| 5 | agent-tool-call-005 — multi-violation |
REJECT | INVALID_AMOUNT, UNBALANCED_ENTRY, INVALID_DIMENSION |
2 → 2 |
- 8/8 assertions pass, including: every invalid write changes ledger size by zero, and the final ledger contains only the two valid transactions.
- Deterministic: three consecutive runs produced byte-identical output and an identical
results.json.
Run it
npm install
npm run build
npm test
npm test compiles, runs the suite, asserts all invariants, and regenerates results.json — exiting non-zero on any failure.
Structure
ledger-types.ts domain types (Transaction, ToolCall, ValidationError, …)
ledger-rules.ts deterministic rules L1–L4
mock-mcp-server.ts mock MCP boundary: write_transaction + in-memory ledger
agent-test-suite.ts 5 simulated agent writes + 8 assertions → results.json
Limitations
- Mock MCP boundary, in-memory ledger, synthetic transactions — no Ambrook infrastructure was touched.
- No production performance claim, and no claim about how Ambrook actually implements validation.
- Zero runtime dependencies: standard Node.js only, no network, no LLM calls, no API keys.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。