update_user
Update user's first name, last name, or organization-level role by user ID. Workspace membership changes are handled separately.
Instructions
Update a user's first name, last name, or organization role by id. Email and workspace roles are not editable here; use update_workspace_member for workspace membership changes.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| user_id | Yes | The user ID to update | |
| first_name | No | New first name | |
| last_name | No | New last name | |
| role | No | New organization-level role |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | Whether the tool call succeeded and returned structured data | |
| data | No | Structured success payload when ok is true | |
| error | No | Structured error payload when ok is false |
Implementation Reference
- src/services/users.service.ts:153-161 (handler)Core handler for update_user. Sends a PUT request to /admin/users/{userId} with the UpdateUserRequest data and returns the updated PortkeyUser.
async updateUser( userId: string, data: UpdateUserRequest, ): Promise<PortkeyUser> { return this.put<PortkeyUser>( `/admin/users/${this.encodePathSegment(userId)}`, data, ); } - src/services/users.service.ts:62-66 (schema)Input schema for the update_user request, defining optional fields: first_name, last_name, and role.
export interface UpdateUserRequest { first_name?: string; last_name?: string; role?: "admin" | "member"; } - src/tools/users.tools.ts:108-116 (schema)Zod validation schema for the update_user tool, defining user_id (required), first_name, last_name, and role (all optional except user_id).
updateUser: { user_id: z.string().describe("The user ID to update"), first_name: z.string().optional().describe("New first name"), last_name: z.string().optional().describe("New last name"), role: z .enum(["admin", "member"]) .optional() .describe("New organization-level role"), }, - src/tools/users.tools.ts:283-306 (registration)Registration of the 'update_user' MCP tool on the server, binding the Zod schema and handler that calls service.users.updateUser().
server.tool( "update_user", "Update a user's first name, last name, or organization role by id. Email and workspace roles are not editable here; use update_workspace_member for workspace membership changes.", USERS_TOOL_SCHEMAS.updateUser, async (params) => { const { user_id, ...updateData } = params; const user = await service.users.updateUser(user_id, updateData); return { content: [ { type: "text", text: JSON.stringify( { message: "Successfully updated user", user: formatUser(user), }, null, 2, ), }, ], }; }, ); - src/services/base.service.ts:53-55 (helper)Helper used by updateUser to safely encode the user_id path segment in the URL.
protected encodePathSegment(value: string): string { return encodeURIComponent(value); }