mrz1880/mcp-keycloak-admin

๐Ÿ”’ Security
0 Views
0 Installs

๐Ÿ“‡ ๐Ÿ  - Administer Keycloak through its Admin REST API โ€” users, roles, clients, groups, identity providers, federation and events. Safe by default: read-only mode, realm allow-list, and confirmation for destructive actions. npx -y mcp-keycloak-admin

Quick Install

One-Click IDE Configuration
claude_desktop_config.json
{
  "mcpServers": {
    "mrz1880-mcp-keycloak-admin": {
      "command": "npx",
      "args": [
        "-y",
        "mrz1880-mcp-keycloak-admin"
      ]
    }
  }
}
Or

Using an AI coding agent (Claude Code, Cursor, etc.)? Copy a ready-made prompt that tells it to fetch the setup instructions and install this server for you.

Documentation Overview

mcp-keycloak-admin

npm version CI CodeQL License: MIT

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 โ€” the admin-cli client with an admin username/password.
  • Safe by default:
    • READ_ONLY mode hides every write/destructive tool.
    • ALLOWED_REALMS restricts which realms the server may operate on.
    • Destructive operations require explicit confirmation (native MCP elicitation, with a confirm: true parameter 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": "preprod-realm",
        "AUTH_MODE": "service_account",
        "KC_CLIENT_ID": "mcp-admin",
        "KC_CLIENT_SECRET": "โ€ฆ",
        "ALLOWED_REALMS": "preprod-realm"
      }
    },
    "kc-prod": {
      "command": "npx",
      "args": ["-y", "mcp-keycloak-admin"],
      "env": {
        "KEYCLOAK_BASE_URL": "https://auth.example.com",
        "KEYCLOAK_REALM": "prod-realm",
        "AUTH_MODE": "service_account",
        "KC_CLIENT_ID": "mcp-admin",
        "KC_CLIENT_SECRET": "โ€ฆ",
        "READ_ONLY": "true",
        "ALLOWED_REALMS": "prod-realm"
      }
    }
  }
}

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

VariableRequiredDescription
KEYCLOAK_BASE_URLyesBase URL of the Keycloak server (no trailing slash).
KEYCLOAK_REALMyesRealm the server operates on.
AUTH_MODEyesservice_account or password.
KC_CLIENT_IDif service_accountConfidential client id (e.g. mcp-admin).
KC_CLIENT_SECRETif service_accountClient secret.
KC_ADMIN_USERNAMEif passwordAdmin username.
KC_ADMIN_PASSWORDif passwordAdmin password.
KC_ADMIN_REALMno (default master)Realm holding the admin user (password mode).
READ_ONLYno (default false)When true, write/destructive tools are not registered.
ALLOWED_REALMSnoComma-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 main branch, which can run ahead of the latest npm release shown by the version badge above. To confirm what's available in your install, check npm view mcp-keycloak-admin version and pin mcp-keycloak-admin@latest.

