mcp-keycloak
Inspect Keycloak configuration and identity data through read-only MCP tools, subject to the configured realm allowlist.
List all visible/allowlisted realms.
Get a single realm's configuration.
List/search users with pagination and get a user by ID.
Count users with optional search.
List OAuth/OIDC clients, optionally filtered by clientId.
List realm-level roles.
List groups with optional search.
No create/update/delete tools are present in this schema.
Provides tools for inspecting and managing Keycloak realms, users, clients, roles, and groups, with configurable access modes and security controls.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-keycloak list all users in the customers realm"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-keycloak
A Model Context Protocol server for Keycloak. It lets an MCP-capable client (Claude Desktop, Claude Code, etc.) inspect and manage Keycloak realms, users, clients, roles, and groups — with security controlled entirely by flags.
The design goal is safe by default: it starts read-only, scopes to an allowlist of realms, protects sensitive realms from mutation, and gates destructive operations behind an explicit opt-in.
Features
Multi-realm — every tool takes a
realmargument; scope it with an allowlist.Access modes —
read-only→read-write→admin, layered so a mode never exposes tools above its level.Security flags — realm allowlist, protected realms, delete gating, dry-run, and JSON audit logging (see below).
Two auth strategies — confidential-client service account (recommended) or admin username/password.
Zero heavy dependencies — a thin fetch-based Admin REST client, plus the MCP SDK and zod.
Related MCP server: keycloak-mcp
Security model
Concern | Flag | Default | Effect |
What can the server do at all? |
|
|
|
Which realms are in scope? |
| (all) | Comma-separated. When set, any operation on a realm outside the list is refused. |
Which realms are read-only forever? |
|
| Protected realms can be read but never mutated or deleted, regardless of mode. |
Can it delete? |
|
|
|
Preview without touching Keycloak |
|
| Write/admin tools validate + log intent, then return without calling Keycloak. |
Audit trail |
|
| Emits a JSON line to stderr per guarded operation ( |
Interactive confirmation | (automatic) | — | Destructive & high-impact actions prompt the human to approve via MCP elicitation before running. The prompt shows the tool, the exact arguments (secrets redacted) and a fingerprint; the target user's version is pinned across the prompt and the action is refused if it changed; a prompt nobody answers is a refusal. |
Self-signed Keycloak certificate |
|
| Set |
Require a human |
|
| When |
These layers are independent — for example admin mode with KEYCLOAK_ALLOW_DELETE=false can create and update users but cannot delete them.
Tools
Read (read-only+): list_realms, get_realm, list_users, get_user, count_users, list_clients, list_realm_roles, list_groups
Write (read-write+): create_user, update_user, reset_password, logout_user
Admin (admin): delete_user
Quickstart — add to your agent
Published on npm as @dockndevai/mcp-keycloak. No clone or build needed — your MCP client runs it on demand with npx. Start in read-only mode; see .env.example for every variable and docs/CLIENTS.md for the full per-client guide.
Claude Code (CLI)
claude mcp add keycloak -e KEYCLOAK_URL="https://keycloak.example.com" -e KEYCLOAK_CLIENT_ID="admin-cli" -e KEYCLOAK_CLIENT_SECRET="your-secret" -e KEYCLOAK_MODE="read-only" -- npx -y @dockndevai/mcp-keycloakClaude Desktop · Cursor · Windsurf — same block in claude_desktop_config.json, .cursor/mcp.json, or ~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"keycloak": {
"command": "npx",
"args": [
"-y",
"@dockndevai/mcp-keycloak"
],
"env": {
"KEYCLOAK_URL": "https://keycloak.example.com",
"KEYCLOAK_CLIENT_ID": "admin-cli",
"KEYCLOAK_CLIENT_SECRET": "your-secret",
"KEYCLOAK_MODE": "read-only"
}
}
}
}OpenAI Codex CLI — in ~/.codex/config.toml:
[mcp_servers.keycloak]
command = "npx"
args = ["-y", "@dockndevai/mcp-keycloak"]
env = { KEYCLOAK_URL = "https://keycloak.example.com", KEYCLOAK_CLIENT_ID = "admin-cli", KEYCLOAK_CLIENT_SECRET = "your-secret", KEYCLOAK_MODE = "read-only" }VS Code (GitHub Copilot, Agent mode) — in .vscode/mcp.json:
{
"servers": {
"keycloak": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@dockndevai/mcp-keycloak"
],
"env": {
"KEYCLOAK_URL": "https://keycloak.example.com",
"KEYCLOAK_CLIENT_ID": "admin-cli",
"KEYCLOAK_CLIENT_SECRET": "your-secret",
"KEYCLOAK_MODE": "read-only"
}
}
}
}Configure
Copy .env.example and fill it in, or set the variables directly in your MCP client config. A confidential client with the realm-management roles you need is the recommended credential.
Run from source (development)
Prefer the published package above. To run from a clone:
npm install
npm run build
node dist/index.js # with the environment variables setDevelop
npm run dev # watch mode
npm test # unit tests for the security policy
npm run typecheckPublishing
This server ships a server.json for the official MCP registry and an mcpName for npm ownership validation. See PUBLISHING.md for publishing to npm and listing on the MCP registry, Smithery, Glama, Cursor, and PulseMCP.
License
MIT
Available Tools
8 toolscount_usersCount usersARead-onlyIdempotent
Return the number of users in a realm, optionally matching a search term.
Inputs: realm (required), search.
get_realmGet realm settingsCRead-onlyIdempotent
Fetch the configuration of a single realm.
Inputs: realm (required).
get_userGet user by idBRead-onlyIdempotent
Fetch a single user representation by their Keycloak id.
Inputs: realm (required), userId (required).
list_clientsList clientsARead-onlyIdempotent
List OAuth/OIDC clients configured in a realm. Client secrets are not included.
Inputs: realm (required), clientId.
list_groupsList groupsCRead-onlyIdempotent
List groups in a realm.
Inputs: realm (required), search.
list_realm_rolesList realm rolesCRead-onlyIdempotent
List the realm-level roles defined in a realm.
Inputs: realm (required).
list_realmsList realmsARead-onlyIdempotent
List all realms visible to the configured credentials. Realms outside the allowlist are filtered out.
Inputs: no named parameters.
list_usersList / search usersBRead-onlyIdempotent
List users in a realm. Supports free-text search and pagination. Passwords and secrets are never returned by Keycloak.
Inputs: realm (required), max, first, search.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool targets a clearly distinct resource and action: get_realm vs list_realms, list_users vs get_user vs count_users, and list_clients/list_realm_roles/list_groups all have separate scopes. Descriptions make the boundaries explicit, so an agent should not confuse them.
All tool names use snake_case with a consistent verb_noun pattern: get_realm, list_users, get_user, count_users, list_clients, list_realm_roles, list_groups, list_realms. There are no mixed conventions or vague verbs.
The server exposes 8 tools, which is well-scoped for a focused Keycloak read/inspection surface. No tool feels redundant, and the count avoids both bloat and a thin single-tool interface.
The surface is read-only and omits all create, update, and delete operations for realms, users, clients, roles, and groups. Even read coverage is incomplete, since there is no get_client, get_group, or get_role, leaving significant gaps for typical Keycloak administration.
Maintenance
Related MCP Connectors
Managed Keycloak from any MCP client: clusters, realms, apps, SSO, users, domains, audit events.
Governed MCP gateway: one endpoint for your tools, with credential custody and audit log.
MCP server for mandates, delegation, policy-gated execution, credential grants, and audit.
Hosted remote MCP for protected account access, permissions, activity history and supported undo.
Related MCP Servers
- AlicenseAqualityBmaintenanceAn MCP server for Keycloak Admin REST API, enabling user, group, event, and security management through service account authentication.3361 PyPIMIT
- AlicenseAqualityDmaintenanceAn MCP server that lets an AI assistant inspect and modify Keycloak realm, client, and protocol-mapper configuration across multiple Keycloak hosts.787 npmMIT
- AlicenseNot gradedqualityDmaintenanceEnables administration of Keycloak identity and access management through MCP, allowing management of realms, clients, users, roles, groups, identity providers, and sessions from any MCP client.47 npmApache 2.0
- AlicenseCqualityDmaintenanceA comprehensive MCP server for Keycloak administration, offering 80+ tools to manage users, realms, clients, roles, groups, sessions, events, organizations, and more directly from AI assistants.8647 npmMIT