Skip to content

Commit 42bafcf

Browse files
Add missing API scope and Application ID URI steps for MCP auth
Customer feedback reported HTTP 401 errors when following the standalone container app authentication steps. The article was missing two critical steps after creating the service principal: 1. Setting the Application ID URI (api://{APP_ID}) 2. Exposing an OAuth2 permission scope (access_as_user) Without these, clients cannot acquire valid access tokens because the v2.0 endpoint has no scope to issue tokens for. Also updated the token acquisition tip to use api:// as the resource (required for v2.0 endpoints), and added a row to the common mismatches table for this scenario. Co-authored-by: Copilot <[email protected]>
1 parent 5170f9a commit 42bafcf

1 file changed

Lines changed: 30 additions & 2 deletions

File tree

articles/container-apps/mcp-authentication.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Learn how to authenticate and authorize MCP servers on Azure Contai
55
ms.topic: how-to
66
ms.service: azure-container-apps
77
ms.collection: ce-skilling-ai-copilot
8-
ms.date: 02/19/2026
8+
ms.date: 04/09/2026
99
author: craigshoemaker
1010
ms.author: cshoe
1111
ms.reviewer: cshoe
@@ -57,6 +57,33 @@ The following steps register a Microsoft Entra ID application and enable built-i
5757
az ad sp create --id $APP_ID
5858
```
5959
60+
1. Set the Application ID URI and expose an API scope. These settings are required so that clients can request access tokens for your MCP server.
61+
62+
```azurecli
63+
az ad app update --id $APP_ID --identifier-uris "api://$APP_ID"
64+
65+
OBJECT_ID=$(az ad app show --id $APP_ID --query id -o tsv)
66+
SCOPE_ID=$(uuidgen)
67+
68+
az rest --method PATCH \
69+
--uri "https://graph.microsoft.com/v1.0/applications/$OBJECT_ID" \
70+
--headers "Content-Type=application/json" \
71+
--body "{
72+
\"api\": {
73+
\"oauth2PermissionScopes\": [{
74+
\"id\": \"$SCOPE_ID\",
75+
\"adminConsentDescription\": \"Access the MCP server\",
76+
\"adminConsentDisplayName\": \"Access MCP Server\",
77+
\"isEnabled\": true,
78+
\"type\": \"User\",
79+
\"userConsentDescription\": \"Access the MCP server\",
80+
\"userConsentDisplayName\": \"Access MCP Server\",
81+
\"value\": \"access_as_user\"
82+
}]
83+
}
84+
}"
85+
```
86+
6087
1. Add a client secret:
6188
6289
```azurecli
@@ -113,7 +140,7 @@ When your MCP server requires a bearer token, configure token retrieval in your
113140
```
114141

115142
> [!TIP]
116-
> For development, get a token by using `az account get-access-token --resource $APP_ID --query accessToken -o tsv` and paste it when prompted. For automated workflows, integrate with your organization's token management system.
143+
> For development, get a token by using `az account get-access-token --resource api://$APP_ID --query accessToken -o tsv` and paste it when prompted. For automated workflows, integrate with your organization's token management system.
117144
118145
### Configure CORS
119146

@@ -206,6 +233,7 @@ A common mistake is using the API key header (`x-ms-apikey`) with a standalone c
206233
|----------|--------|
207234
| `x-ms-apikey` header sent to standalone app | Header is ignored; request hits built-in authentication and returns `401` if auth is enabled |
208235
| `Authorization: Bearer` sent to sessions MCP | Key validation fails and returns `401` |
236+
| Bearer token requested without an exposed API scope | Token acquisition fails or the token has no valid audience, resulting in `401` |
209237

210238
Make sure your MCP client configuration matches the hosting model you deployed.
211239

0 commit comments

Comments
 (0)