Skip to main content
Glama
kapilduraphe

Okta MCP Server

list_group_users

Retrieve and manage users within a specific group in Okta by providing the group ID, with options for pagination and limiting results for efficient user management.

Instructions

List all users in a specific group

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
afterNoCursor for pagination, obtained from previous response
groupIdYesID of the group
limitNoMaximum number of users to return (default: 50, max: 200)

Implementation Reference

  • The main handler function for the 'list_group_users' tool. It validates input parameters using Zod, retrieves the Okta client, calls the Okta API to list users in the specified group with pagination support, formats the user list into a readable text response, and handles errors.
      list_group_users: async (request: { parameters: unknown }) => {
        const params = groupSchemas.listGroupUsers.parse(request.parameters);
    
        try {
          const oktaClient = getOktaClient();
    
          // Build query parameters for pagination
          const queryParams: Record<string, any> = {};
          if (params.limit) queryParams.limit = params.limit;
          if (params.after) queryParams.after = params.after;
    
          // Get group users list
          const users = await oktaClient.groupApi.listGroupUsers({
            groupId: params.groupId,
            ...queryParams,
          });
    
          if (!users) {
            return {
              content: [
                {
                  type: "text",
                  text: "No users data was returned from Okta.",
                },
              ],
            };
          }
    
          // Format the response
          let formattedResponse = `Users in Group (ID: ${params.groupId}):\n`;
          let count = 0;
    
          // Track pagination info
          let after: string | undefined;
    
          // Process the users collection
          for await (const user of users) {
            // Check if user is valid
            if (!user || !user.id) {
              continue;
            }
    
            count++;
    
            // Remember the last user ID for pagination
            after = user.id;
    
            formattedResponse += `
    ${count}. ${user.profile?.firstName || ""} ${user.profile?.lastName || ""} (${user.profile?.email || "No email"})
     - ID: ${user.id}
     - Status: ${user.status || "Unknown"}
     - Created: ${formatDate(user.created)}
     - Last Updated: ${formatDate(user.lastUpdated)}
    `;
          }
    
          if (count === 0) {
            return {
              content: [
                {
                  type: "text",
                  text: "No users found in this group.",
                },
              ],
            };
          }
    
          // Add pagination information
          if (after && count >= (params.limit || 50)) {
            formattedResponse += `\nPagination:\n- Total users shown: ${count}\n`;
            formattedResponse += `- For next page, use 'after' parameter with value: ${after}\n`;
          } else {
            formattedResponse += `\nTotal users in group: ${count}\n`;
          }
    
          return {
            content: [
              {
                type: "text",
                text: formattedResponse,
              },
            ],
          };
        } catch (error) {
          console.error("Error listing group users:", error);
          return {
            content: [
              {
                type: "text",
                text: `Failed to list group users: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
            isError: true,
          };
        }
      },
  • Zod schema for input validation of the 'list_group_users' tool parameters, used in the handler to parse and validate the request.parameters.
    listGroupUsers: z.object({
      groupId: z.string().min(1, "Group ID is required"),
      limit: z.number().min(1).max(200).optional().default(50),
      after: z.string().optional(),
    }),
  • Tool registration entry in the groupTools array, defining the name, description, and JSON inputSchema for the MCP tool 'list_group_users'.
    {
      name: "list_group_users",
      description: "List all users in a specific group",
      inputSchema: {
        type: "object",
        properties: {
          groupId: {
            type: "string",
            description: "ID of the group",
          },
          limit: {
            type: "number",
            description:
              "Maximum number of users to return (default: 50, max: 200)",
          },
          after: {
            type: "string",
            description: "Cursor for pagination, obtained from previous response",
          },
        },
        required: ["groupId"],
      },
    },
  • Utility function to initialize and return the Okta client instance, used by the handler to make API calls.
    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,
      });
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While 'List' implies a read operation, it doesn't mention pagination behavior (though hinted in schema), rate limits, authentication requirements, or what happens with invalid group IDs. For a tool with 3 parameters and no annotation coverage, this leaves significant behavioral gaps.

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 that gets straight to the point with zero wasted words. It's appropriately sized for a straightforward listing tool and front-loads the core functionality without unnecessary elaboration.

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?

For a tool with 3 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain the return format, pagination behavior, error conditions, or how it differs from similar listing tools. The agent would need to rely heavily on the input schema alone to understand this tool's full context.

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%, so the schema already documents all parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema - it mentions 'specific group' which aligns with 'groupId' but provides no extra context about format, validation, or relationships between parameters.

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 ('List') and resource ('users in a specific group'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'list_users' or 'get_group', which could cause confusion about when to use this specific tool versus alternatives.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'list_users' or 'get_group'. There's no mention of prerequisites, context, or exclusions, leaving the agent to guess when this specific group-focused listing is appropriate.

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