update_client
Modify client configurations in mcp-keycloak, including ID, name, enabled status, redirect URIs, CORS origins, and access grant settings. Specify the target realm for updates.
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
| Name | Required | Description | Default |
|---|---|---|---|
| client_id | No | ||
| description | No | ||
| direct_access_grants_enabled | No | ||
| enabled | No | ||
| id | Yes | ||
| name | No | ||
| public_client | No | ||
| realm | No | ||
| redirect_uris | No | ||
| service_accounts_enabled | No | ||
| web_origins | No |
Implementation Reference
- src/tools/client_tools.py:157-216 (handler)The main handler function for the 'update_client' MCP tool. It is decorated with @mcp.tool() which registers it. The function fetches the current client data from Keycloak, updates only the provided fields, and performs a PUT request to save the changes.@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"}