Get the FREE Ultimate OpenClaw Setup Guide →

keycloak

MCP server that integrates with Keycloak, allowing you to manage Keycloak users and realms through a standardized protocol. It uses the official Keycloak Admin Client to interact with Keycloak's API.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio haithamoumerzoug-keycloak-mcp npx -y keycloak-mcp \
  --env KEYCLOAK_URL="http://localhost:8080" \
  --env KEYCLOAK_ADMIN="admin" \
  --env KEYCLOAK_ADMIN_PASSWORD="admin"

How to use

This MCP server provides a standardized interface to manage Keycloak. It exposes a set of MCP tools that map to common Keycloak administrative actions, such as creating and deleting users, listing realms, clients, groups, and roles, and assigning client roles or adding users to groups. By running the server via the included MCP package, you can invoke these tools through the MCP protocol in your workspace, allowing you to orchestrate Keycloak administration from other MCP-enabled components or automation pipelines. The available tools are documented in the README and include create-user, delete-user, list-realms, list-users, list-clients, list-groups, list-client-roles, assign-client-role-to-user, and add-user-to-group. Each tool expects inputs like realm, userId, clientUniqueId, roleName, and other identifiers to perform the corresponding action against your Keycloak instance.

How to install

Prerequisites:

  • Node.js (LTS version recommended)
  • npm
  • A running Keycloak instance

Install and run the MCP server using npm/npx:

  1. Install or run via npx (no local install required):
npx -y keycloak-mcp --keycloak-url <Keycloak Instance URL> --keycloak-admin <Admin Username> --keycloak-admin-password <Admin Password>
  1. Optional: install globally and run the CLI directly:
npm install -g keycloak-mcp@latest
keycloak-mcp --keycloak-url <Keycloak Instance URL> --keycloak-admin <Admin Username> --keycloak-admin-password <Admin Password>
  1. Alternatively, if you prefer to run from a local project (as shown in this repo's development flow):
npm install
npm run dev

Configure environment variables as needed for your environment, or pass them as command-line arguments if supported by your setup.

Additional notes

Environment variables:

  • KEYCLOAK_URL: Base URL of your Keycloak instance
  • KEYCLOAK_ADMIN: Admin username
  • KEYCLOAK_ADMIN_PASSWORD: Admin password Common issues:
  • Ensure Keycloak Admin API access is enabled and the admin user has sufficient privileges
  • If using a self-signed certificate, you may need to configure TLS/SSL verifier settings in your environment
  • When running via npx, ensure network access to npm registry to fetch keycloak-mcp
  • If the MCP server cannot reach Keycloak, verify network connectivity and Keycloak URL/port Configuration tips:
  • Keep KEYCLOAK_URL in sync with your Keycloak deployment (including http/https and port)
  • Store credentials securely; consider using a secret manager instead of hardcoding in env files
  • Use the provided mcpServers configuration to standardize how this server is launched within your MCP ecosystem

Related MCP Servers

Sponsor this space

Reach thousands of developers