Mcp Keycloak

io.github.dockndevaiPublished by GitHub account dockndevaiv0.3.3Updated Oct 26, 2026

Keycloak admin for AI agents — realms, users, clients, roles; safe-by-default governance.

VerifiedSTDIODesktop onlyDeveloper ToolsSecurity & Monitoring

Overview

AI-generated overview

Keycloak admin MCP server that lets an assistant inspect realms, users, clients, roles and groups, with read-only defaults and layered security flags.

What you can do
  • List and read realms, including each realm's configuration
  • Search, page through and count users in a realm, and fetch a single user by id
  • List OAuth/OIDC clients configured in a realm, without client secrets
  • List realm-level roles and groups
  • In read-write or admin mode, create and update users, reset passwords, log users out and delete users
When to use it
Useful when you want an AI client to answer questions about a Keycloak identity setup — which realms exist, who the users are, which clients and roles are configured — or to make controlled user changes without leaving the chat. Start in read-only mode and raise the mode only when mutations are actually needed.
Requirements
Runs locally via npx from the npm package, so Node.js is needed. Requires KEYCLOAK_URL (base URL of the Keycloak server, no trailing slash) and credentials: a service-account client secret via KEYCLOAK_CLIENT_SECRET with KEYCLOAK_CLIENT_ID, or admin username/password. Optional flags cover access mode, realm allowlist, protected realms, delete gating, dry-run and audit logging. Network access to the Keycloak server is required.
Before you install
The server holds Keycloak admin credentials (KEYCLOAK_CLIENT_SECRET or username/password) that can read and, in higher modes, change identity data. KEYCLOAK_MODE defaults to read-only; read-write adds user creation, updates, password resets and logouts, and admin mode with KEYCLOAK_ALLOW_DELETE adds user deletion. Keep the realm allowlist and protected realms set, and note that audit lines are written to stderr.

Installation

In SourceWeft

  1. Open Mcp Keycloak in the dashboard and add it to a workspace.
  2. Enable the server for the chats that should use its tools.

Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.

Other MCP clients

Follow the launch instructions in the repository.

README

mcp-keycloak

[CI] [License: MIT] [npm]

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 realm argument; 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.

Security model

ConcernFlagDefaultEffect
What can the server do at all?KEYCLOAK_MODEread-onlyread-only exposes only read tools; read-write adds mutations; admin adds destructive tools. Tools above the mode are never registered.
Which realms are in scope?KEYCLOAK_REALM_ALLOWLIST(all)Comma-separated. When set, any operation on a realm outside the list is refused.
Which realms are read-only forever?KEYCLOAK_PROTECTED_REALMSmasterProtected realms can be read but never mutated or deleted, regardless of mode.
Can it delete?KEYCLOAK_ALLOW_DELETEfalsedelete_* tools require this and admin mode.
Preview without touching KeycloakKEYCLOAK_DRY_RUNfalseWrite/admin tools validate + log intent, then return without calling Keycloak.
Audit trailKEYCLOAK_AUDIT_LOGtrueEmits a JSON line to stderr per guarded operation (ALLOW / DENY / DRY_RUN).
Interactive confirmation(automatic)—Destructive & high-impact actions prompt the human to approve via MCP elicitation before running; clients without elicitation fall back to the *_ALLOW_* gate.

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)

bash
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-keycloak

Claude Desktop · Cursor · Windsurf — same block in claude_desktop_config.json, .cursor/mcp.json, or ~/.codeium/windsurf/mcp_config.json:

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:

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:

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:

bash
npm installnpm run buildnode dist/index.js   # with the environment variables set

Develop

bash
npm run dev        # watch modenpm test           # unit tests for the security policynpm run typecheck

Publishing

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

Source: README.md at commit c2481a2

Tools

8

list_realms

List realms

List all realms visible to the configured credentials. Realms outside the allowlist are filtered out.

Takes no parameters.

get_realm

Get realm settings

Fetch the configuration of a single realm.

Parametersrealmrequired

list_users

List / search users

List users in a realm. Supports free-text search and pagination. Passwords and secrets are never returned by Keycloak.

Parametersmaxfirstrealmrequiredsearch

get_user

Get user by id

Fetch a single user representation by their Keycloak id.

ParametersrealmrequireduserIdrequired

count_users

Count users

Return the number of users in a realm, optionally matching a search term.

Parametersrealmrequiredsearch

list_clients

List clients

List OAuth/OIDC clients configured in a realm. Client secrets are not included.

ParametersrealmrequiredclientId

list_realm_roles

List realm roles

List the realm-level roles defined in a realm.

Parametersrealmrequired

list_groups

List groups

List groups in a realm.

Parametersrealmrequiredsearch

Version history

3
  1. v0.3.3LatestOct 26, 2026
  2. v0.3.0Sep 29, 2026
  3. v0.2.2Sep 16, 2026

Score

90% of the applicable checks met

How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.

  • Reached in the last 30 days25 pts
  • Auth declared10 pts

    Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.

  • Tools listedRequired15 pts
  • DescriptionRequired15 pts
  • Logo10 pts
  • Documentation15 pts
  • License10 pts