Octodet Keycloak MCP Server

Octodet Keycloak MCP Server

keycloak-mcp•byoctodet

A Model Context Protocol server that exposes tools for administering Keycloak users, realms, and client roles through LLM interfaces.

License: MIT•Runtime: Awaiting documentation review•Category: auth security

WHAT IT DOES

  • •Creates new users in a specified realm with attributes, enabled/verified flags, and optional credentials such as passwords.
  • •Deletes existing users and lists all users in a specified realm.
  • •Lists available realms and lists roles defined for a specific client in a realm.
  • •Adds or removes client roles for a user in a single operation.

BEST FOR

  • •Discovering and validating available realms before performing Keycloak administrative operations.
  • •Looking up user IDs and confirming available client roles before making assignments.
  • •Updating a user's role set by assigning new client roles and revoking obsolete ones at once.

ABOUT KEYCLOAK-MCP

Octodet Keycloak MCP Server is cataloged as an MCP server attributed to octodet. A Model Context Protocol server that exposes tools for administering Keycloak users, realms, and client roles through LLM interfaces. It is categorized under auth security. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: MIT. Check the source repository's current license and terms before using, modifying or distributing this software.

Capability inspector

Capability definitions are not reviewed. Unreviewed imports are not exposed as trusted interfaces.

Tools (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Resources (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Prompts (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for Octodet Keycloak MCP Server are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

Can the server assign and revoke roles for the same user at once?

Yes, update-user-roles supports combined operations where roles are added and removed in one call, requiring at least one of rolesToAdd or rolesToRemove.

Which identifier does listing roles accept for a client?

It accepts either the human-readable client ID or the client UUID.

How is the server configured to reach Keycloak?

It is configured through environment variables for the Keycloak URL, admin credentials, and default realm.

Upstream README

View this exact version on GitHub

README.md · 41649be6e112 · Fetched 2026-11-13 13:23:21 UTC

Original upstream text, without AI rewriting. Scripts, forms and unsafe links are filtered for safety.

Showing the last retrieved documentation snapshot; check the source for current changes.

Octodet Keycloak MCP Server

npm version License: MIT

A powerful Model Context Protocol server for Keycloak administration, providing a comprehensive set of tools to manage users, realms, roles, and other Keycloak resources through LLM interfaces.

Advanced Keycloak server MCP server

Features

  • User Management: Create, delete, and list users across realms
  • Realm Administration: Comprehensive realm management capabilities
  • Secure Integration: Authentication with admin credentials
  • Easy Configuration: Simple setup with environment variables
  • LLM Integration: Seamless use with Claude, ChatGPT, and other MCP-compatible AI assistants

Installation

The server is available as an NPM package:

# Direct usage with npx
npx -y @octodet/keycloak-mcp

# Or global installation
npm install -g @octodet/keycloak-mcp

Configuration

Environment Variables

VariableDescriptionDefault
KEYCLOAK_URLKeycloak server URLhttp://localhost:8080
KEYCLOAK_ADMINAdmin usernameadmin
KEYCLOAK_ADMIN_PASSWORDAdmin passwordadmin
KEYCLOAK_REALMDefault realmmaster

MCP Client Configuration

VS Code

Add this to your settings.json:

{
  "mcp.servers": {
    "keycloak": {
      "command": "npx",
      "args": ["-y", "@octodet/keycloak-mcp"],
      "env": {
        "KEYCLOAK_URL": "http://localhost:8080",
        "KEYCLOAK_ADMIN": "admin",
        "KEYCLOAK_ADMIN_PASSWORD": "admin"
      }
    }
  }
}

Claude Desktop

Configure in your Claude Desktop configuration file:

{
  "mcpServers": {
    "keycloak": {
      "command": "npx",
      "args": ["-y", "@octodet/keycloak-mcp"],
      "env": {
        "KEYCLOAK_URL": "http://localhost:8080",
        "KEYCLOAK_ADMIN": "admin",
        "KEYCLOAK_ADMIN_PASSWORD": "admin"
      }
    }
  }
}

For Local Development

{
  "mcpServers": {
    "keycloak": {
      "command": "node",
      "args": ["path/to/build/index.js"],
      "env": {
        "KEYCLOAK_URL": "http://localhost:8080",
        "KEYCLOAK_ADMIN": "admin",
        "KEYCLOAK_ADMIN_PASSWORD": "admin"
      }
    }
  }
}

Available Tools

The server provides a comprehensive set of MCP tools for Keycloak administration. Each tool is designed to perform specific administrative tasks across realms, users, and roles.

📋 Tool Overview

ToolCategoryDescription
create-userUser ManagementCreate a new user in a specified realm
delete-userUser ManagementDelete an existing user from a realm
list-usersUser ManagementList all users in a specified realm
list-realmsRealm ManagementList all available realms
list-rolesRole ManagementList all roles for a specific client
update-user-rolesRole ManagementAdd or remove client roles for a user

👥 User Management

create-user

Creates a new user in a specified realm with comprehensive user attributes and optional credentials.

Required Parameters:

  • realm (string): Target realm name
  • username (string): Unique username for the new user
  • email (string): Valid email address
  • firstName (string): User's first name
  • lastName (string): User's last name

Optional Parameters:

  • enabled (boolean): Enable/disable user account (default: true)
  • emailVerified (boolean): Mark email as verified
  • credentials (array): Array of credential objects for setting passwords

Credential Object Structure:

  • type (string): Credential type (e.g., "password")
  • value (string): The credential value
  • temporary (boolean): Whether password must be changed on first login

Example Usage:

{
  "realm": "my-app-realm",
  "username": "john.doe",
  "email": "john.doe@company.com",
  "firstName": "John",
  "lastName": "Doe",
  "enabled": true,
  "emailVerified": true,
  "credentials": [
    {
      "type": "password",
      "value": "TempPassword123!",
      "temporary": true
    }
  ]
}

Response: Returns the created user ID and confirmation message.


delete-user

Permanently removes a user from the specified realm. This action cannot be undone.

Required Parameters:

  • realm (string): Target realm name
  • userId (string): Unique identifier of the user to delete

Example Usage:

{
  "realm": "my-app-realm",
  "userId": "8f5c21e3-7c9d-4b5a-9f3e-8d4f6a2e7b1c"
}

Response: Confirmation message of successful deletion.

⚠️ Warning: This operation is irreversible. Ensure you have the correct user ID before execution.


list-users

Retrieves a list of all users in the specified realm with their basic information.

Required Parameters:

  • realm (string): Target realm name

Example Usage:

{
  "realm": "my-app-realm"
}

Response: Returns a formatted list showing usernames and user IDs for all users in the realm.


🏛️ Realm Management

list-realms

Retrieves all available realms in the Keycloak instance.

Parameters: None required

Example Usage:

{}

Response: Returns a list of all realm names available in the Keycloak installation.

Use Cases:

  • Discovering available realms
  • Validating realm names before other operations
  • Administrative overview of the Keycloak setup

🔐 Role Management

list-roles

Lists all roles defined for a specific client within a realm. Useful for understanding available permissions and roles before assignment.

Required Parameters:

  • realm (string): Target realm name
  • clientId (string): Client ID or UUID of the target client

Example Usage:

{
  "realm": "my-app-realm",
  "clientId": "my-application"
}

Alternative with Client UUID:

{
  "realm": "my-app-realm",
  "clientId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}

Response: Returns a formatted list of all role names available for the specified client.

💡 Tip: You can use either the client's human-readable ID or its UUID identifier.


update-user-roles

Manages client role assignments for a user. Allows both adding and removing roles in a single operation.

Required Parameters:

  • realm (string): Target realm name
  • userId (string): User's unique identifier
  • clientId (string): Client ID or UUID

Optional Parameters:

  • rolesToAdd (array): List of role names to assign to the user
  • rolesToRemove (array): List of role names to remove from the user

Example Usage - Adding Roles:

{
  "realm": "my-app-realm",
  "userId": "8f5c21e3-7c9d-4b5a-9f3e-8d4f6a2e7b1c",
  "clientId": "my-application",
  "rolesToAdd": ["admin", "user-manager", "report-viewer"]
}

Example Usage - Removing Roles:

{
  "realm": "my-app-realm",
  "userId": "8f5c21e3-7c9d-4b5a-9f3e-8d4f6a2e7b1c",
  "clientId": "my-application",
  "rolesToRemove": ["temporary-access", "beta-tester"]
}

Example Usage - Combined Operation:

{
  "realm": "my-app-realm",
  "userId": "8f5c21e3-7c9d-4b5a-9f3e-8d4f6a2e7b1c",
  "clientId": "my-application",
  "rolesToAdd": ["senior-user"],
  "rolesToRemove": ["junior-user", "trainee"]
}

Response: Detailed summary of roles added, removed, and any errors encountered.

🔍 Notes:

  • At least one of rolesToAdd or rolesToRemove must be provided
  • Non-existent roles are skipped with warnings
  • The operation is atomic per role list (all or none for each operation type)

🚀 Usage Tips

  1. User IDs vs Usernames: Most operations require user IDs (UUIDs), not usernames. Use list-users to find the correct user ID.

  2. Client Identification: The clientId parameter accepts both human-readable client IDs and UUID identifiers.

  3. Realm Validation: Always verify realm names using list-realms before performing operations.

  4. Role Discovery: Use list-roles to discover available roles before attempting role assignments.

  5. Error Handling: All tools provide detailed error messages for troubleshooting authentication, permission, or parameter issues.

Development

Setting Up Your Development Environment

# Clone the repository
git clone <repository-url>

# Install dependencies
npm install

# Start the development server with watch mode
npm run watch

Adding New Tools

To add a new tool to the server:

  1. Define the tool schema in src/index.ts using Zod
  2. Add the tool definition to the ListToolsRequestSchema handler
  3. Implement the tool handler in the CallToolRequestSchema switch statement
  4. Update this README to document the new tool

Testing

Using MCP Inspector

The MCP Inspector is a great tool for testing your MCP server:

npx -y @modelcontextprotocol/inspector npx -y @octodet/keycloak-mcp

Integration Testing

For testing with a local Keycloak instance:

# Start Keycloak with Docker
docker run -p 8080:8080 -e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=admin quay.io/keycloak/keycloak:latest start-dev

# In another terminal, run the MCP server
npm run build
node build/index.js

Deployment

NPM Package

This project is published to NPM under @octodet/keycloak-mcp.

Automated Deployment

This project uses GitHub Actions for CI/CD to automatically test and publish to NPM when a new release is created.

Prerequisites

  • Node.js 18 or higher
  • Running Keycloak instance

License

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

Author

Octodet - Building intelligent tools for developers

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for Octodet Keycloak MCP Server from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/keycloak-mcp)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

Downloads and pulls

Separate sources, scopes and periods. Never combined or treated as installations, active users or security reviews.

No reviewed package or image identity; download statistics are not listed yet.

Related auth security MCP Servers

Alternative and complementary servers in the same category

View all in auth security →

A modular FastMCP server for interacting with Microsoft Graph API, supporting advanced queries for users, sign-in logs, MFA status, and privileged users.

Repository stats unavailable
Security & Secrets
Keycloak MCP Server
keycloak-mcp-server•sshaaf

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

Repository stats unavailable
Security & Secrets

An MCP server for LLM-driven penetration testing that wraps Kali tools and adds scope enforcement, engagement tracking, and structured output.

Repository stats unavailable
Security & Secrets