Skip to main content
Glama
idoyudha

mcp-keycloak

by idoyudha

update_client

Modify Keycloak client settings including ID, name, redirect URIs, and access permissions to maintain accurate identity management configurations.

Instructions

Update an existing client.

Args:
    id: The client's database ID
    client_id: New client ID
    name: New display name
    description: New description
    enabled: Whether the client is enabled
    redirect_uris: New redirect URIs
    web_origins: New CORS origins
    public_client: Whether client is public
    service_accounts_enabled: Enable service accounts
    direct_access_grants_enabled: Enable direct access grants
    realm: Target realm (uses default if not specified)

Returns:
    Status message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes
client_idNo
nameNo
descriptionNo
enabledNo
redirect_urisNo
web_originsNo
public_clientNo
service_accounts_enabledNo
direct_access_grants_enabledNo
realmNo

Implementation Reference

  • Implements the 'update_client' MCP tool: fetches the current client configuration from Keycloak, applies only the provided field updates, and performs a PUT request to update the client. The @mcp.tool() decorator registers it as an MCP tool. Input schema defined by function parameters and docstring.
    @mcp.tool()
    async def update_client(
        id: str,
        client_id: Optional[str] = None,
        name: Optional[str] = None,
        description: Optional[str] = None,
        enabled: Optional[bool] = None,
        redirect_uris: Optional[List[str]] = None,
        web_origins: Optional[List[str]] = None,
        public_client: Optional[bool] = None,
        service_accounts_enabled: Optional[bool] = None,
        direct_access_grants_enabled: Optional[bool] = None,
        realm: Optional[str] = None,
    ) -> Dict[str, str]:
        """
        Update an existing client.
    
        Args:
            id: The client's database ID
            client_id: New client ID
            name: New display name
            description: New description
            enabled: Whether the client is enabled
            redirect_uris: New redirect URIs
            web_origins: New CORS origins
            public_client: Whether client is public
            service_accounts_enabled: Enable service accounts
            direct_access_grants_enabled: Enable direct access grants
            realm: Target realm (uses default if not specified)
    
        Returns:
            Status message
        """
        # Get current client data
        current_client = await client._make_request("GET", f"/clients/{id}", realm=realm)
    
        # Update only provided fields
        if client_id is not None:
            current_client["clientId"] = client_id
        if name is not None:
            current_client["name"] = name
        if description is not None:
            current_client["description"] = description
        if enabled is not None:
            current_client["enabled"] = enabled
        if redirect_uris is not None:
            current_client["redirectUris"] = redirect_uris
        if web_origins is not None:
            current_client["webOrigins"] = web_origins
        if public_client is not None:
            current_client["publicClient"] = public_client
        if service_accounts_enabled is not None:
            current_client["serviceAccountsEnabled"] = service_accounts_enabled
        if direct_access_grants_enabled is not None:
            current_client["directAccessGrantsEnabled"] = direct_access_grants_enabled
    
        await client._make_request(
            "PUT", f"/clients/{id}", data=current_client, realm=realm
        )
        return {"status": "updated", "message": f"Client {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