Skip to main content
Glama
Fewsats

Fewsats MCP Server

Official
by Fewsats

create_x402_payment_header

Generate X-PAYMENT headers for X402 protocol requests to process payments on Base or Base-Sepolia networks.

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 handler function for the 'create_x402_payment_header' tool. It is registered via @mcp.tool() decorator and implements the logic by calling Fewsats().pay_x402_offer(x402_payload, chain) wrapped in 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 docstring provides the input schema example for 'x402_payload' dictionary and describes the parameters 'chain' and the expected output format.
    """
    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.
    """
  • The @mcp.tool() decorator registers the create_x402_payment_header function as an MCP tool.
    @mcp.tool()

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