iam_add_member_to_group
Add an IAM user or service ID to an access group to grant permissions.
Instructions
Add a member (user or service ID) to an access group
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| access_group_id | Yes | ID of the access group | |
| iam_id | Yes | IAM ID of the member to add | |
| type | Yes | Type of member |
Implementation Reference
- src/tools/iam/index.ts:202-217 (registration)Tool registration: 'iam_add_member_to_group' is registered via server.tool() with name, description, schema, and handler.
// ─── iam_add_member_to_group ────────────────────────────────── server.tool( "iam_add_member_to_group", "Add a member (user or service ID) to an access group", { access_group_id: z.string().describe("ID of the access group"), iam_id: z.string().describe("IAM ID of the member to add"), type: z.enum(["user", "service"]).describe("Type of member"), }, async ({ access_group_id, iam_id, type }) => safeTool(async () => { assertWriteAllowed(config.allowWrite); return client.put(`${IBM_ENDPOINTS.IAM_ACCESS_GROUPS}/groups/${access_group_id}/members`, { members: [{ iam_id, type }], }); }) ); - src/tools/iam/index.ts:211-216 (handler)Handler function: Makes a PUT request to IBM IAM Access Groups API to add a member to an access group. Wraps logic in safeTool() and checks assertWriteAllowed().
async ({ access_group_id, iam_id, type }) => safeTool(async () => { assertWriteAllowed(config.allowWrite); return client.put(`${IBM_ENDPOINTS.IAM_ACCESS_GROUPS}/groups/${access_group_id}/members`, { members: [{ iam_id, type }], }); }) - src/tools/iam/index.ts:206-210 (schema)Input schema: Defines three parameters - access_group_id (string), iam_id (string), and type (enum: user/service).
{ access_group_id: z.string().describe("ID of the access group"), iam_id: z.string().describe("IAM ID of the member to add"), type: z.enum(["user", "service"]).describe("Type of member"), }, - src/server.ts:50-50 (registration)Top-level registration: registerIAMTools() is called in server.ts to register all IAM tools including this one.
registerIAMTools(server, client, config); - src/lib/utils.ts:70-77 (helper)safeTool helper: Wraps handler execution in try/catch, returning success/error content for MCP responses.
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); } }