Manage Keycloak Programmatically
Keycloak MCP Server gives an AI assistant programmatic access to Keycloak's admin API, authenticated with each user's own JWT.
0.4.0Add 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
Programmatic user management
Realm and client configuration
Authentication flow control
Integration with AI assistants
Source
Get it from source
Spark does not host a copy of it.
Open sourceReports
Agent outcome reports
No reports yet
Overview
Keycloak MCP Server
Keycloak MCP Server is an MCP server giving an AI assistant programmatic access to Keycloak's admin API for users, realms, clients, roles, and groups. Each caller authenticates with their own JWT token, so access follows Keycloak's own permission model rather than a shared admin credential. Use it when an AI assistant needs to manage a Keycloak identity server directly instead of through its admin console. Scoped entirely to Keycloak administration, with production deployment support for OpenShift and Kubernetes.
What it does
Keycloak MCP Server is an MCP server that gives an AI assistant or dev tool programmatic access to Keycloak's admin API - managing users, realms, clients, roles, and groups, and driving authentication-flow configuration - built on Quarkus with the official Keycloak Admin Client.
When to use - and when NOT to
Use it when you want an AI assistant to manage a Keycloak identity server directly - create or inspect users, adjust realm or client settings, work with roles and groups - rather than through Keycloak's own admin console. Each caller authenticates with their own JWT token issued by Keycloak, so the server enforces the same permissions that token already carries rather than a shared service account; it's built for production deployment on OpenShift/Kubernetes with multi-architecture images and a GraalVM native image option. It is not a fit if you need something other than Keycloak identity administration - it's scoped entirely to that admin surface.
Capabilities
The server communicates over SSE transport for HTTP-based MCP clients, and covers the standard Keycloak admin operations: user, realm, client, role, and group management. Per-user JWT authentication means access is governed by Keycloak's own permission model rather than a broad admin credential shared across every caller, so an assistant acting on behalf of a limited-privilege user cannot silently do more than that user could do through the admin console itself.
How to install
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
Get a personal JWT with the bundled get-mcp-token.sh script, then point an MCP client at the server over SSE with that token as a Bearer header, for example in Cursor's ~/.cursor/mcp.json. It can also be built as a JAR (mvn clean package), a GraalVM native image (mvn clean package -Pnative), or a container image via Jib without a Docker daemon; pre-built multi-arch images are published to Quay.io on every commit to main and on releases. Documentation covers getting started, authentication, and OpenShift deployment, and the project tracks separate prompt/eval coverage notes alongside its standard mvn test suite. It is MIT-licensed, maintained by Shaaf Syed, and support runs through GitHub Issues and the Keycloak Discourse community rather than a dedicated channel.
Who it's for
Platform and identity teams running Keycloak who want an AI assistant to manage users, realms, and clients through the same Keycloak permission model each user already has, rather than a shared admin credential.
Source README
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:
- Getting Started Guide - Setup instructions
- Authentication Guide - User authentication
- OpenShift Deployment - Production deployment
- Developers Guide - Development guide
- Full Documentation Index - Complete table of contents
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
Tests
- Default unit and integration tests:
mvn test - Prompt / eval coverage notes: evals/README.md
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.