Skip to main content
Glama

web3_subscribe

Subscribe to a paid data tier (build or pro) on Base network using USDC via x402 payment protocol.

Instructions

Subscribe to a paid tier (build or pro) using x402 USDC payment on Base.

TWO-STEP FLOW: Step 1: Call with just tier (omit payment_signature) → returns 402 with payment details (amount in micro-USDC, pay_to treasury address, network, asset_address). Step 2: Sign a USDC EIP-3009 transferWithAuthorization, build the x402 v2 payment payload, base64-encode it, and call again with payment_signature.

PAYMENT PAYLOAD FORMAT (x402 v2): The payment_signature must be a base64-encoded JSON string with this exact structure: { "x402Version": 2, "payload": { "signature": "0x<130+ hex chars — EIP-712 signature>", "authorization": { "from": "0x", "to": "0x<pay_to address from step 1>", "value": "<amount from step 1, as string e.g. '49000000'>", "validAfter": "0", "validBefore": "<unix timestamp ~1hr from now, as string>", "nonce": "0x<64 hex chars — 32 random bytes>" } } }

EIP-712 SIGNING: Domain: { name: 'USD Coin', version: '2', chainId: 8453, verifyingContract: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' } Type: TransferWithAuthorization(address from, address to, uint256 value, uint256 validAfter, uint256 validBefore, bytes32 nonce) Sign the typed data, then hex-encode the 65-byte signature with 0x prefix.

IMPORTANT: All values inside authorization (value, validAfter, validBefore) must be STRINGS, not numbers.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tierYesSubscription tier: 'build' ($49/mo) or 'pro' ($199/mo)
payment_signatureNoBase64-encoded x402 v2 payment payload JSON. Omit on first call to get pricing (402 response). On second call, provide base64(JSON) where JSON has: { "x402Version": 2, "payload": { "signature": "0x...", "authorization": { "from", "to", "value", "validAfter", "validBefore", "nonce" } } }. See tool description for full format.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataYesResult data object

Implementation Reference

  • src/index.ts:2237-2306 (registration)
    Registration of the web3_subscribe tool on the MCP server. Handles the x402 USDC payment flow on Base for subscribing to Build or Pro tiers. First call (without payment_signature) returns 402 with payment details; second call with the signed x402 payload completes the subscription.
    server.registerTool(
      "web3_subscribe",
      {
        description:
          "Subscribe to a paid tier (build or pro) using x402 USDC payment on Base.\n\n" +
          "TWO-STEP FLOW:\n" +
          "Step 1: Call with just tier (omit payment_signature) → returns 402 with payment details " +
          "(amount in micro-USDC, pay_to treasury address, network, asset_address).\n" +
          "Step 2: Sign a USDC EIP-3009 transferWithAuthorization, build the x402 v2 payment payload, " +
          "base64-encode it, and call again with payment_signature.\n\n" +
          "PAYMENT PAYLOAD FORMAT (x402 v2):\n" +
          "The payment_signature must be a base64-encoded JSON string with this exact structure:\n" +
          '{\n  "x402Version": 2,\n' +
          '  "payload": {\n' +
          '    "signature": "0x<130+ hex chars — EIP-712 signature>",\n' +
          '    "authorization": {\n' +
          '      "from": "0x<your wallet address>",\n' +
          '      "to": "0x<pay_to address from step 1>",\n' +
          '      "value": "<amount from step 1, as string e.g. \'49000000\'>",\n' +
          '      "validAfter": "0",\n' +
          '      "validBefore": "<unix timestamp ~1hr from now, as string>",\n' +
          '      "nonce": "0x<64 hex chars — 32 random bytes>"\n' +
          "    }\n  }\n}\n\n" +
          "EIP-712 SIGNING:\n" +
          "Domain: { name: 'USD Coin', version: '2', chainId: 8453, verifyingContract: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' }\n" +
          "Type: TransferWithAuthorization(address from, address to, uint256 value, uint256 validAfter, uint256 validBefore, bytes32 nonce)\n" +
          "Sign the typed data, then hex-encode the 65-byte signature with 0x prefix.\n\n" +
          "IMPORTANT: All values inside authorization (value, validAfter, validBefore) must be STRINGS, not numbers.",
        inputSchema: {
          tier: z.enum(["build", "pro"]).describe("Subscription tier: 'build' ($49/mo) or 'pro' ($199/mo)"),
          payment_signature: z.string().optional().describe(
            "Base64-encoded x402 v2 payment payload JSON. " +
            "Omit on first call to get pricing (402 response). " +
            "On second call, provide base64(JSON) where JSON has: " +
            '{ "x402Version": 2, "payload": { "signature": "0x...", "authorization": { "from", "to", "value", "validAfter", "validBefore", "nonce" } } }. ' +
            "See tool description for full format."
          ),
        },
        outputSchema: ObjectOutputSchema,
        annotations: AUTH_TOOL_ANNOTATIONS,
      },
      async (params: any) => {
        try {
          const headers: Record<string, string> = { "Content-Type": "application/json" };
          if (params.payment_signature) {
            headers["payment-signature"] = params.payment_signature;
          }
          const response = await fetch("https://api.0xarchive.io/v1/web3/subscribe", {
            method: "POST",
            headers,
            body: JSON.stringify({ tier: params.tier }),
          });
          const data = await response.json();
          if (response.status === 402) {
            // Expected first-step response with pricing info
            return formatResponse(data);
          }
          if (!response.ok) {
            return {
              content: [{ type: "text" as const, text: `Error: ${data.error || "Subscribe failed"}` }],
              isError: true,
            };
          }
          return formatResponse(data);
        } catch (err) {
          const error = err instanceof OxArchiveError ? err : new OxArchiveError(String(err), 500);
          return formatError(error);
        }
      }
    );
  • Input schema for web3_subscribe: requires a 'tier' enum (build/pro) and an optional 'payment_signature' string for the x402 v2 payload.
    inputSchema: {
      tier: z.enum(["build", "pro"]).describe("Subscription tier: 'build' ($49/mo) or 'pro' ($199/mo)"),
      payment_signature: z.string().optional().describe(
        "Base64-encoded x402 v2 payment payload JSON. " +
        "Omit on first call to get pricing (402 response). " +
        "On second call, provide base64(JSON) where JSON has: " +
        '{ "x402Version": 2, "payload": { "signature": "0x...", "authorization": { "from", "to", "value", "validAfter", "validBefore", "nonce" } } }. ' +
        "See tool description for full format."
      ),
    },
    outputSchema: ObjectOutputSchema,
    annotations: AUTH_TOOL_ANNOTATIONS,
  • Handler function for web3_subscribe. Makes a POST request to the 0xArchive subscribe API endpoint with the tier. If payment_signature is provided, it's sent as a header. Handles 402 response for first-step pricing and errors.
      async (params: any) => {
        try {
          const headers: Record<string, string> = { "Content-Type": "application/json" };
          if (params.payment_signature) {
            headers["payment-signature"] = params.payment_signature;
          }
          const response = await fetch("https://api.0xarchive.io/v1/web3/subscribe", {
            method: "POST",
            headers,
            body: JSON.stringify({ tier: params.tier }),
          });
          const data = await response.json();
          if (response.status === 402) {
            // Expected first-step response with pricing info
            return formatResponse(data);
          }
          if (!response.ok) {
            return {
              content: [{ type: "text" as const, text: `Error: ${data.error || "Subscribe failed"}` }],
              isError: true,
            };
          }
          return formatResponse(data);
        } catch (err) {
          const error = err instanceof OxArchiveError ? err : new OxArchiveError(String(err), 500);
          return formatError(error);
        }
      }
    );
