diff --git a/samples/ai/README.md b/samples/ai/README.md index f846595..2717bff 100644 --- a/samples/ai/README.md +++ b/samples/ai/README.md @@ -1,10 +1,10 @@ # AI relay cloud access sample -Expose an existing in-cluster AI MCP Frontend or A2A endpoint through +Expose an existing in-cluster AI MCP Gateway or A2A endpoint through authenticated Azure API Management (APIM) and Azure Relay: ```text -Client with Entra token -> APIM -> Azure Relay Hybrid Connection -> relay pod -> MCP Frontend / A2A service +Client with Entra token -> APIM -> Azure Relay Hybrid Connection -> relay pod -> MCP Gateway / A2A service ``` `deploy.sh` deploys the Azure resources from `bicep/ai-relay.bicep` and installs @@ -37,7 +37,7 @@ confirming that no other API references them. Access and organizational registration metadata requirements, still apply. - A configured kubectl context for the target cluster. The script does not create a cluster or switch contexts. -- For MCP: an existing MCP Frontend Service, its TLS trust bundle and +- For MCP: an existing MCP Gateway Service, its TLS trust bundle and service-account-token authentication configured for the intended audience. The relay chart expects the AIO CA trust bundle in the same namespace. - Published, accessible agent/relay release artifacts. The relay chart must @@ -81,8 +81,8 @@ bash samples/ai/deploy.sh \ --aio-extension-name '' \ --entra-app-name '' \ --endpoint-protocol mcp \ - --mcp-frontend-service-name aio-mcp-frontend \ - --mcp-frontend-audience aio-mcp-frontend + --mcp-gateway-service-name aio-mcp-gateway \ + --mcp-gateway-audience aio-mcp-gateway ``` The script downloads the chart before creating Azure resources and uses the @@ -91,12 +91,20 @@ publisher signature. If signature enforcement is required, independently verify the published digest with the approved publisher trust policy before deployment. No MCP role is assigned by default. Add `--mcp-role Reader` only if the existing -frontend policy authorizes that role for the relay ServiceAccount. The annotation +gateway policy authorizes that role for the relay ServiceAccount. The annotation is a JSON array encoded as a string, `aio-mcp-auth/roles: '["Reader"]'`. All callers through the relay share its backend MCP permissions. -The frontend Service name and its inbound SAT audience are independent. Do not -use its backend token audience as `--mcp-frontend-audience`. +The gateway Service name, port, and inbound SAT audience are independent. If the +`MCPGateway` resource sets a different Service port or audiences, pass +`--mcp-gateway-port` and one of its audiences as `--mcp-gateway-audience`. Do +not use the gateway's backend token audience as `--mcp-gateway-audience`. + +MCP Gateway was previously named MCP Frontend. The `--mcp-frontend-service-name` +and `--mcp-frontend-audience` options remain as deprecated aliases for the +`--mcp-gateway-*` options. For an earlier Azure IoT Operations MCP preview that +still serves clients through MCP Frontend, pass `aio-mcp-frontend` to both +`--mcp-gateway-service-name` and `--mcp-gateway-audience`. The script checks response types when looking up Entra apps and reading Azure deployment outputs. Hybrid Connection names, Relay URLs and APIM gateway URLs @@ -130,7 +138,7 @@ An administrator must assign approved callers through **Entra Enterprise applications > your app > Users and groups**, or Microsoft Graph for application assignments. No caller is assigned automatically. -The Entra `AIOMcpAdmin` role, the MCP Frontend `Reader` role, and Azure's Relay +The Entra `AIOMcpAdmin` role, the MCP Gateway `Reader` role, and Azure's Relay Listener/Sender roles are different permissions. ### Use a manually configured app diff --git a/samples/ai/bicep/ai-relay.bicep b/samples/ai/bicep/ai-relay.bicep index 2912261..159c38e 100644 --- a/samples/ai/bicep/ai-relay.bicep +++ b/samples/ai/bicep/ai-relay.bicep @@ -48,7 +48,7 @@ param entraTenantId string @description('Delegated scope advertised by the MCP protected-resource metadata endpoint.') param entraAppScope string = 'mcp.access' -@description('App role required in the caller token. Separate from MCP Frontend roles.') +@description('App role required in the caller token. Separate from MCP Gateway roles.') param entraAppRole string = 'AIOMcpAdmin' var usesSas = authMode == 'SharedAccessSignature' diff --git a/samples/ai/deploy.sh b/samples/ai/deploy.sh index 9b3bb84..bf556d3 100755 --- a/samples/ai/deploy.sh +++ b/samples/ai/deploy.sh @@ -36,10 +36,13 @@ Authentication: Endpoint: --endpoint-protocol Default: mcp. "both" installs two Helm releases. --endpoint-url Required for a2a/both; A2A target URL. - --mcp-frontend-service-name Default: aio-mcp-frontend. - --mcp-frontend-audience Default: aio-mcp-frontend (inbound SAT audience). - --mcp-role Optional single MCP Frontend role, e.g. Reader. + --mcp-gateway-service-name Default: aio-mcp-gateway. + --mcp-gateway-port Default: 443 (MCP Gateway Service port). + --mcp-gateway-audience Default: aio-mcp-gateway (inbound SAT audience). + --mcp-role Optional single MCP Gateway role, e.g. Reader. No role by default. Applied only to the MCP relay. + --mcp-frontend-service-name, --mcp-frontend-audience + Deprecated aliases for the --mcp-gateway-* options. Optional: --chart-version Exact published chart version. Default: 0.1.3. @@ -81,8 +84,9 @@ ENTRA_APP_ROLE="AIOMcpAdmin" ENTRA_APP_SCOPE="mcp.access" ENDPOINT_PROTOCOL="mcp" ENDPOINT_URL="" -MCP_FRONTEND_SERVICE_NAME="aio-mcp-frontend" -MCP_FRONTEND_AUDIENCE="aio-mcp-frontend" +MCP_GATEWAY_SERVICE_NAME="aio-mcp-gateway" +MCP_GATEWAY_PORT=443 +MCP_GATEWAY_AUDIENCE="aio-mcp-gateway" MCP_ROLE="" IMAGE_TAG="0.1.3" VALUES_FILE="" @@ -96,11 +100,12 @@ while [[ $# -gt 0 ]]; do case "$1" in -h|--help) usage; exit 0 ;; --aio-mcp-release-name) - echo "Error: --aio-mcp-release-name is no longer supported; use --mcp-frontend-service-name and --mcp-frontend-audience." >&2 + echo "Error: --aio-mcp-release-name is no longer supported; use --mcp-gateway-service-name and --mcp-gateway-audience." >&2 exit 1 ;; --resource-group|--relay-namespace-name|--apim-name|--apim-publisher-email|--apim-publisher-name|\ --chart-version|--chart-reference|--auth-mode|--cluster-name|--aio-extension-name|\ --entra-app-name|--entra-app-id|--entra-tenant-id|--entra-app-scope|--entra-azure-config-dir|--endpoint-protocol|--endpoint-url|\ + --mcp-gateway-service-name|--mcp-gateway-port|--mcp-gateway-audience|\ --mcp-frontend-service-name|--mcp-frontend-audience|--mcp-role|--image-tag|--values|\ --hybrid-connection-name|--apim-sku|--apim-capacity|--k8s-namespace|--helm-release-name) if [[ $# -lt 2 || ! "${2:-}" =~ [^[:space:]] || "${2:-}" == --* ]]; then @@ -127,8 +132,15 @@ while [[ $# -gt 0 ]]; do --entra-azure-config-dir) ENTRA_AZURE_CONFIG_DIR="$2" ;; --endpoint-protocol) ENDPOINT_PROTOCOL="$2" ;; --endpoint-url) ENDPOINT_URL="$2" ;; - --mcp-frontend-service-name) MCP_FRONTEND_SERVICE_NAME="$2" ;; - --mcp-frontend-audience) MCP_FRONTEND_AUDIENCE="$2" ;; + --mcp-gateway-service-name) MCP_GATEWAY_SERVICE_NAME="$2" ;; + --mcp-gateway-port) MCP_GATEWAY_PORT="$2" ;; + --mcp-gateway-audience) MCP_GATEWAY_AUDIENCE="$2" ;; + --mcp-frontend-service-name) + echo "Warning: --mcp-frontend-service-name is deprecated; use --mcp-gateway-service-name." >&2 + MCP_GATEWAY_SERVICE_NAME="$2" ;; + --mcp-frontend-audience) + echo "Warning: --mcp-frontend-audience is deprecated; use --mcp-gateway-audience." >&2 + MCP_GATEWAY_AUDIENCE="$2" ;; --mcp-role) MCP_ROLE="$2" ;; --image-tag) IMAGE_TAG="$2" ;; --values) VALUES_FILE="$2" ;; @@ -182,8 +194,12 @@ if [[ "$ENDPOINT_PROTOCOL" == a2a && -n "$MCP_ROLE" ]]; then echo "Error: --mcp-role requires --endpoint-protocol mcp or both." >&2 exit 1 fi -if [[ "$ENDPOINT_PROTOCOL" != a2a && ( -z "$MCP_FRONTEND_SERVICE_NAME" || -z "$MCP_FRONTEND_AUDIENCE" ) ]]; then - echo "Error: MCP Frontend Service name and audience must not be empty." >&2 +if [[ "$ENDPOINT_PROTOCOL" != a2a && ( -z "$MCP_GATEWAY_SERVICE_NAME" || -z "$MCP_GATEWAY_AUDIENCE" ) ]]; then + echo "Error: MCP Gateway Service name and audience must not be empty." >&2 + exit 1 +fi +if [[ ! "$MCP_GATEWAY_PORT" =~ ^[1-9][0-9]{0,4}$ ]] || (( MCP_GATEWAY_PORT > 65535 )); then + echo "Error: --mcp-gateway-port must be a port number from 1 to 65535." >&2 exit 1 fi if [[ "$CHART_REFERENCE" != oci://* || ! "$APIM_CAPACITY" =~ ^[1-9][0-9]*$ ]]; then @@ -376,10 +392,10 @@ install_relay_release() { args+=("--set-string" "relay.auth.managedIdentity.extension=$AIO_EXTENSION_NAME") fi if [[ "$protocol" == mcp ]]; then - args+=("--set-string" "endpoint.url=https://${MCP_FRONTEND_SERVICE_NAME}.${K8S_NAMESPACE}:443/mcp" - "--set-string" "endpoint.serviceAccountTokens[0].name=aio-mcp-frontend" - "--set-string" "endpoint.serviceAccountTokens[0].audience=$MCP_FRONTEND_AUDIENCE" - "--set-string" "endpoint.auth.file=/var/run/secrets/tokens/aio-mcp-frontend" + args+=("--set-string" "endpoint.url=https://${MCP_GATEWAY_SERVICE_NAME}.${K8S_NAMESPACE}:${MCP_GATEWAY_PORT}/mcp" + "--set-string" "endpoint.serviceAccountTokens[0].name=aio-mcp-gateway" + "--set-string" "endpoint.serviceAccountTokens[0].audience=$MCP_GATEWAY_AUDIENCE" + "--set-string" "endpoint.auth.file=/var/run/secrets/tokens/aio-mcp-gateway" "--set-string" "endpoint.auth.kind=bearer-token") if [[ -n "$MCP_ROLE" ]]; then annotations="$(jq -cn --arg role "$MCP_ROLE" '{"aio-mcp-auth/roles":([$role]|tojson)}')"