mcp-keycloak-admin
Enables administrators to manage Keycloak realms, users, roles, clients, groups, and more through its Admin REST API, with safe-by-default configuration and destructive operation confirmation.
README
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).
Install
No install needed — run it straight from npm with npx:
npx -y mcp-keycloak-admin
The server speaks MCP over stdio, so you normally wire it into an MCP client rather than running it by hand — see Usage with an MCP client. New to it? The Quickstart spins up a local Keycloak and a client config in a couple of minutes.
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.
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.
Multiple Keycloak instances
Each server entry targets one Keycloak (one base URL + realm + auth). To manage several environments, add one entry per instance — each fully isolated, with its own credentials and guardrails:
{
"mcpServers": {
"kc-preprod": {
"command": "npx",
"args": ["-y", "mcp-keycloak-admin"],
"env": {
"KEYCLOAK_BASE_URL": "https://preprod.example.com",
"KEYCLOAK_REALM": "Pandi-Panda-Preprod",
"AUTH_MODE": "service_account",
"KC_CLIENT_ID": "mcp-admin",
"KC_CLIENT_SECRET": "…",
"ALLOWED_REALMS": "Pandi-Panda-Preprod"
}
},
"kc-prod": {
"command": "npx",
"args": ["-y", "mcp-keycloak-admin"],
"env": {
"KEYCLOAK_BASE_URL": "https://auth.example.com",
"KEYCLOAK_REALM": "Pandi-Panda",
"AUTH_MODE": "service_account",
"KC_CLIENT_ID": "mcp-admin",
"KC_CLIENT_SECRET": "…",
"READ_ONLY": "true",
"ALLOWED_REALMS": "Pandi-Panda"
}
}
}
}
The client namespaces the tools per server (e.g. kc-prod:keycloak_user_delete),
so there's no risk of running an operation against the wrong environment. This
is the recommended pattern: you can, for example, keep production READ_ONLY
while preprod stays writable.
Configuration
| Variable | Required | Description |
|---|---|---|
KEYCLOAK_BASE_URL |
yes | Base URL of the Keycloak server (no trailing slash). |
KEYCLOAK_REALM |
yes | Realm the server operates on. |
AUTH_MODE |
yes | service_account or password. |
KC_CLIENT_ID |
if service_account |
Confidential client id (e.g. mcp-admin). |
KC_CLIENT_SECRET |
if service_account |
Client secret. |
KC_ADMIN_USERNAME |
if password |
Admin username. |
KC_ADMIN_PASSWORD |
if password |
Admin password. |
KC_ADMIN_REALM |
no (default master) |
Realm holding the admin user (password mode). |
READ_ONLY |
no (default false) |
When true, write/destructive tools are not registered. |
ALLOWED_REALMS |
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:
Note: this table tracks the
mainbranch, which can run ahead of the latest npm release shown by the version badge above. To confirm what's available in your install, checknpm view mcp-keycloak-admin versionand pinmcp-keycloak-admin@latest.
| Tool | Level | Description |
|---|---|---|
keycloak_user_search |
R | Search realm users by email, username or free text. |
keycloak_user_get |
R | Fetch a single user by id. |
keycloak_user_sessions_list |
R | List a user's active sessions. |
keycloak_user_create |
W | Create a realm user. |
keycloak_user_update |
W | Update a user's email, name or enabled flag. |
keycloak_user_set_enabled |
W | Enable or disable a user. |
keycloak_user_send_action_email |
W | Send a required-actions email. |
keycloak_user_reset_password |
D | Set a new password for a user. |
keycloak_user_logout |
D | Revoke all of a user's sessions. |
keycloak_user_delete |
D | Permanently delete a user (id + username must match). |
keycloak_role_list |
R | List realm roles. |
keycloak_user_roles_get |
R | List a user's realm roles. |
keycloak_user_role_assign |
W | Grant a realm role to a user. |
keycloak_user_role_unassign |
D | Revoke a realm role from a user. |
keycloak_client_roles_list |
R | List the roles defined on a client. |
keycloak_user_client_roles_get |
R | List a user's client roles. |
keycloak_user_client_role_assign |
W | Grant a client role to a user. |
keycloak_user_client_role_unassign |
D | Revoke a client role from a user. |
keycloak_client_list |
R | List the realm clients. |
keycloak_client_create |
W | Create a realm client. |
keycloak_client_update |
W | Update a client (enabled, public, redirect URIs). |
keycloak_client_delete |
D | Delete a client. |
keycloak_client_get |
R | Fetch a client by its clientId. |
keycloak_client_get_secret |
R | Read a client secret (masked unless reveal). |
keycloak_client_scopes_list |
R | List the realm's client scopes. |
keycloak_client_default_scopes_get |
R | List a client's default scopes. |
keycloak_client_mappers_list |
R | List a client's protocol mappers. |
keycloak_client_scope_assign |
W | Add a default scope to a client. |
keycloak_client_scope_unassign |
D | Remove a default scope from a client. |
keycloak_client_regenerate_secret |
D | Regenerate a client secret (old one stops working). |
keycloak_group_list |
R | List the realm's top-level groups. |
keycloak_group_members_list |
R | List the members of a group. |
keycloak_user_groups_list |
R | List the groups a user belongs to. |
keycloak_group_create |
W | Create a top-level group. |
keycloak_group_member_add |
W | Add a user to a group. |
keycloak_group_role_assign |
W | Grant a realm role to a group. |
keycloak_group_member_remove |
D | Remove a user from a group. |
keycloak_group_delete |
D | Delete a group. |
keycloak_idp_list |
R | List identity providers. |
keycloak_idp_get |
R | Fetch an identity provider by alias. |
keycloak_idp_mappers_list |
R | List an identity provider's mappers. |
keycloak_idp_create |
W | Create an identity provider. |
keycloak_idp_delete |
D | Delete an identity provider. |
keycloak_federation_list |
R | List user federation (LDAP/Kerberos) providers. |
keycloak_federation_get |
R | Fetch a federation provider by id. |
keycloak_federation_sync |
W | Trigger a user sync (full or changed). |
keycloak_auth_flows_list |
R | List authentication flows. |
keycloak_auth_required_actions_list |
R | List required actions. |
keycloak_auth_required_action_set_enabled |
W | Enable/disable a required action. |
keycloak_authz_resources_list |
R | List a client's authorization resources. |
keycloak_authz_policies_list |
R | List a client's authorization policies. |
keycloak_authz_permissions_list |
R | List a client's authorization permissions. |
keycloak_events_login |
R | Read recent login events (filterable). |
keycloak_events_admin |
R | Read recent admin events. |
keycloak_realm_get_config |
R | Read key realm configuration flags. |
keycloak_server_info |
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/
Releases are automated — see docs/releasing.md.
Contributing
Contributions are welcome — please read CONTRIBUTING.md.
License
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。