create_user
Create new user accounts in BookStack with required name, email, and password fields, plus optional role assignments and language preferences.
Instructions
Create a new user account
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| Yes | Email address (required, must be unique) | ||
| external_auth_id | No | External authentication ID | |
| language | No | User interface language code | |
| name | Yes | Full name of the user (required) | |
| password | Yes | Password (required, min 8 characters) | |
| roles | No | Array of role IDs to assign to the user | |
| send_invite | No | Send invitation email to user |
Implementation Reference
- src/tools/search-user-tools.ts:369-401 (handler)Handler logic for the 'create_user' tool. Validates input parameters (name, email, password), constructs the data payload, calls the BookStackClient.createUser method, and formats the API response.case "create_user": { const { name, email, password, roles, language, external_auth_id, send_invite, } = args; if (!name || !email || !password) { throw new Error("name, email, and password are required"); } if (password.length < 8) { throw new Error("Password must be at least 8 characters long"); } const data = { name, email, password, roles: roles || [], language, external_auth_id, send_invite, }; const result = await client.createUser(data); return formatApiResponse(result); }
- src/tools/search-user-tools.ts:61-99 (schema)MCP tool definition for 'create_user', including name, description, and detailed inputSchema with properties and required fields.{ name: "create_user", description: "Create a new user account", inputSchema: { type: "object", properties: { name: { type: "string", description: "Full name of the user (required)", }, email: { type: "string", description: "Email address (required, must be unique)", }, password: { type: "string", description: "Password (required, min 8 characters)", }, roles: { type: "array", description: "Array of role IDs to assign to the user", items: { type: "number" }, }, language: { type: "string", description: "User interface language code", }, external_auth_id: { type: "string", description: "External authentication ID", }, send_invite: { type: "boolean", description: "Send invitation email to user", }, }, required: ["name", "email", "password"], }, },
- src/index.ts:103-128 (registration)Registration of 'create_user' tool in the MCP server's CallToolRequest handler. Listed in searchUserToolNames and routed to handleSearchAndUserTool.const searchUserToolNames = [ "search_all", "list_users", "get_user", "create_user", "update_user", "delete_user", "list_roles", "get_role", "create_role", "update_role", "delete_role", "list_attachments", "get_attachment", "delete_attachment", "list_images", "get_image", "update_image", "delete_image", ]; if (contentToolNames.includes(name)) { result = await handleContentTool(name, args, bookStackClient); } else if (searchUserToolNames.includes(name)) { result = await handleSearchAndUserTool(name, args, bookStackClient); } else {
- src/lib/bookstack-client.ts:292-294 (helper)BookStackClient helper method that sends POST request to /users endpoint with user data to create a new user.async createUser(data: CreateUserRequest): Promise<User> { return this.post<User>("/users", data); }
- src/lib/validation.ts:80-90 (schema)Zod validation schema for CreateUserRequest used in type definitions and potentially for input validation.export const CreateUserSchema = z.object({ name: z.string().min(1).max(100), email: z.string().email(), external_auth_id: z.string().optional(), language: z.string().max(15).optional(), password: z.string().min(8).optional(), roles: z.array(z.number()).optional(), send_invite: z.boolean().optional(), }); export const UpdateUserSchema = CreateUserSchema.partial();