remove_user_from_group
Remove a user from a specified group in Keycloak by providing the user ID, group ID, and optional realm. Returns a status message indicating success or failure.
Instructions
Remove a user from a group.
Args:
user_id: User ID
group_id: Group ID
realm: Target realm (uses default if not specified)
Returns:
Status message
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| group_id | Yes | ||
| realm | No | ||
| user_id | Yes |
Implementation Reference
- src/tools/group_tools.py:191-212 (handler)The main handler function for the 'remove_user_from_group' tool. It is decorated with @mcp.tool(), which registers it as an MCP tool. The function removes the user from the group using the KeycloakClient and returns a status message.@mcp.tool() async def remove_user_from_group( user_id: str, group_id: str, realm: Optional[str] = None ) -> Dict[str, str]: """ Remove a user from a group. Args: user_id: User ID group_id: Group ID realm: Target realm (uses default if not specified) Returns: Status message """ await client._make_request( "DELETE", f"/users/{user_id}/groups/{group_id}", realm=realm ) return { "status": "removed", "message": f"User {user_id} removed from group {group_id}", }