# Keycloak Model Context Protocol

> Keycloak Model Context Protocol is an open-source MCP server for ai models and llm tooling. Manage Keycloak users, groups and roles with confirm-first guardrails. It runs locally on your machine and is started by your AI client.

- **Kind:** MCP server
- **Pricing:** Open source
- **Platforms:** CLI, self-hosted
- **Repository:** https://github.com/christophenglisch/keycloak-model-context-protocol
- **MCP Registry name:** io.github.ChristophEnglisch/keycloak-model-context-protocol
- **Categories:** [AI models and LLM tooling](https://ai-powered.com/categories/ai-and-llm), [security](https://ai-powered.com/categories/security), [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-11-18

## About

This server administers Keycloak through the Admin REST API and is built around limiting what an AI assistant can change. The README recommends a dedicated service-account client with only needed realm-management roles, never the bootstrap admin, and the server acts with whatever rights that account holds.

It registers 24 tools in seven toolsets (core, groups, roles, clients, sessions, events, security), with core, groups and roles on by default. Guardrails include a read-only mode, a realm allowlist, write protection for the master realm, and a preview step: sensitive or destructive tools return a preview until called with confirm true. Grants of administrative rights are detected through composite roles and parent groups.

There are four guided prompts (onboarding, offboarding, security audit, failed-login investigation) and resources for realms and users. It runs locally over stdio on Node.js 22 or newer and was tested with Keycloak 24.0 to 26.8.

## Features

- **Seven toolsets:** Enable only the toolsets needed: core, groups, roles, clients, sessions, events, security.
- **Preview then confirm:** Changing tools return a preview until confirm true is passed.
- **Read-only mode:** KEYCLOAK_MCP_READ_ONLY registers only read tools.
- **Realm allowlist:** Limit targets with KEYCLOAK_MCP_REALMS and block master-realm writes by default.
- **Guided prompts:** Prompts for onboarding, offboarding, security audit and failed-login investigation.
- **Secrets kept out:** Secrets and credentials are never returned or logged.

## Good for

- Search users and show group membership
- Onboard or offboard an employee in a realm
- Audit a realm's security posture
- Investigate failed logins
- Assign or revoke roles with a preview first

## Install

### Claude Code (Terminal)

```sh
claude mcp add keycloak-model-context-protocol --env KEYCLOAK_URL='<KEYCLOAK_URL>' --env KEYCLOAK_CLIENT_SECRET='<KEYCLOAK_CLIENT_SECRET>' --env KEYCLOAK_PASSWORD='<KEYCLOAK_PASSWORD>' -- npx -y keycloak-model-context-protocol
```

### Claude Desktop (claude_desktop_config.json)

```json
{
  "mcpServers": {
    "keycloak-model-context-protocol": {
      "command": "npx",
      "args": [
        "-y",
        "keycloak-model-context-protocol"
      ],
      "env": {
        "KEYCLOAK_URL": "<KEYCLOAK_URL>",
        "KEYCLOAK_CLIENT_SECRET": "<KEYCLOAK_CLIENT_SECRET>",
        "KEYCLOAK_PASSWORD": "<KEYCLOAK_PASSWORD>"
      }
    }
  }
}
```

### Cursor (~/.cursor/mcp.json)

```json
{
  "mcpServers": {
    "keycloak-model-context-protocol": {
      "command": "npx",
      "args": [
        "-y",
        "keycloak-model-context-protocol"
      ],
      "env": {
        "KEYCLOAK_URL": "<KEYCLOAK_URL>",
        "KEYCLOAK_CLIENT_SECRET": "<KEYCLOAK_CLIENT_SECRET>",
        "KEYCLOAK_PASSWORD": "<KEYCLOAK_PASSWORD>"
      }
    }
  }
}
```

### VS Code (.vscode/mcp.json)

```json
{
  "servers": {
    "keycloak-model-context-protocol": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "keycloak-model-context-protocol"
      ],
      "env": {
        "KEYCLOAK_URL": "<KEYCLOAK_URL>",
        "KEYCLOAK_CLIENT_SECRET": "<KEYCLOAK_CLIENT_SECRET>",
        "KEYCLOAK_PASSWORD": "<KEYCLOAK_PASSWORD>"
      }
    }
  }
}
```

### Windsurf (~/.codeium/windsurf/mcp_config.json)

```json
{
  "mcpServers": {
    "keycloak-model-context-protocol": {
      "command": "npx",
      "args": [
        "-y",
        "keycloak-model-context-protocol"
      ],
      "env": {
        "KEYCLOAK_URL": "<KEYCLOAK_URL>",
        "KEYCLOAK_CLIENT_SECRET": "<KEYCLOAK_CLIENT_SECRET>",
        "KEYCLOAK_PASSWORD": "<KEYCLOAK_PASSWORD>"
      }
    }
  }
}
```

### Other clients (your client's MCP settings (most use this shape))

```json
{
  "mcpServers": {
    "keycloak-model-context-protocol": {
      "command": "npx",
      "args": [
        "-y",
        "keycloak-model-context-protocol"
      ],
      "env": {
        "KEYCLOAK_URL": "<KEYCLOAK_URL>",
        "KEYCLOAK_CLIENT_SECRET": "<KEYCLOAK_CLIENT_SECRET>",
        "KEYCLOAK_PASSWORD": "<KEYCLOAK_PASSWORD>"
      }
    }
  }
}
```

## Tools

- `realm_list`: List accessible realms.
- `realm_get`: Get a realm.
- `user_search`: Search users.
- `user_get`: Get a user.
- `user_create`: Create a user (sensitive).
- `user_update`: Update a user (sensitive).
- `user_delete`: Delete a user (destructive).
- `user_send_actions_email`: Send an actions email (sensitive).
- `group_list`: List groups.
- `group_members_list`: List group members.
- `user_group_add`: Add a user to a group (sensitive).
- `user_group_remove`: Remove a user from a group (destructive).
- `role_list`: List roles.
- `user_roles_list`: List a user's roles.
- `user_role_assign`: Assign a role (sensitive).
- `user_role_revoke`: Revoke a role (destructive).

## FAQ

### Which auth methods does it support?

client_credentials with a service account (recommended) or the password grant.

### Can it delete users without asking?

By default destructive tools need confirm true, though the README notes the model can set it itself, so client approval is the real check.

### What Keycloak versions were tested?

24.0 to 26.8.

### What does it need to run?

Node.js 22 or newer, a reachable Keycloak server and an MCP client.

### Is Keycloak Model Context Protocol free?

Yes. Keycloak Model Context Protocol is open source, so you can use and self-host it for free.

### How do I add Keycloak Model Context Protocol to Claude Code?

Run this command in your terminal: claude mcp add keycloak-model-context-protocol --env KEYCLOAK_URL='<KEYCLOAK_URL>' --env KEYCLOAK_CLIENT_SECRET='<KEYCLOAK_CLIENT_SECRET>' --env KEYCLOAK_PASSWORD='<KEYCLOAK_PASSWORD>' -- npx -y keycloak-model-context-protocol

### What are the best alternatives to Keycloak Model Context Protocol?

The closest alternatives to Keycloak Model Context Protocol are REA, Context7, Chrome DevTools MCP, Codebase Memory and GitHub.

## Where this comes from

- Description: written from the project's README.
- Install steps: from the official MCP Registry entry.

## Alternatives

- [REA](https://ai-powered.com/mcp/rea): REA is an open-source MCP server for developer tools.
- [Context7](https://ai-powered.com/mcp/context7): Context7 is a freemium MCP server for developer tools.
- [Chrome DevTools MCP](https://ai-powered.com/mcp/chrome-devtools-mcp-2): Chrome DevTools MCP is an open-source MCP server for browser automation.
- [Codebase Memory](https://ai-powered.com/mcp/codebase-memory): Codebase Memory is an open-source MCP server for knowledge and memory.
- [GitHub](https://ai-powered.com/mcp/github-2): GitHub is an open-source MCP server for developer tools.
- [Serena MCP: the IDE for your agent](https://ai-powered.com/mcp/serena-mcp-the-ide-for-your-agent): Serena MCP: the IDE for your agent is an open-source MCP server for developer tools.
- [awesome-mcp-servers](https://ai-powered.com/mcp/awesome-mcp-servers-2): awesome-mcp-servers is an open-source MCP server for developer tools.
- [XERJ](https://ai-powered.com/mcp/xerj): XERJ is an open-source MCP server for knowledge and memory.

---
Source: https://ai-powered.com/mcp/keycloak-model-context-protocol
