keycloak-model-context-protocol

v1.1.0
io.github.ChristophEnglisch/keycloak-model-context-protocol Checked 1 day ago Published 1 month ago

Manage Keycloak users, groups, roles and realms through the Keycloak Admin REST API.

Values you need

VariableWhat it is
KEYCLOAK_URLrequired Base URL of the Keycloak server, e.g. https://keycloak.example.com
KEYCLOAK_AUTH_REALMoptional Realm used to obtain the admin token Default: master
KEYCLOAK_CLIENT_IDoptional Client ID used for login (default admin-cli for the password grant, required for client_credentials)
KEYCLOAK_CLIENT_SECREToptional secret Client secret for the client_credentials grant (recommended: a dedicated service account)
KEYCLOAK_USERNAMEoptional Username for the password grant (alternative to client credentials)
KEYCLOAK_PASSWORDoptional secret Password for the password grant
KEYCLOAK_GRANT_TYPEoptional Grant type; auto-detected if unset (client_credentials when a secret is set, else password)
KEYCLOAK_MCP_READ_ONLYoptional If true, only read-only tools are registered Default: false
KEYCLOAK_MCP_REALMSoptional Comma-separated allowlist of target realms; empty means all realms
KEYCLOAK_MCP_ALLOW_MASTER_WRITEoptional If true, write tools may modify the master realm Default: false
KEYCLOAK_MCP_TOOLSETSoptional Comma-separated enabled toolsets (core, groups, roles, clients, sessions, events, security) or all Default: core,groups,roles
KEYCLOAK_MCP_REQUIRE_CONFIRMATIONoptional If true, destructive tools require confirm=true Default: true
KEYCLOAK_MCP_TIMEOUT_MSoptional HTTP timeout for Keycloak requests in milliseconds Default: 30000
KEYCLOAK_MCP_LOG_LEVELoptional Log level written to stderr Default: info

npm (npx)

Requires Node.js 18+

Run in a terminal
claude mcp add keycloak-model-context-protocol -e 'KEYCLOAK_URL=<KEYCLOAK_URL>' -- npx -y keycloak-model-context-protocol@1.1.0
Add to claude_desktop_config.json
{
  "mcpServers": {
    "keycloak-model-context-protocol": {
      "args": [
        "-y",
        "keycloak-model-context-protocol@1.1.0"
      ],
      "command": "npx",
      "env": {
        "KEYCLOAK_URL": "<KEYCLOAK_URL>"
      }
    }
  }
}
Add to ~/.cursor/mcp.json
{
  "mcpServers": {
    "keycloak-model-context-protocol": {
      "args": [
        "-y",
        "keycloak-model-context-protocol@1.1.0"
      ],
      "command": "npx",
      "env": {
        "KEYCLOAK_URL": "<KEYCLOAK_URL>"
      }
    }
  }
}
Add to .vscode/mcp.json
{
  "inputs": [
    {
      "description": "KEYCLOAK_URL",
      "id": "keycloak-url",
      "password": true,
      "type": "promptString"
    }
  ],
  "servers": {
    "keycloak-model-context-protocol": {
      "args": [
        "-y",
        "keycloak-model-context-protocol@1.1.0"
      ],
      "command": "npx",
      "env": {
        "KEYCLOAK_URL": "${input:keycloak-url}"
      },
      "type": "stdio"
    }
  }
}
Add to ~/.codex/config.toml
[mcp_servers.keycloak-model-context-protocol]
command = "npx"
args = ["-y", "keycloak-model-context-protocol@1.1.0"]
env = { "KEYCLOAK_URL" = "<KEYCLOAK_URL>" }

For AI agents

  1. Ask the user for: KEYCLOAK_URL. Never invent or guess these values; secrets go into the client config, not into chat logs.
  2. Pick the user's MCP client and apply the matching config from the first install method (it is the one verified by the smoke test when available).
  3. Restart or reload the client so it starts the server.
  4. If it fails, check that the required runtime is installed (Node.js 18+) and that the values above are set.

Machine-readable: install.md · manifest.json