Skip to main content
Glama

rotate_api_key

Generate a new API key and invalidate the old one to enhance security. Triggers a withdrawal cooldown period: 60 minutes for operators, 30 minutes for agents.

Instructions

Generate a new API key, invalidating the old one. For operators: triggers 60-min withdrawal cooldown. For agents: 30-min cooldown.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
agent_idNoAgent ID (operators only). Omit to rotate operator key.

Implementation Reference

  • The implementation of the rotateApiKey method in the LightningFaucetClient class.
     * Rotate API key (operator or agent)
     */
    async rotateApiKey(agentId?: number): Promise<{
      apiKey: string;
      message: string;
      cooldownUntil?: string;
      rawResponse: ApiResponse;
    }> {
      const action = agentId ? 'regenerate_agent_key' : 'regenerate_operator_key';
      const data: Record<string, unknown> = {};
      if (agentId) data.agent_id = agentId;
    
      const result = await this.request<ApiResponse & {
        api_key?: string;
        new_api_key?: string;
        message?: string;
        cooldown_until?: string;
      }>(action, data);
    
      return {
        apiKey: result.api_key || result.new_api_key || '',
        message: result.message || 'API key rotated',
        cooldownUntil: result.cooldown_until,
        rawResponse: result,
      };
    }
  • src/index.ts:201-203 (registration)
    Zod schema definition for rotate_api_key tool arguments.
    const RotateApiKeySchema = z.object({
      agent_id: z.number().int().positive().optional().describe('Agent ID (operators only). If omitted, rotates operator key.'),
    });
  • Request handler for the rotate_api_key tool.
    case 'rotate_api_key': {
      const parsed = RotateApiKeySchema.parse(args);
      const result = await session.requireClient().rotateApiKey(parsed.agent_id);
      // Auto-switch to the new key
      session.setClient(new LightningFaucetClient(result.apiKey));
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify({
              success: true,
              message: result.message || 'API key rotated. New key is now active.',
              new_api_key: result.apiKey,
              cooldown_until: result.cooldownUntil,
            }, null, 2),
          },
        ],
      };
    }
Behavior4/5

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

With no annotations provided, the description carries the full burden and does so effectively. It discloses critical behavioral traits: the action generates a new key and invalidates the old one, and specifies cooldown durations (60 minutes for operators, 30 minutes for agents). This covers mutation impact and timing constraints clearly.

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 highly concise and front-loaded, with two sentences that efficiently convey the core action and key behavioral details (cooldowns). Every sentence adds essential value without redundancy.

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 the tool's complexity (a mutation with cooldown effects), no annotations, and no output schema, the description is largely complete. It covers the action, resource, and behavioral constraints. A slight gap exists in not detailing the output (e.g., what the new key looks like), but it's adequate for the 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?

The input schema has 100% description coverage, so the baseline is 3. The description does not add meaning beyond the schema's parameter details (e.g., it doesn't explain the implications of omitting 'agent_id' further than the schema does), but it doesn't need to compensate for gaps.

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 specific action ('Generate a new API key, invalidating the old one') and identifies the resource (API key). It distinguishes itself from siblings like 'set_operator_key' by focusing on rotation with invalidation rather than initial setting or updating.

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?

The description provides clear context for usage by specifying different cooldown periods for operators and agents, which helps guide when to use it. However, it does not explicitly state when not to use it or name alternatives (e.g., compared to 'set_operator_key'), leaving some room for improvement.

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/lightningfaucet/lightning-wallet-mcp'

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