Skip to main content
Glama
clawallex

Clawallex MCP Server

by clawallex

refill_card

Refill a virtual payment card with USDC stablecoin funds for online checkouts. Supports two payment modes: Mode A uses client request ID for idempotency, while Mode B requires EIP-3009 authorization signing for direct wallet transfers.

Instructions

Advanced: refill a stream card with full control over payment mode. Maps directly to POST /payment/cards/:card_id/refill. Refill mode follows the card's creation mode (cannot switch mid-life).

Mode A: client_request_id as idempotency key. Mode B: no 402 challenge — caller signs the EIP-3009 authorization independently. Step 1: call get_x402_payee_address to get payee_address for payment_requirements.payTo. Step 2: sign EIP-3009 transferWithAuthorization using your own wallet/signing library. Step 3: submit with x402_reference_id as idempotency key + payment_payload (signature + wallet address) + payment_requirements.

Only cards created by this agent (same client_id) can be refilled.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
card_idYesStream card ID to refill, e.g. 'c_123'
amountYesRefill amount in USD, decimal string e.g. '30.0000'
client_request_idNoUUID idempotency key — REQUIRED for Mode A. Omitting on a Mode A card will cause the server to reject the request. Reuse the same UUID to retry safely without double-charging.
x402_reference_idNox402 reference ID. Card creation Stage 1: optional (server generates if omitted). Stage 2: use value from 402 response. Refill Mode B: required, serves as idempotency key.
x402_versionNox402 version (Mode B Stage 2, required)
payment_payloadNox402 payment payload (Mode B Stage 2, required)
payment_requirementsNox402 payment requirements (Mode B Stage 2, required)
payer_addressNoPayer wallet address (optional, final value from verify)

Implementation Reference

  • The handler function for the refill_card tool, which constructs the request body and calls the ClawallexClient post method to initiate a card refill.
    async (params) => {
      try {
        const body: Record<string, unknown> = {
          amount: params.amount,
        };
        if (params.client_request_id !== undefined) body.client_request_id = params.client_request_id;
        if (params.x402_reference_id !== undefined) body.x402_reference_id = params.x402_reference_id;
        if (params.x402_version !== undefined) body.x402_version = params.x402_version;
        if (params.payment_payload !== undefined) body.payment_payload = params.payment_payload;
        if (params.payment_requirements !== undefined) body.payment_requirements = params.payment_requirements;
        if (params.payer_address !== undefined) body.payer_address = params.payer_address;
    
        const result = await client.post<unknown>(
          `/payment/cards/${params.card_id}/refill`,
          body,
        );
        return toolOk(result);
      } catch (err) {
        return toolError(err);
      }
    },
  • Registration of the refill_card tool, including schema validation definitions.
    server.tool(
      "refill_card",
      [
        "Advanced: refill a stream card with full control over payment mode.",
        "Maps directly to POST /payment/cards/:card_id/refill.",
        "Refill mode follows the card's creation mode (cannot switch mid-life).",
        "",
        "Mode A: client_request_id as idempotency key.",
        "Mode B: no 402 challenge — caller signs the EIP-3009 authorization independently.",
        "  Step 1: call get_x402_payee_address to get payee_address for payment_requirements.payTo.",
        "  Step 2: sign EIP-3009 transferWithAuthorization using your own wallet/signing library.",
        "  Step 3: submit with x402_reference_id as idempotency key + payment_payload (signature + wallet address) + payment_requirements.",
        "",
        "Only cards created by this agent (same client_id) can be refilled.",
      ].join("\n"),
      {
        card_id: z.string().describe("Stream card ID to refill, e.g. 'c_123'"),
        amount: z.string().describe("Refill amount in USD, decimal string e.g. '30.0000'"),
        client_request_id: z
          .string()
          .max(64)
          .describe(
            "UUID idempotency key — REQUIRED for Mode A. Omitting on a Mode A card will cause the server to reject the request. Reuse the same UUID to retry safely without double-charging.",
          )
          .optional(),
        ...x402Fields,
      },
      async (params) => {
        try {
          const body: Record<string, unknown> = {
            amount: params.amount,
          };
          if (params.client_request_id !== undefined) body.client_request_id = params.client_request_id;
          if (params.x402_reference_id !== undefined) body.x402_reference_id = params.x402_reference_id;
          if (params.x402_version !== undefined) body.x402_version = params.x402_version;
          if (params.payment_payload !== undefined) body.payment_payload = params.payment_payload;
          if (params.payment_requirements !== undefined) body.payment_requirements = params.payment_requirements;
          if (params.payer_address !== undefined) body.payer_address = params.payer_address;
    
          const result = await client.post<unknown>(
            `/payment/cards/${params.card_id}/refill`,
            body,
          );
          return toolOk(result);
        } catch (err) {
          return toolError(err);
        }
      },
    );
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: idempotency via UUID reuse 'to retry safely without double-charging', rejection condition 'Omitting on a Mode A card will cause the server to reject', and state constraint that modes cannot be switched mid-life. Minor gap: does not describe success response format or explicit side effects (e.g., balance update timing).

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?

Excellent structure with zero waste. Front-loaded with 'Advanced: refill...' statement. Clear visual separation of Mode A vs Mode B using headers and numbered steps. Every sentence conveys critical workflow, constraint, or API mapping information. Appropriate length for complexity (8 parameters, 2 distinct modes).

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?

Very complete for complex tool with nested objects and multi-stage workflow. Covers prerequisites (get_x402_payee_address), authorization requirements (EIP-3009 signing), and ownership constraints (same client_id). Minor gap: no output schema exists and description does not specify return value structure or success indicators, though API endpoint mapping provides partial context.

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 has 100% coverage (baseline 3). Description adds significant orchestration context: maps parameters to modes (Mode A: client_request_id; Mode B: x402_* fields), provides 3-step workflow for Mode B explaining parameter relationships ('payment_payload (signature + wallet address)'), and clarifies that x402_reference_id serves as idempotency key in Mode B despite different parameter name.

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?

Description uses specific verb 'refill' with resource 'stream card' and explicitly maps to API endpoint 'POST /payment/cards/:card_id/refill'. The 'Advanced:' prefix and detailed mode differentiation (A vs B) clearly distinguish this from sibling tool 'clawallex_refill'. The constraint 'Only cards created by this agent' further clarifies scope.

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

Usage Guidelines5/5

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

Provides explicit when-to-use guidance: 'Refill mode follows the card's creation mode (cannot switch mid-life)'. Details Mode A (client_request_id) vs Mode B (EIP-3009 signing) workflows. References sibling tool 'get_x402_payee_address' as prerequisite for Mode B. Explains idempotency retry behavior for safe usage.

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/clawallex/clawallex-mcp'

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