Skip to main content
Glama
kapilduraphe

Okta MCP Server

list_users

Retrieve and manage Okta user data with filtering, sorting, and pagination options to streamline user management tasks.

Instructions

List users from Okta with optional filtering and pagination

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
afterNoCursor for pagination, obtained from previous response
filterNoSCIM filter expression to filter users
limitNoMaximum number of users to return (default: 50, max: 200)
searchNoFree-form text search across multiple fields
sortByNoField to sort results by
sortOrderNoSort order (asc or desc, default: asc)

Implementation Reference

  • The main handler function for the 'list_users' tool. It validates input parameters using Zod schema, constructs query parameters for the Okta API, fetches the list of users, iterates through them using a for-await loop, formats a detailed text response including user details and pagination info, and returns the content in the expected MCP format.
      list_users: async (request: { parameters: unknown }) => {
        const params = userSchemas.listUsers.parse(request.parameters);
    
        try {
          // Build query parameters
          const queryParams: Record<string, any> = {};
          if (params.limit) queryParams.limit = params.limit;
          if (params.after) queryParams.after = params.after;
          if (params.filter) queryParams.filter = params.filter;
          if (params.search) queryParams.search = params.search;
          if (params.sortBy) queryParams.sortBy = params.sortBy;
          if (params.sortOrder) queryParams.sortOrder = params.sortOrder;
    
          const oktaClient = getOktaClient();
    
          // Get users list
          const users = await oktaClient.userApi.listUsers(queryParams);
    
          if (!users) {
            return {
              content: [
                {
                  type: "text",
                  text: "No users data was returned from Okta.",
                },
              ],
            };
          }
    
          // Format the response
          let formattedResponse = "Users:\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 matching your criteria.",
                },
              ],
            };
          }
    
          // 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: ${count}\n`;
          }
    
          return {
            content: [
              {
                type: "text",
                text: formattedResponse,
              },
            ],
          };
        } catch (error) {
          console.error("Error listing users:", error);
          return {
            content: [
              {
                type: "text",
                text: `Failed to list users: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
            isError: true,
          };
        }
      },
  • Zod schema definition for validating the input parameters of the list_users tool, used in the handler for parsing request.parameters.
    listUsers: z.object({
      limit: z.number().min(1).max(200).optional().default(50),
      filter: z.string().optional(),
      search: z.string().optional(),
      after: z.string().optional(),
      sortBy: z.string().optional(),
      sortOrder: z.enum(["asc", "desc"]).optional().default("asc"),
    }),
  • The tool registration object in the userTools export array, defining the name 'list_users', description, and JSON inputSchema for MCP tool registration.
    {
      name: "list_users",
      description: "List users from Okta with optional filtering and pagination",
      inputSchema: {
        type: "object",
        properties: {
          limit: {
            type: "number",
            description:
              "Maximum number of users to return (default: 50, max: 200)",
          },
          filter: {
            type: "string",
            description: "SCIM filter expression to filter users",
          },
          search: {
            type: "string",
            description: "Free-form text search across multiple fields",
          },
          after: {
            type: "string",
            description: "Cursor for pagination, obtained from previous response",
          },
          sortBy: {
            type: "string",
            description: "Field to sort results by",
          },
          sortOrder: {
            type: "string",
            description: "Sort order (asc or desc, default: asc)",
            enum: ["asc", "desc"],
          },
        },
      },
    },
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'optional filtering and pagination' which gives some context about capabilities, but fails to describe important behaviors like authentication requirements, rate limits, error conditions, response format, or whether this is a read-only operation (implied by 'list' but not explicit).

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 communicates the core functionality upfront. Every word earns its place - 'List users from Okta' establishes the purpose, while 'with optional filtering and pagination' adds important contextual information without unnecessary elaboration.

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

Completeness3/5

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

For a list operation with 6 well-documented parameters but no output schema and no annotations, the description is minimally adequate. It identifies the tool's purpose and hints at key features, but doesn't provide enough context about the response format, error handling, or integration patterns that would be helpful for an AI agent to use this tool effectively.

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?

The schema description coverage is 100%, providing complete documentation for all 6 parameters. The description adds minimal value beyond the schema by mentioning 'optional filtering and pagination' which aligns with the 'filter' and 'after/limit' parameters, but doesn't provide additional semantic context or usage examples beyond what's already in the parameter descriptions.

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 from Okta'), making the purpose immediately understandable. It distinguishes from siblings like 'get_user' by indicating it returns multiple users rather than a single one, though it doesn't explicitly contrast with other list operations like 'list_groups'.

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 'get_user' (for single users) or 'list_group_users' (for users within a group). It mentions optional filtering and pagination but doesn't explain when these features are appropriate or what scenarios warrant this tool over others.

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