Skip to main content
Glama

cortex_get_user

Retrieve details of a specific user in the Cortex platform using a superadmin API key, enabling security investigations and access control management.

Instructions

Get details about a specific user (requires superadmin API key)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
userIdYesThe user login/ID

Implementation Reference

  • MCP tool handler for 'cortex_get_user' - receives a userId, checks superadmin availability, calls client.getUser(), and returns the user details as JSON.
    server.tool(
      "cortex_get_user",
      "Get details about a specific user (requires superadmin API key)",
      {
        userId: z.string().describe("The user login/ID"),
      },
      async ({ userId }) => {
        try {
          if (!client.superadminAvailable) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: "User management requires CORTEX_SUPERADMIN_KEY environment variable to be set.",
                },
              ],
              isError: true,
            };
          }
    
          const user = await client.getUser(userId);
          return {
            content: [
              {
                type: "text" as const,
                text: JSON.stringify(user, null, 2),
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text" as const,
                text: `Error getting user: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
            isError: true,
          };
        }
      },
    );
  • Client method getUser() - makes a GET request to /user/{userId} using superadmin auth, returns a CortexUser object. This is the API call backing the handler.
    async getUser(userId: string): Promise<CortexUser> {
      return this.request<CortexUser>(
        `/user/${encodeURIComponent(userId)}`,
        {},
        true,
      );
    }
  • CortexUser interface - defines the shape of a user object returned by the API, including id, name, organization, roles, status, hasKey, hasPassword, and timestamps.
    export interface CortexUser {
      id: string;
      name: string;
      organization: string;
      roles: string[];
      status: string;
      hasKey?: boolean;
      hasPassword?: boolean;
      createdAt?: number;
      createdBy?: string;
      updatedAt?: number;
      updatedBy?: string;
      _type?: string;
    }
  • src/index.ts:44-44 (registration)
    Registration of the user tools module - calls registerUserTools(server, client) to register all user tools including cortex_get_user on the MCP server.
    registerUserTools(server, client);
  • registerUserTools function - registers all user-related MCP tools (list, get, create, renew key, get key) on the server instance.
    export function registerUserTools(
      server: McpServer,
      client: CortexClient,
    ): void {
      server.tool(
        "cortex_list_users",
        "List all users across organizations (requires superadmin API key via CORTEX_SUPERADMIN_KEY)",
        {},
        async () => {
          try {
            if (!client.superadminAvailable) {
              return {
                content: [
                  {
                    type: "text" as const,
                    text: "User listing across organizations requires CORTEX_SUPERADMIN_KEY environment variable to be set.",
                  },
                ],
                isError: true,
              };
            }
    
            const users = await client.listUsers();
            const summary = users.map((u) => ({
              id: u.id,
              name: u.name,
              organization: u.organization,
              roles: u.roles,
              status: u.status,
              hasKey: u.hasKey,
              hasPassword: u.hasPassword,
            }));
    
            return {
              content: [
                {
                  type: "text" as const,
                  text: JSON.stringify(summary, null, 2),
                },
              ],
            };
          } catch (error) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: `Error listing users: ${error instanceof Error ? error.message : String(error)}`,
                },
              ],
              isError: true,
            };
          }
        },
      );
    
      server.tool(
        "cortex_get_user",
        "Get details about a specific user (requires superadmin API key)",
        {
          userId: z.string().describe("The user login/ID"),
        },
        async ({ userId }) => {
          try {
            if (!client.superadminAvailable) {
              return {
                content: [
                  {
                    type: "text" as const,
                    text: "User management requires CORTEX_SUPERADMIN_KEY environment variable to be set.",
                  },
                ],
                isError: true,
              };
            }
    
            const user = await client.getUser(userId);
            return {
              content: [
                {
                  type: "text" as const,
                  text: JSON.stringify(user, null, 2),
                },
              ],
            };
          } catch (error) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: `Error getting user: ${error instanceof Error ? error.message : String(error)}`,
                },
              ],
              isError: true,
            };
          }
        },
      );
    
      server.tool(
        "cortex_create_user",
        "Create a new user in an organization (requires superadmin API key)",
        {
          login: z.string().describe("User login (used as ID)"),
          name: z.string().describe("User display name"),
          organization: z.string().describe("Organization to assign the user to"),
          roles: z
            .array(z.string())
            .describe(
              'User roles: "read", "analyze", "orgadmin", or "superadmin"',
            ),
          password: z.string().optional().describe("Optional initial password"),
        },
        async ({ login, name, organization, roles, password }) => {
          try {
            if (!client.superadminAvailable) {
              return {
                content: [
                  {
                    type: "text" as const,
                    text: "User creation requires CORTEX_SUPERADMIN_KEY environment variable to be set.",
                  },
                ],
                isError: true,
              };
            }
    
            const user = await client.createUser({
              login,
              name,
              roles,
              organization,
              password,
            });
    
            return {
              content: [
                {
                  type: "text" as const,
                  text: JSON.stringify(
                    {
                      id: user.id,
                      name: user.name,
                      organization: user.organization,
                      roles: user.roles,
                      status: user.status,
                      message: `User "${user.name}" (${user.id}) created in org "${user.organization}".`,
                    },
                    null,
                    2,
                  ),
                },
              ],
            };
          } catch (error) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: `Error creating user: ${error instanceof Error ? error.message : String(error)}`,
                },
              ],
              isError: true,
            };
          }
        },
      );
    
      server.tool(
        "cortex_renew_user_key",
        "Generate a new API key for a user (invalidates the previous key). Requires superadmin API key.",
        {
          userId: z.string().describe("The user login/ID to renew the key for"),
        },
        async ({ userId }) => {
          try {
            if (!client.superadminAvailable) {
              return {
                content: [
                  {
                    type: "text" as const,
                    text: "User key management requires CORTEX_SUPERADMIN_KEY environment variable to be set.",
                  },
                ],
                isError: true,
              };
            }
    
            const newKey = await client.renewUserKey(userId);
            return {
              content: [
                {
                  type: "text" as const,
                  text: JSON.stringify(
                    {
                      userId,
                      apiKey: newKey,
                      message: `New API key generated for user "${userId}". The previous key is now invalid.`,
                      warning: "Store this key securely. It will not be shown again.",
                    },
                    null,
                    2,
                  ),
                },
              ],
            };
          } catch (error) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: `Error renewing user key: ${error instanceof Error ? error.message : String(error)}`,
                },
              ],
              isError: true,
            };
          }
        },
      );
    
      server.tool(
        "cortex_get_user_key",
        "Get the current API key for a user. Requires superadmin API key.",
        {
          userId: z.string().describe("The user login/ID"),
        },
        async ({ userId }) => {
          try {
            if (!client.superadminAvailable) {
              return {
                content: [
                  {
                    type: "text" as const,
                    text: "User key management requires CORTEX_SUPERADMIN_KEY environment variable to be set.",
                  },
                ],
                isError: true,
              };
            }
    
            const key = await client.getUserKey(userId);
            return {
              content: [
                {
                  type: "text" as const,
                  text: JSON.stringify(
                    {
                      userId,
                      apiKey: key,
                    },
                    null,
                    2,
                  ),
                },
              ],
            };
          } catch (error) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: `Error getting user key: ${error instanceof Error ? error.message : String(error)}`,
                },
              ],
              isError: true,
            };
          }
        },
      );
    }
Behavior2/5

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

With no annotations, the description carries full burden. It only mentions authentication requirement but does not disclose what 'details' are returned, whether the operation is read-only, or any side effects. Insufficient behavioral context.

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?

Single sentence, no redundancy, front-loaded with key verb and resource. Optimally concise.

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 simple one-parameter retrieval tool, the description is adequate but lacks information about return values (no output schema). Could mention typical response fields or error conditions for completeness.

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 coverage is 100% with a clear description for the single parameter. The tool description adds no additional semantics beyond what the schema already provides, resulting in a baseline score of 3.

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

Purpose5/5

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

The description clearly states 'Get details about a specific user', which is a specific verb + resource. It distinguishes from siblings like 'cortex_list_users' (listing all) and 'cortex_create_user' (creating).

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

Usage Guidelines4/5

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

Explicitly notes the requirement of a superadmin API key, providing important context for when to use the tool. It implicitly differentiates from listing all users but lacks explicit when-not-to-use or alternative guidance.

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

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/solomonneas/cortex-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server