Skip to main content
Glama
kapilduraphe

Okta MCP Server

get_user

Retrieve detailed user information from Okta by providing a unique user ID. Use this tool to access specific user data within the Okta MCP Server's user management system.

Instructions

Retrieve detailed user information from Okta by user ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
userIdYesThe unique identifier of the Okta user

Implementation Reference

  • The core handler function for the 'get_user' MCP tool. Parses input parameters using Zod schema, initializes Okta client, fetches user details via Okta SDK, formats comprehensive user profile (personal info, employment, contact, dates) into a markdown-style text response, and handles errors gracefully.
      get_user: async (request: { parameters: unknown }) => {
        const { userId } = userSchemas.getUser.parse(request.parameters);
    
        try {
          const oktaClient = getOktaClient();
    
          const user = await oktaClient.userApi.getUser({ userId });
    
          if (!user.profile) {
            throw new Error("User profile is undefined");
          }
    
          const formattedUser = `• User Details:
      ID: ${user.id}
      Status: ${user.status}
    
    - Account Dates:
      Created: ${formatDate(user.created)}
      Activated: ${formatDate(user.activated)}
      Last Login: ${formatDate(user.lastLogin)}
      Last Updated: ${formatDate(user.lastUpdated)}
      Status Changed: ${formatDate(user.statusChanged)}
      Password Changed: ${formatDate(user.passwordChanged)}
    
    - Personal Information:
      Login: ${user.profile.login}
      Email: ${user.profile.email}
      Secondary Email: ${getProfileValue(user.profile.secondEmail)}
      First Name: ${user.profile.firstName}
      Last Name: ${user.profile.lastName}
      Display Name: ${user.profile.displayName}
      Nickname: ${getProfileValue(user.profile.nickName)}
    
    - Employment Details:
      Organization: ${user.profile.organization}
      Title: ${user.profile.title}
      Division: ${user.profile.division}
      Department: ${user.profile.department}
      Employee Number: ${user.profile.employeeNumber}
      User Type: ${user.profile.userType}
      Cost Center: ${user.profile.costCenter}
      Manager: ${getProfileValue(user.profile.manager)}
      ManagerId ${getProfileValue(user.profile.managerId)}
    
    - Contact Information:
      Mobile Phone: ${getProfileValue(user.profile.mobilePhone)}
      Primary Phone: ${getProfileValue(user.profile.primaryPhone)}
      
    - Address:
      Street: ${user.profile.streetAddress}
      City: ${user.profile.city}
      State: ${user.profile.state}
      Zip Code: ${user.profile.zipCode}
      Country: ${user.profile.countryCode}
    
    - Preferences:
      Preferred Language: ${user.profile.preferredLanguage}
      Profile URL: ${getProfileValue(user.profile.profileUrl)}`;
    
          return {
            content: [
              {
                type: "text",
                text: formattedUser,
              },
            ],
          };
        } catch (error) {
          console.error("Error fetching user:", error);
          return {
            content: [
              {
                type: "text",
                text: `Failed to get user: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
            isError: true,
          };
        }
      },
  • MCP tool registration entry for 'get_user' within the userTools array export. Defines the tool name, description, and JSON input schema for Model Context Protocol integration.
    {
      name: "get_user",
      description: "Retrieve detailed user information from Okta by user ID",
      inputSchema: {
        type: "object",
        properties: {
          userId: {
            type: "string",
            description: "The unique identifier of the Okta user",
          },
        },
        required: ["userId"],
      },
    },
  • Zod runtime validation schema for 'get_user' tool input parameters, ensuring userId is a non-empty string. Used in the handler for safe parsing.
    getUser: z.object({
      userId: z.string().min(1, "User ID is required"),
    }),
  • Utility helper function to instantiate the Okta SDK client using environment variables OKTA_ORG_URL and OKTA_API_TOKEN. Called by the get_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,
      });
    }
  • Helper function to safely format dates from Okta user data into readable locale strings, with fallback handling for invalid dates. Extensively used in the get_user response formatting.
    function formatDate(dateString: Date | string | undefined | null): string {
      if (!dateString) return "N/A";
      try {
        return new Date(dateString).toLocaleString();
      } catch (e) {
        return dateString instanceof Date
          ? dateString.toISOString()
          : dateString || "N/A";
      }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states it retrieves information (implying read-only), but doesn't disclose behavioral traits like authentication needs, rate limits, error handling, or what 'detailed information' entails. For a tool with zero annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It's front-loaded with the core action and resource, making it easy to scan. Every word earns its place without redundancy or fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, no output schema, and a single parameter with full schema coverage, the description is incomplete. It doesn't explain what 'detailed user information' includes, potential errors, or response format. For a retrieval tool in a context with many sibling tools, more guidance is needed to be fully helpful.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the parameter 'userId' documented as 'The unique identifier of the Okta user'. The description adds that it retrieves by user ID, but doesn't provide additional semantics beyond what the schema already states. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Retrieve') and resource ('detailed user information from Okta'), specifying it's by user ID. It distinguishes from siblings like list_users (which lists multiple users) but doesn't explicitly contrast with get_user_last_location (which retrieves location data). The purpose is specific but could be more precise about what 'detailed information' includes.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when you need user details by ID, but doesn't explicitly state when to use this vs. alternatives like list_users (for multiple users) or get_user_last_location (for location data). No guidance on prerequisites, error conditions, or exclusions is provided. Usage is contextually implied but not clearly articulated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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