Skip to main content
Glama

cortex_get_user_key

Retrieve the current API key for a specified user. Requires superadmin privileges.

Instructions

Get the current API key for a user. Requires superadmin API key.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
userIdYesThe user login/ID

Implementation Reference

  • Registration of the 'cortex_get_user_key' tool via server.tool(), with Zod schema for userId parameter
    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,
          };
        }
      },
    );
  • Handler function that checks superadmin availability, calls client.getUserKey(userId), and returns the API key in JSON format
    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,
        };
      }
    },
  • The client.getUserKey() helper method that makes the actual HTTP request to GET /user/{userId}/key
    async getUserKey(userId: string): Promise<string> {
      return this.requestText(
        `/user/${encodeURIComponent(userId)}/key`,
        {},
        true,
      );
    }
  • src/tools/users.ts:5-8 (registration)
    The registerUserTools function that contains all user tool registrations, including cortex_get_user_key
    export function registerUserTools(
      server: McpServer,
      client: CortexClient,
    ): void {
Behavior3/5

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

With no annotations provided, the description correctly identifies the operation as a read action requiring superadmin privileges. However, it does not disclose behavioral traits such as response format, error handling, or whether the key is returned in plaintext.

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 extremely concise with two sentences, front-loading the action and then providing a key prerequisite. No unnecessary words are present.

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 tool with no output schema, the description adequately states purpose and authorization but lacks information about the return value (e.g., format or content of the API key). This leaves a minor gap in understanding the tool's complete behavior.

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 input schema covers 100% of the parameter info, so the description does not need to add detail. The baseline score of 3 applies as the description adds no extra meaning beyond what the schema provides.

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 uses a specific verb 'Get' and resource 'current API key for a user', making the tool's purpose unambiguous. It implicitly distinguishes from the sibling 'cortex_renew_user_key' by focusing on retrieval rather than renewal.

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 mentions the superadmin requirement but does not provide explicit guidance on when to use this tool versus alternatives like 'cortex_renew_user_key'. Usage context is implied but not fully detailed.

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