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()
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It describes the creation action and the return format, but lacks details on permissions, rate limits, error handling, or whether the operation is idempotent. The example payload adds some context but doesn't fully compensate for the missing behavioral traits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core purpose, but includes a lengthy JSON example that could be condensed or referenced externally. The sentences are informative but the example takes up substantial space without adding proportional value to conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, 2 parameters with 0% schema coverage, no output schema, and nested objects, the description is partially complete. It explains the purpose, parameters, and return value, but lacks details on error cases, side effects, or integration context with sibling tools, leaving gaps for a mutation tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0% description coverage, so the description must compensate. It adds significant meaning by specifying the chain options ('base-sepolia or base') and providing a detailed example structure for 'x402_payload', which clarifies the expected format beyond the schema's generic 'object' type. However, it doesn't explain all possible fields or constraints for the payload.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Creates a payment header') and the resource ('for the X402 protocol'), which is specific and unambiguous. However, it doesn't explicitly differentiate this tool from its sibling tools like 'pay_offer' or 'payment_info', which might also involve payment-related operations, so it doesn't fully achieve sibling differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It mentions the chain options ('base-sepolia or base') and the payload structure, but doesn't specify prerequisites, when-not-to-use scenarios, or direct comparisons to sibling tools like 'pay_offer' or 'payment_info'.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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