Skip to main content
Glama
kapilduraphe

Okta MCP Server

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
NameRequiredDescriptionDefault
groupIdYesID of the group to delete

Implementation Reference

  • 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,
        };
      }
    },
  • 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"],
      },
    },
  • 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"),
    }),
  • 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,
      });
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kapilduraphe/okta-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server