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),
          },
        ],
      };
    }

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