MCP Connector

Manage Keycloak Programmatically

An MCP server providing programmatic access to Keycloak - user, realm, client, role, and group administration over SSE, with per-user JWT auth.

Works with keycloakopenshiftkubernetesgraalvm

90
Spark score
out of 100
Updated 2 months ago
Version 0.3.0
Models
universal

Add to Favorites

Why it matters

Automate Keycloak administration tasks for AI assistants and development tools. Interact with Keycloak for user management, realm configuration, client administration, and authentication flow management.

Outcomes

What it gets done

01

Programmatic user management

02

Realm and client configuration

03

Authentication flow control

04

Integration with AI assistants

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/vb-keycloak-mcp-server | bash

Overview

Keycloak MCP Server

An MCP server exposing Keycloak's user, realm, client, role, and group administration as tools, authenticated per-user via JWT and served over SSE transport. Use when an AI assistant needs to manage Keycloak realms, users, clients, roles, or groups programmatically instead of through the admin console.

What it does

Gives AI assistants and development tools programmatic access to Keycloak administration through the Model Context Protocol, covering user management, realm configuration, client administration, and authentication flow management. Users authenticate with their own JWT tokens obtained directly from Keycloak, via a bundled token-fetch script, rather than a shared service credential, and the server communicates over SSE transport for HTTP-based access. It ships as a production-ready OpenShift/Kubernetes deployment with multi-architecture container images and GraalVM native-image support, built on Quarkus with the official Keycloak Admin Client as its Java-side integration, and Jib for containerization without a Docker daemon.

When to use - and when NOT to

Use it when an AI assistant or tool needs to manage Keycloak realms, users, clients, roles, or groups programmatically rather than through Keycloak's own admin console. Running it is a single Docker invocation:

docker run -d \
  --name keycloak-mcp-server \
  -p 8080:8080 \
  -e KC_URL=https://keycloak.example.com \
  -e KC_REALM=master \
  -e OIDC_CLIENT_ID=mcp-server \
  quay.io/sshaaf/keycloak-mcp-server:latest

and MCP clients like Cursor connect over SSE with a per-user bearer token in the Authorization header, rather than a static server-wide secret. Beyond the container, the project also builds as a plain JAR or a native image via Maven profiles for environments that need one of those forms instead.

Capabilities

Covers the full range of Keycloak admin operations - users, realms, clients, roles, groups - exposed as MCP tools, plus SSE-based HTTP transport so a remote MCP client can connect without a local process.

How to install

Pull the pre-built image from Quay.io and run it with the required Keycloak URL, realm, and OIDC client ID environment variables, or build it directly from source with Maven as a JAR, a GraalVM native binary, or a container image. Full documentation - a getting-started guide, an authentication guide, an OpenShift deployment guide, and a developers guide - lives in the project's own docs directory, built with MkDocs Material and served locally at http://localhost:8000 for anyone contributing to the docs themselves rather than just consuming the pre-built images.

Who it's for

Teams that want an AI assistant to perform Keycloak administration tasks - creating users, configuring realms, managing clients and roles - through natural-language requests instead of the Keycloak admin console or raw REST calls. The project is MIT-licensed, maintained by Shaaf Syed, with pre-built container images published to Quay.io and updated automatically on every commit to main and every release, and community support available through the project's GitHub issues and the Keycloak Discourse forum.

Source README

Project Logo

An MCP Server for Keycloak

Keycloak MCP Server

A Model Context Protocol (MCP) server that provides programmatic access to Keycloak administration functionality.

Overview

The Keycloak MCP Server enables AI assistants and development tools to interact with Keycloak through the Model Context Protocol. It supports comprehensive Keycloak operations including user management, realm configuration, client administration, and authentication flow management.

Key Features

  • User JWT Token Authentication
  • Comprehensive Keycloak Operations (users, realms, clients, roles, groups, etc.)
  • SSE Transport for HTTP-based communication
  • Production-ready OpenShift/Kubernetes deployment
  • Multi-architecture container images
  • GraalVM native image support

Quick Start

Using Docker

docker run -d \
  --name keycloak-mcp-server \
  -p 8080:8080 \
  -e KC_URL=https://keycloak.example.com \
  -e KC_REALM=master \
  -e OIDC_CLIENT_ID=mcp-server \
  quay.io/sshaaf/keycloak-mcp-server:latest

Authentication

Users authenticate with their own JWT tokens from Keycloak:

# Get your token
./scripts/get-mcp-token.sh \
  --keycloak-url https://keycloak.example.com \
  --username your-username \
  --password your-password

Configure in your MCP client (~/.cursor/mcp.json):

{
  "mcpServers": {
    "keycloak": {
      "transport": "sse",
      "url": "https://mcp-server.example.com/mcp/sse",
      "headers": {
        "Authorization": "Bearer <your-jwt-token>"
      }
    }
  }
}

Documentation

Complete documentation is available in the docs directory:

Building Documentation

This project uses MkDocs for documentation. To build and serve locally:

pip install mkdocs-material
mkdocs serve

Visit http://localhost:8000 to view the documentation.

Container Images

Pre-built images are available on Quay.io:

docker pull quay.io/sshaaf/keycloak-mcp-server:latest

Images are automatically built and pushed on commits to main and on releases.

Building

JAR

mvn clean package
java -jar target/quarkus-app/quarkus-run.jar

Native Image

mvn clean package -Pnative
./target/keycloak-mcp-server-runner

Container Image

mvn clean package -Dquarkus.container-image.build=true

Technology Stack

  • Quarkus - Cloud-native Java framework
  • Keycloak Admin Client - Official Keycloak Java client
  • MCP Protocol - Model Context Protocol for AI integration
  • Jib - Containerization without Docker daemon
  • GraalVM - Native image compilation support

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.