Skip to main content
Glama
HaithamOumerzoug

Keycloak MCP Server

add-user-to-group

Assign a user to a specific group in Keycloak by specifying the realm, user ID, and group ID. Streamlines group management for organized user access and permissions.

Instructions

Add a user to a group

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
groupIdYes
realmYes
userIdYes

Implementation Reference

  • The core handler function for 'add-user-to-group' tool. Parses input arguments using Zod schema and calls Keycloak admin client to add the user to the specified group.
    public async addUserToGroup(args: unknown): Promise<string> { const { realm, userId, groupId } = AddUserToGroupSchema.parse(args); await this.kcAdminClient.users.addToGroup({ realm, id: userId, groupId, }); return `User ${userId} added to group ${groupId} in realm ${realm}`; }
  • JSON schema definition for the 'add-user-to-group' tool input, used in tool registration.
    "add-user-to-group": { type: "object", properties: { realm: { type: "string" }, userId: { type: "string" }, groupId: { type: "string" }, }, required: ["realm", "userId", "groupId"], },
  • Zod schema for validating inputs in the handler, corresponding to the tool's input schema.
    export const AddUserToGroupSchema = z.object({ realm: z.string(), userId: z.string(), groupId: z.string(), });
  • src/server.ts:61-65 (registration)
    Tool registration in the ListTools handler, defining name, description, and input schema.
    { name: "add-user-to-group", description: "Add a user to a group", inputSchema: InputSchema["add-user-to-group"], },
  • src/server.ts:128-136 (registration)
    Dispatch in the CallTool request handler that routes to the keycloakService.addUserToGroup method.
    case "add-user-to-group": return { content: [ { type: "text", text: await keycloakService.addUserToGroup(args), }, ], };

Other Tools

Related Tools

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/HaithamOumerzoug/keycloak-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server