revoke_api_key
Remove an API key from the Stacksfinder MCP server to prevent further access. This action is permanent and cannot be reversed.
Instructions
Revokes an API key. This action cannot be undone.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| keyId | Yes | The UUID of the API key to revoke |
Implementation Reference
- dist/tools/api-keys.js:185-236 (handler)The handler function that executes the revoke_api_key tool. It validates the presence of a configured API key, makes a DELETE request to the StacksFinder API to revoke the specified keyId, handles various error responses, and returns a success or error message.export async function executeRevokeApiKey(input) { const config = getConfig(); const { keyId } = input; if (!config.apiKey) { return { text: `**Error**: No API key configured. Set STACKSFINDER_API_KEY environment variable.`, isError: true }; } debug('Revoking API key', keyId); try { const response = await fetch(`${config.apiUrl}/api/v1/keys/${keyId}`, { method: 'DELETE', headers: { Authorization: `Bearer ${config.apiKey}`, 'Content-Type': 'application/json' } }); if (!response.ok) { if (response.status === 401) { return { text: '**Error**: Invalid API key. Please reconfigure with a valid key.', isError: true }; } if (response.status === 404) { return { text: `**Error**: API key not found or already revoked.`, isError: true }; } const errorText = await response.text(); return { text: `**Error**: Failed to revoke key (${response.status}): ${errorText}`, isError: true }; } return { text: `## API Key Revoked The API key \`${keyId}\` has been revoked and can no longer be used. **Note**: If you revoked the key you're currently using, you'll need to configure a new one.` }; } catch (err) { const errorMessage = err instanceof Error ? err.message : 'Failed to revoke API key'; return { text: `**Error**: ${errorMessage}`, isError: true }; }
- dist/tools/api-keys.js:172-174 (schema)Zod input schema defining the required keyId parameter as a UUID string.export const RevokeApiKeyInputSchema = z.object({ keyId: z.string().uuid().describe('The UUID of the API key to revoke') });
- dist/server.js:236-250 (registration)Registers the revoke_api_key tool with the MCP server, providing title, description, input schema, and a handler wrapper that parses input and calls executeRevokeApiKey.server.registerTool(revokeApiKeyToolDefinition.name, { title: 'Revoke API Key', description: revokeApiKeyToolDefinition.description, inputSchema: { keyId: z.string().uuid().describe('The UUID of the API key to revoke') } }, async (args) => { debug('revoke_api_key called', args.keyId); const input = RevokeApiKeyInputSchema.parse(args); const { text, isError } = await executeRevokeApiKey(input); return { content: [{ type: 'text', text }], isError }; });
- dist/tools/api-keys.js:178-181 (helper)Tool definition object containing the name and description used for registration.export const revokeApiKeyToolDefinition = { name: 'revoke_api_key', description: 'Revokes an API key. This action cannot be undone.' };