get_usage
Retrieve BubblyPhone usage data showing call counts, minutes, call costs, and number costs for specified months to track telephony spending and activity volumes.
Instructions
Get usage statistics for a time period — inbound/outbound call counts, minutes, costs, and number costs.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| period | No | Month in YYYY-MM format (default: current month) |
Implementation Reference
- src/tools/billing.ts:42-46 (handler)The handler function for get_usage tool - receives params, builds query object with period if provided, and calls the billing/usage API endpoint
async (params) => { const query: Record<string, string> = {}; if (params.period) query.period = params.period; return callTool(() => client.get("/billing/usage", query)); } - src/tools/billing.ts:37-39 (schema)Input schema for get_usage tool using Zod - defines optional 'period' parameter for month in YYYY-MM format
inputSchema: { period: z.string().optional().describe("Month in YYYY-MM format (default: current month)"), }, - src/tools/billing.ts:33-47 (registration)Registration of the get_usage tool with MCP server including name, description, schema, annotations, and handler
server.registerTool( "get_usage", { description: "Get usage statistics for a time period — inbound/outbound call counts, minutes, costs, and number costs.", inputSchema: { period: z.string().optional().describe("Month in YYYY-MM format (default: current month)"), }, annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false }, }, async (params) => { const query: Record<string, string> = {}; if (params.period) query.period = params.period; return callTool(() => client.get("/billing/usage", query)); } ); - src/tools/billing.ts:13-20 (helper)Helper function callTool that wraps API calls with error handling - returns tool result on success or toolError on ApiError
async function callTool<T>(fn: () => Promise<T>) { try { return toolResult(await fn()); } catch (err) { const apiErr = err as ApiError; return toolError(`API error (${apiErr.status}): ${apiErr.message}`); } } - src/client.ts:21-31 (helper)BubblyPhoneClient.get method used by get_usage handler - constructs URL with query params and makes authenticated GET request
async get<T = unknown>(path: string, params?: Record<string, string>): Promise<T> { const url = new URL(`${this.baseUrl}${path}`); if (params) { for (const [key, value] of Object.entries(params)) { if (value !== undefined && value !== "") { url.searchParams.set(key, value); } } } return this.request<T>(url.toString(), { method: "GET" }); }