Skip to content

Commit 7893e2a

Browse files
Merge pull request #307750 from mattchenderson/ea-mcp
App Service Auth for MCP
2 parents 7198695 + 0fbca75 commit 7893e2a

6 files changed

Lines changed: 89 additions & 3 deletions

File tree

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
title: Configure MCP server authorization
3+
description: Learn how to configure Model Context Protocol (MCP) server authorization in Azure App Service and Azure Functions
4+
ms.topic: how-to
5+
ms.date: 11/04/2025
6+
author: mattchenderson
7+
ms.author: mahender
8+
ms.service: azure-app-service
9+
---
10+
11+
# Configure built-in MCP server authorization (Preview)
12+
13+
[App Service Authentication](./overview-authentication-authorization.md) allows you to control access to your Model Context Protocol (MCP) server by requiring MCP clients to authenticate with an identity provider. You can make your app comply with the [MCP server authorization specification][spec] by following the instructions in this article.
14+
15+
> [!IMPORTANT]
16+
> MCP server authorization defines access to the server, and it doesn't provide granular control to individual MCP tools or other constructs.
17+
18+
## Configure an identity provider
19+
20+
[Configure App Service Authentication with an identity provider](./overview-authentication-authorization.md#identity-providers). The identity provider registration should be unique for the MCP server. Don't reuse an existing registration from another application component.
21+
22+
As you create the registration, make note of what scopes are defined in your registration or in the identity provider's documentation.
23+
24+
## Configure protected resource metadata (preview)
25+
26+
MCP server authorization requires that the server host [protected resource metadata (PRM)](./overview-authentication-authorization.md#protected-resource-metadata-preview). Support for PRM with App Service Authentication is currently in preview.
27+
28+
To configure PRM for your MCP server, set the `WEBSITE_AUTH_PRM_DEFAULT_WITH_SCOPES` application setting to a comma-separated list of scopes for your application. The scopes you need are either defined as part of your app registration or documented by your identity provider. For example, if you used the [Microsoft Entra ID provider](./configure-authentication-provider-aad.md) and let App Service create the registration for you, a default scope of `api://<client-id>/user_impersonation` was created. You would set `WEBSITE_AUTH_PRM_DEFAULT_WITH_SCOPES` to that value.
29+
30+
## MCP client considerations
31+
32+
In order to sign in users, the MCP client must be registered with the identity provider. Some providers support Dynamic Client Registration (DCR), but many don't, including Microsoft Entra ID. When DCR isn't available, the client needs to be preconfigured with a client ID. Consult the documentation for your client or client SDK to understand how to provide a client ID.
33+
34+
### Entra ID consent authoring
35+
36+
If you're using Microsoft Entra ID, you can specify known client applications and mark them as preauthorized for access. preauthorization is recommended when possible. Without preauthorization, users or an administrator need to [consent to the MCP server registration](/entra/identity-platform/permissions-consent-overview#consent) and any permissions it requires.
37+
38+
For user consent scenarios, consent authoring involves the MCP client using interactive login to display the consent prompt. Some MCP clients might not surface an interactive login. For example, if you are building an MCP tool to be used by GitHub Copilot in Visual Studio Code, the client attempts to use the context of the logged-in user and doesn't display a consent prompt. In these cases, preauthorizing the client application is required to avoid consent issues.
39+
40+
For dev/test purposes, you can author user consent for yourself by signing into the application directly in a browser. Navigating to `<your-app-url>/.auth/login/aad` initiates the sign-in flow and prompts you for consent if needed. Then you can attempt sign-in from another client.
41+
42+
## MCP server considerations
43+
44+
App Service Authentication validates tokens provided by MCP clients and applies any configured authorization policies before responding to the MCP initialization request. You might need to update your authorization rules for the MCP scenario. For example, if you used the Microsoft Entra ID provider and let App Service create the registration for you, a default policy only allows tokens obtained by the app itself. You therefore would add your MCP client to the allowed applications list in the auth configuration. For more information, see [Use a built-in authorization policy](./configure-authentication-provider-aad.md#use-a-built-in-authorization-policy).
45+
46+
MCP server frameworks frequently abstract away the transport, but in some cases they might expose the underlying HTTP context. When the HTTP context is available, you can [access user claims and other authentication information](./configure-authentication-user-identities.md) provided by App Service Authentication.
47+
48+
> [!CAUTION]
49+
> The token used for MCP server authorization is meant to represent access to your MCP server, and not to a downstream resource. Pass-through scenarios where the server forwards its token create security vulnerabilities, so avoid these patterns. If you need to access a downstream resource, obtain a new token through the on-behalf-of flow or another mechanism for explicit delegation.
50+
51+
## Related content
52+
53+
- [Model Context Protocol Authorization specification][spec]
54+
- [Azure Functions Model Context Protocol bindings](../azure-functions/functions-bindings-mcp.md)
55+
- [Integrate an App Service app as an MCP Server (.NET)](./tutorial-ai-model-context-protocol-server-dotnet.md)
56+
- [Integrate an App Service app as an MCP Server (Java)](./tutorial-ai-model-context-protocol-server-java.md)
57+
- [Integrate an App Service app as an MCP Server (Node.js)](./tutorial-ai-model-context-protocol-server-node.md)
58+
- [Integrate an App Service app as an MCP Server (Python)](./tutorial-ai-model-context-protocol-server-python.md)
59+
60+
[spec]: https://modelcontextprotocol.io/specification/2025-06-18/basic/authorization

articles/app-service/overview-authentication-authorization.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,27 @@ App Service authentication mitigates cross-site request forgery by inspecting cl
170170

171171
When a request fulfills all these conditions, App Service authentication automatically rejects it. You can work around this mitigation logic by adding your external domain to the redirect list in **Settings** > **Authentication** > **Edit authentication settings** > **Allowed external redirect URLs**.
172172

173+
### Protected resource metadata (preview)
174+
175+
App Service can serve OAuth 2.0 protected resource metadata, as defined in [RFC 9728](https://datatracker.ietf.org/doc/html/rfc9728). This can help OAuth 2.0 clients understand how to interact with your app. It is required for [Model Context Protocol (MCP) server authorization](./configure-authentication-mcp.md).
176+
177+
> [!NOTE]
178+
> Support for protected resource metadata is currently in preview, and the way you configure it may change before the feature is generally available.
179+
180+
During the preview period, you can enable a default protected resource metadata document by configuring the `WEBSITE_AUTH_PRM_DEFAULT_WITH_SCOPES` [application setting](./configure-common.md#configure-app-settings) with a comma-separated list of scopes needed by the application. For example, when you let App Service configure the Microsoft Entra provider for you, it will set up a scope like `api://<client-id>/user_impersonation`, replacing `<client-id>` with the actual client ID of your app registration.
181+
182+
The default protected resource metadata document includes the following properties:
183+
184+
| Property | Description |
185+
|-|-|
186+
| `resource` | The resource URI corresponding to the endpoint at which the protected resource metadata was accessed. |
187+
| `authorization_servers` | A list of authorization servers for the identity providers that you have configured. |
188+
| `scopes_supported` | The list of scopes that you specified in the `WEBSITE_AUTH_PRM_DEFAULT_WITH_SCOPES` application setting. |
189+
190+
Additional properties are not supported when using the default configuration.
191+
192+
Configuring the default protected resource metadata document also changes how App Service handles unauthenticated requests for APIs. When the app issues an authorization challenge, it includes the URL of the protected resource metadata, which the client can then retrieve and process. The challenge also includes the scopes that you configured in the `WEBSITE_AUTH_PRM_DEFAULT_WITH_SCOPES` application setting.
193+
173194
## Considerations for using Azure Front Door
174195

175196
When you're using Azure App Service with authentication behind Azure Front Door or other reverse proxies, consider the following actions.

articles/app-service/reference-app-settings.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,7 @@ The following environment variables are related to [App Service authentication](
535535
| `WEBSITE_AUTH_ENABLED` | Read-only. Injected into a Windows or Linux app to indicate whether App Service authentication is enabled. |
536536
| `WEBSITE_AUTH_ENCRYPTION_KEY` | By default, the automatically generated key is used as the encryption key. To override, set to a desired key. We recommend this environment variable if you want to share tokens or sessions across multiple apps. If you specify it, it supersedes the `MACHINEKEY_DecryptionKey` setting. |
537537
| `WEBSITE_AUTH_SIGNING_KEY` | By default, the automatically generated key is used as the signing key. To override, set to a desired key. We recommend this environment variable if you want to share tokens or sessions across multiple apps. If you specify it, it supersedes the `MACHINEKEY_ValidationKey` setting. |
538+
| `WEBSITE_AUTH_PRM_DEFAULT_WITH_SCOPES` | A comma-separated list of scopes needed by the application. When set, this variable configures a default protected resource metadata document, which declares that the specified scopes are supported. The scopes are also included in authentication challenges returned by the application. |
538539

539540
<!-- System settings
540541
WEBSITE_AUTH_RUNTIME_VERSION

articles/app-service/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,8 @@ items:
416416
href: configure-authentication-api-version.md
417417
- name: Use file-based configuration
418418
href: configure-authentication-file-based.md
419+
- name: MCP server authorization
420+
href: configure-authentication-mcp.md
419421
- name: Security and networking
420422
items:
421423
- name: Security overview

articles/azure-functions/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,8 @@
521521
href: ../app-service/configure-authentication-api-version.md?toc=/azure/azure-functions/toc.json
522522
- name: File-based configuration
523523
href: ../app-service/configure-authentication-file-based.md?toc=/azure/azure-functions/toc.json
524+
- name: MCP server authorization
525+
href: ../app-service/configure-authentication-mcp.md?toc=/azure/azure-functions/toc.json
524526
- name: Secure
525527
items:
526528
- name: Work with access keys

articles/azure-functions/functions-bindings-mcp.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ MCP clients accept this configuration in various ways. Consult the documentation
153153

154154
## Related articles
155155

156-
[Create a tool endpoint in your remote MCP server](./functions-bindings-mcp-trigger.md)
156+
- [Create a tool endpoint in your remote MCP server](./functions-bindings-mcp-trigger.md)
157+
- [Configure built-in MCP server authorization][authorization]
157158

158-
159-
[extension bundle]: ./extension-bundles.md
159+
[authorization]: ../app-service/configure-authentication-mcp.md?toc=/azure/azure-functions/toc.json

0 commit comments

Comments
 (0)