Skip to main content
Glama
idoyudha

mcp-keycloak

by idoyudha

get_user_sessions

Retrieve active user sessions from Keycloak identity management by providing a user ID and optional realm to monitor authentication activity.

Instructions

Get active sessions for a user.

Args:
    user_id: The user's ID
    realm: Target realm (uses default if not specified)

Returns:
    List of active sessions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
user_idYes
realmNo

Implementation Reference

  • The handler function for the 'get_user_sessions' tool. It is decorated with @mcp.tool() which also serves as registration. Retrieves active sessions for the specified user from the Keycloak API via the KeycloakClient.
    @mcp.tool()
    async def get_user_sessions(
        user_id: str, realm: Optional[str] = None
    ) -> List[Dict[str, Any]]:
        """
        Get active sessions for a user.
    
        Args:
            user_id: The user's ID
            realm: Target realm (uses default if not specified)
    
        Returns:
            List of active sessions
        """
        return await client._make_request("GET", f"/users/{user_id}/sessions", realm=realm)

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