get_usage
Check current usage statistics and plan limits for the RendrKit image generation API to monitor image generation counts and subscription details.
Instructions
Check current usage statistics including images generated this month and plan limits
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/get-usage.ts:14-44 (handler)The main tool handler that executes the get_usage tool logic. It calls client.getUsage() to fetch usage statistics and formats the response with plan details, images used/limit, and period dates. Includes error handling.
async () => { try { const usage = await client.getUsage(); return { content: [ { type: "text" as const, text: [ `Usage Statistics`, ``, `Plan: ${usage.plan}`, `Images Used: ${usage.imagesUsed} / ${usage.imagesLimit}`, `Period: ${usage.periodStart} to ${usage.periodEnd}`, ].join("\n"), }, ], }; } catch (error) { const message = error instanceof Error ? error.message : String(error); return { content: [ { type: "text" as const, text: `Failed to get usage stats: ${message}`, }, ], isError: true, }; } - src/tools/get-usage.ts:4-47 (registration)The registerGetUsageTool function that registers the get_usage tool with the MCP server, including the tool schema/description and the handler function.
export function registerGetUsageTool( server: McpServer, client: RendrKitClient, ): void { server.registerTool( "get_usage", { description: "Check current usage statistics including images generated this month and plan limits", }, async () => { try { const usage = await client.getUsage(); return { content: [ { type: "text" as const, text: [ `Usage Statistics`, ``, `Plan: ${usage.plan}`, `Images Used: ${usage.imagesUsed} / ${usage.imagesLimit}`, `Period: ${usage.periodStart} to ${usage.periodEnd}`, ].join("\n"), }, ], }; } catch (error) { const message = error instanceof Error ? error.message : String(error); return { content: [ { type: "text" as const, text: `Failed to get usage stats: ${message}`, }, ], isError: true, }; } }, ); } - src/types.ts:38-44 (schema)The UsageStats interface defining the schema for usage statistics data including plan name, images used/limit, and period start/end dates.
export interface UsageStats { plan: string; imagesUsed: number; imagesLimit: number; periodStart: string; periodEnd: string; } - src/server.ts:21-21 (registration)Where the get_usage tool is registered with the MCP server by calling registerGetUsageTool in the createServer function.
registerGetUsageTool(server, client); - src/api-client.ts:105-107 (helper)The getUsage() method in RendrKitClient that makes the actual API call to /api/v1/usage endpoint to fetch usage statistics.
async getUsage(): Promise<UsageStats> { return this.request<UsageStats>("GET", "/api/v1/usage"); }