assign_user_to_group
Assign a specific user to a designated group within Okta’s user management system to streamline access and permissions.
Instructions
Assign a user to a group in Okta
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| groupId | Yes | ID of the group | |
| userId | Yes | ID of the user to assign to the group |
Implementation Reference
- src/tools/groups.ts:470-503 (handler)The handler function for the 'assign_user_to_group' tool. It validates input parameters using Zod schema, retrieves Okta client, calls the Okta API to assign the user to the group, and returns a success or error response.assign_user_to_group: async (request: { parameters: unknown }) => { const { groupId, userId } = groupSchemas.assignUserToGroup.parse( request.parameters ); try { const oktaClient = getOktaClient(); await oktaClient.groupApi.assignUserToGroup({ groupId, userId, }); return { content: [ { type: "text", text: `User with ID ${userId} has been successfully assigned to group with ID ${groupId}.`, }, ], }; } catch (error) { console.error("Error assigning user to group:", error); return { content: [ { type: "text", text: `Failed to assign user to group: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } },
- src/tools/groups.ts:176-193 (registration)The tool registration object defining the name, description, and input schema, included in the exported groupTools array which is spread into the main TOOLS export in index.ts.{ name: "assign_user_to_group", description: "Assign a user to a group in Okta", inputSchema: { type: "object", properties: { groupId: { type: "string", description: "ID of the group", }, userId: { type: "string", description: "ID of the user to assign to the group", }, }, required: ["groupId", "userId"], }, },
- src/tools/groups.ts:29-32 (schema)Zod schema for validating the input parameters (groupId and userId) used in the handler function.assignUserToGroup: z.object({ groupId: z.string().min(1, "Group ID is required"), userId: z.string().min(1, "User ID is required"), }),