Skip to main content
Glama

x402_balance

Check your AgentCash USDC wallet balance on Base to see available funds for x402 payments and estimate how many calls you can make. If not set up, get instructions to create and fund a wallet.

Instructions

Check your AgentCash USDC wallet balance on Base.

Returns current balance available for x402 payments and approximate number of calls you can afford. No parameters required.

If AgentCash is not set up, provides instructions to create and fund a wallet.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Tool definition and input schema for x402_balance. Defines the tool name, description, and empty inputSchema (no parameters required).
      {
        name: 'x402_balance',
        description: `Check your AgentCash USDC wallet balance on Base.
    
    Returns current balance available for x402 payments and approximate number of 
    calls you can afford. No parameters required.
    
    If AgentCash is not set up, provides instructions to create and fund a wallet.`,
        inputSchema: {
          type: 'object',
          properties: {},
          required: [],
        },
      },
  • cli.js:534-557 (handler)
    Handler function handleBalance() that executes the x402_balance tool logic. Calls getBalance() which invokes 'agentcash balance --format json', formats the response showing USDC balance and estimated number of calls.
    async function handleBalance() {
      const result = await getBalance();
    
      if (!result.success) {
        return {
          content: [{
            type: 'text',
            text: `Could not check balance: ${result.error}\n\nTo set up AgentCash:\n1. Run: npx agentcash install\n2. Fund at https://agentcash.dev/deposit`,
          }],
          isError: true,
        };
      }
    
      const balance = result.data.balance ?? result.data.raw ?? 'unknown';
      const numBalance = Number(balance);
      const callEstimate = isNaN(numBalance) ? '?' : Math.floor(numBalance / 0.12);
    
      return {
        content: [{
          type: 'text',
          text: `AgentCash balance: $${balance} USDC on Base\nApproximately ${callEstimate} calls at $0.12/call.`,
        }],
      };
    }
  • getBalance() helper function that wraps agentcashExec to call 'agentcash balance --format json' and parse the result.
    async function getBalance() {
      return agentcashExec('balance --format json');
    }
  • cli.js:678-696 (registration)
    Registration of the x402_balance tool in the MCP server's CallToolRequestSchema handler. Routes the tool name 'x402_balance' to the handleBalance() function.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: args } = request.params;
    
      switch (name) {
        case 'x402_discover':
          return handleDiscover(args);
        case 'x402_call':
          return handleCall(args);
        case 'x402_balance':
          return handleBalance();
        case 'x402_research':
          return handleResearch(args);
        default:
          return {
            content: [{ type: 'text', text: `Unknown tool: ${name}. Available: x402_discover, x402_call, x402_balance, x402_research` }],
            isError: true,
          };
      }
    });
Behavior4/5

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

No annotations provided, so description carries full burden. It accurately describes the read-only behavior, the information returned, and the fallback for unset wallets. No contradictions or hidden side effects noted.

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?

Three sentences, each providing essential info: purpose, return details, and fallback. No redundancy, perfectly front-loaded.

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?

For a simple balance check tool with no output schema, description covers all needed aspects: what it does, what it returns, and what happens if setup is missing. Context is fully complete.

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?

Zero parameters and schema coverage 100%. Description reiterates no parameters are required, which adds no new info but is consistent. Baseline 4 is appropriate for zero-parameter tools.

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 specifies the tool checks the AgentCash USDC wallet balance on Base, detailing what is returned (balance and approximate call count). It clearly distinguishes itself from siblings like x402_call (which likely makes payments) and x402_discover.

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 states no parameters are needed and mentions setup instructions if missing. It implicitly conveys when to use (when you need balance info), but does not explicitly discuss when not to use or provide alternatives.

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/8randonpickart5/x402-buyer-mcp'

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