list-clients
Retrieve a list of clients in a specified Keycloak realm using the MCP server, enabling streamlined management of client configurations and permissions.
Instructions
List clients in a specific realm
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| realm | Yes |
Implementation Reference
- src/services/keycloak.ts:99-106 (handler)The core handler function that executes the 'list-clients' tool logic: validates input, queries Keycloak for clients in the specified realm, and formats the results as a string.public async listClients(args: unknown): Promise<string> { const { realm } = ListClientsSchema.parse(args); const clients: ClientRepresentation[] = await this.kcAdminClient.clients.find({ realm }); return `Clients in realm ${realm}:\n${clients .map((c) => `- ${c.clientId} (${c.id})`) .join("\n")}`; }
- src/schemas/index.ts:97-103 (schema)Input schema (JSON Schema format) for the 'list-clients' tool, defining the required 'realm' parameter."list-clients": { type: "object", properties: { realm: { type: "string" }, }, required: ["realm"], },
- src/server.ts:67-70 (registration)Tool registration in the MCP server's ListTools handler, exposing name, description, and schema.name: "list-clients", description: "List clients in a specific realm", inputSchema: InputSchema["list-clients"], },
- src/server.ts:137-142 (handler)Dispatch handler in the CallToolRequest that invokes the KeycloakService.listClients method.case "list-clients": return { content: [ { type: "text", text: await keycloakService.listClients(args) }, ], };