list_api_keys
List all API keys for your account. Each key shows name, masked key, scope, and status to help you control access.
Instructions
List all API keys for the authenticated user. Response: { keys: [{ id, name, masked_key, scope, enabled, created }] }. Use the record id with delete_api_key to revoke.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| user_id | Yes | Your user ID (shown on your dashboard) |
Implementation Reference
- src/index.ts:705-720 (handler)Tool handler for 'list_api_keys' – requires API key auth, accepts a user_id parameter, and sends a GET request to /api/api-keys?userId=... using the configured API key headers. Returns the JSON result via formatResult.
server.tool( "list_api_keys", "List all API keys for the authenticated user. Response: { keys: [{ id, name, masked_key, scope, enabled, created }] }. Use the record id with delete_api_key to revoke.", { user_id: z.string().describe("Your user ID (shown on your dashboard)"), }, async ({ user_id }) => { const guard = requireApiKey(); if (guard) return guard; const result = await apiFetch(`/api/api-keys?userId=${encodeURIComponent(user_id)}`, { method: "GET", headers: apiKeyHeaders(), }); return formatResult(result); } ); - src/index.ts:708-710 (schema)Input schema for the 'list_api_keys' tool – requires a single string parameter 'user_id' validated by Zod.
{ user_id: z.string().describe("Your user ID (shown on your dashboard)"), }, - src/index.ts:705-720 (registration)Registration of 'list_api_keys' as a tool on the MCP server via server.tool(). No separate registration file – it's inline in src/index.ts.
server.tool( "list_api_keys", "List all API keys for the authenticated user. Response: { keys: [{ id, name, masked_key, scope, enabled, created }] }. Use the record id with delete_api_key to revoke.", { user_id: z.string().describe("Your user ID (shown on your dashboard)"), }, async ({ user_id }) => { const guard = requireApiKey(); if (guard) return guard; const result = await apiFetch(`/api/api-keys?userId=${encodeURIComponent(user_id)}`, { method: "GET", headers: apiKeyHeaders(), }); return formatResult(result); } ); - src/index.ts:73-82 (helper)Helper function called by the list_api_keys handler to format the API response as MCP text content.
function formatResult(result: ApiResult): { content: Array<{ type: "text"; text: string }> } { return { content: [ { type: "text" as const, text: JSON.stringify(result.data, null, 2), }, ], }; } - src/index.ts:34-38 (helper)Helper function used by the list_api_keys handler to attach the X-API-Key header to the HTTP request.
function apiKeyHeaders(extra?: Record<string, string>): Record<string, string> { const h: Record<string, string> = { "Content-Type": "application/json" }; if (API_KEY) h["X-API-Key"] = API_KEY; return { ...h, ...extra }; }