pain001.mcp package#

Model Context Protocol (MCP) server for Pain001.

Exposes Pain001’s generation and validation as MCP tools, resources, and prompts so LLM clients (Claude Desktop, etc.) can build and check ISO 20022 payment files. Install with pip install "pain001[mcp]" and run pain001-mcp.

Submodules#

pain001.mcp.server module#

Pain001 MCP server (stdio transport).

Tools, resources, and prompts are thin adapters over the existing core functions. Unlike the REST API, the MCP tools take inline data (a list of payment-row dicts) and return XML as a string, because an MCP client does not share the server’s filesystem.

Run it with:

pain001-mcp
pain001.mcp.server.build_payment_batch(message_type: str = 'pain.001.001.03') → str[source]#

Guided prompt for assembling a compliant payment batch.

Parameters:

message_type – The target ISO 20022 message type.

Returns:

A prompt string instructing the model how to proceed.

pain001.mcp.server.generate_payment_file(message_type: str, rows: list[dict[str, Any]]) → str[source]#

Generate validated ISO 20022 XML from inline payment rows.

Parameters:
  • message_type – The ISO 20022 message type to generate.

  • rows – Payment rows as a list of dicts (one per transaction).

Returns:

The validated XML document as a string.

Raises:

ValueError – If the message type is not supported or rows are empty.

pain001.mcp.server.inspect_template(message_type: str) → dict[str, Any][source]#

Return the payment-row columns a message type expects.

Parameters:

message_type – The ISO 20022 message type (e.g. pain.001.001.03).

Returns:

A dict with the message type and its required column names. Raises ValueError for an unsupported message type.

pain001.mcp.server.list_supported_versions() → list[str][source]#

List every ISO 20022 message type Pain001 can generate.

Returns:

The supported message type identifiers.

pain001.mcp.server.main() → None[source]#

Run the Pain001 MCP server over stdio.

pain001.mcp.server.schema_resource(message_type: str) → str[source]#

Return the official XSD schema text for a message type.

Parameters:

message_type – The ISO 20022 message type.

Returns:

The XSD schema contents. Raises ValueError for an unsupported message type.

pain001.mcp.server.suggest_record_fix(record: dict[str, Any], validation_error: dict[str, Any], message_type: str = 'pain.001.001.03') → dict[str, Any][source]#

Suggest deterministic, review-only patches to non-financial fields.

Parameters:
  • record – One payment record, which is never mutated.

  • validation_error – A structured error with field and rule keys.

  • message_type – Bundled schema used for authoritative field limits.

Returns:

Candidate patches, or a structured cannot_autofix reason. Never proposes IBAN, BIC, account, amount or currency changes.

pain001.mcp.server.validate_payment_data(message_type: str, rows: list[dict[str, Any]]) → dict[str, Any][source]#

Validate payment rows against the message type’s schema (dry run).

Parameters:
  • message_type – The ISO 20022 message type.

  • rows – Payment rows as a list of dicts.

Returns:

A dict with is_valid, total_rows, valid_rows, and a list of errors (field, message). Raises ValueError for an unsupported message type.

pain001.mcp.server.validate_payment_scheme(rows: list[dict[str, Any]], profile: str = 'sepa-sct') → dict[str, Any][source]#

Validate rows against a payment-scheme rulebook (e.g. SEPA).

Parameters:
  • rows – Payment rows as a list of dicts.

  • profile – The scheme profile name (sepa-sct, sepa-sdd, sepa-b2b, sepa-inst, xborder-ct, or anti-duplicate), or several comma-separated to run them together.

Returns:

A dict with profile, is_valid, and structured violations (rule, message, field, remediation). Raises ValueError for an unknown profile.