Skip to main content
Glama

create_user

Add a new user to Okta by providing first name, last name, email, and optional details like login and activation status. Simplifies user management within the Okta MCP Server.

Instructions

Create a new user in Okta

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
activateNoWhether to activate the user immediately (default: false)
emailYesUser's email address
firstNameYesUser's first name
lastNameYesUser's last name
loginNoUser's login (defaults to email if not provided)

Implementation Reference

  • Handler function that executes the create_user tool: validates input with Zod schema, creates user via Okta SDK, handles errors, and formats response.
    create_user: async (request: { parameters: unknown }) => { const params = userSchemas.createUser.parse(request.parameters); try { const oktaClient = getOktaClient(); const newUser = { profile: { firstName: params.firstName, lastName: params.lastName, email: params.email, login: params.login || params.email, }, }; const user = await oktaClient.userApi.createUser({ body: newUser, activate: params.activate, }); return { content: [ { type: "text", text: `User created successfully: ID: ${user.id} Login: ${user.profile?.login} Status: ${user.status} Created: ${formatDate(user.created)}`, }, ], }; } catch (error) { console.error("Error creating user:", error); return { content: [ { type: "text", text: `Failed to create user: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } },
  • Zod schema for input validation of create_user parameters, used in the handler.
    createUser: z.object({ firstName: z.string().min(1, "First name is required"), lastName: z.string().min(1, "Last name is required"), email: z.string().email("Valid email is required"), login: z.string().optional(), activate: z.boolean().optional().default(false), }),
  • Tool registration definition including name, description, and JSON inputSchema for the MCP tool system.
    { name: "create_user", description: "Create a new user in Okta", inputSchema: { type: "object", properties: { firstName: { type: "string", description: "User's first name", }, lastName: { type: "string", description: "User's last name", }, email: { type: "string", description: "User's email address", }, login: { type: "string", description: "User's login (defaults to email if not provided)", }, activate: { type: "boolean", description: "Whether to activate the user immediately (default: false)", }, }, required: ["firstName", "lastName", "email"], }, },
  • Utility function to initialize and return the OktaClient instance, used by the create_user handler and other user 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, }); }
  • src/tools/index.ts:6-6 (registration)
    Aggregation of all tool registrations including create_user from userTools.
    export const TOOLS = [...userTools, ...groupTools, ...onboardingTools];

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