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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

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",
        }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states the action ('logout all sessions') which implies a destructive operation affecting user access, but doesn't mention authentication requirements, side effects, rate limits, or what 'logout' entails compared to 'remove' sessions. This leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly structured with a clear purpose statement followed by organized Args and Returns sections. Every sentence earns its place, with no wasted words, making it easy to parse while maintaining completeness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given a destructive operation with no annotations but an output schema (implied by 'Returns: Status message'), the description covers basic purpose and parameters adequately. However, for a tool that terminates all user sessions, more context about permissions, consequences, and relationship to similar tools would improve completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description compensates well by explaining both parameters: 'user_id' as 'The user's ID' and 'realm' with its default behavior ('uses default if not specified'). This adds meaningful context beyond the bare schema, though it could elaborate on realm format or user_id constraints.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Logout all sessions') and resource ('for a user'), making the purpose immediately understandable. It doesn't explicitly differentiate from sibling tools like 'remove_all_user_sessions', but the verb 'logout' suggests a different scope than 'remove', providing some implicit distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'remove_all_user_sessions' or other session management tools. It mentions the realm parameter's default behavior but offers no context about appropriate use cases or prerequisites.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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