feat(sell): add obol sell mcp — paid MCP tool over x402 in-band _meta#609
feat(sell): add obol sell mcp — paid MCP tool over x402 in-band _meta#609bussyjd wants to merge 2 commits into
obol sell mcp — paid MCP tool over x402 in-band _meta#609Conversation
|
Walk me through this. Someone else is going to find the mcp, add it, and their agent is going to decide when to pay for it? what paid mcp tools exist in the wild? what examples of MCP x x402 are out there at the moment? i'm not convinced theres moat in paid tools, but if its just a different type of discovery that's not a massive transition. What tools are you paying for/is anyone paying for? |
|
Reworked the example off the back of this. You're right that paying for inference over MCP is pointless and a bad example. The one I should've pointed at is in the x402 repo itself: On the moat: agreed, there's none at the protocol layer — it's standardised discovery + auth. The durable bit is the wrapped capability and aggregating demand — fronting one backend for many agents — not the transport. Paying today? Basically no — ~$28k/day on Base, ~$0.20 average, half of it tests. Real endpoints exist (Firecrawl/Exa, Cloudflare's |
c9cb5e3 to
8cf2830
Compare
Module-path migration (not a version bump): the SDK renamed its path in the post-2026-03-31 releases. `github.com/coinbase/x402/go` → `github.com/x402-foundation/x402/go` @ v0.0.0-20260529172747; the foundation module is the maintained path (and where new schemes land). Pure path swap of the single `.../go/types` import across the tree; types API unchanged. Unlocks the upto + batch-settlement schemes already shipped under mechanisms/evm/. Folded in from #613 so this branch is self-contained on the latest module.
Runs a local x402-paid MCP (Model Context Protocol) server. The paid tool forwards the buyer's JSON arguments to a backend HTTP service and returns the response, so any real service can be resold to agents per call. Buyers settle in-band via the MCP request _meta["x402/payment"] field (per specs/transports-v2/mcp.md); verify -> execute -> settle runs inside the tool call, so a caller is never charged for a failed tool. Mirrors the canonical x402 paid-MCP example (a paid get_weather tool), generalising the upstream from a stub to a real backend. - internal/x402mcp: PaymentWrapper over the official modelcontextprotocol/go-sdk; proxyTool forwards args (+ optional backend auth header, set server-side, never sent to buyers) and returns the service response; free ping tool + /health. - cmd/obol/sell.go: `sell mcp` subcommand (--pay-to/--price/--chain/--tool-name/ --port/--upstream/--upstream-header/--description/--facilitator). Uses the x402-foundation/x402/go SDK.
|
Superseded by the v0.10.0-rc14 release train: #616 — this PR's branch is merged there verbatim (merge commit preserved, full union build + test green). Closing in favor of the consolidated release PR. |
Summary
This PR does two things, both on the latest x402 SDK:
github.com/coinbase/x402/go→github.com/x402-foundation/x402/go(the maintained module path) — folded in from chore(deps): migrate x402 SDK to x402-foundation/x402/go (unlocks upto + batch-settlement) #613, so this branch is self-contained offmain.obol sell mcp— runs a local x402-paid MCP (Model Context Protocol) server. The paid tool forwards the buyer's JSON arguments to a backend HTTP service and returns the response, so any real service can be resold to agents per call. Buyers settle in-band via the MCP request_meta["x402/payment"]field (perspecs/transports-v2/mcp.md).Why it matters: the MCP server is the application-layer counterpart to the HTTP-402 ForwardAuth gate used by
obol sell inference/obol sell http. It mirrors the canonical x402 paid-MCP example — the x402 repo's ownexamples/go/servers/mcpis a paidget_weathertool built with the sameNewPaymentWrapper— except the upstream is generalised from a stub to a real backend. The point is not "pay for inference over MCP" (an agent would just call an inference endpoint directly); it's metered, pay-per-call access to a service an agent doesn't have its own account for.verify → execute → settleruns inside the tool call, so a caller is never charged for a failed tool.Risk level: low — the migration is a pure module-path swap (types API unchanged); the MCP server is a new, opt-in subcommand with no change to existing
sellpaths.Commits
chore(deps): migrate x402 SDK coinbase/x402/go → x402-foundation/x402/go— folded in from chore(deps): migrate x402 SDK to x402-foundation/x402/go (unlocks upto + batch-settlement) #613 (chore(deps): migrate x402 SDK to x402-foundation/x402/go (unlocks upto + batch-settlement) #613 is superseded by this PR).feat(sell): add obol sell mcp — paid MCP tool over x402 in-band _meta.Scope
x402-foundation/x402/go; addsmodelcontextprotocol/go-sdk v1.3.0Base branch: main
Implementation notes
internal/x402mcp/server.go— wraps a tool withx402-foundation/x402/go/mcp'sPaymentWrapperover the officialmodelcontextprotocol/go-sdk. The paid tool (proxyTool) POSTs the buyer's tool arguments verbatim to--upstreamand returns the service response; the backend's own auth header (if any) is passed via--upstream-header, set server-side and never sent to buyers. Serves streamable HTTP at/mcp, plus a freepingtool and/health.cmd/obol/sell.go—sell mcpsubcommand:--pay-to / --price / --chain / --tool-name / --port / --upstream / --upstream-header (repeatable "Key: Value") / --description / --facilitator. Headline example fronts a weather API.Validation
go build ./...clean;go test ./internal/x402/... ./internal/x402mcp/... ./internal/inference/... ./cmd/obol/...pass;go.sumclean ofcoinbase/x402. MCP tests cover the upstream proxy (arg forwarding + backend-auth-header injection + service-response passthrough, modeled on a weather backend; upstream error; missing upstream),Servevalidation, CAIP-2 mapping,--upstream-headerparsing, and result helpers.