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),
          },
        ],
      };
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('Add') but doesn't explain what this entails—whether it requires admin permissions, if it's idempotent (e.g., adding an already-member user), what happens on success/failure, or any rate limits. For a mutation tool with zero annotation coverage, this leaves critical behavioral traits unspecified.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, direct sentence with zero wasted words. It's front-loaded with the core action and resources, making it easy to parse quickly. Every word earns its place by conveying the essential purpose without redundancy or fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a mutation with 3 required parameters), lack of annotations, and no output schema, the description is incomplete. It doesn't address behavioral aspects like permissions or idempotency, parameter meanings, or expected outcomes. For a tool that modifies group membership, this minimal description fails to provide sufficient context for safe and effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the schema provides no parameter details. The description adds no information about the three required parameters (groupId, realm, userId), such as their formats, examples, or relationships. It doesn't compensate for the schema's lack of documentation, leaving parameters semantically unclear beyond their names.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Add') and the target resources ('a user to a group'), making the purpose immediately understandable. It distinguishes from siblings like 'create-user' or 'list-groups' by focusing on membership modification rather than creation or listing. However, it doesn't specify the system context (e.g., identity management) or differentiate from similar tools like 'assign-client-role-to-user', keeping it from a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., existing user and group), exclusions, or comparisons to siblings like 'assign-client-role-to-user' for role-based assignments. Without such context, an agent might struggle to choose between this and other user-group management tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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