ToolLevelDescription
keycloak_user_searchRSearch realm users by email, username or free text.
keycloak_user_getRFetch a single user by id.
keycloak_user_sessions_listRList a user's active sessions.
keycloak_user_createWCreate a realm user.
keycloak_user_updateWUpdate a user's email, name or enabled flag.
keycloak_user_set_enabledWEnable or disable a user.
keycloak_user_send_action_emailWSend a required-actions email.
keycloak_user_reset_passwordDSet a new password for a user.
keycloak_user_logoutDRevoke all of a user's sessions.
keycloak_user_deleteDPermanently delete a user (id + username must match).
keycloak_role_listRList realm roles.
keycloak_user_roles_getRList a user's realm roles.
keycloak_user_role_assignWGrant a realm role to a user.
keycloak_user_role_unassignDRevoke a realm role from a user.
keycloak_client_roles_listRList the roles defined on a client.
keycloak_user_client_roles_getRList a user's client roles.
keycloak_user_client_role_assignWGrant a client role to a user.
keycloak_user_client_role_unassignDRevoke a client role from a user.
keycloak_client_listRList the realm clients.
keycloak_client_createWCreate a realm client.
keycloak_client_updateWUpdate a client (enabled, public, redirect URIs, CORS web origins).
keycloak_client_deleteDDelete a client.
keycloak_client_getRFetch a client by its clientId.
keycloak_client_get_secretRRead a client secret (masked unless reveal).
keycloak_client_scopes_listRList the realm's client scopes.
keycloak_client_default_scopes_getRList a client's default scopes.
keycloak_client_mappers_listRList a client's protocol mappers.
keycloak_client_scope_assignWAdd a default scope to a client.
keycloak_client_scope_unassignDRemove a default scope from a client.
keycloak_client_regenerate_secretDRegenerate a client secret (old one stops working).
keycloak_group_listRList the realm's top-level groups.
keycloak_group_members_listRList the members of a group.
keycloak_user_groups_listRList the groups a user belongs to.
keycloak_group_createWCreate a top-level group.
keycloak_group_member_addWAdd a user to a group.
keycloak_group_role_assignWGrant a realm role to a group.
keycloak_group_member_removeDRemove a user from a group.
keycloak_group_deleteDDelete a group.
keycloak_idp_listRList identity providers.
keycloak_idp_getRFetch an identity provider by alias.
keycloak_idp_mappers_listRList an identity provider's mappers.
keycloak_idp_createWCreate an identity provider.
keycloak_idp_deleteDDelete an identity provider.
keycloak_federation_listRList user federation (LDAP/Kerberos) providers.
keycloak_federation_getRFetch a federation provider by id.
keycloak_federation_syncWTrigger a user sync (full or changed).
keycloak_auth_flows_listRList authentication flows.
keycloak_auth_required_actions_listRList required actions.
keycloak_auth_required_action_set_enabledWEnable/disable a required action.
keycloak_authz_resources_listRList a client's authorization resources.
keycloak_authz_policies_listRList a client's authorization policies.
keycloak_authz_permissions_listRList a client's authorization permissions.
keycloak_events_loginRRead recent login events (filterable).
keycloak_events_adminRRead recent admin events.
keycloak_realm_get_configRRead key realm configuration flags.
keycloak_server_infoRRead 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

MIT

Related MCP Servers

13bm/GhidraMCP

๐Ÿ โ˜• ๐Ÿ  - MCP server for integrating Ghidra with AI assistants. This plugin enables binary analysis, providing tools for function inspection, decompilation, memory exploration, and import/export analysis via the Model Context Protocol.

๐Ÿ”’ Security1 views
123Ergo/unphurl-mcp

๐Ÿ“‡ โ˜๏ธ - URL intelligence for AI agents. 13 tools for security signals and data quality: redirect behaviour, brand impersonation detection, domain age, SSL validation, parked detection, URL structural analysis, DNS enrichment.

๐Ÿ”’ Security0 views
82ch/MCP-Dandan

๐Ÿ ๐Ÿ“‡ ๐Ÿ  ๐ŸŽ ๐ŸชŸ ๐Ÿง - Real-time security framework for MCP servers that detects and blocks malicious AI agent behavior by analyzing tool call patterns and intent across multiple threat detection engines.

๐Ÿ”’ Security0 views
9hannahnine-jpg/arc-gate-mcp

๐Ÿ - Runtime governance for MCP tool calls. Blocks prompt injection and capability abuse before tool results reach your agent.

๐Ÿ”’ Security0 views

Engagement

Views
0
Installs
0
Upvotes
0

Views and upvotes are unique per visitor network (hashed IP). Installs count copy actions.

Status

Health: Not checked yet

We have not completed a health check for this listing yet.

No check timestamp yet.

Unclaimed listing (imported or pending owner verification). Claim it โ†’
โ˜… Spotlight Slot

Feature Your MCP Server

Get maximum visibility for your server across our directory, search results, and detail pages.

Spotlight Your Server

Own this project?

This directory is pre-filled from public sources. Claim via GitHub README, site badge, or DNS TXT to get the verified badge and attach your website.

Claim this listing

Promote this listing

Optional paid placement. Free listings stay free forever.

Share & Embed

Add our SVG badge (dark/light directory styles) or embeddable widget to your site.