Skip to main content
Glama
collapseindex

CI-1T Prediction Stability Engine

create_api_key

Generate a new API key for accessing the Prediction Stability Engine. Requires a user ID and key name; the returned key is shown only once and must be saved immediately.

Instructions

Create a new CI-1T API key. Response: { api_key, masked_key, scope, record }. IMPORTANT: Save the returned api_key — it cannot be retrieved again after creation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
user_idYesYour user ID (shown on your dashboard)
nameYesHuman-readable name for the key
scopeNoEndpoint scope (default: all)

Implementation Reference

  • The handler function for the 'create_api_key' tool. It generates a cryptographically random API key (ci_...), hashes it with SHA-256, sends the hash to the backend API, and returns the raw key to the caller with a warning to save it.
    async ({ user_id, name, scope }) => {
      const guard = requireApiKey();
      if (guard) return guard;
      // Generate a random API key using cryptographic RNG
      const chars = "abcdefghijklmnopqrstuvwxyz0123456789";
      const bytes = randomBytes(32);
      let raw = "ci_";
      for (let i = 0; i < 32; i++) {
        raw += chars[bytes[i] % chars.length];
      }
      const masked = raw.slice(0, 6) + "••••••";
    
      // SHA-256 hash the key
      const encoder = new TextEncoder();
      const data = encoder.encode(raw);
      const hashBuffer = await crypto.subtle.digest("SHA-256", data);
      const hashArray = Array.from(new Uint8Array(hashBuffer));
      const keyHash = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
    
      const result = await apiFetch("/api/api-keys", {
        method: "POST",
        headers: apiKeyHeaders(),
        body: {
          user: user_id,
          name,
          key_hash: keyHash,
          masked_key: masked,
          scope: scope || "all",
          enabled: true,
        },
      });
    
      if (result.ok) {
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify(
                {
                  api_key: raw,
                  masked_key: masked,
                  scope: scope || "all",
                  record: result.data,
                  note: "Save this key — it cannot be retrieved again.",
                },
                null,
                2
              ),
            },
          ],
        };
      }
      return formatResult(result);
    }
  • Input schema for the 'create_api_key' tool: user_id (string), name (string 1-100 chars), and optional scope (enum: all, evaluate, fleet).
    {
      user_id: z.string().describe("Your user ID (shown on your dashboard)"),
      name: z.string().min(1).max(100).describe("Human-readable name for the key"),
      scope: z.enum(["all", "evaluate", "fleet"]).optional().describe("Endpoint scope (default: all)"),
    },
  • src/index.ts:722-784 (registration)
    Registration of the 'create_api_key' tool with the MCP server using server.tool(), including description and Zod schema.
    server.tool(
      "create_api_key",
      "Create a new CI-1T API key. Response: { api_key, masked_key, scope, record }. IMPORTANT: Save the returned api_key — it cannot be retrieved again after creation.",
      {
        user_id: z.string().describe("Your user ID (shown on your dashboard)"),
        name: z.string().min(1).max(100).describe("Human-readable name for the key"),
        scope: z.enum(["all", "evaluate", "fleet"]).optional().describe("Endpoint scope (default: all)"),
      },
      async ({ user_id, name, scope }) => {
        const guard = requireApiKey();
        if (guard) return guard;
        // Generate a random API key using cryptographic RNG
        const chars = "abcdefghijklmnopqrstuvwxyz0123456789";
        const bytes = randomBytes(32);
        let raw = "ci_";
        for (let i = 0; i < 32; i++) {
          raw += chars[bytes[i] % chars.length];
        }
        const masked = raw.slice(0, 6) + "••••••";
    
        // SHA-256 hash the key
        const encoder = new TextEncoder();
        const data = encoder.encode(raw);
        const hashBuffer = await crypto.subtle.digest("SHA-256", data);
        const hashArray = Array.from(new Uint8Array(hashBuffer));
        const keyHash = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
    
        const result = await apiFetch("/api/api-keys", {
          method: "POST",
          headers: apiKeyHeaders(),
          body: {
            user: user_id,
            name,
            key_hash: keyHash,
            masked_key: masked,
            scope: scope || "all",
            enabled: true,
          },
        });
    
        if (result.ok) {
          return {
            content: [
              {
                type: "text" as const,
                text: JSON.stringify(
                  {
                    api_key: raw,
                    masked_key: masked,
                    scope: scope || "all",
                    record: result.data,
                    note: "Save this key — it cannot be retrieved again.",
                  },
                  null,
                  2
                ),
              },
            ],
          };
        }
        return formatResult(result);
      }
    );
Behavior4/5

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

With no annotations, the description must disclose behavior. It states that the API key cannot be retrieved after creation and specifies the response structure, which are important behavioral traits.

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 two sentences long, front-loads the purpose, and includes a critical warning. No redundant or unnecessary information.

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

Completeness4/5

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

Given no output schema, the description explains the response structure and includes the essential 'save the key' warning. It covers the creation aspect well, though could mention authentication or rate limits if applicable.

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%, so the schema already documents all parameters. The description does not add extra meaning beyond what the schema provides, hence 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 the action ('Create a new CI-1T API key') and lists the response fields. It distinguishes itself from sibling tools like delete_api_key and list_api_keys by focusing on creation.

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 lacks explicit guidance on when to use this tool versus alternatives such as list_api_keys or delete_api_key. It provides a critical note about saving the key but no usage context.

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/collapseindex/ci-1t-mcp'

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