Skip to main content
Glama

update_user

Modify user details in Keycloak, including username, email, name, and attributes. Use to enable/disable accounts, verify emails, or update user info in specified or default realms.

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
attributesNo
emailNo
email_verifiedNo
enabledNo
first_nameNo
last_nameNo
realmNo
user_idYes
usernameNo

Implementation Reference

  • The async handler function for the 'update_user' MCP tool. Decorated with @mcp.tool() for automatic registration and schema inference from parameters. Updates user attributes in Keycloak by merging provided changes with existing data.
    @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"}

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