Skip to main content
Key0 exposes two tools via the Model Context Protocol (MCP) when mcp: 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

Returns the MCP server metadata and transport URL.

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

Response:

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

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.
Response:
The content[0].text includes additional fields for MCP clients:

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.
Response:
The _meta["x402/payment-response"] contains the settlement receipt per the x402 MCP transport spec.

Idempotency

For the request_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 from request_access are returned as isError: true results:
  • Plan not found: Returns a standard Key0 error JSON in content[0].text.
  • Payment failed: Returns isError: true with structuredContent containing the original payment requirements plus the specific failure reason.
  • Already redeemed: Returns the cached AccessGrant directly (not an error).

Transport Notes

  • The MCP server runs in stateless mode — a new server instance is created per request.
  • GET /mcp returns HTTP 405 (SSE not supported in stateless mode).
  • DELETE /mcp returns HTTP 405 (session management not supported in stateless mode).
  • The Accept header should include application/json, text/event-stream for compatibility with Streamable HTTP.

MCP Integration

Setup guide for enabling MCP alongside A2A endpoints.

Claude Code Integration

How to connect Claude Code to a Key0 MCP seller.

Data Models

TypeScript types for all protocol messages used by MCP tools.