Skip to main content
Glama
idoyudha

mcp-keycloak

by idoyudha

logout_user

Terminate all active sessions for a specific user in Keycloak identity management to enforce access control and security policies.

Instructions

Logout all sessions for a user.

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

Returns:
    Status message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
user_idYes
realmNo

Implementation Reference

  • The logout_user tool handler. Decorated with @mcp.tool() which registers it with the MCP server. Calls Keycloak API to logout all sessions for the user.
    @mcp.tool()
    async def logout_user(user_id: str, realm: Optional[str] = None) -> Dict[str, str]:
        """
        Logout all sessions for a user.
    
        Args:
            user_id: The user's ID
            realm: Target realm (uses default if not specified)
    
        Returns:
            Status message
        """
        await client._make_request("POST", f"/users/{user_id}/logout", realm=realm)
        return {
            "status": "success",
            "message": f"User {user_id} logged out from all sessions",
        }

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