get_user
Retrieve your Recraft account details: email, name, and credit balance.
Instructions
Get information about the current Recraft API user (their email, name, and credit balance).
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_user"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/GetUser.ts:17-45 (handler)The handler function that executes the get_user tool logic. Calls server.api.userApi.getCurrentUser() and returns the user's email, name, and credit balance with a low-credit warning if applicable.
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)The tool definition and input schema for get_user. Defines name as 'get_user', a description, and an 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-79 (registration)Registration of get_user tool in the ListToolsRequestSchema handler, adding getUserTool to the list of available tools.
server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ generateImageTool, createStyleTool, vectorizeImageTool, imageToImageTool, removeBackgroundTool, replaceBackgroundTool, crispUpscaleTool, creativeUpscaleTool, getUserTool, - src/index.ts:118-119 (registration)Routing of the get_user tool call to its handler in the CallToolRequestSchema switch statement.
case getUserTool.name: return await getUserHandler(recraftServer, args ?? {}) - src/index.ts:20-20 (registration)Import of getUserHandler and getUserTool from the GetUser module.
import { getUserHandler, getUserTool } from "./tools/GetUser"