user_create_api_key
Generate a new API key for Crafty Controller users to authenticate and access server functionality programmatically.
Instructions
Generate a new API key for a Crafty Controller user
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| user_id | Yes | User ID or '@me' | |
| name | No | Optional name/description for the API key |
Implementation Reference
- src/tools/users.ts:149-164 (handler)The registration and handler implementation for the 'user_create_api_key' tool. It uses zod for input validation and calls the client to create an API key.
server.tool( "user_create_api_key", "Generate a new API key for a Crafty Controller user", { user_id: z.string().describe("User ID or '@me'"), name: z.string().optional().describe("Optional name/description for the API key"), }, async ({ user_id, name }) => { try { const data = await client.post(`/users/${user_id}/api`, name ? { name } : undefined); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } catch (error) { const msg = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Error: ${msg}` }], isError: true }; } }