Problem
Endpoints with dynamic pricing that depend on request body content (e.g. agentcash.dev/api/send) fail to register because the probe sends an empty request and gets a 500 instead of a 402.
$ curl -X POST https://agentcash.dev/api/send
{"success":false,"error":"x402 challenge build failed: Recipient address is required"}
The payment middleware needs fields like address to build the 402 challenge, so it can't respond with a valid payment challenge when probed empty.
Meanwhile, @agentcash/discovery correctly identifies the endpoint from the OpenAPI spec:
{
"method": "POST",
"source": "openapi",
"authMode": "paid",
"estimatedPrice": "0-10000 USD",
"protocols": ["x402"],
"inputSchema": {
"properties": {
"amount": { "type": "number", "exclusiveMinimum": 0 },
"address": { "type": "string", "minLength": 1 },
"network": { "type": "string", "enum": ["base", "tempo", "solana"] }
},
"required": ["amount", "address", "network"]
}
}
Root cause
registerResourcesFromDiscovery always calls probeX402Endpoint() which requires a live 402 response. When the probe gets a non-402 status (500 in this case), it returns "No valid x402 response found" and the resource is counted as failed.
Proposed fix
When the probe fails but the discovery source is "openapi" and the endpoint has authMode: "paid" with protocols: ["x402"], allow registration using the OpenAPI metadata alone — the pricing info from x-payment-info and the input schema are sufficient to render the resource in the UI without a live 402 body.
Affected endpoints
Any dynamic-priced endpoint where the 402 challenge requires request body content:
agentcash.dev/api/send (needs address to build challenge)
- Likely others with body-dependent pricing
🤖 Generated with Claude Code
Problem
Endpoints with dynamic pricing that depend on request body content (e.g.
agentcash.dev/api/send) fail to register because the probe sends an empty request and gets a 500 instead of a 402.The payment middleware needs fields like
addressto build the 402 challenge, so it can't respond with a valid payment challenge when probed empty.Meanwhile,
@agentcash/discoverycorrectly identifies the endpoint from the OpenAPI spec:{ "method": "POST", "source": "openapi", "authMode": "paid", "estimatedPrice": "0-10000 USD", "protocols": ["x402"], "inputSchema": { "properties": { "amount": { "type": "number", "exclusiveMinimum": 0 }, "address": { "type": "string", "minLength": 1 }, "network": { "type": "string", "enum": ["base", "tempo", "solana"] } }, "required": ["amount", "address", "network"] } }Root cause
registerResourcesFromDiscoveryalways callsprobeX402Endpoint()which requires a live 402 response. When the probe gets a non-402 status (500 in this case), it returns"No valid x402 response found"and the resource is counted as failed.Proposed fix
When the probe fails but the discovery source is
"openapi"and the endpoint hasauthMode: "paid"withprotocols: ["x402"], allow registration using the OpenAPI metadata alone — the pricing info fromx-payment-infoand the input schema are sufficient to render the resource in the UI without a live 402 body.Affected endpoints
Any dynamic-priced endpoint where the 402 challenge requires request body content:
agentcash.dev/api/send(needsaddressto build challenge)🤖 Generated with Claude Code