mcp-keycloak-admin
Administer a Keycloak instance through its Admin REST API, providing tools for managing users, roles, clients, groups, identity providers, authentication flows, events, and more.
Click on "Install 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-adminsearch for user by username jdoe"
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-admin
A Model Context Protocol (MCP) server to administer a Keycloak instance through its Admin REST API. Safe by default, configurable, and built with a clean, test-driven architecture.
Compatible with Keycloak 26.x (validated against 26.0.5).
Project status: early. The architecture, tooling and safety model are in place and exercised by unit and integration tests. The exposed tool surface is being grown incrementally — see Tools and Roadmap.
Why
Administering Keycloak from an MCP client (an assistant, an IDE, a custom agent) means exposing day-to-day operations — searching users, managing roles, reading events — as MCP tools, without handing over a raw admin console. This server does that with strong guardrails so destructive actions never happen silently.
Related MCP server: mcp-keycloak
Features
Two authentication modes, selectable by configuration:
service_account— a confidential client with a service account (recommended; no admin password stored).password— theadmin-cliclient with an admin username/password.
Safe by default:
READ_ONLYmode hides every write/destructive tool.ALLOWED_REALMSrestricts which realms the server may operate on.Destructive operations require explicit confirmation (native MCP elicitation, with a
confirm: trueparameter fallback for clients that do not support elicitation).
Clean Architecture: a framework-free domain, application use cases, and infrastructure adapters. No business concept travels as a raw string or number — every one is a validated value object.
Requirements
Node.js >= 20
A reachable Keycloak 26.x server
Usage with an MCP client
Add the server to your MCP client configuration:
{
"mcpServers": {
"keycloak-admin": {
"command": "npx",
"args": ["-y", "mcp-keycloak-admin"],
"env": {
"KEYCLOAK_BASE_URL": "http://localhost:8080",
"KEYCLOAK_REALM": "demo-realm",
"AUTH_MODE": "service_account",
"KC_CLIENT_ID": "mcp-admin",
"KC_CLIENT_SECRET": "your-secret"
}
}
}
}See docs/setup-keycloak.md to create the mcp-admin
client and grant it the least-privilege roles it needs.
Configuration
Variable | Required | Description |
| yes | Base URL of the Keycloak server (no trailing slash). |
| yes | Realm the server operates on. |
| yes |
|
| if | Confidential client id (e.g. |
| if | Client secret. |
| if | Admin username. |
| if | Admin password. |
| no (default | Realm holding the admin user ( |
| no (default | When |
| no | Comma-separated allow-list of realms. Empty = all. |
A full example lives in .env.example.
Tools
Levels: [R] read-only · [W] write · [D] destructive (requires
confirmation). Every tool carries the matching MCP annotations
(readOnlyHint / destructiveHint / idempotentHint).
Currently implemented:
Tool | Level | Description |
| R | Search realm users by email, username or free text. |
| R | Fetch a single user by id. |
| R | List a user's active sessions. |
| W | Create a realm user. |
| W | Update a user's email, name or enabled flag. |
| W | Enable or disable a user. |
| W | Send a required-actions email. |
| D | Set a new password for a user. |
| D | Revoke all of a user's sessions. |
| D | Permanently delete a user (id + username must match). |
| R | List realm roles. |
| R | List a user's realm roles. |
| W | Grant a realm role to a user. |
| D | Revoke a realm role from a user. |
| R | List the realm clients. |
| R | Fetch a client by its clientId. |
| R | Read a client secret (masked unless |
| R | List the realm's client scopes. |
| R | List a client's default scopes. |
| R | List a client's protocol mappers. |
| W | Add a default scope to a client. |
| D | Remove a default scope from a client. |
| D | Regenerate a client secret (old one stops working). |
| R | List the realm's top-level groups. |
| R | List the members of a group. |
| R | List the groups a user belongs to. |
| W | Create a top-level group. |
| W | Add a user to a group. |
| W | Grant a realm role to a group. |
| D | Remove a user from a group. |
| D | Delete a group. |
| R | List identity providers. |
| R | Fetch an identity provider by alias. |
| R | List an identity provider's mappers. |
| W | Create an identity provider. |
| D | Delete an identity provider. |
| R | List user federation (LDAP/Kerberos) providers. |
| R | Fetch a federation provider by id. |
| W | Trigger a user sync (full or changed). |
| R | List authentication flows. |
| R | List required actions. |
| W | Enable/disable a required action. |
| R | List a client's authorization resources. |
| R | List a client's authorization policies. |
| R | List a client's authorization permissions. |
| R | Read recent login events (filterable). |
| R | Read recent admin events. |
| R | Read key realm configuration flags. |
| R | Read the Keycloak server version. |
See docs/users.md, docs/roles.md, docs/clients.md, docs/groups.md and docs/events-realm.md for parameters and examples, and docs/security.md for the safety model.
Roadmap
The architecture is designed to keep growing as thin use cases + tools. Remaining candidates: authorization policy/permission CRUD and evaluation, authentication flow mutation (copy/add executions), and advanced federation and identity-provider configuration. See docs/development.md for how to add one.
Development
npm install
npm test # unit tests
npm run test:integration # spins up a real Keycloak 26 via Testcontainers (needs Docker)
npm run check # typecheck + lint + format check + unit tests
npm run build # bundle to dist/Contributing
Contributions are welcome — please read CONTRIBUTING.md.
License
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
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/mrz1880/mcp-keycloak-admin'
If you have feedback or need assistance with the MCP directory API, please join our Discord server