Skip to main content
Glama
kapilduraphe

Okta MCP Server

activate_user

Enable user activation in Okta by providing a user ID. Optionally configure email notifications for activation.

Instructions

Activate a user in Okta

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sendEmailNoWhether to send an activation email (default: true)
userIdYesThe unique identifier of the Okta user

Implementation Reference

  • The primary handler function for the 'activate_user' tool. Parses input parameters using Zod schema, retrieves Okta client, calls the activateUser API, and returns a success message or error response.
    activate_user: async (request: { parameters: unknown }) => {
      const { userId, sendEmail } = userSchemas.activateUser.parse(
        request.parameters
      );
    
      try {
        const oktaClient = getOktaClient();
    
        await oktaClient.userApi.activateUser({
          userId,
          sendEmail,
        });
    
        return {
          content: [
            {
              type: "text",
              text: `User with ID ${userId} has been activated successfully.${
                sendEmail ? " An activation email has been sent." : ""
              }`,
            },
          ],
        };
      } catch (error) {
        console.error("Error activating user:", error);
        return {
          content: [
            {
              type: "text",
              text: `Failed to activate user: ${error instanceof Error ? error.message : String(error)}`,
            },
          ],
          isError: true,
        };
      }
    },
  • Zod schema for input validation of the activate_user tool, defining required userId and optional sendEmail parameters.
    activateUser: z.object({
      userId: z.string().min(1, "User ID is required"),
      sendEmail: z.boolean().optional().default(true),
    }),
  • Tool registration definition in the userTools array, specifying name, description, and input schema for the MCP tool list.
    {
      name: "activate_user",
      description: "Activate a user in Okta",
      inputSchema: {
        type: "object",
        properties: {
          userId: {
            type: "string",
            description: "The unique identifier of the Okta user",
          },
          sendEmail: {
            type: "boolean",
            description: "Whether to send an activation email (default: true)",
          },
        },
        required: ["userId"],
      },
    },
  • Combines userTools (including activate_user) and userHandlers into global TOOLS and HANDLERS exports used by the MCP server.
    import { userTools, userHandlers } from "./users.js";
    import { groupTools, groupHandlers } from "./groups.js";
    import { onboardingTools, onboardingHandlers } from "./onboarding.js";
    
    // Combine all tools from different modules
    export const TOOLS = [...userTools, ...groupTools, ...onboardingTools];
    
    // Combine all handlers from different modules
    export const HANDLERS = {
      ...userHandlers,
      ...groupHandlers,
      ...onboardingHandlers,
    };
  • src/index.ts:32-66 (registration)
    MCP server request handlers that expose the combined TOOLS list and execute HANDLERS[toolName] for tool calls, enabling the activate_user tool.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      log('Received list tools request');
      return { tools: TOOLS };
    });
    
    // Handle tool calls
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const toolName = request.params.name;
      log(`Received tool call: ${toolName}`);
    
      try {
        if (!(toolName in HANDLERS)) {
          throw new Error(`Unknown tool: ${toolName}`);
        }
    
        // Execute handler
        log(`Executing handler for tool: ${toolName}`);
        const result = await HANDLERS[toolName as keyof typeof HANDLERS]({ parameters: request.params.arguments || {} });
        log(`Handler execution completed for: ${toolName}`);
    
        return result;
      } catch (error) {
        log(`Error handling tool call: ${error instanceof Error ? error.message : String(error)}`);
        return {
          content: [
            {
              type: 'text',
              text: `Error: ${error instanceof Error ? error.message : String(error)}`,
            },
          ],
          isError: true,
        };
      }
    });

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