delete_group
Remove a group in Okta by specifying its unique group ID. This tool is part of the Okta MCP Server, enabling efficient group management within the system.
Instructions
Delete a group from Okta
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| groupId | Yes | ID of the group to delete |
Implementation Reference
- src/tools/groups.ts:438-468 (handler)The asynchronous handler function for the 'delete_group' tool. It validates input using Zod, calls the Okta API to delete the specified group, and returns a formatted success or error response.delete_group: async (request: { parameters: unknown }) => { const { groupId } = groupSchemas.deleteGroup.parse(request.parameters); try { const oktaClient = getOktaClient(); await oktaClient.groupApi.deleteGroup({ groupId, }); return { content: [ { type: "text", text: `Group with ID ${groupId} has been successfully deleted.`, }, ], }; } catch (error) { console.error("Error deleting group:", error); return { content: [ { type: "text", text: `Failed to delete group: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } },
- src/tools/groups.ts:162-175 (registration)The registration of the 'delete_group' tool in the exported groupTools array, including name, description, and JSON input schema.{ name: "delete_group", description: "Delete a group from Okta", inputSchema: { type: "object", properties: { groupId: { type: "string", description: "ID of the group to delete", }, }, required: ["groupId"], }, },
- src/tools/groups.ts:25-27 (schema)Zod schema for input validation of the delete_group tool parameters, ensuring groupId is a non-empty string.deleteGroup: z.object({ groupId: z.string().min(1, "Group ID is required"), }),
- src/tools/groups.ts:47-67 (helper)Utility function to initialize and return the OktaClient instance, used by the delete_group handler and other group tools.function getOktaClient() { const oktaDomain = process.env.OKTA_ORG_URL; const apiToken = process.env.OKTA_API_TOKEN; if (!oktaDomain) { throw new Error( "OKTA_ORG_URL environment variable is not set. Please set it to your Okta domain." ); } if (!apiToken) { throw new Error( "OKTA_API_TOKEN environment variable is not set. Please generate an API token in the Okta Admin Console." ); } return new OktaClient({ orgUrl: oktaDomain, token: apiToken, }); }