create_user
Add new users to the Kapiti platform by providing email, name, password, and role assignments for account management.
Instructions
Create a new user in the current account
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| claims | No | User roles/claims (string or array of strings) | |
| Yes | User email address | ||
| firstName | Yes | User first name | |
| lastName | Yes | User last name | |
| password | No | User password |
Implementation Reference
- src/index.ts:291-338 (handler)Handler function that builds payload and POSTs to /tools/membership/users API to create a new user.async ({ email, firstName, lastName, password, claims }) => { try { // Build payload object more carefully const payload: any = { email, firstName, lastName, }; // Only add password if provided if (password) { payload.password = password; } // Only add claims if provided and convert to array format if (claims !== undefined && claims !== null) { if (typeof claims === "string") { payload.claims = [claims]; } else if (Array.isArray(claims) && claims.length > 0) { payload.claims = claims; } // If claims is an empty array or invalid, don't include it in payload } console.error("Create user payload:", JSON.stringify(payload, null, 2)); // Debug log const response: AxiosResponse<ApiResponse<User>> = await apiClient.post("/tools/membership/users", payload); return { content: [ { type: "text", text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: handleApiError(error), }, ], isError: true, }; } }
- src/index.ts:281-289 (schema)Zod input schema defining parameters for create_user tool: email (required), firstName, lastName, optional password and claims.email: z.string().email().describe("User email address"), firstName: z.string().describe("User first name"), lastName: z.string().describe("User last name"), password: z.string().optional().describe("User password"), claims: z .union([z.string(), z.array(z.string())]) .optional() .describe("User roles/claims (string or array of strings)"), },
- src/index.ts:275-339 (registration)MCP server registration of the create_user tool including title, description, input schema, and handler.server.registerTool( "create_user", { title: "Create User", description: "Create a new user in the current account", inputSchema: { email: z.string().email().describe("User email address"), firstName: z.string().describe("User first name"), lastName: z.string().describe("User last name"), password: z.string().optional().describe("User password"), claims: z .union([z.string(), z.array(z.string())]) .optional() .describe("User roles/claims (string or array of strings)"), }, }, async ({ email, firstName, lastName, password, claims }) => { try { // Build payload object more carefully const payload: any = { email, firstName, lastName, }; // Only add password if provided if (password) { payload.password = password; } // Only add claims if provided and convert to array format if (claims !== undefined && claims !== null) { if (typeof claims === "string") { payload.claims = [claims]; } else if (Array.isArray(claims) && claims.length > 0) { payload.claims = claims; } // If claims is an empty array or invalid, don't include it in payload } console.error("Create user payload:", JSON.stringify(payload, null, 2)); // Debug log const response: AxiosResponse<ApiResponse<User>> = await apiClient.post("/tools/membership/users", payload); return { content: [ { type: "text", text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: handleApiError(error), }, ], isError: true, }; } } );