get_balance
Check your current BubblyPhone credit balance in USD to monitor available funds for phone calls, AI voice agents, and telephony services.
Instructions
Get your current BubblyPhone credit balance in USD.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/billing.ts:30-30 (handler)The actual handler function that executes the get_balance tool logic - calls the API endpoint /billing/balance via the client
async () => callTool(() => client.get("/billing/balance")) - src/tools/billing.ts:23-31 (registration)Registration of the get_balance tool with MCP server, including tool name, description, schema, annotations, and handler binding
server.registerTool( "get_balance", { description: "Get your current BubblyPhone credit balance in USD.", inputSchema: {}, annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false }, }, async () => callTool(() => client.get("/billing/balance")) ); - src/tools/billing.ts:27-27 (schema)Input schema for get_balance - empty object indicating no input parameters required
inputSchema: {}, - src/tools/billing.ts:13-20 (helper)Helper function callTool that wraps API calls with standardized error handling and result formatting
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 - the underlying HTTP GET implementation used by the get_balance handler to fetch from /billing/balance
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" }); }