Skip to main content
Glama
idoyudha

mcp-keycloak

by idoyudha

get_user_groups

Retrieve all groups associated with a specific user in Keycloak identity management to manage access permissions and organizational structure.

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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'get_user_groups' tool. It is decorated with @mcp.tool() for registration and uses the KeycloakClient to fetch the list of groups a user belongs to via the Keycloak API.
    @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)
  • Input schema defined by function parameters (user_id: str required, realm: Optional[str]) and output as List[Dict[str, Any]].
    async def get_user_groups(
        user_id: str, realm: Optional[str] = None
    ) -> List[Dict[str, Any]]:
  • Registration of the tool using the @mcp.tool() decorator.
    @mcp.tool()
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 this is a read operation ('Get'), which is helpful, but lacks critical details: whether it requires authentication, rate limits, pagination behavior, error conditions, or what happens if the user_id doesn't exist. For a tool with no annotation coverage, 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 concise and well-structured: a clear purpose statement followed by brief, bullet-like sections for Args and Returns. Every sentence earns its place with no redundancy or fluff, making it easy to parse quickly.

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 2 parameters with 0% schema coverage and no annotations, the description is moderately complete: it covers purpose and basic parameter semantics, and an output schema exists (so return values needn't be detailed). However, for a tool in a security/identity context (Keycloak-like), it lacks critical behavioral context like auth requirements or error handling, leaving gaps despite the output schema.

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

Parameters3/5

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

Schema description coverage is 0%, so the description must compensate. It explains 'user_id' as 'User ID' and 'realm' as 'Target realm (uses default if not specified)', adding basic meaning beyond the schema's titles. However, it doesn't clarify format (e.g., UUID for user_id), realm examples, or what 'default' means contextually. This provides minimal but not comprehensive parameter context.

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 verb ('Get') and resource ('all groups for a user'), making the purpose immediately understandable. It distinguishes this from sibling tools like 'list_groups' (which likely lists all groups) and 'get_group_members' (which focuses on members of a specific group). However, it doesn't explicitly contrast with these alternatives, preventing a perfect score.

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 'list_groups' or 'get_group_members'. It doesn't mention prerequisites (e.g., needing user_id), exclusions, or specific contexts. The agent must infer usage from the purpose alone, which is insufficient for optimal tool selection.

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