MCP Tools
Key0 exposes two tools via the Model Context Protocol (MCP) whenmcp: true is set in SellerConfig. These tools are available over the Streamable HTTP transport at POST /mcp.
MCP discovery is at GET /.well-known/mcp.json.
Discovery Endpoint
Tool: discover_plans
A free tool that returns the full plan catalog with pricing, wallet address, and chain ID. No payment required.Input Schema
This tool takes no input parameters.Output
Returns a JSON object with the plan catalog:Example with curl
Tool: request_access
The payment-gated tool. When called without a payment in_meta, it returns an x402 PaymentRequired signal. When called with an _meta["x402/payment"] payload, it settles the payment and returns an AccessGrant.
Input Schema
| Parameter | Type | Required | Description |
|---|---|---|---|
planId | string | Yes | Plan ID from discover_plans. |
resourceId | string | No | Specific resource identifier. Defaults to "default". |
Case 1: No Payment (PaymentRequired Response)
When called without_meta["x402/payment"], the tool returns isError: true with a structuredContent object containing x402 payment requirements.
content[0].text includes additional fields for MCP clients:
| Field | Description |
|---|---|
x402PaymentUrl | The URL to POST to with PAYMENT-SIGNATURE header (e.g., https://api.example.com/x402/access). |
paymentInstructions | Human-readable instructions for completing payment via make_http_request_with_x402. |
Case 2: With Payment (AccessGrant Response)
When called with_meta["x402/payment"] containing an EIP-3009 signed authorization, the tool settles the payment on-chain and returns the access grant.
_meta["x402/payment-response"] contains the settlement receipt per the x402 MCP transport spec.
Idempotency
For therequest_access tool, the requestId is deterministically derived from the payment signature using SHA-256. This means retrying the same payment payload produces the same requestId, enabling idempotent recovery. If the grant was already delivered, the cached grant is returned without re-settling.
Error Handling
Errors fromrequest_access are returned as isError: true results:
- Plan not found: Returns a standard Key0 error JSON in
content[0].text. - Payment failed: Returns
isError: truewithstructuredContentcontaining the original payment requirements plus the specific failure reason. - Already redeemed: Returns the cached
AccessGrantdirectly (not an error).
Transport Notes
- The MCP server runs in stateless mode — a new server instance is created per request.
GET /mcpreturns HTTP 405 (SSE not supported in stateless mode).DELETE /mcpreturns HTTP 405 (session management not supported in stateless mode).- The
Acceptheader should includeapplication/json, text/event-streamfor compatibility with Streamable HTTP.

