Skip to main content
Glama
HaithamOumerzoug

Keycloak MCP Server

delete-user

Remove a user from a specific realm in Keycloak using the MCP server. Specify the realm and user ID to ensure accurate deletion, streamlining user management tasks.

Instructions

Delete a user from a specific realm

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
realmYes
userIdYes

Implementation Reference

  • Implements the core logic for deleting a user: validates input with DeleteUserSchema, deletes via Keycloak admin client users.del, and returns success message.
    public async deleteUser(args: unknown): Promise<string> {
      const { realm, userId } = DeleteUserSchema.parse(args);
      await this.kcAdminClient.users.del({ id: userId, realm });
      return `User ${userId} deleted successfully from realm ${realm}`;
    }
  • Dispatches the delete-user tool invocation to KeycloakService.deleteUser in the CallToolRequest handler.
    case "delete-user":
      return {
        content: [
          { type: "text", text: await keycloakService.deleteUser(args) },
        ],
      };
  • JSON Schema definition for delete-user tool input parameters, referenced in tool registration.
    "delete-user": {
      type: "object",
      properties: {
        realm: { type: "string" },
        userId: { type: "string" },
      },
      required: ["realm", "userId"],
    },
  • Zod validation schema for delete-user input arguments, used in the service handler.
    export const DeleteUserSchema = z.object({
      realm: z.string(),
      userId: z.string(),
    });
  • src/server.ts:41-45 (registration)
    Registers the delete-user tool in the MCP server's ListTools response with name, description, and input schema.
    {
      name: "delete-user",
      description: "Delete a user from a specific realm",
      inputSchema: InputSchema["delete-user"],
    },
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 tool performs a 'delete' operation, implying it's destructive and non-read-only, which is helpful. However, it lacks critical details: whether deletion is permanent or reversible, what permissions are required, if there are rate limits, what happens to associated data, or what the response looks like. For a destructive tool with zero annotation coverage, this is insufficient.

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, clear sentence that efficiently conveys the core action without unnecessary words. It's front-loaded with the verb 'Delete' and avoids redundancy. Every word earns its place, making it easy for an agent 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?

Given the tool's complexity (a destructive operation with 2 parameters), lack of annotations, 0% schema description coverage, and no output schema, the description is incomplete. It doesn't address critical aspects like error conditions, return values, side effects, or security implications. The agent is left with significant gaps in understanding how to use this tool safely and effectively.

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 input schema has 0% description coverage, so parameters 'realm' and 'userId' are undocumented in the schema. The description adds minimal value by implying 'realm' specifies where the user exists and 'userId' identifies the user, but doesn't explain what these parameters represent (e.g., realm as an organizational boundary, userId as a unique identifier), their formats, or examples. It fails to compensate for the schema's lack of documentation.

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 ('Delete') and target resource ('a user from a specific realm'), making the purpose immediately understandable. It distinguishes this tool from sibling tools like 'create-user' or 'list-users' by specifying a destructive operation. However, it doesn't explicitly mention what 'delete' entails (e.g., permanent removal vs. deactivation), which prevents 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., user must exist), consequences of deletion, or relationships with sibling tools like 'create-user' or 'list-users'. The agent receives no help in deciding when this tool is appropriate versus other user management operations.

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