Skip to main content
Glama
keycloak-mcp

keycloak-mcp

by shigechika

get_user_sessions

Get active sessions for a user.

Instructions

Get active sessions for a user.

Sessions are listed over several separate connections and merged, because behind a load balancer a KeyCloak node that does not share sessions with the others lists only its own (KEYCLOAK_SESSION_PROBES, default 8).

Args: username: Exact username (email).

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "username": "<username>"
    },
    "name": "get_user_sessions"
  }
}

Input Schema

NameRequiredDescriptionDefault
usernameYes

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.1/5.0
Behavior4/5

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

With no annotations, the description carries the full behavioral burden, and it discloses an important quirk: results are gathered across several connections and merged because load-balanced KeyCloak nodes may only see their own sessions. It also exposes the KEYCLOAK_SESSION_PROBES control (default 8), which materially affects result completeness. It does not state read-only/permission requirements, but the 'Get' framing and the deep operational caveat make this well above baseline.

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

Conciseness4/5

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

The purpose is front-loaded in the first sentence, and the Args section is compact. The load-balancer explanation is slightly long but earns its place because it explains why results can vary; no sentence is pure filler.

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

Completeness4/5

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

An output schema exists, so return-value documentation is unnecessary. The description covers purpose, parameter semantics, and the non-obvious merged-connection behavior, leaving only minor gaps around access requirements and failure modes.

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?

Schema coverage is 0%, so the description must compensate, and it does: 'username: Exact username (email)' clarifies both matching strictness and expected format. That is meaningful added value for the single required parameter, though it stops short of examples or edge-case behavior.

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

Purpose5/5

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

The description opens with a specific verb and resource: 'Get active sessions for a user.' That phrasing also distinguishes it from the sibling get_client_sessions by scoping the result to a user rather than a client.

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

Usage Guidelines3/5

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

The description implies the tool is for inspecting a user's active sessions, but it does not say when to prefer it over siblings like get_session_stats, logout_user, or get_client_sessions. There are no explicit exclusions or alternative-selection guidance.

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