get_usage
Retrieve your current API usage and quota. Monitor consumption to stay within plan limits and avoid overage charges.
Instructions
Get current usage and quota for your API key.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- packages/mcp/src/tools.ts:714-721 (handler)The get_usage tool handler definition. It accepts no input parameters (empty schema) and makes a GET request to /api/usage via the apiRequest helper.
get_usage: { description: "Get current usage and quota for your API key.", inputSchema: z.object({}), handler: async () => { return apiRequest("/api/usage"); }, }, - packages/mcp/src/tools.ts:714-717 (schema)Input schema for get_usage: an empty object (z.object({})), meaning no parameters are required.
get_usage: { description: "Get current usage and quota for your API key.", inputSchema: z.object({}), - packages/mcp/src/server.ts:21-54 (registration)All tools including get_usage are dynamically registered on the McpServer via a loop over the exported tools object.
for (const [name, tool] of Object.entries(tools)) { server.tool( name, tool.description, tool.inputSchema.shape, async (input: Record<string, unknown>) => { try { const result = await tool.handler(input as any); return { content: [ { type: "text" as const, text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { const message = error instanceof Error ? error.message : String(error); return { content: [ { type: "text" as const, text: JSON.stringify({ error: message, hint: "Check the input parameters and try again. Use list_qr_codes to verify available QR codes.", }), }, ], isError: true, }; } } ); } - packages/mcp/src/api-client.ts:13-40 (helper)The apiRequest helper that get_usage's handler calls to perform the HTTP GET request to /api/usage.
export async function apiRequest(path: string, options: RequestOptions = {}) { const { method = "GET", body, query } = options; let url = `${BASE_URL}${path}`; if (query) { const params = new URLSearchParams(); for (const [key, value] of Object.entries(query)) { params.set(key, String(value)); } url += `?${params.toString()}`; } const headers: Record<string, string> = { "X-API-Key": API_KEY, }; if (body) { headers["Content-Type"] = "application/json"; } const res = await fetch(url, { method, headers, body: body ? JSON.stringify(body) : undefined, }); return res.json(); }