get_user
Retrieve detailed information about the current Recraft API user, including email, name, and credit balance, for seamless integration and account management.
Instructions
Get information about the current Recraft API user (their email, name, and credit balance).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/GetUser.ts:17-45 (handler)The handler function for the 'get_user' tool. It retrieves the current user's information (email, name, credits) via the Recraft API and returns a formatted text response, including a warning if credits are low.export const getUserHandler = async (server: RecraftServer, _args: Record<string, unknown>): Promise<CallToolResult> => { try { const result = await server.api.userApi.getCurrentUser() return { content: [ { type: 'text', text: `User email: ${result.email}, name: ${result.name}.\nYou have ${result.credits} credits left.` + ( result.credits >= ALMOST_ZERO_CREDITS ? "" : `\nYou are ${result.credits > 0 ? "almost" : ""} out of credits. Please top up your account on https://www.recraft.ai/profile/api.` ) }, ] } } catch (error) { return { content: [ { type: 'text', text: `Get user error: ${error}` } ], isError: true } } }
- src/tools/GetUser.ts:6-15 (schema)Tool schema definition including name, description, and empty input schema (no parameters required).export const getUserTool = { name: "get_user", description: "Get information about the current Recraft API user (their email, name, and credit balance).", inputSchema: { type: "object", properties: { }, required: [] } }
- src/index.ts:68-82 (registration)Registration of the getUserTool in the list of available tools returned by ListToolsRequestHandler.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ generateImageTool, createStyleTool, vectorizeImageTool, imageToImageTool, removeBackgroundTool, replaceBackgroundTool, crispUpscaleTool, creativeUpscaleTool, getUserTool, ], } })
- src/index.ts:118-119 (registration)Dispatch/registration of the getUserHandler in the switch statement for CallToolRequestHandler.case getUserTool.name: return await getUserHandler(recraftServer, args ?? {})
- src/index.ts:20-20 (registration)Import of getUserTool and getUserHandler from the implementation file.import { getUserHandler, getUserTool } from "./tools/GetUser"