Skip to main content
Glama

get_user_groups

Retrieve a list of groups associated with a specific user in Keycloak. Specify the user ID and optionally the realm to manage access and identity effectively.

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
realmNo
user_idYes

Implementation Reference

  • The handler function implementing the 'get_user_groups' tool logic. Decorated with @mcp.tool() which handles registration and infers the input schema from type annotations and docstring.
    @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)
  • src/main.py:23-23 (registration)
    Import of the group_tools module in the main entrypoint, which executes the @mcp.tool() decorators to register the tool with the MCP server.
    from .tools import group_tools # noqa: F401
  • Global KeycloakClient instance used by the get_user_groups handler to make the API request.
    client = KeycloakClient()
  • Import of KeycloakClient helper class used in the tool implementation.
    from .keycloak_client import KeycloakClient

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