Skip to content

feat(sell): add obol sell mcp — paid MCP tool over x402 in-band _meta#609

Closed
bussyjd wants to merge 2 commits into
mainfrom
feat/sell-mcp
Closed

feat(sell): add obol sell mcp — paid MCP tool over x402 in-band _meta#609
bussyjd wants to merge 2 commits into
mainfrom
feat/sell-mcp

Conversation

@bussyjd

@bussyjd bussyjd commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR does two things, both on the latest x402 SDK:

  1. Migrates the x402 Go SDK github.com/coinbase/x402/gogithubproxy.fjygbaifeng.eu.org/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 off main.
  2. Adds 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 (per specs/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 own examples/go/servers/mcp is a paid get_weather tool built with the same NewPaymentWrapper — 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 → settle runs 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 sell paths.

Commits

Scope

  • Code
  • Charts / manifests
  • Flows / QA scripts
  • Docs / skills
  • Images / dependencies — migrates x402 SDK to x402-foundation/x402/go; adds modelcontextprotocol/go-sdk v1.3.0
  • Other

Base branch: main

Implementation notes

  • internal/x402mcp/server.go — wraps a tool with x402-foundation/x402/go/mcp's PaymentWrapper over the official modelcontextprotocol/go-sdk. The paid tool (proxyTool) POSTs the buyer's tool arguments verbatim to --upstream and 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 free ping tool and /health.
  • cmd/obol/sell.gosell mcp subcommand: --pay-to / --price / --chain / --tool-name / --port / --upstream / --upstream-header (repeatable "Key: Value") / --description / --facilitator. Headline example fronts a weather API.
# Front a weather API as a paid MCP tool (the canonical x402 paid-MCP shape):
obol sell mcp weather --pay-to 0x... --price 0.001 --chain base-sepolia \
    --tool-name get_weather \
    --description 'Current weather for a city. Args: {city}' \
    --upstream https://your-weather-service/current

Validation

go build ./... clean; go test ./internal/x402/... ./internal/x402mcp/... ./internal/inference/... ./cmd/obol/... pass; go.sum clean of coinbase/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), Serve validation, CAIP-2 mapping, --upstream-header parsing, and result helpers.

@OisinKyne

Copy link
Copy Markdown
Contributor

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?

@bussyjd

bussyjd commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

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: examples/go/servers/mcp is a paid get_weather tool ($0.001, plus get_forecast at $0.005) next to a free ping, built with the same NewPaymentWrapper we use. That's the canonical paid MCP tool — pay per call, settle in-band, server returns the data. obol sell mcp is exactly that, with the upstream generalised: instead of a stub weather function it fronts a real backend service, so an agent gets metered, pay-per-call access to something it doesn't have its own account for.

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 paidTool, Coinbase's Bazaar auto-listing anything that settles a payment) and Stripe's MPP is the same bet with Anthropic/OpenAI on board — but early. A cheap bet on agent-native distribution, not a revenue line.

@bussyjd
bussyjd force-pushed the feat/sell-mcp branch 2 times, most recently from c9cb5e3 to 8cf2830 Compare June 9, 2026 12:36
@bussyjd
bussyjd changed the base branch from main to chore/bump-coinbase-x402-go June 9, 2026 12:37
bussyjd added 2 commits June 9, 2026 17:03
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.
@bussyjd

bussyjd commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

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.

@bussyjd bussyjd closed this Jun 10, 2026
@OisinKyne
OisinKyne deleted the feat/sell-mcp branch July 1, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants