home / mcp / keycloak mcp server
The Keycloak MCP Server designed for agentic applications to manage and search data in Keycloak efficiently
Configuration
View docs{
"mcpServers": {
"idoyudha-mcp-keycloak": {
"url": "http://127.0.0.1:8000/mcp/",
"headers": {
"PASSWORD": "admin-password",
"USERNAME": "admin-username",
"CLIENT_ID": "optional-client-id",
"REALM_NAME": "your-realm",
"SERVER_URL": "https://your-keycloak-server.com",
"CLIENT_SECRET": "optional-client-secret"
}
}
}
}You can manage Keycloak identity and access management through a dedicated MCP server that accepts natural language commands. This server acts as a bridge between your AI workflows and Keycloak’s REST API, enabling you to create users, configure clients, manage realms and roles, and control authentication flows with ease.
Connect your MCP client to the Keycloak MCP Server and start sending commands that cover user provisioning, client configuration, group and realm administration, and role-based access management. When you issue actions, you will be able to perform tasks such as creating users, assigning roles, configuring clients, and adjusting realm settings through natural language requests that map to the server’s available tools.
Prerequisites you need before installing:
- Python 3.8 or higher
- Access to a Keycloak server with admin credentials
- Optional: uvx or uv for local MCP runners, and npm for Smithery installation if you choose that path.# Quick start: install the Python MCP package
pip install mcp-keycloak
# Run the server in standard stdio mode (default)
python -m src.main
# Run the server in HTTP mode on the default port
TRANSPORT=http python -m src.main
# Run HTTP mode on a custom port
TRANSPORT=http PORT=8080 python -m src.main
# Convenience script (if you have the script available)
./scripts/run_server.sh
```}]
}, {Configure connection to your Keycloak instance using environment variables. Provide the server URL, admin credentials, and the target realm. You can optionally specify OAuth2 client details if you plan to use client-side integrations.
# 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
```}]} ,{The HTTP transport follows the MCP specification for secure, streamable communication. When deploying, consider these practices to protect your environment: use HTTPS with valid certificates and deploy behind a reverse proxy, apply strict firewall rules, and enable authentication at the network boundary if needed.
For local development, connections are designed to be simple and do not require user-level authentication by default. For production, add appropriate authentication and network protections.
If you encounter connection issues, verify that your Keycloak server is reachable at SERVER_URL and that the REALM_NAME exists. Check that the MCP server is started with the correct mode (stdio for local CLI tools or http for network access) and ensure you are using the expected port and host. If you use the HTTP transport, confirm that you are sending requests to the /mcp/ endpoint and that the Accept header includes both application/json and text/event-stream when streaming responses.
- Onboard a new user and assign realm roles to automate access provisioning for a new team.
Configure a new OAuth2 client for a service and grant it appropriate client roles.
List users with options for pagination and filtering.
Create a new user with optional attributes and credentials.
Update an existing user's attributes or credentials.
Remove a user from the directory.
Reset a user’s password.
Retrieve active sessions for a user.
Log out a user from all sessions.
Return user statistics and counts.
List OAuth2/OIDC clients in a realm.
Retrieve details for a specific client.
Create a new OAuth2/OIDC client.
Fetch the client secret for a given client.
Regenerate the client secret.
Retrieve the service account associated with a client.
Update client configuration.
Delete a client.
List roles defined at the realm level.
Create a new realm-wide role.
List roles defined for a specific client.
Create a new role for a client.
Assign a realm role to a user.
Remove a realm role from a user.
Get realm roles assigned to a user.
Assign a client role to a user.
List groups in a realm.
Create a new group.
Update a group's configuration.
Get members of a group.
Add a user to a group.
List groups a user belongs to.
Remove a user from a group.
List realms accessible to the authenticated user.
Retrieve realm information.
Update realm settings.
Get realm events configuration.
Update realm events configuration.
Add a default group for a realm.
Remove a default group from a realm.
List authentication flows.
Get details of an authentication flow.
Create a new authentication flow.
Update an authentication flow.
Delete an authentication flow.
Copy an authentication flow.
Get executions within a flow.
Update executions for a flow.
Create an authentication execution.
Delete an authentication execution.
Get configuration for an authenticator.
Create a new authenticator configuration.
List required actions.
Update a required action configuration.