Skip to main content
Glama
idoyudha

mcp-keycloak

by idoyudha

get_user_groups

Retrieve all groups associated with a specific user in Keycloak identity management to manage access permissions and organizational structure.

Instructions

Get all groups for a user.

Args:
    user_id: User ID
    realm: Target realm (uses default if not specified)

Returns:
    List of groups the user belongs to

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
user_idYes
realmNo

Implementation Reference

  • The main handler function for the 'get_user_groups' tool. It is decorated with @mcp.tool() for registration and uses the KeycloakClient to fetch the list of groups a user belongs to via the Keycloak API.
    @mcp.tool()
    async def get_user_groups(
        user_id: str, realm: Optional[str] = None
    ) -> List[Dict[str, Any]]:
        """
        Get all groups for a user.
    
        Args:
            user_id: User ID
            realm: Target realm (uses default if not specified)
    
        Returns:
            List of groups the user belongs to
        """
        return await client._make_request("GET", f"/users/{user_id}/groups", realm=realm)
  • Input schema defined by function parameters (user_id: str required, realm: Optional[str]) and output as List[Dict[str, Any]].
    async def get_user_groups(
        user_id: str, realm: Optional[str] = None
    ) -> List[Dict[str, Any]]:
  • Registration of the tool using the @mcp.tool() decorator.
    @mcp.tool()

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