Skip to main content
Glama
HaithamOumerzoug

Keycloak MCP Server

create-user

Add a new user to a Keycloak realm by specifying username, email, first name, and last name using the Keycloak MCP Server tool.

Instructions

Create a new user in a specific realm

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
emailYes
firstNameYes
lastNameYes
realmYes
usernameYes

Implementation Reference

  • The core handler function that executes the create-user tool logic: parses input with Zod schema and creates user using Keycloak Admin Client.
    public async createUser(args: unknown): Promise<string> {
      const { realm, username, email, firstName, lastName } =
        CreateUserSchema.parse(args);
      const user: UserRepresentation = await this.kcAdminClient.users.create({
        realm,
        username,
        email,
        firstName,
        lastName,
        enabled: true,
      });
      return `User created successfully. User ID: ${user.id}`;
    }
  • JSON Schema definition for the 'create-user' tool input, referenced in tool registration.
    "create-user": {
      type: "object",
      properties: {
        realm: { type: "string" },
        username: { type: "string" },
        email: { type: "string", format: "email" },
        firstName: { type: "string" },
        lastName: { type: "string" },
      },
      required: ["realm", "username", "email", "firstName", "lastName"],
    },
  • Zod validation schema for create-user arguments, used inside the handler for input parsing.
    export const CreateUserSchema = z.object({
      realm: z.string(),
      username: z.string(),
      email: z.string().email(),
      firstName: z.string(),
      lastName: z.string(),
    });
  • src/server.ts:36-40 (registration)
    Tool registration in the listTools handler: defines name, description, and input schema.
    {
      name: "create-user",
      description: "Create a new user in a specific realm",
      inputSchema: InputSchema["create-user"],
    },
  • Dispatch case in the callToolRequest handler that invokes the createUser service method.
    case "create-user":
      return {
        content: [
          { type: "text", text: await keycloakService.createUser(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 'Create' which implies a write/mutation operation, but doesn't mention permissions required, whether the operation is idempotent, what happens on duplicate entries, or any rate limits. This leaves significant gaps for a mutation tool.

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, efficient sentence with zero wasted words. It's appropriately sized and front-loaded with the core purpose, making it easy to parse quickly.

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?

For a mutation tool with 5 parameters, 0% schema coverage, no annotations, and no output schema, the description is inadequate. It doesn't explain what happens after creation (e.g., returns user ID), error conditions, or behavioral nuances, leaving too many unknowns for effective tool 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?

The schema has 5 parameters with 0% description coverage, so the description must compensate. However, it only mentions 'realm' implicitly ('in a specific realm') and doesn't explain any parameters like email format requirements, username constraints, or the relationship between fields. This fails to add meaningful semantic context beyond the bare schema.

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 ('Create') and resource ('new user in a specific realm'), providing a specific verb+resource combination. However, it doesn't differentiate from sibling tools like 'add-user-to-group' or 'list-users', which would require explicit comparison to achieve a score of 5.

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 like 'add-user-to-group' or 'delete-user'. It mentions 'in a specific realm' which implies a context but doesn't specify prerequisites, exclusions, or when-not-to-use scenarios.

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