reciprocal-ruler-mcp
Reciprocal Ruler MCP provides a settlement oracle for agent-to-agent transactions, combining deterministic arithmetic checks, quote locking, and post-settlement reconciliation paid per call via x402 USDC on Base.
Run free trial arithmetic checks (
ruler_trial_verify_math) comparing expected vs actual amounts with optional tolerance, returningMATCHED,SHORTFALL, orOVERPAID.Run free trial reconciliations (
ruler_trial_reconcile) to previewSETTLED_OK,COMPENSATED, orPENDING_RECONCILIATIONjudgments.Pay $0.01 for deterministic arithmetic verification (
ruler_verify_math).Pay $0.05 to lock agreed trade terms and receive a deterministic
quote_hash(ruler_quote_lock).Pay $0.25 for idempotent settlement reconciliation recorded in an append-only audit ledger (
ruler_reconcile), where retries with the same idempotency key are not charged again.Handle x402 payment challenges through
payment_header, using USDC on Base with no account or API key.Compensate shortfalls from an agreed KRW holdback, while leaving half-open timeout shortfalls
PENDING_RECONCILIATIONinstead of auto-compensating.
Provides an importable n8n workflow for quote-lock → reconcile, enabling n8n users to lock agent trade terms and run settlement reconciliation without using an MCP client.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@reciprocal-ruler-mcp Reconcile a 220,000 KRW trade that only settled 180,000 with a 22,000 holdback"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
reciprocal-ruler-mcp
Using n8n instead of an MCP client?
examples/n8n/has an importable quote-lock → reconcile workflow. Using Claude Code?examples/claude-code/has a ready-to-copySKILL.mdandPreToolUseverification hook. Need a quick human CSV/TSV check? Open https://reciprocal-ruler-x402.vercel.app/app.
An MCP (Model Context Protocol) server that gives any MCP-capable agent — Claude Desktop, Claude Code, Cursor, or your own client — a settlement oracle for agent-to-agent transactions.
When two AI agents fail to agree on what must be proven before money moves, Reciprocal Ruler
acts as the third party: it locks the agreed terms into a deterministic quote_hash, then judges
the settlement afterwards (SETTLED_OK, COMPENSATED, PENDING_RECONCILIATION) and compensates
shortfalls out of the agreed holdback. The service is paid per call with
x402 in USDC on Base — no account, no API key, no invoice.
API: https://reciprocal-ruler-x402.vercel.app · OpenAPI docs:
/docsFree trial: 3 evaluation calls per client, no payment, no signup
Standard library only — the server has no third-party dependencies
Tools
Tool | Price | What it does |
| free (3 calls/client) | Free trial of the deterministic arithmetic check ( |
| $0.01 | Ultra-low-cost deterministic arithmetic check ( |
| free (3 calls/client) | Runs the real reconciliation engine and returns the judgment, so you can evaluate it before paying. Not written to the audit ledger. |
| $0.05 | Locks the terms both agents agreed on and returns a deterministic |
| $0.25 | Idempotent settlement judgment recorded in an append-only audit ledger; retries with the same |
Amounts are KRW integers. A reconciliation compares expected_amount_krw with
actual_settled_krw and uses holdback_krw as the compensation pool:
{
"expected_amount_krw": 220000,
"actual_settled_krw": 180000,
"holdback_krw": 22000,
"event_type": "POST_TRADE_REFUND"
}→ {"status": "COMPENSATED", "compensated_krw": 22000, "uncovered_krw": 18000, "credit_delta": -17}
event_type is POST_TRADE_REFUND (a refund or shortfall after the trade) or
HALF_OPEN_TIMEOUT (an unfinished settlement at timer expiry — such a shortfall is left
PENDING_RECONCILIATION, never auto-compensated).
Related MCP server: hive-mcp-barter
How the paid calls work
This MCP server holds no wallet and signs nothing. On a paid tool the call happens in two steps:
First call (no
payment_header) returns the HTTP 402 x402 challenge, decoded for you: scheme, network, USDC asset, amount in atomic units and USDC,payTo, timeout, plus what to do next.Pay and retry: produce the signed payment payload with an x402-capable client (the
x402Python SDK,x402-fetch/x402-axiosfor Node, or a Coinbase CDP / AgentKit wallet) and pass it back in the tool'spayment_headerargument. The same call then returns HTTP 200.
Example payment summary from a 402 response:
{
"status": "PAYMENT_REQUIRED",
"payment_summary": {
"x402_version": 2,
"scheme": "exact",
"network": "eip155:8453",
"network_name": "Base mainnet (eip155:8453)",
"asset_name": "USDC",
"amount_atomic": "50000",
"amount_usdc": "0.050000",
"pay_to": "0x…",
"resource_url": "https://reciprocal-ruler-x402.vercel.app/v1/quote-lock"
},
"how_to_pay": ["…"]
}Install
The package is not published on PyPI yet, so install it from this folder:
pip install . # console script `reciprocal-ruler-mcp`
pip install -e ".[dev]" # editable, with pytest, for developmentNothing outside the Python standard library is pulled in. Either install path gives you the
reciprocal-ruler-mcp console script, and python -m reciprocal_ruler_mcp works as well. The
server speaks MCP over stdio.
Connect a client
Claude Desktop
claude_desktop_config.json (macOS: ~/Library/Application Support/Claude/, Windows:
%APPDATA%\Claude\):
{
"mcpServers": {
"reciprocal-ruler": {
"command": "python3",
"args": ["-m", "reciprocal_ruler_mcp"],
"env": {
"RULER_API_BASE": "https://reciprocal-ruler-x402.vercel.app",
"RULER_TRIAL_CLIENT_ID": "my-agent-01"
}
}
}
}Claude Code
claude mcp add reciprocal-ruler -- python3 -m reciprocal_ruler_mcpCursor
~/.cursor/mcp.json — same mcpServers shape as the Claude Desktop example above.
See examples/ for ready-to-copy files.
Run without installing
The server is a single standard-library module, so a checkout works directly:
{
"mcpServers": {
"reciprocal-ruler": {
"command": "python3",
"args": ["/absolute/path/to/src/reciprocal_ruler_mcp/server.py"]
}
}
}One-click install (MCPB bundle)
Every release also ships a .mcpb bundle, the package format Claude Desktop and other
hosts open in one click (Linux, macOS, Windows):
python3 scripts/build_mcpb.py # -> dist/reciprocal-ruler-mcp.mcpbOr take the bundle from the latest release: https://github.com/hwcho310/reciprocal-ruler-mcp/releases/latest/download/reciprocal-ruler-mcp.mcpb
The bundle needs python3 on the machine and nothing else — the server has no dependencies.
Registries
Registry | Entry |
Official MCP Registry |
|
Glama |
Configuration
Environment variable | Default | Purpose |
|
| API base URL (point it at a local or self-hosted instance if you run one). |
| unset | Sent as |
|
| Per-request timeout. The free hosting tier sleeps when idle, so the first call of a session may need a warm-up; the client retries once on a network failure. |
Every tool also accepts trial_client_id (ruler_trial_reconcile) and payment_header
(the paid tools) as arguments, which override the environment defaults for that call.
Protocol
initialize (protocol versions 2025-06-18, 2025-03-26, 2024-11-05, 2024-10-07),
tools/list, tools/call, ping, and the standard notifications. Diagnostics go to stderr;
stdout carries JSON-RPC frames only.
Tool failures come back as a normal result with isError: true and a JSON body explaining the
case (PAYMENT_REQUIRED, TRIAL_EXHAUSTED, VERSION_MISMATCH, INVALID_ARGUMENTS,
API_UNREACHABLE), so an agent can recover instead of crashing.
Test
pip install -e ".[dev]"
pytest -qtests/test_protocol.py starts the real server as a subprocess against a local mock of the API
and drives a full JSON-RPC exchange — initialize → tools/list → tools/call — including the
402 payment path, the trial quota, and error handling, all offline.
scripts/live_smoke.py calls the live public API with the tools (free trial only; it never
spends money) to check a deployment end to end. scripts/sdk_interop_check.py connects with the
official MCP Python SDK client (pip install mcp) to confirm the stdio server works with a real
client implementation, not only with raw frames.
License
MIT. The service behind it is operated as Reciprocal Ruler; the API terms are whatever the endpoint itself reports at request time.
Available Tools
5 toolsruler_quote_lockReciprocal Ruler - quote lock (x402 paid)AIdempotent
Lock the trade terms the two agents agreed on and get a deterministic quote_hash both sides can cite later. Costs $0.05 USDC on Base, paid with x402. Without a payment this tool returns the HTTP 402 payment challenge decoded into Base USDC instructions; pay it with an x402 wallet and pass the signed payload back as payment_header to complete the call. If the two agents run different rule versions the call is refused with VERSION_MISMATCH (409) and nothing is charged.
Inputs: terms (required), buyer_id (required), supplier_id (required), buyer_version (required), +2 more.
ruler_reconcileReciprocal Ruler - settlement reconciliation (x402 paid)AIdempotent
Idempotent settlement reconciliation recorded in an append-only audit ledger. Costs $0.25 USDC on Base via x402; without payment it returns the decoded payment challenge and Base USDC instructions. Reusing the same idempotency_key makes a retry return the original judgment instead of charging again, so always pass the key your first attempt used. Judgment is one of SETTLED_OK, COMPENSATED, PENDING_RECONCILIATION.
Inputs: idempotency_key (required), actual_settled_krw (required), expected_amount_krw (required), tx_id, +4 more.
ruler_trial_reconcileReciprocal Ruler - free trial reconciliationARead-only
Run a settlement reconciliation between two AI agents for free (up to 3 calls per client). Compares the expected amount with what actually settled and returns a deterministic judgment: SETTLED_OK, COMPENSATED (shortfall covered from the holdback), or PENDING_RECONCILIATION (half-open timeout, left pending). Use it to evaluate whether Reciprocal Ruler fits your agent-to-agent transaction flow before paying. Amounts are KRW integers.
Inputs: actual_settled_krw (required), expected_amount_krw (required), tx_id, event_type, +4 more.
ruler_trial_verify_mathReciprocal Ruler - free trial arithmetic checkARead-only
Free trial of the $0.01 deterministic arithmetic check (up to 3 calls per client across trial tools). Compares expected_amount vs actual_amount with optional tolerance and returns MATCHED, SHORTFALL, or OVERPAID.
Inputs: actual_amount (required), expected_amount (required), currency, tolerance, +1 more.
ruler_verify_mathReciprocal Ruler - arithmetic check ($0.01 x402 paid)ARead-only
Ultra-low-cost ($0.01 USDC on Base) deterministic arithmetic verification (MATCHED / SHORTFALL / OVERPAID). Without payment_header it returns the HTTP 402 challenge; pass the signed x402 payload to complete.
Inputs: actual_amount (required), expected_amount (required), currency, tolerance, +1 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Tools split into three core actions—arithmetic verification, quote locking, and settlement reconciliation—plus trial duplicates of verification and reconciliation. The free/paid pairs are clearly signaled by the 'trial' prefix, though an agent could briefly confuse trial and paid variants, or verify_math vs reconcile since both compare expected and actual amounts.
All names use snake_case with a consistent ruler_ prefix, and trial variants are consistently prefixed. However the action pattern is not fully uniform: ruler_verify_math and ruler_trial_verify_math are verb_noun, ruler_reconcile is a bare verb, and ruler_quote_lock uses noun_verb.
Five tools is a compact, appropriate surface for a narrow paid verification/reconciliation service. Three core paid operations plus two trial entry points each serve a clear purpose, with no excessive tool sprawl.
The set covers the main lifecycle from locking a quote, to verifying arithmetic, to settling/reconciling with an audit ledger. The main gap is the absence of any read/query tool for retrieving a previously locked quote or ledger entry, though agents can still complete the core workflows using returned hashes and judgments.
Maintenance
Related MCP Connectors
Neutral acceptance and signed agent-delivery verification over MCP + x402 USDC on Base.
x402 pay-per-call APIs over MCP, settled in USDC on Base for autonomous agents and developers.
Deterministic MCP utilities, validation, evidence verification, and x402 commerce on Base.
USDC/x402 agent marketplace. Verified Base mainnet pilot, testnet and public enrollment.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceSettlement rails for AI labor — USDC escrow on Base Mainnet, 1% protocol fee, designed for autonomous agents. 10 MCP tools covering the full escrow lifecycle: * Quoting calldata for create-intent, submit-proof, release-funds (broadcast gated) * Single-call x402 payment binding (replaces the 5-step x402 dance with one HMAC-signed POST) * Server-side reputation from on-chain event scan * LiMIT
- AlicenseNot gradedqualityDmaintenanceAn outbound arbitrage agent for 402-enabled MCP endpoints that probes, counter-offers, and settles USDC on Base L2, automating margin arbitrage without human intervention.MIT
- AlicenseNot gradedqualityDmaintenanceMulti-party escrow and settlement for autonomous agent transactions with x402 micropayments and dispute resolution on Base, Ethereum, or Solana.MIT
- AlicenseNot gradedqualityDmaintenanceEnables agents to access production-grade paid MCP tools with real on-chain x402 v2 settlement, including EVM wallet risk scoring, payload normalization, and facilitator discovery, all discoverable via Bazaar-compatible metadata.MIT