Documentation
¶
Overview ¶
Command mcppay-client pays for an MCP tool call whose payment challenge arrives inline in the CallToolResult, rather than as an HTTP 402. Some MCP servers gate a tool this way: an unauthenticated call returns a {status:"payment_required", challenge:{x402:{...}}} result instead of a transport-level 402, and expect the signed credential back as a tool argument on retry. That's the MCP-tool-shaped counterpart to examples/x402stranger's HTTP-402 client; this one drives x402signer the same way, just against a different transport for the challenge/retry.
Usage:
MCP_ENDPOINT=http://127.0.0.1:8080/mcp \
MCP_API_KEY=<bearer token> \
X402_PRIVATE_KEY=<hex> \
go run ./examples/mcppay/client \
-tool account -arg action=buy_credits -arg pack=Starter
Pass -challenge-only to stop after the first call and print the payment_required result, without ever loading a key, signing, or paying. Useful for proving a merchant's challenge path (e.g. DCR registration) works without moving any money:
MCP_ENDPOINT=http://127.0.0.1:8080/mcp MCP_API_KEY=<bearer token> \
go run ./examples/mcppay/client -challenge-only \
-tool account -arg action=buy_credits -arg pack=Starter