mcp-keycloak
mcp-keycloak
一个用于 Keycloak 的 Model Context Protocol 服务器。它让支持 MCP 的客户端(如 Claude Desktop、Claude Code 等)能够检查和管理 Keycloak 的 realm、用户、客户端、角色和组——安全性完全由标志(flags)控制。
设计目标是 默认安全:以只读模式启动,将范围限定在允许的 realm 列表(allowlist)内,保护敏感 realm 不受更改,并让破坏性操作必须通过显式的选入(opt-in)才能执行。
特性
多 realm — 每个工具都接受一个
realm参数;作用域可通过允许列表(allowlist)限定。访问模式 —
read-only→read-write→admin,进阶级设计,任何模式都不会暴露高于其层级的工具。安全开关 — realm 允许列表、受保护 realm、删除控制(delete gating)、试运行(dry-run)和 JSON 审计日志(见下表)。
两种认证策略 — 机密客户端服务账号(推荐)或管理员用户名/密码。
零重型依赖 — 一个基于 fetch 的精简 Admin REST 客户端,外加 MCP SDK 和 zod。
Related MCP server: mcp-keycloak-admin
安全模型
关注点 | 标志 | 默认值 | 效果 |
服务器能做什么? |
|
|
|
哪些 realm 在作用域内? |
|
| 逗号分隔。设置后,任何在列表之外 realm 上的操作都会被拒绝。 |
哪些 realm 将永远只读? |
|
| 受保护的 realm 可以被读取,但无论处于什么模式,都不能被修改或删除。 |
可以执行删除吗? |
|
|
|
不触碰 Keycloak 的情况下预览 |
|
| 写入/管理工具会先校验并记录操作意图,然后直接返回,不调用 Keycloak。 |
审计记录 |
|
| 每次受保护的操作都会向 stderr 输出一行 JSON( |
这些安全层级相互独立——例如,admin 模式下如果 KEYCLOAK_ALLOW_DELETE=false,就可以创建和更新用户,但不能删除用户。
工具
检查 (read-only+): list_realms, get_realm, list_users, get_user, count_users, list_clients, list_realm_roles, list_groups
写入 (read-write+): create_user, update_user, reset_password, logout_user
管理 (admin): delete_user
与你的 MCP 客户端配合使用
支持 Claude Code、Claude Desktop、Cursor、OpenAI Codex CLI、Windsurf、VS Code (Copilot) 以及任何其他 MCP 客户端——每个客户端的配置方式另见 docs/CLIENTS.md。
安装
npm install
npm run build配置
复制 .env.example 并按需填入内容,或者直接在 MCP 客户端配置中设置这些变量。推荐使用一个带有所需 realm-management 角色的机密客户端作为凭据。
使用 Claude Desktop 运行
在 MCP 客户端配置中添加该服务器(claude_desktop_config.json 或通过 claude mcp add):
{
"mcpServers": {
"keycloak": {
"command": "node",
"args": ["/absolute/path/to/mcp-keycloak/dist/index.js"],
"env": {
"KEYCLOAK_URL": "https://keycloak.example.com",
"KEYCLOAK_CLIENT_ID": "admin-cli",
"KEYCLOAK_CLIENT_SECRET": "your-secret",
"KEYCLOAK_MODE": "read-only",
"KEYCLOAK_REALM_ALLOWLIST": "app,customers"
}
}
}
}只有当你有意让模型进行变更时,才将 KEYCLOAK_MODE 提升到 read-write(如需删除,还要设置为 admin + KEYCLOAK_ALLOW_DELETE=true)。
开发
npm run dev # watch mode
npm test # unit tests for the security policy
npm run typecheck发布
该服务器附带一个用于官方 MCP 注册表的 server.json,以及一个用于 npm 所有权校验的 mcpName。发布到 npm 并在 MCP registry、Smithery、Glama、Cursor 和 PulseMCP 等平台列出,请参阅 PUBLISHING.md。
许可证
MIT
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityAmaintenanceAn MCP server for Keycloak Admin REST API, enabling user, group, event, and security management through service account authentication.30MIT
- AlicenseAqualityAmaintenanceEnables 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.56421MIT
- AlicenseAqualityCmaintenanceAn MCP server that lets an AI assistant inspect and modify Keycloak realm, client, and protocol-mapper configuration across multiple Keycloak hosts.787MIT
- AlicenseNot gradedqualityBmaintenanceEnables 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.41Apache 2.0
Related MCP Connectors
Managed Keycloak from any MCP client: clusters, realms, apps, SSO, users, domains, audit events.
Remote MCP for A2A caller identity, scope policy, verdict receipts, and audit history.
The official MCP Server from Mia-Platform to interact with Mia-Platform Console
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/dockndevai/mcp-keycloak'
If you have feedback or need assistance with the MCP directory API, please join our Discord server