Repository navigation
Operations
This directory contains operational documentation for McpServer authentication and configuration.
Describes the three OIDC clients configured in Keycloak for McpServer authentication:
- mcp-server-api — Confidential client for JWT validation on the API server
- mcp-director — Public client for CLI authentication via Device Authorization Flow
- mcp-web — Confidential client for browser-based authentication via Authorization Code Flow
Learn about the OAuth 2.0 flows used by each client, their configuration, and how they integrate with the McpServer codebase.
Instructions for running the automated Keycloak setup scripts that:
- Create the
mcpserverrealm - Configure all three OIDC clients
- Add protocol mappers for audience and realm roles
- Create realm roles (
admin,agent-manager,viewer) - Display client secrets for configuration
Includes both PowerShell (Windows) and bash (Linux/macOS) script documentation.
Instructions for using helper scripts to sync client secrets from Keycloak into application configuration files:
- Update-McpWebClientSecret.ps1 (PowerShell)
- update-mcp-web-client-secret.sh (bash)
These scripts automate updating the mcp-web client secret in appsettings.Development.json to ensure the Web UI stays in sync with Keycloak.
-
Start Keycloak:
docker compose -f infra/docker-compose.keycloak.yml up -d
-
Run the setup script:
# PowerShell .\scripts\Setup-McpKeycloak.ps1
# Bash ./scripts/setup-mcp-keycloak.sh -
Sync the Web UI client secret:
# PowerShell .\scripts\Update-McpWebClientSecret.ps1
# Bash ./scripts/update-mcp-web-client-secret.sh -
Update the MCP server configuration with the
mcp-server-apiclient secret from the setup output -
Create users and assign roles in the Keycloak admin console (
http://localhost:7080/admin)
┌──────────────────────────────────────────────────────────────────┐
│ Keycloak (IdP) │
│ Realm: mcpserver │
│ ┌────────────────┐ ┌────────────────┐ ┌────────────────┐ │
│ │ mcp-server-api │ │ mcp-director │ │ mcp-web │ │
│ │ (confidential) │ │ (public) │ │ (confidential) │ │
│ │ JWT validation │ │ Device Flow │ │ Auth Code │ │
│ └────────────────┘ └────────────────┘ └────────────────┘ │
└──────────────────────────────────────────────────────────────────┘
│ │ │
│ │ │
▼ ▼ ▼
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ MCP Server API │ │ Director CLI │ │ Web UI │
│ Validates JWT │ │ Device Flow │ │ Auth Code Flow │
│ tokens │ │ authentication │ │ + session │
└──────────────────┘ └──────────────────┘ └──────────────────┘
- Director CLI: User authenticates via Device Flow → receives JWT → stores locally → includes in API requests
- Web UI: User authenticates via Auth Code Flow → receives JWT → stored in HTTP-only cookie → included in API requests
-
MCP Server: Validates JWT tokens from both clients using
mcp-server-apicredentials
All tokens include:
-
Audience (
aud):mcp-server-api -
Realm Roles (
realm_roles): User's assigned roles -
Username (
preferred_username): User's username
- Keycloak Documentation: https://www.keycloak.org/documentation
- OAuth 2.0 Device Flow: https://oauth.net/2/device-flow/
- OAuth 2.0 Authorization Code Flow: https://oauth.net/2/grant-types/authorization-code/
- JWT Validation: https://jwt.io/
For issues or questions:
- Check the Troubleshooting section in each document
- Review the Keycloak logs:
docker compose -f infra/docker-compose.keycloak.yml logs -f - Inspect the MCP server logs for authentication errors
Generated from MCP requirements wiki export.