This guide provides detailed technical information for developers working on the Keycloak MCP Server project.
git clone https://github.com/yourusername/keycloak-mcp-server.git
cd keycloak-mcp-server
./mvnw clean package
Keycloak MCP Server uses GitHub Actions to automatically build and test the project on every commit.
Official releases are created when changes are pushed to the main branch. You can find the latest release with all artifacts on the Releases page.
The Keycloak MCP Server is built using Quarkus, which provides fast startup times and a low memory footprint.
To run the application in development mode:
./mvnw quarkus:dev
This enables hot deployment with background compilation, allowing you to make changes to the code and automatically reload the application.
The application can be configured using the application.properties file located in src/main/resources/. Key configuration properties include:
quarkus.keycloak.url: The URL of the Keycloak serverAn example docker-compose file is provided for local development.
Keycloak MCP Server includes a comprehensive test suite to ensure code quality and prevent regressions.
To run the tests locally:
./mvnw test
This will execute all tests and generate a report in build/reports/tests/test/index.html.
The GitHub Actions workflow automatically runs all tests for:
This ensures that all code changes pass tests before being merged, maintaining code quality and preventing regressions.
Follows a layered architecture with tool classes that expose functionality through the MCP protocol and service classes that handle the actual operations with Keycloak. Each tool class follows a similar pattern:
The project includes the following main components:
UserService: Manages user-related operationsRealmService: Manages realm-related operationsClientService: Manages client-related operationsRoleService: Manages role-related operationsGroupService: Manages group-related operationsIdentityProviderService: Manages identity provider-related operationsAuthenticationService: Manages authentication flow-related operations
UserTool: Exposes user-related operationsRealmTool: Exposes realm-related operationsClientTool: Exposes client-related operationsRoleTool: Exposes role-related operationsGroupTool: Exposes group-related operationsIdentityProviderTool: Exposes identity provider-related operationsAuthenticationTool: Exposes authentication flow-related operationsBelow is a class diagram showing the structure of the tools package and its relationships with the service layer:
graph TD
subgraph "Goose CLI"
GooseCLI[Goose CLI]
end
subgraph "Tools Layer"
UserTool["UserTool"]
RealmTool["RealmTool"]
ClientTool["ClientTool"]
RoleTool["RoleTool"]
GroupTool["GroupTool"]
end
subgraph "Service Layer"
UserService["UserService"]
RealmService["RealmService"]
ClientService["ClientService"]
RoleService["RoleService"]
GroupService["GroupService"]
end
subgraph "External Services"
Keycloak[("Keycloak")]
end
%% Define Relationships
GooseCLI --> UserTool
GooseCLI --> RealmTool
GooseCLI --> ClientTool
GooseCLI --> RoleTool
GooseCLI --> GroupTool
UserTool --> UserService
RealmTool --> RealmService
ClientTool --> ClientService
RoleTool --> RoleService
GroupTool --> GroupService
UserService --> Keycloak
RealmService --> Keycloak
ClientService --> Keycloak
RoleService --> Keycloak
GroupService --> Keycloak
%% Styling
style GooseCLI fill:#d4edda,stroke:#c3e6cb
style Keycloak fill:#f8d7da,stroke:#f5c6cb
The project follows a layered architecture with tool classes that expose functionality through the MCP protocol and service classes that handle the actual operations with Keycloak.
The tools package contains classes that expose Keycloak functionality through the MCP protocol:
UserTool: Manages Keycloak users, including creation, deletion, updating user information, and managing user roles and groups.
RealmTool: Manages Keycloak realms, including creation, deletion, updating realm settings, and managing realm events configuration.
ClientTool: Manages Keycloak clients, including creation, deletion, updating client settings, managing client secrets, and client roles.
RoleTool: Manages Keycloak roles, including creation, deletion, updating role settings, and managing role composites.
GroupTool: Manages Keycloak groups, including creation, deletion, updating group settings, managing group members, and group roles.
Each tool class follows a similar pattern:
You can start a local Keycloak instance using Docker Compose:
docker-compose -f deploy/docker-compose.yml up
To build the application using Maven:
./mvnw clean package
To build an uber jar:
./mvnw clean package -Dquarkus.package.type=uber-jar