Skip to main content
Glama

get_billing

Retrieve billing and usage data for your account, including credit consumption, API call history, and Stripe portal access. Filter by date range, event type, or tags to analyze costs.

Instructions

Get billing and usage events for your account. Returns credit consumption, API call history, and a link to the Stripe customer portal. Filter by date range, event type, or tags.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
account_idYesYour account UUID
start_dateNoFilter events from this ISO 8601 date (inclusive)
end_dateNoFilter events until this ISO 8601 date (inclusive)
typeNoFilter by event type
tagsNoComma-separated tags to filter by

Implementation Reference

  • Main implementation of the get_billing tool. Contains the tool registration, schema definition (Zod validation for account_id, start_date, end_date, type, tags), and the async handler function that calls the API and returns formatted results.
    export function register(server: McpServer, api: ApiClient): void {
      server.tool(
        "get_billing",
        "Get billing and usage events for your account. Returns credit consumption, " +
          "API call history, and a link to the Stripe customer portal. " +
          "Filter by date range, event type, or tags.",
        {
          account_id: z.string().describe("Your account UUID"),
          start_date: z
            .string()
            .optional()
            .describe("Filter events from this ISO 8601 date (inclusive)"),
          end_date: z
            .string()
            .optional()
            .describe("Filter events until this ISO 8601 date (inclusive)"),
          type: z
            .string()
            .optional()
            .describe("Filter by event type"),
          tags: z
            .string()
            .optional()
            .describe("Comma-separated tags to filter by"),
        },
        async (params) => {
          try {
            const result = await api.get(
              `/api/v1/billing/${encodeURIComponent(params.account_id)}`,
              {
                start_date: params.start_date,
                end_date: params.end_date,
                type: params.type,
                tags: params.tags,
              },
            );
            return {
              content: [
                { type: "text" as const, text: JSON.stringify(result, null, 2) },
              ],
            };
          } catch (err) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: `Error: ${err instanceof Error ? err.message : String(err)}`,
                },
              ],
              isError: true as const,
            };
          }
        },
      );
    }
  • Input schema definition using Zod. Validates required account_id parameter and optional start_date, end_date, type, and tags filters for the billing query.
    {
      account_id: z.string().describe("Your account UUID"),
      start_date: z
        .string()
        .optional()
        .describe("Filter events from this ISO 8601 date (inclusive)"),
      end_date: z
        .string()
        .optional()
        .describe("Filter events until this ISO 8601 date (inclusive)"),
      type: z
        .string()
        .optional()
        .describe("Filter by event type"),
      tags: z
        .string()
        .optional()
        .describe("Comma-separated tags to filter by"),
    },
  • src/index.ts:21-21 (registration)
    Import of the get_billing tool registration function from ./tools/get-billing.js
    import { register as getBilling } from "./tools/get-billing.js";
  • src/index.ts:67-67 (registration)
    Registration call that initializes the get_billing tool with the MCP server and API client instance
    getBilling(server, api);
  • ApiClient.get() method used by the get_billing handler to make HTTP GET requests with query parameters and Bearer token authentication
    async get<T = unknown>(
      path: string,
      params?: Record<string, string | undefined>,
    ): Promise<T> {
      const url = new URL(`${this.baseUrl}${path}`);
      if (params) {
        for (const [k, v] of Object.entries(params)) {
          if (v !== undefined) url.searchParams.set(k, v);
        }
      }
      return this.request<T>(url, { method: "GET" });
    }
Behavior3/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It describes the tool as a 'Get' operation, implying read-only behavior, and lists return types, but lacks details on permissions, rate limits, pagination, or error handling. This is a moderate gap for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, with the core purpose stated first and filtering details added concisely. Both sentences earn their place by clarifying scope and capabilities, though it could be slightly more structured for optimal readability.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (5 parameters, no output schema, no annotations), the description is partially complete. It covers the purpose and return data but lacks usage guidelines, behavioral details like authentication or limits, and output specifics. This leaves gaps for an agent to operate effectively without additional context.

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%, so the schema already documents all 5 parameters thoroughly. The description adds minimal value by mentioning filtering by date range, event type, or tags, which aligns with the schema but does not provide additional syntax or format details beyond what's in the structured fields.

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's purpose with specific verbs ('Get billing and usage events') and resources ('for your account'), and it distinguishes itself from sibling tools by focusing on billing data rather than media processing, detection, or job management. It specifies what data is returned (credit consumption, API call history, Stripe portal link), making the purpose explicit and differentiated.

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?

The description provides no guidance on when to use this tool versus alternatives. It mentions filtering capabilities but does not specify scenarios, prerequisites, or exclusions, nor does it reference any sibling tools for related tasks. Without such context, an agent might struggle to determine the appropriate use case.

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

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