wp_create_user
Add new users to a WordPress site by specifying username, email, password, and optional roles for access management.
Instructions
Creates a new user.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| site | No | The ID of the WordPress site to target (from mcp-wordpress.config.json). Required if multiple sites are configured. | |
| username | Yes | The username for the new user. | |
| Yes | The email address for the new user. | ||
| password | Yes | The password for the new user. | |
| roles | No | An array of roles to assign to the user. |
Implementation Reference
- src/tools/users.ts:315-323 (handler)The core handler function for the 'wp_create_user' tool. It extracts parameters, calls WordPressClient.createUser(), handles the response with a success message, and propagates errors.public async handleCreateUser(client: WordPressClient, params: Record<string, unknown>): Promise<unknown> { const createParams = params as unknown as CreateUserRequest; try { const user = await client.createUser(createParams); return `✅ User "${user.name}" created successfully with ID: ${user.id}.`; } catch (_error) { throw new Error(`Failed to create user: ${getErrorMessage(_error)}`); } }
- src/tools/users.ts:79-109 (registration)The tool registration within UserTools.getTools(). Defines the tool name, description, input schema (parameters), and binds the handler function for MCP tool system integration.{ name: "wp_create_user", description: "Creates a new user.", parameters: [ { name: "username", type: "string", required: true, description: "The username for the new user.", }, { name: "email", type: "string", required: true, description: "The email address for the new user.", }, { name: "password", type: "string", required: true, description: "The password for the new user.", }, { name: "roles", type: "array", items: { type: "string" }, description: "An array of roles to assign to the user.", }, ], handler: this.handleCreateUser.bind(this), },