paytriage
paytriage
支払いゲートウェイのエラーを読み取り、それが何を意味するか、次に何を確認すべきか、再試行が安全かどうかを教えてくれます。
ログ行、エラー文字列、ログファイル全体を指定できます。調べに行かなければならないコードではなく、平易な言葉で答えます。
依存関係なし。Python 3.8以上。CLI、ライブラリ、エージェントが呼び出せるMCPサーバーとして動作します。
なぜ
サポート担当者や実装担当者は、response_code="51" を「顧客のカードに残高がなかった、これはあなたのバグではない」に変換するのに多くの時間を費やしています。その変換は人々の頭の中や、ブックマークされたPDFに存在します。これを、読んで、grepして、修正できるファイルに置きます。
タイムアウトのケースが最も重要です。タイムアウトは拒否ではありません。取引はすでに相手側で承認されている可能性があるため、盲目的な再試行は二重請求の原因になります。paytriageはそのたびにそれを明確に伝えます。
Related MCP server: ErrorLens MCP
インストール
git clone https://github.com/Flyingmiata-droid/paytriage.git
cd paytriage
pip install -e .または、インストールをスキップして、python -m paytriage.cli でその場で実行します。
コマンドラインから使う
$ paytriage 'AUTH DECLINED response_code="51" insufficient funds'
[low] Insufficient funds (decline)
cause: The issuer declined the authorization because the account did not have
enough available balance or credit.
check: Nothing to fix on the integration side. Ask the cardholder to use
another card or retry later.
matched response code: 51
safe to retry: noファイル全体をまとめて:
$ paytriage -f examples/gateway.log --summary
lines: 11 matched: 9 unmatched: 2
by severity:
low: 2
medium: 3
high: 2
critical: 2
by signature:
decline.insufficient_funds: 1
transport.tls_handshake: 1
format.signature_mismatch: 1
...任意の呼び出しに --json を追加すると、機械可読な出力が得られます。
ライブラリとして使う
from paytriage import triage_line
result = triage_line("SSLError: handshake failure tlsv1 alert protocol version")
result.severity # "critical"
result.retryable # True
result.findings[0].label # "TLS handshake failure"
result.findings[0].fix # what to checkMCPサーバーとして使う
サーバーはstdio上でJSON-RPCを話し、triage_payment_error という1つのツールを公開するので、エージェントはエラーを渡して構造化された出力を得ることができます。
python -m paytriage.mcp_serverClaude DesktopまたはClaude Codeの設定:
{
"mcpServers": {
"paytriage": {
"command": "python",
"args": ["-m", "paytriage.mcp_server"]
}
}
}カバー範囲
6つのファミリーにわたる24のシグネチャ:
拒否: 残高不足、do not honor、有効期限切れカード、カード回収、無効な番号
検証: AVS不一致、CVV不一致
トランスポート: TLSハンドシェイク、証明書の有効期限切れまたは信頼できない、タイムアウト、接続拒否またはリセット、DNS
API: 401、403、429、5xx
メッセージ形式: XMLパース、JSONパース、署名またはHMAC不一致、必須フィールド欠落
ビジネスルール: 重複取引、未対応通貨、不正な金額、無効なトークン
マッチングは、レスポンスコードが存在する場合はそれに基づき、それ以外はパターンに基づきます。1行が複数のシグネチャにマッチすることがあり、結果は深刻度の高い順に返されます。
そうではないもの
不正検知スコアリングでも、リスクエンジンでもありません。
どのゲートウェイにも接続しません。既に持っているテキストを読み、ネットワーク呼び出しは行いません。
網羅的ではありません。これは一次トリアージのヘルパーです。特定のコードに関する権威は、依然として発行元自身のドキュメントです。
意思決定者ではありません。ここにあるものは、単独で支払いを自動再試行すべきではありません。
シグネチャの追加
すべては paytriage/signatures.py の1つのテーブルにあります。シグネチャは、パターンまたはコードのセットに加えて、原因、修正、深刻度です。エントリを追加し、テストを追加し、プルリクエストを開いてください。既存の文言の修正も、新しいエントリと同じくらい歓迎します。
テスト
python -m unittest discover -s tests -t .23テスト、ネットワークなし、ダウンロードするフィクスチャなし。
ライセンス
MIT。LICENSE を参照してください。
Available Tools
1 tooltriage_payment_errorA
Triage a payment gateway error string or log excerpt. Returns the likely cause, what to check next, a severity, and whether a retry is safe.
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | The error message, response body, or log excerpt. | |
| multiline | No | Treat the input as many log lines instead of one. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full transparency burden. It does disclose the core behavioral trait well by enumerating return values (cause, next steps, severity, retry safety). However, it never explicitly states the operation is non-destructive/read-only (only implied by 'triage') and says nothing about edge cases such as empty input, unrecognized formats, or whether triage is heuristic versus calling an external service.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two tight sentences with zero filler. The purpose is front-loaded first, then the return contract is enumerated. Every clause earns its place, and the length is proportionate to the tool's simplicity.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Since there is no output schema, the description correctly takes on the job of explaining return content, which it does thoroughly. Both parameters are covered by the schema, and complexity is low. The only minor gap: it could note the format expectation for text (e.g., an excerpt length limit or what 'multiline' affects) to further reduce ambiguity.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100% — both 'text' and 'multiline' are fully documented with type, requirement, and a description. The tool description's 'error string or log excerpt' roughly mirrors what the schema already says, adding only marginal enrichment (framing 'text' as an excerpt) rather than genuinely new meaning. Baseline 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb ('Triage') and resource ('payment gateway error string or log excerpt'), and enumerates exactly what it returns: likely cause, what to check next, severity, and retry safety. Though there are no siblings to distinguish from, the purpose is unambiguous and concrete.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The domain is clearly scoped to payment gateway error strings or log excerpts, which effectively conveys when to use it. With no sibling tools, there are no alternatives to exclude, but the 'when' is implicit rather than explicitly framed — no explicit statement like 'use when a payment fails with an unknown downstream reason'.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
1 tool update
v0.1.0- First observed
triage_payment_error
TDQS
Scored across 1 tool
With only one tool, there is no possibility of confusion or overlap. The tool's purpose is clearly singular and distinct.
The single tool 'triage_payment_error' follows a clear verb_noun pattern, consistent with best practices. No inconsistency exists in a one-tool set.
The tool count is at the thin end of the spectrum (1 tool), which feels minimal for a server, but the narrow scope of payment error triage makes it borderline acceptable.
The single tool fully addresses the stated purpose of triaging payment errors, providing cause, next steps, severity, and retry safety—no obvious gaps for this focused domain.
Maintenance
Related MCP Connectors
Payment identity intelligence for AI agents.
Pre-payment checks for AI agents: sanctions and AML screening of payees, payment pages and requests.
Machine-paid revenue intelligence, recovery decisions, and x402 routing for AI agents.
MCP diagnostics that help AI agents find safe next steps for HTTP, API, and MCP failures.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides AI-native fraud scoring, risk intelligence, and compliance tools for AI agents processing payments across multiple rails.MIT
- AlicenseNot gradedqualityBmaintenanceProvides structured error classification and recovery guidance for MCP agents, turning opaque failures into actionable retry and state information.17 npmMIT
- AlicenseNot gradedqualityDmaintenanceClassifies agent errors and provides clear recovery actions (retry, escalate) with configurable categories and strategies, plus MCP tools for direct agent use.8 npm1MIT

attest-mcpofficial
AlicenseAqualityDmaintenanceEnables AI agents to scan payment endpoints for safety, returning a letter grade (A–F) and verdict before authorizing payments.2109 npmMIT