ap2-iso20022
Bridges AP2/x402 agent-payment mandates into validated ISO 20022 payment records with guardrails, without moving money.
Serve MCP tools over stdio, streamable HTTP, or SSE.
Normalise AP2 mandate payloads into a canonical mandate.
Normalise x402 payment payloads into a canonical mandate.
Guardrail mandates: required fields, spending cap, expiry, authorisation proof.
Convert canonical mandates into pain.001 customer credit transfer records.
Convert canonical mandates into pacs.008 FI-to-FI credit transfer records.
Fetch live token-to-fiat spot rates for USDC, USDT, EURC, ETH and SOL.
Check an agent's proposed spend against per-transaction, daily and monthly caps.
Validate mandate expiry by unix-epoch comparison.
Normalise raw token base units into human token amounts.
Verify x402 EIP-191 personal_sign signatures and recover the signer address.
Validate EIP-2612 permits (owner, spender, value, nonce, deadline).
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., "@ap2-iso20022 normalize this AP2 mandate and run guardrails"
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.
ap2-iso20022: Agent-payment mandates → wire-valid ISO 20022
Bridge AP2 (Google's Agent Payments Protocol) and x402
(Coinbase's HTTP-402) mandates into ISO 20022 pain.001 / pacs.008 records —
with spending-cap, expiry and authorisation guardrails, and an MCP
server. These agentic-payment protocols authorise a payment; this library
turns that authorisation into the bank-rail message that actually settles it
— the rail the card networks and stablecoins don't cover.
Latest release: v0.0.7: 11 MCP tools over stdio, streamable HTTP or SSE, pure-Python (only
mcp), 100% branch coverage, for Python 3.10+. Output feeds straight intopain001/pacs008to generate wire-valid XML. Part of the ISO 20022 MCP suite.
Why
An agent with a signed AP2 mandate (or an x402 payment authorisation) can prove
it's allowed to pay — but nothing in those protocols emits the pain.001 a
bank needs to move the money. ap2-iso20022 is that missing hop. And because
moving money is consequential, it only transforms and validates — producing
the ISO record is deliberately separate from generating and sending it, so the
actual payment stays an explicit, guarded step.
Related MCP server: iso20022-mcp
Install
pip install ap2-iso20022
# or run the MCP server without installing:
uvx --from ap2-iso20022 ap2-iso20022-mcpMCP client config (e.g. Claude Desktop):
{
"mcpServers": {
"ap2-iso20022": {
"command": "ap2-iso20022-mcp"
}
}
}Transports
One command line, three transports:
Command | Transport | Endpoint | Protocol revisions |
| stdio | the client spawns the process | 2026-07-28, 2025-11-25 |
| Streamable HTTP |
| 2026-07-28 (stateless, |
| HTTP+SSE (2024-11-05) |
| for clients that still expect the older transport |
--host and --port change the bind address (defaults 127.0.0.1 and
8000). The HTTP transports carry no authentication of their own: bind
loopback, or put the server behind a gateway you trust before binding a
routable address. Every release is verified over streamable HTTP with
scout in both protocol
eras and over SSE with the MCP SDK client; see
ADR 0001.
{
"mcpServers": {
"ap2-iso20022": { "url": "http://127.0.0.1:8000/mcp" }
}
}Flow: normalise → guardrail → convert
from ap2_iso20022 import bridge
# 1. Normalise the protocol payload into a canonical mandate.
mandate = bridge.from_ap2({
"intent_id": "AP2-CoffeeRun-7",
"payer": "Alice's Shopping Agent",
"payer_account": "DE89370400440532013000",
"merchant_name": "Blue Bottle Coffee",
"payee_account": "GB29NWBK60161331926819",
"amount": "12.50", "currency": "EUR", "memo": "oat latte",
"spending_limit": "50.00",
"signature": "eyJ...", "signature_type": "jws",
})
# 2. Guardrail before it becomes a payment.
check = bridge.check_mandate(mandate, as_of="2026-03-02T09:00:00")
assert check["ok"] # required fields ok, within cap, not expired, signed
# 3. Convert to a pain.001 record that feeds pain001 -> wire-valid XML.
record = bridge.to_pain001(mandate) # exact pain001 field names + JSON number amountsTools
normalize_ap2— AP2 mandate payload → canonical mandate.normalize_x402— x402 payment payload → canonical mandate.check_mandate— Guardrail: required fields, spending cap, expiry (withas_of), authorisation proof.to_pain001— Canonical mandate →pain.001record (customer credit transfer).to_pacs008— Canonical mandate →pacs.008record (FI-to-FI).
The output field names and types match what pain001 / pacs008 expect
(validated against their JSON schemas), so to_pain001(mandate) → pain001
generate_message → XSD-valid pain.001 with no glue.
Guardrails
check_mandate returns {ok, violations, warnings}:
required fields — payer/payee name + account, amount, currency
spending cap —
amount <= max_amountwhen a cap is presentexpiry — refuses an expired mandate when you pass
as_ofauthorisation proof — warns when no
proof_type/proof_valueis present
It never moves money; it tells you whether the mandate is safe to act on.
The suite
Part of a family of vendor-neutral, Python-native ISO 20022 MCP servers:
iso20022-mcp— unified gateway across the families.pain001-mcp·pacs008-mcp— generate the XML this bridge feeds.reconcile-mcp— statement/payment reconciliation.camt-exceptions— E&I messages (cancellation, investigation).
Development
git clone https://github.com/sebastienrousseau/ap2-iso20022
cd ap2-iso20022
python -m venv .venv && . .venv/bin/activate
pip install -e . && pip install pytest pytest-cov ruff black mypy
pytest # 100% branch coverage gate
ruff check ap2_iso20022 tests && black --check ap2_iso20022 tests && mypy ap2_iso20022License
Licensed under the Apache License, Version 2.0 (LICENSE).
mcp-name: io.github.sebastienrousseau/ap2-iso20022
Available Tools
11 toolscheck_agent_spend_limitsARead-onlyIdempotent
Guardrail an agent's proposed spend against per-transaction, daily and monthly caps. Stateless: pass the current spent_today/spent_month running totals; nothing is stored. Returns is_allowed, the remaining daily cap and any violations.
Inputs: agent_id (required), proposed_amount_usd (required), daily_cap, per_tx_cap, +3 more. Returns: object
check_mandateARead-onlyIdempotent
Guardrail a mandate before it becomes a payment: check required fields, the spending cap (amount <= max_amount), expiry (when 'as_of' is supplied), and whether an authorisation proof is present. Returns ok plus any violations and warnings. Run this before converting.
Inputs: mandate (required), as_of. Returns: object
get_token_fiat_rateARead-only
Fetch a spot token->fiat exchange rate from the CoinGecko public API, e.g. to price a crypto-denominated (x402) mandate in fiat. Supports USDC, USDT, EURC, ETH and SOL. Requires the optional 'oracle' extra (pip install ap2-iso20022[oracle]). Reaches an external service: the returned rate is a live spot price, not a guarantee, and this tool never moves money.
Inputs: token_symbol (required), fiat_currency. Returns: object
normalize_ap2ARead-onlyIdempotent
Normalise a Google AP2 (Agent Payments Protocol) mandate payload into a canonical mandate the other tools accept.
Inputs: payload (required). Returns: object
normalize_token_amountARead-onlyIdempotent
Normalise raw on-chain base units to a human token amount using the token's decimals (USDC/USDT/EURC=6, SOL=9, ETH=18). Returns amount and decimals. Errors on an unsupported token.
Inputs: token_symbol (required), raw_base_units (required). Returns: object
normalize_x402ARead-onlyIdempotent
Normalise a Coinbase x402 (HTTP-402) payment requirement/receipt into a canonical mandate the other tools accept.
Inputs: payload (required). Returns: object
to_pacs008ARead-onlyIdempotent
Convert a canonical mandate into a pacs.008 record (FI-to-FI credit transfer) using the field names pacs008 expects, for interbank settlement of an agent-authorised payment.
Inputs: mandate (required). Returns: object
to_pain001ARead-onlyIdempotent
Convert a canonical mandate into a pain.001 record (customer credit transfer initiation) using the exact field names pain001 expects, so it feeds straight into pain001 generate_message for wire-valid XML.
Inputs: mandate (required). Returns: object
validate_eip712_permitARead-onlyIdempotent
Validate an EIP-2612 permit: owner/spender/value/nonce/deadline must be present and well-formed, and deadline must not be before the caller-supplied now_timestamp. Returns is_valid and any violations.
Inputs: permit (required), now_timestamp (required). Returns: object
validate_mandate_expiryARead-onlyIdempotent
Check a mandate's expiry by unix-epoch (seconds) comparison. The caller supplies now_timestamp (the server never reads the clock); a mandate is valid while now is before expiration. Returns is_valid.
Inputs: now_timestamp (required), expiration_timestamp (required). Returns: object
verify_x402_signatureARead-onlyIdempotent
Verify an x402 EIP-191 personal_sign over the mandate JSON: recover the signer with eth_account and compare (case-insensitively) to the expected address. Returns is_valid and the recovered_address.
Inputs: mandate_json (required), signature_hex (required), expected_address (required). Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 11 tools
Most tools have clearly distinct targets: normalization (ap2/x402/token_amount), validation (expiry/signature/eip712), conversion (pain001/pacs008), and rate/limit checks. The main overlap is check_mandate, which is a composite guardrail covering required fields, spend cap, expiry and authorization proof—partly duplicating validate_mandate_expiry and check_agent_spend_limits, though the descriptions clarify it is the umbrella 'run this before converting' tool.
All names are snake_case and mostly follow verb_noun (get_/check_/validate_/verify_/normalize_). The two converters use a different to_<format> pattern (to_pain001, to_pacs008) with embedded domain codes, a minor deviation but still readable and predictable.
11 tools is well-scoped for an agent-payments/ISO 20022 pipeline; each tool covers a distinct stage (rate lookup, normalization, validation, conversion) and none feels redundant or gratuitous.
The surface covers the full normalize -> validate -> convert pipeline with both pain.001 and pacs.008 outputs plus input normalizers for AP2 and x402. Minor gaps exist around the ISO 20022 lifecycle (no pacs.002 status or camt statement handling, no parsing of an existing ISO message), but core workflows are covered.
Maintenance
Related MCP Connectors
MEOK Google AP2 Mandate MCP — issue + verify + revoke signed user-side spend authorisations for
x402 MCP with exact and batched payments for recurring wallet, trading, market and web workflows.
Single-connection MCP & A2A gateway indexing 490+ verified tools with x402 & MPP settlement.
MCP server for Modern Treasury — payment orders, transactions, counterparties and ledgers.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceMCP server for agent-native and human-accessible payments using MPP and x402 protocols, enabling payment flows from CLI or agent hosts.MIT
- AlicenseAqualityBmaintenanceUnified gateway for ISO 20022 message families, providing meta-tools to search, describe, validate, generate, and parse financial messages.759 PyPI1Apache 2.0
- AlicenseNot gradedqualityDmaintenanceDual-rail MCP server for initiating and verifying MPP and x402 payments, plus MPP-attested identity claims, enabling agent-native financial settlement.MIT
- AlicenseNot gradedqualityDmaintenanceA generic MCP and REST payments gateway enabling agents and services to accept payments via x402 USDC and XMR/ZEC top-ups, and make outbound ZEC payments with human co-signing, all without holding spending keys.MIT