mesa-mcp
tercet
マシンペイメントの記録の正本。 エージェントのすべての購入は、発生したその場で記録され(リクエスト → クォート → 署名済み承認)、オンチェーン上の決済と照合されます。そして、その差異には必ず名前が付きます —— 納品済みだが回収未了(delivered-but-uncollected)、支払済みだが未納(paid-without-delivery)、リプレイ(replay)、チェーン孤児(chain-orphan)。tercet は鍵・残高・決済経路に一切触れません。ただ監視し、証拠を生成するだけです。
tercet とは、互いに属し合う三行から成る詩節です。ここでは、すべての購入がそのひとつです。すなわち、リクエスト、承認、決済です。ダンテは tercet を連鎖させて、一つを抜けば詩全体が壊れるようにしました。この台帳も同じように、エントリを連鎖させます。
Python パッケージ名は依然として mesa(仮称)です。最初の PyPI リリースで tercet に改名されます。docs/ のプロジェクト文書はポルトガル語で書かれています。これらはビルド日記であり、フェーズごとの設計ドキュメントです。コード、スキーマ、この README は英語です。
アプリ — 台帳をライブで、6つの画面で
uv run mesa-app # -> http://127.0.0.1:840001 blotter(エージェントが購入した内容、導出状態、各購入のイベントチェーン)・02 tca(無駄、エージェント間の重複排除、成果物ごとのコスト)・03 risk(タスクツリーごとの予算、人間による詳細、支払者パスポート)・04 lab(時点ベースの支出ポリシー・バックテストと、誠実な信頼区間)・05 books(三者照合、第三者タイムスタンプ2つで封印された期間、取引先ごとの明細、BR 税表示)・06 operations(監査済みエンジンをを画面から実行できます — デモ、コレクタ、エクスポート — テストネットのみ)。
アプリは構造的に読み取り専用です。Postgres のセッションは default_transaction_read_only=on で開始されるため、仮に望んでも台帳への書き込みはできません。tests/test_app.py がそれを証明しています。データは常に実データです。テストネットと合成取引行は画面自体にラベル表示されます。ピルを押すと凡例が表示されます。
Related MCP server: ACA PoC MCP Tools Server
MCP サーバ — エージェントのための台帳ツール
claude mcp add tercet -- uv run mesa-mcp # then ask: "how much did my agents spend?"READツールは7つ(クローズドリスト、テストで証明済み): status_do_livro、gasto、compras(絞り込み可能)、compra(1件の購入 + そのイベントチェーン)、vereditos、passaportes、fiscal。アプリと同じ保証です。セッションは構造的に読み取り専用で、MCP サーバには書き込み経路がありません。tests/test_mcp_livro.py がそれを証明しています。トランスポート: stdio、ローカル。
エクスポート — ユニバーサル会計 + OECD CARF ビュー
uv run python scripts/fase13/contabil_build.py # -> contabil/<yyyy-mm>/ (universal CSV, QuickBooks, Xero + per-tx audit detail)
uv run python scripts/fase13/carf_build.py # -> fiscal/carf/<year>/ (OECD CARF view, born as OECD11 test data)期間ごとの複式仕訳帳(借方 == 貸方は検証済み。少数決済を誠実に集計し、6桁の監査用ブリッジで1セント ごとに tx hash に紐付け)。さらに CARF ビュー — OECD フレームワーク(2025年7月の公式ガイド)に基づき、報告義務のある crypto-asset サービスプロバイダがこれらの取引をどのように報告するか。デモ用のラベル、合成された身分、実データです。詳細と注意点は docs/fase13-export.md にあります。
ゼロから、この README だけで
前提条件: uv、Docker、Python 3.11+。
# 1. dependencies + database (Postgres 17 on 127.0.0.1:5433 — your machine only)
uv sync
docker run -d --name mesa-pg -e POSTGRES_USER=mesa -e POSTGRES_PASSWORD=mesa `
-e POSTGRES_DB=mesa -p 127.0.0.1:5433:5432 `
-v mesa-pgdata:/var/lib/postgresql/data postgres:17
uv run python scripts/check_db.py # migrations + hash-chain genesis, idempotent
# 2. TEST wallets (written to a local .env; never committed) + faucet USDC
uv run python scripts/setup_wallets.py
# -> paste the buyer address into https://faucet.circle.com (USDC / Base Sepolia)
uv run python scripts/check_balance.py # balance read on-chain
# 3. a toy seller + 10 REAL x402 payments on testnet
uv run uvicorn mesa.http.seller:app --port 8402 # terminal 1
uv run python scripts/fase1/buyer.py 10 # terminal 2 (writes the ledger)
# 4. the chain is the source of truth: collect and reconcile
uv run python -m mesa.collector # matches (authorizer, nonce) with the ledger
uv run python -m mesa.cli # the verdict table, orphans in red
# 5. the product
uv run mesa-app # -> http://127.0.0.1:8400実在のお金は一切かかりません: faucet で USDC を取得し、super 方式の下では faciliten の経費を負担します。
これまでの経過、証明されたこと、今後の予定: docs/DIARIO.md(ポルトガル語)— タスクごとのビルド日記。フェーズ別設計ドキュメントは
docs/faseN.mdにあります。秘密情報 (
setup_wallets.pyが生成する秘密鍵) はローカルの.envに置きます(gitignore 済み、コミット禁止)。別の場所に置きたい場合はMESA_ENV_FILEをそのファイルに指定し、同期フォルダ(OneDrive/Dropbox)の外に保管してください。同期フォルダに入れた鍵は、クラウドに入れたも対応です。
リポジトリマップ
パス | 内容 |
| 定数(USDC、ネットワーク、チェーンID) + |
| 台帳へのアクセス — 構造的に挿入のみ |
| 中心機能: 三者照合(純粋関数) |
| オンチェーンコレクタ: |
|
|
| HTTP レール: トイ売り側(カオスモード付き)+ 計測された買い手 |
| MCP: 有料ツールのレール(売り/買い)+ |
| Web アプリ(FastAPI + Jinja2、サーバーレンダリング、読み取り専用セッション) |
| 支払人のパスポート: 可搬で自己署名の決済履歴 |
| 出力用レンダラ(会計 / OECD CARF / ブラジル) |
| 連番の素の SQL — レールやトランスポートに依存しないスキーマ |
| 環境ユーティリティ + |
| pytest のゲート:汚れたデータを入れ → 期待通りの分類 |
| ビルド日記 + フェーズ別設計書(ポルトガ語) |
| スタンドアロン検証器 — このリポジトリを信頼せずに台帳とパスポートを検証 |
環境
uv sync
docker run -d --name mesa-pg -e POSTGRES_USER=mesa -e POSTGRES_PASSWORD=mesa `
-e POSTGRES_DB=mesa -p 127.0.0.1:5433:5432 `
-v mesa-pgdata:/var/lib/postgresql/data postgres:17
# 127.0.0.1 is mandatory: without it the ledger is open to any machine on the same
# Wi-Fi (docs/seguranca.md, hole #1). scripts/saude.py checks this, always.
uv run python scripts/setup_wallets.py # generates the EOAs -> .env (NEVER committed)
uv run python scripts/check_db.py # Postgres up + migrations + genesis
uv run python scripts/check_balance.py # USDC balance read on-chain
uv run python scripts/saude.py # ONE command: ruff+mypy+pytest+verifier+ports+secret scan
uv run python scripts/backup_db.py # ledger dump -> backups/ (routine, ~5s)フォーセット: https://faucet.circle.com → USDC → Base Sepolia(1アドレスあたり2時間で20 USDC)。
Anthropic キー(請求レールのエージェント・デモのみ): シークレット環境ファイルに ANTHROPIC_API_KEY=... を記入します。
各フェーズの証明を実行する
# Phase 1 — the ledger closes on dirty data
uv run uvicorn mesa.http.seller:app --port 8402 # terminal 1: HTTP seller
uv run python scripts/fase1/chaos_run.py # terminal 2: chaos + reconciliation + asserts
# Phase 2 — x402 over MCP
uv run python -m mesa.mcp.seller # terminal 1: MCP seller (port 8403)
uv run python scripts/fase2/mcp_once.py # terminal 2: 1 paid tool call + ledger
# Phase 10 — the payer passport (emits, verifies, gates a seller)
uv run python scripts/fase10/gate10_demo.py
# Any time: sweep the chain and reconcile
uv run python -m mesa.collector # testnet (seller payTo)
uv run python -m mesa.collector --pagador # mainnet (payer-side)
uv run python -m mesa.cli品質(「done」辞書の定義がある)
uv run python scripts/saude.py # ONE command: ruff+mypy+pytest+verifier+ports+secret scan脅威モデルと、適用範囲外を名前で素子を指定: docs/seguranca.md。
Available Tools
7 toolscompraB
Uma compra específica (por rid, vindo de 'compras') com a cadeia de eventos dela — a gaveta do blotter.
Inputs: rid (required). Returns: object
comprasC
As compras do livro, mais recentes primeiro, com filtros: estado (um de liquidado, pago-sem-entrega, entregue-sem-cobrar, cobranca-pendente, expirou-sem-uso, autorizado-pendente, sem-pagamento, fatura-conciliada, fatura-pendente, ingerido), rede (CAIP-2), trilho (x402/invoice/mpp/ap2), agente, contem (texto no domínio) e limite (1-100, padrão 20).
Inputs: rede, agente, contem, estado, +2 more. Returns: object
fiscalB
A competência fiscal BR (DeCripto, F11): nº de saídas mainnet, total em R$ pela PTAX persistida e o veredito do limiar de obrigação PF. Sem ano/mes usa a competência atual (data de SP).
Inputs: ano, mes. Returns: object
gastoB
Resumo do gasto no livro inteiro: real (mainnet) vs testnet vs invoice, por trilho, por agente, por dia, e o desperdício (mesmo recurso, mesmo byte, comprado de novo).
Inputs: no named parameters. Returns: object
passaportesB
Os passaportes de pagador (F10) emitidos neste checkout, RE-VERIFICADOS offline nesta chamada: íntegro?, aceito pela política?, motivos nomeados, métricas assinadas.
Inputs: no named parameters. Returns: object
status_do_livroA
Até onde o livro está atualizado: cursores do coletor (bloco por rede) e a corrente de hash (seq/elos). Chame antes de confiar em qualquer número — o livro nunca finge tempo real.
Inputs: no named parameters. Returns: object
vereditosC
A reconciliação de três pontas (pedido × autorização × chain) feita AGORA: contagem por veredito nomeado, com a explicação de cada um. Uma diferença nunca é um gap silencioso.
Inputs: no named parameters. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Each tool targets a distinct aspect of the financial domain: status check, spending summary, purchase listing, purchase detail, reconciliation verdicts, payer verification, and tax calculation. No two tools have overlapping purposes, and even the singular/plural pair (compra/compras) is clearly differentiated.
All tool names are lowercase Portuguese nouns (e.g., gasto, compras, vereditos). The only deviation is status_do_livro, which uses underscores and is more descriptive. While the pattern is consistent in being noun-based, the mixed style (underscore vs. single-word) is a minor inconsistency.
With 7 tools, the server is well-scoped for a financial reporting and reconciliation service. Each tool covers a necessary function without being overly granular or bloaty, fitting comfortably in the optimal 3-15 tool range.
The tool set covers the full read-only lifecycle for the domain: status checking, spending summaries, purchase listing and detail retrieval, three-way reconciliation, passport verification, and tax computation. There are no obvious gaps for the server's apparent purpose of audit and analysis.
Maintenance
Related MCP Connectors
Read your Golem fleet's ledger from any MCP client: agents' sessions, live activity, signed record.
Read-only gateway for durable agent identity, consent, recognized work, and signed receipts.
Ledger of AI-agent money on Base: payments, detections, Gate, signed Pass, Agent Books, free checks
Read-only discovery for exact-commit Agent Skill validation, x402 payment, and signed receipts.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables agents to perform financial operations including categorization, reconciliation, and reporting on a tamper-evident, self-hosted ledger.AGPL 3.0
- AlicenseNot gradedqualityDmaintenanceProvides financial audit reporting and ledger query tools for AI agents, enabling generation of compliance, risk, and transaction reports and querying of transaction data, balances, and summaries from an in-memory SQLite database via MCP.MIT
- FlicenseNot gradedqualityDmaintenanceProvides a stateless Agent Chat Protocol bridge that lets agents inspect proposed payments against policy, retrieve public signed receipts, and verify their cryptographic proofs without wallet or payment capabilities.-
- AlicenseAqualityBmaintenanceEnables read-only, keyless queries of timestamped, definition-backed data about AI agent payments and activity on Base, including rankings, agent records, detections, metric histories, and evidence-pack pricing, from MCP clients or the terminal.29333 npmApache 2.0