Skip to main content
Glama
idoyudha

mcp-keycloak

by idoyudha

get_accessible_realms

List all Keycloak realms accessible to the current user for identity and access management.

Instructions

Get accessible realms.

Returns:
    List of accessible realms

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The 'get_accessible_realms' tool handler function. It is decorated with @mcp.tool() and makes an HTTP GET request to the Keycloak admin API endpoint '/realms' with skip_realm=True, meaning it fetches realms accessible to the admin user without scoping to a specific realm.
    @mcp.tool()
    async def get_accessible_realms() -> List[Dict[str, Any]]:
        """
        Get accessible realms.
    
        Returns:
            List of accessible realms
        """
        return await client._make_request("GET", "/realms", skip_realm=True)
  • The FastMCP server instance ('mcp') used to register tools. The @mcp.tool() decorator on get_accessible_realms registers it with the server. The server is initialized as FastMCP('Keycloak MCP Server').
    from mcp.server.fastmcp import FastMCP
    
    # Initialize FastMCP server
    mcp = FastMCP("Keycloak MCP Server", dependencies=["dotenv"])
  • src/main.py:17-23 (registration)
    The registration import chain: importing 'realm_tools' in main.py triggers the module load, which executes the @mcp.tool() decorator on get_accessible_realms, registering it with the FastMCP server.
    # Import all tool modules to register them with the MCP server
    from . import tools  # noqa: F401
    from .tools import user_tools  # noqa: F401
    from .tools import client_tools  # noqa: F401
    from .tools import realm_tools  # noqa: F401
    from .tools import role_tools  # noqa: F401
    from .tools import group_tools  # noqa: F401
  • The realm_tools module is imported in __init__.py, which causes the @mcp.tool() decorators (including get_accessible_realms) to execute and register with the MCP server.
    from . import realm_tools
Behavior2/5

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

No annotations are present, so the description should disclose behavioral traits. It only states the operation and return type, without any information about authentication, side effects, or error conditions.

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 extremely concise, using only two sentences to convey the essential information without unnecessary words.

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?

While the tool is simple with no parameters, the description lacks details about what 'accessible' means, potential prerequisites, or output structure. It is minimally adequate.

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?

There are no parameters, so the description does not need to add semantic value. The schema coverage is 100%, achieving a baseline of 4.

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 clearly states the tool retrieves 'accessible realms' and the return type is a list. It is distinct from sibling tools that focus on specific realms or roles.

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?

No guidance is provided on when to use this tool versus alternatives. It does not mention context or exclusions, leaving the agent to infer usage.

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