mcp-keycloak

mcp-keycloak

Managing Keycloak identity and access management

Category
Visit Server

README

Keycloak MCP Server

Integration Python Version MIT licensed smithery badge

A Model Context Protocol (MCP) server that provides a natural language interface for managing Keycloak identity and access management through its REST API. This server enables AI agents to perform user management, client configuration, realm administration, and role-based access control operations seamlessly.

Overview

The Keycloak MCP Server bridges the gap between AI applications and Keycloak's powerful identity management capabilities. Whether you're building an AI assistant that needs to manage users, configure clients, or handle complex authorization scenarios, this server provides the tools you need through simple, natural language commands.

Features

🔐 Comprehensive User Management

Manage users lifecycle from creation to deletion, including password resets, session management, and user attribute updates.

🏢 Client Configuration

Create and configure OAuth2/OIDC clients, manage client secrets, and handle service accounts programmatically.

👥 Role-Based Access Control

Define and assign realm and client-specific roles, manage user permissions, and implement fine-grained access control.

🏛️ Realm Administration

Configure realm settings, manage default groups, handle event configurations, and control realm-wide policies.

🔄 Group Management

Organize users into groups, manage group hierarchies, and handle group-based permissions efficiently.

Installation

Installing via Smithery

To install mcp-keycloak for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install mcp-keycloak --client claude

Quick Start

Install using pip:

pip install mcp-keycloak

Development Installation

Clone the repository and install dependencies:

git clone https://github.com/idoyudha/mcp-keycloak.git
cd mcp-keycloak
pip install -e .

Configuration

The server can be configured using environment variables or a .env file:

# Required configuration
SERVER_URL=https://your-keycloak-server.com
USERNAME=admin-username
PASSWORD=admin-password
REALM_NAME=your-realm

# Optional OAuth2 client configuration
CLIENT_ID=optional-client-id
CLIENT_SECRET=optional-client-secret

Tools

The Keycloak MCP Server provides a comprehensive set of tools organized by functionality:

User Management

Complete user lifecycle management including:

  • list_users - List users with pagination and filtering
  • create_user / update_user / delete_user - Full CRUD operations
  • reset_user_password - Password management
  • get_user_sessions / logout_user - Session control
  • count_users - User statistics

Client Management

OAuth2/OIDC client configuration:

  • list_clients / get_client / create_client - Client operations
  • get_client_secret / regenerate_client_secret - Secret management
  • get_client_service_account - Service account access
  • update_client / delete_client - Client modifications

Role Management

Fine-grained permission control:

  • list_realm_roles / create_realm_role - Realm role operations
  • list_client_roles / create_client_role - Client-specific roles
  • assign_realm_role_to_user / remove_realm_role_from_user - Role assignments
  • get_user_realm_roles / assign_client_role_to_user - User role queries

Group Management

Hierarchical user organization:

  • list_groups / create_group / update_group - Group operations
  • get_group_members / add_user_to_group - Membership management
  • get_user_groups / remove_user_from_group - User group associations

Realm Administration

System-wide configuration:

  • get_realm_info / update_realm_settings - Realm configuration
  • get_realm_events_config / update_realm_events_config - Event management
  • add_realm_default_group / remove_realm_default_group - Default settings

Usage

Running the Server

Start the MCP server directly:

python -m src.main

Integration Examples

Claude Desktop

  1. Clone the server:
git clone https://github.com/idoyudha/mcp-keycloak.git
  1. Configure in claude_desktop_config.json:
{
  "mcpServers": {
    "keycloak": {
      "command": "uv",
      "args": [
        "--directory",
        "/path/to/mcp-keycloak",
        "run",
        "src/main.py"
      ],
      "env": {
        "SERVER_URL": "https://your-keycloak.com",
        "USERNAME": "admin",
        "PASSWORD": "admin-password",
        "REALM_NAME": "your-realm"
      }
    }
  }
}

Using uvx

{
  "mcpServers": {
    "keycloak": {
      "command": "uvx",
      "args": [
        "mcp-keycloak"
      ],
      "env": {
        "SERVER_URL": "https://your-keycloak.com",
        "USERNAME": "admin",
        "PASSWORD": "admin-password",
        "REALM_NAME": "your-realm"
      }
    }
  }
}

Example Use Cases

🤖 AI-Powered Identity Management

Build AI assistants that can handle user onboarding, permission management, and access control through natural language commands.

🔄 Automated User Provisioning

Create workflows that automatically provision users, assign roles, and configure client applications based on business rules.

📊 Identity Analytics

Query and analyze user data, session information, and access patterns to gain insights into your identity infrastructure.

🚀 DevOps Integration

Integrate Keycloak management into your CI/CD pipelines, allowing automated configuration of identity services.

Requirements

  • Python 3.8 or higher
  • Keycloak server (tested with Keycloak 18+)
  • Admin access to Keycloak realm

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

For issues, questions, or contributions, please visit the GitHub repository.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured