@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"}