Skip to main content
Glama
Fewsats

Fewsats MCP Server

Official
by Fewsats

create_x402_payment_header

Generates a payment header for the X402 protocol required in HTTP requests, specifying payment details such as asset, amount, and network for processing on the Fewsats MCP Server.

Instructions

Creates a payment header for the X402 protocol. The chain is base-sepolia or base The x402 payload must be a dict with this structure: { "accepts": [ { "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e", "description": "Payment for GET https://proxy402.com/7Yhuf2O3zs", "extra": { "name": "USDC", "version": "2" }, "maxAmountRequired": "10", "maxTimeoutSeconds": 300, "mimeType": "", "network": "base-sepolia", "payTo": "0xbA5Ae80f48E0C74878c1a362D69c27c2135Aa594", "resource": "https://proxy402.com/7Yhuf2O3zs", "scheme": "exact" } ], "error": "X-PAYMENT header is required", "x402Version": 1 } Returns a dict with the payment_header field that must be set in X-PAYMENT header in a x402 http request.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chainYes
x402_payloadYes

Implementation Reference

  • The main handler function for the 'create_x402_payment_header' tool, decorated with @mcp.tool() for automatic registration in FastMCP. It takes chain and x402_payload as inputs, describes the expected payload structure in the docstring (serving as schema), and delegates to Fewsats.pay_x402_offer, wrapping the response with handle_response.
    @mcp.tool() async def create_x402_payment_header(chain: str, x402_payload: dict) -> dict: """ Creates a payment header for the X402 protocol. The chain is base-sepolia or base The x402 payload must be a dict with this structure: { "accepts": [ { "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e", "description": "Payment for GET https://proxy402.com/7Yhuf2O3zs", "extra": { "name": "USDC", "version": "2" }, "maxAmountRequired": "10", "maxTimeoutSeconds": 300, "mimeType": "", "network": "base-sepolia", "payTo": "0xbA5Ae80f48E0C74878c1a362D69c27c2135Aa594", "resource": "https://proxy402.com/7Yhuf2O3zs", "scheme": "exact" } ], "error": "X-PAYMENT header is required", "x402Version": 1 } Returns a dict with the payment_header field that must be set in X-PAYMENT header in a x402 http request. """ return handle_response(Fewsats().pay_x402_offer(x402_payload, chain))
  • The @mcp.tool() decorator registers the create_x402_payment_header function as an MCP tool.
    @mcp.tool()
  • Type hints (chain: str, x402_payload: dict -> dict) and detailed docstring describing the input payload structure and output.
    async def create_x402_payment_header(chain: str, x402_payload: dict) -> dict: """ Creates a payment header for the X402 protocol. The chain is base-sepolia or base The x402 payload must be a dict with this structure: { "accepts": [ { "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e", "description": "Payment for GET https://proxy402.com/7Yhuf2O3zs", "extra": { "name": "USDC", "version": "2" }, "maxAmountRequired": "10", "maxTimeoutSeconds": 300, "mimeType": "", "network": "base-sepolia", "payTo": "0xbA5Ae80f48E0C74878c1a362D69c27c2135Aa594", "resource": "https://proxy402.com/7Yhuf2O3zs", "scheme": "exact" } ], "error": "X-PAYMENT header is required", "x402Version": 1 } Returns a dict with the payment_header field that must be set in X-PAYMENT header in a x402 http request. """ return handle_response(Fewsats().pay_x402_offer(x402_payload, chain))

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Fewsats/fewsats-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server