From 00e0e6ad58e6275f5f6b79cb5c516f1c974cef39 Mon Sep 17 00:00:00 2001 From: acedata-bot Date: Sun, 10 May 2026 02:17:11 -0700 Subject: [PATCH] fix(mcp): use scheme="exact" in X-Payment envelope (was "solana") MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The aceguard_pay_for_api MCP tool was constructing the X-Payment envelope with scheme="solana", but FacilitatorX402 (the upstream that api.acedata.cloud routes to) is x402-spec compliant: its multichain view matches on (scheme="exact", network=), not on scheme=. In practice this means every aceguard_pay_for_api call would loop on 402 even after a successful on-chain agent_vault.spend() — the policy check, SPL transfer, and tx signature were all real, but the facilitator rejected the envelope as an unrecognized scheme and returned 402 again, making the agent see the call as "payment failed" with no way to debug. Fix: scheme: "solana" -> scheme: "exact". Wire-format alignment with @acedatacloud/x402-client (typescript/scripts/test-solana-e2e.ts:172) and the AceDataCloud Python SDK payment_handler that downstream demos will plug into. payload.signature stays the same — facilitator solana_chain.py:_extract_signature accepts {payload: {signature: }} exactly. No test added: this code path requires a real on-chain spend + live facilitator round-trip; covered by the manual demo in scripts/ (next PR). --- api/routes/mcp.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/api/routes/mcp.py b/api/routes/mcp.py index 6c53ad5..7dfe399 100644 --- a/api/routes/mcp.py +++ b/api/routes/mcp.py @@ -338,12 +338,14 @@ async def _tool_pay_for_api( ) # Construct an X-Payment header that the facilitator understands. - # AceDataCloud's facilitator accepts - # `{"x402Version":1,"scheme":"solana","network":"solana","payload":{"signature":""}}` - # base64-encoded as a single header value. + # The facilitator (FacilitatorX402) is x402-spec compliant: it matches + # `scheme="exact"` + `network="solana"` and reads the on-chain tx + # signature out of `payload.signature`. See + # https://github.com/AceDataCloud/FacilitatorX402 (`solana_chain.py + # ::_extract_signature`). envelope = { "x402Version": 1, - "scheme": "solana", + "scheme": "exact", "network": "solana", "payload": {"signature": result.tx_signature}, }