MCPtslive · you pay per call

Paywall MCP tools, resources & prompts

A minimal MCP server exposing a weather.today tool, a weather://today resource and a weather.ensureCity prompt — all protected with credit-based access via the x402 v2 in-band MCP transport.

mcp-examples/weather-mcp/
1 What you'll learn

MCP says what an agent can do; Nevermined adds who can access it and how to charge.

  • Protect MCP tools, resources and prompts with a Nevermined paywall
  • Authenticate the MCP session with Authorization: Bearer and read payment in-band from _meta["x402/payment"]
  • Compute credits dynamically per request
  • Compare a high-level McpServer SDK build with a low-level JSON-RPC one
2 How it works

The MCP session is OAuth-protected: the client authenticates with an Authorization: Bearer access token, and the per-call payment is read in band from the MCP request _meta["x402/payment"]. A header-only payment (no _meta) still works as a deprecated fallback for one release.

Nevermined handles the Express server, sessions, OAuth discovery endpoints, credit checks and deduction — you expose the capability.

Bearer sessionOAuth
call tool_meta x402/payment
check + deductcredits
resultweather
3 Under the hood
TypeScriptModel Context Protocol@nevermined-io/payments ≥ 1.9Streamable HTTP
# the capabilities this server exposes
weather.today(city)        # tool
weather://today/{city}      # resource
weather.ensureCity          # prompt
src/main.tsMCP server with Nevermined Payments (withPaywall wrapper)
src/services/weather.service.tsweather data via Open-Meteo
RUN.mdsetup and running instructions
4 See it run
Paywall MCP tools, resources & prompts

Sandbox agent — real payment round-trips (402 → authorize → settle) with a per-session credit balance, no external service and no real money. Streamable-HTTP MCP, compatible with MCP Inspector; the sandbox runs the gated tool call locally. See the README to connect a hosted weather-mcp server.