Skip to main content
Glama
idoyudha

mcp-keycloak

by idoyudha

update_user

Modify user account details in Keycloak, including username, email, name, status, and attributes, by providing the user ID and updated values.

Instructions

Update an existing user.

Args:
    user_id: The user's ID
    username: New username
    email: New email address
    first_name: New first name
    last_name: New last name
    enabled: Whether the user is enabled
    email_verified: Whether the email is verified
    attributes: Updated user attributes
    realm: Target realm (uses default if not specified)

Returns:
    Status message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
user_idYes
usernameNo
emailNo
first_nameNo
last_nameNo
enabledNo
email_verifiedNo
attributesNo
realmNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • This is the main handler function for the 'update_user' tool. It is decorated with @mcp.tool() which registers it as an MCP tool. The function fetches the current user data from Keycloak, updates only the provided fields, and performs a PUT request to update the user.
    @mcp.tool()
    async def update_user(
        user_id: str,
        username: Optional[str] = None,
        email: Optional[str] = None,
        first_name: Optional[str] = None,
        last_name: Optional[str] = None,
        enabled: Optional[bool] = None,
        email_verified: Optional[bool] = None,
        attributes: Optional[Dict[str, List[str]]] = None,
        realm: Optional[str] = None,
    ) -> Dict[str, str]:
        """
        Update an existing user.
    
        Args:
            user_id: The user's ID
            username: New username
            email: New email address
            first_name: New first name
            last_name: New last name
            enabled: Whether the user is enabled
            email_verified: Whether the email is verified
            attributes: Updated user attributes
            realm: Target realm (uses default if not specified)
    
        Returns:
            Status message
        """
        # First get the current user data
        current_user = await client._make_request("GET", f"/users/{user_id}", realm=realm)
    
        # Update only provided fields
        if username is not None:
            current_user["username"] = username
        if email is not None:
            current_user["email"] = email
        if first_name is not None:
            current_user["firstName"] = first_name
        if last_name is not None:
            current_user["lastName"] = last_name
        if enabled is not None:
            current_user["enabled"] = enabled
        if email_verified is not None:
            current_user["emailVerified"] = email_verified
        if attributes is not None:
            current_user["attributes"] = attributes
    
        await client._make_request(
            "PUT", f"/users/{user_id}", data=current_user, realm=realm
        )
        return {"status": "updated", "message": f"User {user_id} updated 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. While 'Update an existing user' implies a mutation operation, the description doesn't specify what permissions are needed, whether changes are reversible, if there are rate limits, or what happens when partial updates are provided. The 'Returns: Status message' is minimal and doesn't describe success/failure patterns.

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 with clear sections (Args, Returns) and uses bullet-like formatting. Each sentence earns its place, though the parameter explanations could be slightly more detailed given the complexity. The front-loaded purpose statement is effective.

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?

For a 9-parameter mutation tool with no annotations, the description provides basic parameter semantics and return information. However, it lacks critical context about permissions, error conditions, and behavioral details that would help an agent use it correctly. The existence of an output schema reduces the need to fully describe returns, but more operational guidance is needed.

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 provides a helpful parameter list with brief explanations for all 9 parameters, adding significant value beyond the schema which has 0% description coverage. It clarifies that 'user_id' identifies the target user, other fields represent new values, and 'realm' is optional with default behavior. However, it doesn't explain the format of 'attributes' or what 'enabled' and 'email_verified' actually control.

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 verb ('Update') and resource ('an existing user'), making the purpose immediately understandable. However, it doesn't differentiate this tool from similar sibling tools like 'update_client' or 'update_group' beyond the resource type, 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 like 'create_user' or 'delete_user'. There's no mention of prerequisites, permissions required, or typical use cases, leaving the agent to infer usage context from the tool name alone.

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