Skip to main content
Glama
metrxbots

Metrx MCP Server

by metrxbots

Get Budget Status

metrx_get_budget_status
Read-onlyIdempotent

Monitor spending governance across your agent fleet by checking current budget status, including spending versus limits, warning/exceeded counts, and enforcement modes.

Instructions

Get the current status of all budget configurations. Shows spending vs limits, warning/exceeded counts, and enforcement modes. Use this to monitor spending governance across your agent fleet. Do NOT use for creating/changing budgets — use set_budget or update_budget_mode.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Main handler function for get_budget_status tool. Fetches budget status from the API endpoint '/budgets/status', handles errors, and formats the response using formatBudgetStatus helper.
    async () => {
      const result = await client.get<BudgetStatus>('/budgets/status');
    
      if (result.error) {
        return {
          content: [{ type: 'text', text: `Error fetching budget status: ${result.error}` }],
          isError: true,
        };
      }
    
      const text = formatBudgetStatus(result.data!);
    
      return {
        content: [{ type: 'text', text }],
      };
    }
  • Tool registration for 'get_budget_status'. Defines the tool metadata including title, description, input schema (empty - no parameters required), and annotations (readOnly, idempotent).
    server.registerTool(
      'get_budget_status',
      {
        title: 'Get Budget Status',
        description:
          'Get the current status of all budget configurations. ' +
          'Shows spending vs limits, warning/exceeded counts, and enforcement modes. ' +
          'Use this to monitor spending governance across your agent fleet. ' +
          'Do NOT use for creating/changing budgets — use set_budget or update_budget_mode.',
        inputSchema: {},
        annotations: {
          readOnlyHint: true,
          destructiveHint: false,
          idempotentHint: true,
          openWorldHint: false,
        },
      },
      async () => {
        const result = await client.get<BudgetStatus>('/budgets/status');
    
        if (result.error) {
          return {
            content: [{ type: 'text', text: `Error fetching budget status: ${result.error}` }],
            isError: true,
          };
        }
    
        const text = formatBudgetStatus(result.data!);
    
        return {
          content: [{ type: 'text', text }],
        };
      }
    );
  • Type definitions for BudgetStatus and BudgetSummary interfaces. BudgetStatus contains the response structure including has_budgets, total_budgets, warning_count, exceeded_count, paused_count, and budgets array.
    export interface BudgetStatus {
      has_budgets: boolean;
      total_budgets: number;
      paused_count: number;
      warning_count: number;
      exceeded_count: number;
      budgets: BudgetSummary[];
    }
    
    export interface BudgetSummary {
      id: string;
      period: string;
      agent_id: string | null;
      limit_microcents: number;
      spent_microcents: number;
      pct_used: number;
      enforcement_mode: string;
      paused: boolean;
      over_warning: boolean;
      over_limit: boolean;
    }
  • src/index.ts:74-103 (registration)
    Prefix registration logic that adds 'metrx_' namespace to all tools. Wraps the original server.registerTool to apply rate limiting and automatically prefix tool names (e.g., 'get_budget_status' becomes 'metrx_get_budget_status').
    // ── Rate limiting middleware + metrx_ namespace prefix ──
    // All tools are registered exclusively as metrx_{name}.
    // The metrx_ prefix namespaces our tools to avoid collisions when
    // multiple MCP servers are used together.
    const METRX_PREFIX = 'metrx_';
    const originalRegisterTool = server.registerTool.bind(server);
    (server as any).registerTool = function (
      name: string,
      config: any,
      handler: (...handlerArgs: any[]) => Promise<any>
    ) {
      const wrappedHandler = async (...handlerArgs: any[]) => {
        if (!rateLimiter.isAllowed(name)) {
          return {
            content: [
              {
                type: 'text' as const,
                text: `Rate limit exceeded for tool '${name}'. Maximum 60 requests per minute allowed.`,
              },
            ],
            isError: true,
          };
        }
        return handler(...handlerArgs);
      };
    
      // Register with metrx_ prefix (only — no deprecated aliases)
      const prefixedName = name.startsWith(METRX_PREFIX) ? name : `${METRX_PREFIX}${name}`;
      originalRegisterTool(prefixedName, config, wrappedHandler);
    };
  • formatBudgetStatus helper function that formats the BudgetStatus API response into a human-readable markdown string with total budgets, warnings, exceeded counts, and detailed budget information.
    /** Format budget status */
    export function formatBudgetStatus(status: BudgetStatus): string {
      if (!status.has_budgets) {
        return 'No budgets configured. Use set_budget to create spending limits for your agents.';
      }
    
      const lines: string[] = [
        `## Budget Status`,
        '',
        `**Total Budgets**: ${status.total_budgets}`,
        `**Warnings**: ${status.warning_count}`,
        `**Exceeded**: ${status.exceeded_count}`,
        `**Paused**: ${status.paused_count}`,
      ];
    
      if (status.budgets.length > 0) {
        lines.push('');
        for (const b of status.budgets) {
          lines.push(formatBudget(b));
        }
      }
    
      return lines.join('\n');
    }
Behavior4/5

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

The description adds valuable context about what information is returned (spending vs limits, warning/exceeded counts, enforcement modes) and the monitoring purpose, which goes beyond what the annotations provide. The annotations already declare readOnlyHint=true, destructiveHint=false, openWorldHint=false, and idempotentHint=true, so the description appropriately focuses on behavioral details rather than repeating safety information.

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?

The description is perfectly concise with two sentences that each serve distinct purposes: the first explains what the tool does and what information it returns, the second provides clear usage guidelines. There is zero wasted text.

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 read-only tool with comprehensive annotations and no parameters, the description provides complete context about purpose, returned information, and usage guidelines. The absence of an output schema is compensated by the description detailing what information is returned.

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?

With 0 parameters and 100% schema description coverage, the baseline would be 4. The description appropriately doesn't discuss parameters since none exist, and instead focuses on the tool's purpose and usage context.

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 verb 'Get' and resource 'current status of all budget configurations' with specific details about what information is returned (spending vs limits, warning/exceeded counts, enforcement modes). It explicitly distinguishes from sibling tools by naming alternatives for budget creation/changing.

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?

The description provides explicit guidance on when to use this tool ('to monitor spending governance across your agent fleet') and when NOT to use it ('Do NOT use for creating/changing budgets'), with specific alternative tools named (set_budget, update_budget_mode).

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

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