Skip to main content
Glama
localseodata

Local SEO Data

Official

get_balance

Read-only

Check your current credit balance, daily spending cap, and plan info before starting any multi-step analysis to understand available budget.

Instructions

Check the user's current credit balance. Returns credits remaining, daily spending cap, and plan info. Always call this FIRST before starting any multi-step analysis to understand the budget available. Costs 0 credits (free).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler for get_balance. Calls GET /v1/account/balance via callApiGet and returns formatted balance data.
      withErrorHandling(async () => {
        const result = await callApiGet("/v1/account/balance", getAuth());
        return { content: [{ type: "text" as const, text: formatResult(result.data, result) }] };
      })
    );
  • The registerAccountTools function that registers the 'get_balance' tool on the MCP server with its description, empty schema, and readOnly hint.
    export function registerAccountTools(server: McpServer, getAuth: () => string) {
      server.tool(
        "get_balance",
        "Check the user's current credit balance. Returns credits remaining, daily spending cap, and plan info. Always call this FIRST before starting any multi-step analysis to understand the budget available. Costs 0 credits (free).",
        {},
        READ_ONLY,
        withErrorHandling(async () => {
          const result = await callApiGet("/v1/account/balance", getAuth());
          return { content: [{ type: "text" as const, text: formatResult(result.data, result) }] };
        })
      );
    }
  • The callApiGet helper used by get_balance to make the GET request to the balance API endpoint.
    export async function callApiGet(
      path: string,
      authHeader: string
    ): Promise<{ data: unknown; credits_used: number; credits_remaining: number; cached: boolean }> {
      const url = `${env.API_BASE_URL}${path}`;
    
      console.log(`[api] GET ${url} (auth: ${authHeader ? `${authHeader.slice(0, 15)}...` : "MISSING"})`);
    
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: authHeader,
        },
        signal: AbortSignal.timeout(60_000),
      });
    
      if (!response.ok) {
        const text = await response.text();
        console.error(`[api] ${response.status} ${response.statusText} from ${path}: ${text.slice(0, 200)}`);
        throw new Error(`API returned ${response.status}: ${text.slice(0, 200)}`);
      }
    
      const result = (await response.json()) as ApiResponse;
    
      if (result.status === "error") {
        throw new Error(result.error.message);
      }
    
      console.log(`[api] ${path} OK (${result.credits_used} credits used, ${result.credits_remaining} remaining)`);
    
      return {
        data: result.data,
        credits_used: result.credits_used,
        credits_remaining: result.credits_remaining,
        cached: result.cached,
      };
    }
  • The formatResult helper used to format the API response (credits meta + JSON data) for get_balance.
    export function formatResult(
      data: unknown,
      meta: { credits_used: number; credits_remaining: number; cached: boolean }
    ): string {
      const metaLine = `[${meta.credits_used} credit${meta.credits_used !== 1 ? "s" : ""} used | ${meta.credits_remaining} remaining${meta.cached ? " | cached" : ""}]`;
      return `${metaLine}\n\n${JSON.stringify(data, null, 2)}`;
    }
  • The withErrorHandling wrapper that catches errors from the get_balance handler and returns them as structured MCP error content.
    export function withErrorHandling<T>(
      fn: (args: T) => Promise<ToolResult>
    ): (args: T) => Promise<ToolResult> {
      return async (args) => {
        try {
          return await fn(args);
        } catch (err) {
          const message = err instanceof Error ? err.message : String(err);
          console.error(`[mcp] Tool error: ${message}`);
          return {
            content: [{ type: "text" as const, text: `Error: ${message}` }],
            isError: true,
          };
        }
      };
    }
Behavior4/5

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

Annotations already declare readOnlyHint=true and destructiveHint=false. The description adds value by stating the operation is free (0 credits) and listing return fields (credits, cap, plan info). No contradictions.

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 concise sentences: purpose, outputs, usage guidance with cost. Front-loaded and no redundant information.

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?

Comprehensive for a parameterless tool: describes action, return values, when to use, and cost. Output schema absent but return fields are described. Sibling tools are all more complex, so this description stands alone effectively.

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?

Input schema has no parameters, so baseline is 4. The description does not need to explain parameters; it correctly omits any param info.

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 checks the user's current credit balance, specifying returns of credits remaining, daily spending cap, and plan info. The verb 'check' and resource 'credit balance' are specific and distinct from siblings which are more complex analysis tools.

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?

Explicit guidance: 'Always call this FIRST before starting any multi-step analysis to understand the budget available.' Also notes it costs 0 credits, providing clear usage context.

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/localseodata/mcp-server'

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