Behavior5/5

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

The description goes far beyond the sparse annotations (which only indicate non-readonly, non-destructive, non-idempotent, open-world). It details the HTTP 402 response, payment payload format, EIP-712 signing, and the two-step interaction. No contradictions with annotations.

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

Conciseness4/5

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

The description is well-structured with clear section headers (TWO-STEP FLOW, PAYMENT PAYLOAD FORMAT, EIP-712 SIGNING, IMPORTANT). It is front-loaded with the purpose. While long, every section is necessary given the complexity of the payment flow, making it appropriately concise for its informational density.

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

Completeness5/5

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

Given the complexity of the tool (two-step payment, signing, etc.) and that an output schema exists (so return values need not be detailed), the description covers all necessary aspects: the flow, payload format, signing details, and important constraints. It is comprehensive and leaves no ambiguity.

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?

Schema coverage is 100% and schema descriptions include pricing for tier and a brief note for payment_signature. The tool description adds substantial value by providing the full payload structure, signing instructions, and critical data type constraints (values must be strings), which goes beyond the schema.

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?

The description clearly states the tool's purpose: 'Subscribe to a paid tier (build or pro) using x402 USDC payment on Base.' It specifies the action (subscribe), the resource (paid tier), and the method. This clearly distinguishes it from sibling tools, which are predominantly data retrieval tools.

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

Usage Guidelines4/5

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

The description explicitly outlines a two-step flow: step 1 (call with only tier) and step 2 (call with payment_signature). It provides clear instructions on when to omit or include parameters. Although it does not explicitly state when not to use the tool, the context is sufficient given the exclusive nature of subscription among siblings.

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/0xArchiveIO/0xarchive-mcp'

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