Skip to main content
Glama
idoyudha

mcp-keycloak

by idoyudha

create_user

Add new users to Keycloak identity management with username, email, and profile details. Set initial passwords and configure user attributes for access control.

Instructions

Create a new user.

Args:
    username: Username for the new user
    email: Email address
    first_name: First name
    last_name: Last name
    enabled: Whether the user is enabled
    email_verified: Whether the email is verified
    temporary_password: Initial password (user will be required to change it)
    attributes: Additional user attributes
    realm: Target realm (uses default if not specified)

Returns:
    Dict with status and location of created user

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYes
emailNo
first_nameNo
last_nameNo
enabledNo
email_verifiedNo
temporary_passwordNo
attributesNo
realmNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'create_user' MCP tool. It is decorated with @mcp.tool(), which handles both registration and schema definition via type hints and docstring. The function constructs user data and calls the Keycloak client to create the user.
    @mcp.tool()
    async def create_user(
        username: str,
        email: Optional[str] = None,
        first_name: Optional[str] = None,
        last_name: Optional[str] = None,
        enabled: bool = True,
        email_verified: bool = False,
        temporary_password: Optional[str] = None,
        attributes: Optional[Dict[str, List[str]]] = None,
        realm: Optional[str] = None,
    ) -> Dict[str, str]:
        """
        Create a new user.
    
        Args:
            username: Username for the new user
            email: Email address
            first_name: First name
            last_name: Last name
            enabled: Whether the user is enabled
            email_verified: Whether the email is verified
            temporary_password: Initial password (user will be required to change it)
            attributes: Additional user attributes
            realm: Target realm (uses default if not specified)
    
        Returns:
            Dict with status and location of created user
        """
        user_data = {
            "username": username,
            "enabled": enabled,
            "emailVerified": email_verified,
        }
    
        if email:
            user_data["email"] = email
        if first_name:
            user_data["firstName"] = first_name
        if last_name:
            user_data["lastName"] = last_name
        if attributes:
            user_data["attributes"] = attributes
    
        if temporary_password:
            user_data["credentials"] = [
                {"type": "password", "value": temporary_password, "temporary": True}
            ]
    
        # Create user returns no content, but includes Location header
        await client._make_request("POST", "/users", data=user_data, realm=realm)
        return {"status": "created", "message": f"User {username} created successfully"}
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 mentions that 'temporary_password' requires the user to change it, which adds some context. However, it lacks critical details: whether this is a destructive/mutative operation (implied but not stated), authentication requirements, rate limits, error conditions, or side effects. For a user creation 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.

Conciseness4/5

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

The description is well-structured and appropriately sized. It starts with a clear purpose statement, followed by organized 'Args' and 'Returns' sections. Each sentence adds value without redundancy. Minor improvements could include bolding key terms, but overall it's efficient and easy to parse.

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

Completeness3/5

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

Given the complexity (9 parameters, 1 required) and the presence of an output schema (which handles return values), the description is moderately complete. It covers parameter semantics well but lacks behavioral context (no annotations) and usage guidelines. For a user creation tool, it should address permissions, idempotency, or error handling to be fully adequate.

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

Parameters4/5

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

The description adds significant value beyond the input schema, which has 0% description coverage. It provides clear explanations for each parameter (e.g., 'temporary_password: Initial password (user will be required to change it)'), clarifying purposes that aren't evident from schema titles alone. This compensates well for the schema's lack of descriptions, though it doesn't cover all nuances like default behaviors or constraints.

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 tool's purpose: 'Create a new user.' It specifies the verb ('Create') and resource ('user'), making the function unambiguous. However, it doesn't differentiate from sibling tools like 'update_user' or 'delete_user' beyond the basic action, 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., permissions), compare to sibling tools like 'update_user' for existing users, or specify contexts where creation is appropriate versus other operations. This lack of usage context leaves the agent without clear decision-making criteria.

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

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

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