home / mcp / keycloak mcp server
Provides an MCP interface to manage Keycloak realms, users, clients, and groups via standardized actions.
Configuration
View docs{
"mcpServers": {
"haithamoumerzoug-keycloak-mcp": {
"command": "npx",
"args": [
"-y",
"keycloak-mcp"
],
"env": {
"KEYCLOAK_URL": "http://localhost:8080",
"KEYCLOAK_ADMIN": "admin",
"KEYCLOAK_ADMIN_PASSWORD": "admin"
}
}
}
}You can manage Keycloak users and realms through a standardized MCP interface built for Keycloak. This server lets you perform common identity-management tasks with a consistent set of endpoints, making it easier to integrate Keycloak into your MCP-driven workflows.
You interact with the Keycloak MCP Server through an MCP client. With the server running, you can create, delete, and list users, realms, clients, groups, and their roles. You can also assign client roles to users and add users to groups. Use the available tools to perform these actions in real time against your Keycloak instance.
Prerequisites: you need Node.js (latest LTS is recommended) and npm installed. You also need a running Keycloak instance to connect to.
# Install and run using npx (no local install required)
npx -y keycloak-mcp --keycloak-url <Keycloak Instance URL> --keycloak-admin <Admin Username> --keycloak-admin-password <Admin Password># Or install globally and run
npm install -g keycloak-mcp@latest
keycloak-mcp --keycloak-url <Keycloak Instance URL> --keycloak-admin <Admin Username> --keycloak-admin-password <Admin Password>Configure the server by providing the Keycloak connection details as environment variables or CLI arguments. The following environment variables are recognized by the server when running locally or via a config file.
{
"mcpServers": {
"keycloak": {
"command": "npx",
"args": ["-y", "keycloak-mcp"],
"env": {
"KEYCLOAK_URL": "http://localhost:8080",
"KEYCLOAK_ADMIN": "admin",
"KEYCLOAK_ADMIN_PASSWORD": "admin"
}
}
}
}Keep admin credentials secure. Use the recommended Keycloak admin account with the minimum required permissions for MCP operations. Consider using a dedicated Keycloak service account with restricted access for MCP tasks and rotate credentials regularly.
If you encounter connection issues, verify that the Keycloak URL is reachable from the MCP server host and that the admin credentials provided have sufficient permissions. Check that the Keycloak Admin Client library is present and that the MCP server has network access to Keycloak.
The server exposes a set of tools to manage Keycloak resources: 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 accepts the required inputs described in its usage and operates against the connected Keycloak instance.
- create-user: Creates a new user in a specified realm. Inputs: realm, username, email, firstName, lastName. - delete-user: Deletes a user from a specified realm. Inputs: realm, userId. - list-realms: Lists all available realms. - list-users: Lists all users in a specified realm. Inputs: realm. - list-clients: Lists all clients in a specified realm. Inputs: realm. - list-groups: Lists all groups in a specified realm. Inputs: realm. - list-client-roles: Lists all roles for a specific client in a realm. Inputs: realm, clientUniqueId. - assign-client-role-to-user: Assigns a client role to a user. Inputs: realm, userId, clientUniqueId, roleName. - add-user-to-group: Adds a user to a group. Inputs: realm, userId, groupId.
{
"mcpServers": {
"keycloak": {
"command": "npx",
"args": ["-y", "keycloak-mcp"],
"env": {
"KEYCLOAK_URL": "http://localhost:8080",
"KEYCLOAK_ADMIN": "admin",
"KEYCLOAK_ADMIN_PASSWORD": "admin"
}
}
}
}Creates a new user in a specified realm with provided username, email, first name, and last name.
Deletes a user from a specified realm by user ID.
Lists all available realms in the Keycloak instance.
Lists all users within a specified realm.
Lists all clients within a specified realm.
Lists all groups within a specified realm.
Lists all roles for a specific client in a realm.
Assigns a client role to a specific user in a realm.
Adds a user to a specific group within a realm.