iam_get_api_key
Retrieve detailed information about an IBM Cloud API key using its unique ID.
Instructions
Get details of a specific API key by its ID
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| api_key_id | Yes | The ID of the API key |
Implementation Reference
- src/tools/iam/index.ts:40-49 (handler)The handler/registration for the iam_get_api_key tool. It accepts an api_key_id parameter and makes a GET request to the IAM Identity API endpoint /v1/apikeys/{api_key_id} to retrieve API key details. Uses safeTool for error handling.
server.tool( "iam_get_api_key", "Get details of a specific API key by its ID", { api_key_id: z.string().describe("The ID of the API key"), }, async ({ api_key_id }) => safeTool(async () => { return client.get(`${iamIdentityBase}/apikeys/${api_key_id}`); }) ); - src/tools/iam/index.ts:43-45 (schema)Zod schema for the tool's input. Defines a single required parameter 'api_key_id' of type string.
{ api_key_id: z.string().describe("The ID of the API key"), }, - src/tools/iam/index.ts:40-49 (registration)Registration via server.tool() call. The tool is named 'iam_get_api_key' and is registered within the registerIAMTools function, which is called from src/server.ts.
server.tool( "iam_get_api_key", "Get details of a specific API key by its ID", { api_key_id: z.string().describe("The ID of the API key"), }, async ({ api_key_id }) => safeTool(async () => { return client.get(`${iamIdentityBase}/apikeys/${api_key_id}`); }) ); - src/lib/utils.ts:70-77 (helper)The safeTool helper wraps the handler logic in try/catch, returning formatted success or error MCP content blocks.
export async function safeTool<T>(fn: () => Promise<T>): Promise<ReturnType<typeof successContent> | ReturnType<typeof errorContent>> { try { const result = await fn(); return successContent(result); } catch (error) { return errorContent(error); } } - src/lib/api-client.ts:128-129 (helper)The client.get() method used by the handler to make the authenticated GET request to the IAM Identity API.
async get<T = unknown>(url: string, queryParams?: Record<string, string | number | boolean | undefined>): Promise<T> { return this.request<T>(url, { method: "GET", queryParams });