### Start Keycloak MCP Server via Command Line Source: https://context7.com/haithamoumerzoug/keycloak-mcp/llms.txt Provides instructions on how to start the Keycloak MCP server using npx for quick usage or after a global npm installation. It requires Keycloak connection details. ```bash # Using npx (recommended for quick usage) npx -y keycloak-mcp \ --keycloak-url http://localhost:8080 \ --keycloak-admin admin \ --keycloak-admin-password admin # Global installation and usage npm install -g keycloak-mcp@latest keycloak-mcp \ --keycloak-url http://localhost:8080 \ --keycloak-admin admin \ --keycloak-admin-password admin ``` -------------------------------- ### Keycloak MCP Server Configuration Source: https://context7.com/haithamoumerzoug/keycloak-mcp/llms.txt Configuration for the Keycloak MCP Server within an MCP client. This includes the command to run the server, arguments, and environment variables for connecting to the Keycloak instance. ```json { "mcpServers": { "keycloak": { "command": "npx", "args": ["-y", "keycloak-mcp"], "env": { "KEYCLOAK_URL": "http://localhost:8080", "KEYCLOAK_ADMIN": "admin", "KEYCLOAK_ADMIN_PASSWORD": "admin" } } } } ``` -------------------------------- ### Create Keycloak User Source: https://context7.com/haithamoumerzoug/keycloak-mcp/llms.txt Tool call and response for creating a new user in a specified Keycloak realm. The user is created in an enabled state with provided profile information. ```typescript // MCP Tool Call { "name": "create-user", "arguments": { "realm": "my-app", "username": "newuser", "email": "newuser@example.com", "firstName": "New", "lastName": "User" } } // Response { "content": [ { "type": "text", "text": "User created successfully. User ID: a1b2c3d4-e5f6-7890-abcd-ef1234567890" } ] } ``` -------------------------------- ### List Keycloak Clients Source: https://context7.com/haithamoumerzoug/keycloak-mcp/llms.txt Tool call and response for listing all OAuth/OIDC clients configured in a specified Keycloak realm. The output includes the client ID and unique identifier for each client. ```typescript // MCP Tool Call { "name": "list-clients", "arguments": { "realm": "my-app" } } // Response { "content": [ { "type": "text", "text": "Clients in realm my-app:\n- account (account-client-uuid)\n- admin-cli (admin-cli-uuid)\n- my-frontend-app (frontend-uuid)" } ] } ``` -------------------------------- ### List Keycloak Realms Source: https://context7.com/haithamoumerzoug/keycloak-mcp/llms.txt Tool call and response for listing all available Keycloak realms. This operation requires no input parameters and returns a list of realms accessible by the admin client. ```typescript // MCP Tool Call { "name": "list-realms", "arguments": {} } // Response { "content": [ { "type": "text", "text": "Available realms:\n- master (master-realm-id)\n- my-app (my-app-realm-id)" } ] } ``` -------------------------------- ### List Keycloak Client Roles Source: https://context7.com/haithamoumerzoug/keycloak-mcp/llms.txt Tool call and response for listing all roles defined for a specific client within a realm. This requires the client's unique ID. ```typescript // MCP Tool Call { "name": "list-client-roles", "arguments": { "realm": "my-app", "clientUniqueId": "frontend-uuid" } } // Response { "content": [ { "type": "text", "text": "Roles in client frontend-uuid in realm my-app:\n- admin\n- editor\n- viewer" } ] } ``` -------------------------------- ### List Keycloak Users Source: https://context7.com/haithamoumerzoug/keycloak-mcp/llms.txt Tool call and response for listing all users within a specified Keycloak realm. The output includes the username and user ID for each user. ```typescript // MCP Tool Call { "name": "list-users", "arguments": { "realm": "my-app" } } // Response { "content": [ { "type": "text", "text": "Users in realm my-app:\n- john.doe (user-uuid-1234)\n- jane.smith (user-uuid-5678)" } ] } ``` -------------------------------- ### List Keycloak Groups Source: https://context7.com/haithamoumerzoug/keycloak-mcp/llms.txt Tool call and response for listing all groups defined within a specified Keycloak realm. The output includes the group name and ID for each group. ```typescript // MCP Tool Call { "name": "list-groups", "arguments": { "realm": "my-app" } } // Response { "content": [ { "type": "text", "text": "Groups in realm my-app:\n- administrators (group-uuid-admin)\n- developers (group-uuid-dev)\n- viewers (group-uuid-view)" } ] } ``` -------------------------------- ### Assign Client Role to User Source: https://context7.com/haithamoumerzoug/keycloak-mcp/llms.txt Tool call and response for assigning a client-specific role to a user. This enables fine-grained access control by granting users specific permissions within client applications. ```typescript // MCP Tool Call { "name": "assign-client-role-to-user", "arguments": { "realm": "my-app", "userId": "user-uuid-1234", "clientUniqueId": "frontend-uuid", "roleName": "editor" } } // Response { "content": [ { "type": "text", "text": "Assigned role 'editor' to user user-uuid-1234 in client frontend-uuid" } ] } ``` -------------------------------- ### Add User to Group in Keycloak Source: https://context7.com/haithamoumerzoug/keycloak-mcp/llms.txt Demonstrates how to add a user to a specified group within a Keycloak realm using the MCP tool. This operation is crucial for managing access control and role inheritance. ```typescript // MCP Tool Call { "name": "add-user-to-group", "arguments": { "realm": "my-app", "userId": "user-uuid-1234", "groupId": "group-uuid-dev" } } // Response { "content": [ { "type": "text", "text": "User user-uuid-1234 added to group group-uuid-dev in realm my-app" } ] } ``` -------------------------------- ### Add User to Group Source: https://context7.com/haithamoumerzoug/keycloak-mcp/llms.txt Adds a specified user to a specified group within a Keycloak realm. This operation is crucial for managing access control through group memberships and inherited role mappings. ```APIDOC ## POST /add-user-to-group ### Description Adds a user to a group, enabling group-based access control and inherited role mappings. ### Method POST ### Endpoint /add-user-to-group ### Parameters #### Request Body - **realm** (string) - Required - The name of the Keycloak realm. - **userId** (string) - Required - The unique identifier (UUID) of the user to add. - **groupId** (string) - Required - The unique identifier (UUID) of the group to add the user to. ### Request Example ```json { "name": "add-user-to-group", "arguments": { "realm": "my-app", "userId": "user-uuid-1234", "groupId": "group-uuid-dev" } } ``` ### Response #### Success Response (200) - **content** (array) - Contains the result of the operation, typically a text message confirming the user's addition. - **type** (string) - The type of content, usually 'text'. - **text** (string) - A message indicating the success of the operation. #### Response Example ```json { "content": [ { "type": "text", "text": "User user-uuid-1234 added to group group-uuid-dev in realm my-app" } ] } ``` ``` -------------------------------- ### Delete Keycloak User Source: https://context7.com/haithamoumerzoug/keycloak-mcp/llms.txt Tool call and response for deleting an existing user from a specified Keycloak realm using their user ID. ```typescript // MCP Tool Call { "name": "delete-user", "arguments": { "realm": "my-app", "userId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890" } } // Response { "content": [ { "type": "text", "text": "User a1b2c3d4-e5f6-7890-abcd-ef1234567890 deleted successfully from realm my-app" } ] } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.