Skip to main content
Glama

x402_fetch

Fetch URLs with automatic cryptocurrency payments when encountering HTTP 402 responses, returning both content and payment details.

Instructions

Fetch a URL with automatic x402 payment. If the server responds with HTTP 402, automatically sign a cryptocurrency payment and retry. Returns the response along with payment details if payment was made.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesTarget URL to fetch (HTTPS required)
methodNoHTTP method (default: GET)
headersNoAdditional HTTP headers
bodyNoRequest body string
wallet_idNoTarget wallet ID. Required for multi-wallet sessions; auto-resolved when session has a single wallet.

Implementation Reference

  • The handler function that processes the x402_fetch tool request by calling the apiClient.
    async (args) => {
      const requestBody: Record<string, unknown> = { url: args.url };
      if (args.method) requestBody['method'] = args.method;
      if (args.headers) requestBody['headers'] = args.headers;
      if (args.body) requestBody['body'] = args.body;
      if (args.wallet_id) requestBody['walletId'] = args.wallet_id;
      const result = await apiClient.post('/v1/x402/fetch', requestBody);
      return toToolResult(result);
    },
  • The schema definition for the x402_fetch tool arguments using Zod.
    {
      url: z.string().url().describe('Target URL to fetch (HTTPS required)'),
      method: z.enum(['GET', 'POST', 'PUT', 'DELETE', 'PATCH']).optional()
        .describe('HTTP method (default: GET)'),
      headers: z.record(z.string()).optional()
        .describe('Additional HTTP headers'),
      body: z.string().optional()
        .describe('Request body string'),
      wallet_id: z.string().optional().describe('Target wallet ID. Required for multi-wallet sessions; auto-resolved when session has a single wallet.'),
    },
  • The registration function that registers the x402_fetch tool with the McpServer.
    export function registerX402Fetch(
      server: McpServer,
      apiClient: ApiClient,
      walletContext?: WalletContext,
    ): void {
      server.tool(
        'x402_fetch',
        withWalletPrefix(
          'Fetch a URL with automatic x402 payment. If the server responds with HTTP 402, automatically sign a cryptocurrency payment and retry. Returns the response along with payment details if payment was made.',
          walletContext?.walletName,
        ),
        {
          url: z.string().url().describe('Target URL to fetch (HTTPS required)'),
          method: z.enum(['GET', 'POST', 'PUT', 'DELETE', 'PATCH']).optional()
            .describe('HTTP method (default: GET)'),
          headers: z.record(z.string()).optional()
            .describe('Additional HTTP headers'),
          body: z.string().optional()
            .describe('Request body string'),
          wallet_id: z.string().optional().describe('Target wallet ID. Required for multi-wallet sessions; auto-resolved when session has a single wallet.'),
        },
        async (args) => {
          const requestBody: Record<string, unknown> = { url: args.url };
          if (args.method) requestBody['method'] = args.method;
          if (args.headers) requestBody['headers'] = args.headers;
          if (args.body) requestBody['body'] = args.body;
          if (args.wallet_id) requestBody['walletId'] = args.wallet_id;
          const result = await apiClient.post('/v1/x402/fetch', requestBody);
          return toToolResult(result);
        },
      );
    }
Behavior4/5

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

No annotations provided, so description carries full burden. Discloses key behaviors: automatic signing of cryptocurrency payments, retry logic on 402 responses, and conditional return of payment details. Missing explicit warnings about irreversibility, gas costs, or failure modes if payment signing fails.

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

Conciseness5/5

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

Two sentences, zero waste. First sentence establishes capability, second details the unique x402 automation behavior and return value. Perfectly front-loaded with no redundancy.

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

Completeness4/5

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

Good coverage for a 5-parameter tool with no output schema: describes return values ('response along with payment details') and documents the x402 retry mechanism. Could improve by describing error scenarios or the specific payment token standard used.

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

Parameters3/5

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

Schema coverage is 100%, so baseline 3 is appropriate. Description implies URL and wallet usage through behavior explanation, but doesn't add syntax details beyond schema (e.g., no mention of body format expectations).

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

Purpose5/5

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

Excellent specific verb 'Fetch' + resource 'URL' + mechanism 'automatic x402 payment'. Clearly distinguishes from blockchain-only siblings (send_token, sign_message) by specifying HTTP fetching behavior.

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

Usage Guidelines3/5

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

Explains the automatic retry mechanism when receiving HTTP 402, which implies when to use (paid endpoints). However, lacks explicit 'when not to use' guidance or alternatives (e.g., don't use for free endpoints, or when to use standard fetch vs this).

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/minhoyoo-iotrust/WAIaaS'

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