Skip to main content
Glama
AlephantAI

Alephant MCP

Official
by AlephantAI

get_my_budget

Read-onlyIdempotent

Check the current budget status for your virtual key, with options for 24h, 7d, 30d, or billing cycle periods.

Instructions

Returns budget status for the current virtual key.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
periodNoBudget window for cockpit/budget-status query parambilling_cycle

Implementation Reference

  • Registers the 'get_my_budget' tool with a Zod schema for the 'period' parameter (24h, 7d, 30d, billing_cycle; defaults to billing_cycle). The handler calls cockpit.budgetStatus(period) via safeCall.
    export function registerVkBudgetTools(server: McpServer, deps: ToolDeps): void {
      server.tool(
        "get_my_budget",
        {
          period: z
            .enum(["24h", "7d", "30d", "billing_cycle"])
            .default("billing_cycle")
            .describe("Budget window for cockpit/budget-status query param"),
        },
        async ({ period }) => {
          const cockpit = requireCockpit(deps);
          return safeCall(() => cockpit.budgetStatus(period), "vk");
        },
      );
  • The CockpitClient.budgetStatus method that makes the actual HTTP GET request to /api/v1/cockpit/budget-status with the period query param and returns BudgetStatusResponse.
    async budgetStatus(period = "30d"): Promise<BudgetStatusResponse> {
      const { data } = await this.http.get("/api/v1/cockpit/budget-status", {
        params: { period },
      });
      return data as BudgetStatusResponse;
    }
  • BudgetStatusResponse interface: budgetCents, spentCents, remainingCents, percentUsed, exceededAction, period.
    export interface BudgetStatusResponse {
      budgetCents: number;
      spentCents: number;
      remainingCents: number;
      percentUsed: number;
      exceededAction: string;
      period: string;
    }
  • TOOL_DESCRIPTIONS entry for 'get_my_budget' with description 'Returns budget status for the current virtual key.' Also registered via registerVkBudgetTools on line 213.
    get_my_budget:
      "Returns budget status for the current virtual key.",
  • safeCall utility used by the tool handler to wrap the async call with error handling, rate limiting, and JSON serialization.
    export async function safeCall<T>(
      fn: () => Promise<T>,
      mode: AuthMode,
    ): Promise<CallToolResult> {
      await acquireGlobalRateSlot();
      try {
        const data = await fn();
        let text: string;
        try {
          text = JSON.stringify(data, null, 2);
        } catch {
          if (data && typeof data === "object") {
            text = JSON.stringify(data) || String(data);
          } else {
            text = String(data);
          }
        }
        return {
          content: [{ type: "text", text }],
        };
      } catch (err) {
        const e = toHttpLike(err);
        const statusLabel = e.status ? `HTTP ${e.status}` : e.code ?? "unknown";
        console.error(`[safeCall] ${statusLabel}: ${e.message}`);
        const authOrRate = toolResultForAuthAndRateLimit(e, mode);
        if (authOrRate) return authOrRate;
        if (e.status === 400) {
          return {
            content: [{ type: "text", text: `Bad request: ${e.message}` }],
            isError: true,
          };
        }
        if (e.status === 404) {
          return {
            content: [{ type: "text", text: `Not found: ${e.message}` }],
            isError: true,
          };
        }
        if (e.status === 502) {
          return {
            content: [{ type: "text", text: "Bad gateway. The backend service is unavailable." }],
            isError: true,
          };
        }
        if (e.status === 504) {
          return {
            content: [
              {
                type: "text",
                text: "Gateway timeout. The backend service is slow to respond.",
              },
            ],
            isError: true,
          };
        }
        if (e.status === 500) {
          return {
            content: [{ type: "text", text: "Internal server error. Please contact support." }],
            isError: true,
          };
        }
        if (e.code === "ETIMEDOUT" || e.code === "ECONNABORTED") {
          return {
            content: [
              {
                type: "text",
                text: "Request timeout. Check your network connection or API availability.",
              },
            ],
            isError: true,
          };
        }
        return {
          content: [{ type: "text", text: `Unexpected error: ${e.message}` }],
          isError: true,
        };
      }
    }
Behavior3/5

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

Annotations already indicate readOnlyHint=true, destructiveHint=false, idempotentHint=true. The description adds the scope 'for current virtual key', which is useful but not deeply behavioral. 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?

Single sentence, no extraneous text. Perfectly concise.

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 one optional parameter, no output schema, and rich annotations, the description is sufficient. It covers the purpose and scope without gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% (the period parameter is fully described in schema). The tool description does not add extra parameter context, so baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool returns budget status for the current virtual key. This is specific and distinguishes from siblings like get_cost_by_model or get_daily_costs, though it doesn't explicitly call out the difference.

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

Usage Guidelines2/5

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

No guidance on when to use this tool versus alternatives (e.g., get_daily_costs for cost breakdown, get_usage_summary for usage). The description does not provide context for selection.

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/AlephantAI/alephant-mcp'

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