list-realms
Retrieve a comprehensive list of all available realms in the Advanced Keycloak MCP server for easy management and monitoring.
Instructions
List all available realms
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:523-535 (handler)The handler function for the 'list-realms' tool within the CallToolRequestSchema switch statement. It calls keycloakService.listRealms() and returns a formatted text response listing the realms.case "list-realms": { const realms = await keycloakService.listRealms(); return { content: [ { type: "text", text: `Available realms:\n${realms .map((r) => `- ${r.realm}`) .join("\n")}`, }, ], }; }
- src/index.ts:378-385 (schema)The tool definition in the ListToolsRequestSchema handler, including the name, description, and input schema (empty object since no parameters are required).name: "list-realms", description: "List all available realms", inputSchema: { type: "object", properties: {}, required: [], }, },
- src/index.ts:146-149 (helper)The KeycloakService.listRealms() method that performs authentication and retrieves the list of realms using the Keycloak admin client's realms.find() method.async listRealms() { await this.authenticate(); return await this.client.realms.find(); }
- src/index.ts:332-440 (registration)The ListToolsRequestSchema handler where all tools, including 'list-realms', are registered by returning the tools list.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ { name: "create-user", description: "Create a new user in a specific realm", inputSchema: { type: "object", properties: { realm: { type: "string", description: "Realm name" }, username: { type: "string", description: "Username for the new user" }, email: { type: "string", format: "email", description: "Email address for the new user" }, firstName: { type: "string", description: "First name of the user" }, lastName: { type: "string", description: "Last name of the user" }, enabled: { type: "boolean", description: "Whether the user is enabled", default: true }, emailVerified: { type: "boolean", description: "Whether the email is verified" }, credentials: { type: "array", items: { type: "object", properties: { type: { type: "string", description: "Credential type (e.g., 'password')" }, value: { type: "string", description: "Credential value" }, temporary: { type: "boolean", description: "Whether the credential is temporary" }, }, required: ["type", "value"], }, description: "User credentials", }, }, required: ["realm", "username", "email", "firstName", "lastName"], }, }, { name: "delete-user", description: "Delete a user from a specific realm", inputSchema: { type: "object", properties: { realm: { type: "string", description: "Realm name" }, userId: { type: "string", description: "User ID to delete" }, }, required: ["realm", "userId"], }, }, { name: "list-realms", description: "List all available realms", inputSchema: { type: "object", properties: {}, required: [], }, }, { name: "list-users", description: "List users in a specific realm", inputSchema: { type: "object", properties: { realm: { type: "string", description: "Realm name" }, }, required: ["realm"], }, }, { name: "list-roles", description: "List all roles of a specific client in a specific realm", inputSchema: { type: "object", properties: { realm: { type: "string", description: "Realm name" }, clientId: { type: "string", description: "Client ID" }, }, required: ["realm", "clientId"], }, }, { name: "update-user-roles", description: "Add and/or remove client roles for a user in a specific realm and client", inputSchema: { type: "object", properties: { realm: { type: "string", description: "Realm name" }, userId: { type: "string", description: "User ID" }, clientId: { type: "string", description: "Client ID" }, rolesToAdd: { type: "array", items: { type: "string" }, description: "Roles to add" }, rolesToRemove: { type: "array", items: { type: "string" }, description: "Roles to remove" }, }, required: ["realm", "userId", "clientId"], }, }, { name: "reset-user-password", description: "Reset or set a new password for a user in a specific realm", inputSchema: { type: "object", properties: { realm: { type: "string", description: "Realm name" }, userId: { type: "string", description: "User ID" }, password: { type: "string", description: "New password" }, temporary: { type: "boolean", description: "Whether the password is temporary", default: false }, }, required: ["realm", "userId", "password"], }, }, ], }; });