Skip to content

Commit 0cbef60

Browse files
author
gitName
committed
partition security content
1 parent 8525443 commit 0cbef60

File tree

6 files changed

+84
-44
lines changed

6 files changed

+84
-44
lines changed

articles/api-management/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@
260260
href: export-rest-mcp-server.md
261261
- name: Expose existing MCP server
262262
href: expose-existing-mcp-server.md
263+
- name: Secure access to MCP servers
264+
href: secure-mcp-servers.md
263265
- name: Manage APIs with policies
264266
items:
265267
- name: API Management policies overview

articles/api-management/export-rest-mcp-server.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ The following limitations currently apply to this preview:
4444
> [!NOTE]
4545
> Other API types in API Management that aren't HTTP-compatible can't be exposed as MCP servers.
4646
47+
+ If you’ve enabled diagnostic logging via Application Insights or Azure Monitor at the global scope (All APIs) for your API Management service instance, ensure that the **Number of payload bytes to log** setting for Frontend Response is set to 0. This prevents unintended logging of response bodies across all APIs and helps ensure proper functioning of MCP servers. To log payloads selectively for specific APIs, configure the setting individually at the API scope, allowing targeted control over response logging.
48+
4749
+ To test the MCP server, you can use Visual Studio Code with access to [GitHub Copilot](https://code.visualstudio.com/docs/copilot/setup).
4850

4951

articles/api-management/expose-existing-mcp-server.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ The following limitations currently apply to this preview:
5656

5757
+ Appropriate credentials to the MCP server (such as OAuth 2.0 client credentials or API keys, depending on the server) for secure access.
5858

59+
+ If you’ve enabled diagnostic logging via Application Insights or Azure Monitor at the global scope (All APIs) for your API Management service instance, ensure that the **Number of payload bytes to log** setting for Frontend Response is set to 0. This prevents unintended logging of response bodies across all APIs and helps ensure proper functioning of MCP servers. To log payloads selectively for specific APIs, configure the setting individually at the API scope, allowing targeted control over response logging.
60+
5961
+ To test the MCP server, you can use Visual Studio Code with access to [GitHub Copilot](https://code.visualstudio.com/docs/copilot/setup).
6062

6163
## Expose an existing MCP server

articles/api-management/mcp-server-overview.md

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -85,45 +85,7 @@ Configure policies such as the following::
8585

8686
## Secure access to the MCP server
8787

88-
You can secure either or both inbound access to the MCP server (from an MCP client to API Management) and outbound access (from API Management to the MCP server backend).
89-
90-
### Secure inbound access
91-
92-
One option to secure inbound access is to configure a policy to validate a JSON web token (JWT) generated using an identity provider in the incoming requests. This ensures that only authorized clients can access the MCP server. Use the generic [validate-jwt](validate-jwt-policy.md) policy, or the [validate-azure-ad-token](validate-azure-ad-token-policy.md) policy when using Microsoft Entra ID, to validate the JWT token in the incoming requests.
93-
94-
The following is a basic example of validating a Microsoft Entra ID token presented in an `Authorization` header in the incoming request:
95-
96-
```xml
97-
<validate-azure-ad-token header-name="Authorization" failed-validation-httpcode="401" failed-validation-error-message="Unauthorized. Access token is missing or invalid.">
98-
<client-application-ids>
99-
<application-id>your-client-id</application-id>
100-
</client-application-ids>
101-
</validate-azure-ad-token>
102-
```
103-
104-
For more inbound authorization options and samples, including using OAuth authorization, see:
105-
106-
* [MCP server authorization with Protected Resource Metadata (PRM) sample](https://github.com/blackchoey/remote-mcp-apim-oauth-prm)
107-
108-
* [Secure Remote MCP Servers using Azure API Management (Experimental)](https://github.com/Azure-Samples/remote-mcp-apim-functions-python)
109-
110-
* [MCP client authorization lab](https://github.com/Azure-Samples/AI-Gateway/tree/main/labs/mcp-client-authorization)
111-
112-
> [!CAUTION]
113-
> When you use an MCP server in API Management, incoming headers like **Authorization** aren't automatically passed to your backend API. If your backend needs a token, you can add it as an input parameter in your API definition. Alternatively, use policies like `get-authorization-context` and `set-header` to generate and attach the token, as noted in the following section.
114-
115-
116-
### Secure outbound access
117-
118-
You can use API Management's [credential manager](credentials-overview.md) to securely inject secrets or tokens for calls to a backend API. At a high level, the process is as follows:
119-
120-
1. Register an application in a supported identity provider.
121-
1. Create a credential provider resource in API Management to manage the credentials from the identity provider.
122-
1. Configure a connection to the provider in API Management.
123-
1. Configure `get-authorization-context` and `set-header` policies to fetch the token credentials and present them in an **Authorization** header of the API requests.
124-
125-
For a step-by-step guide to call an example backend API using credentials generated in credential manager, see [Configure credential manager - GitHub](credentials-how-to-github.md).
126-
88+
You can secure either or both inbound access to the MCP server (from an MCP client to API Management) and outbound access (from API Management to the MCP server backend). For information and examples, see [Secure access to MCP servers](secure-mcp-servers.md).
12789

12890
## Monitoring
12991

@@ -147,16 +109,14 @@ Use [Azure API Center](../api-center/register-discover-mcp-server.md) to registe
147109

148110
## Availability
149111

150-
<!-- availability in workspaces?-->
151-
152-
153112
MCP servers in API Management are available in the following service tiers:
154113

155114
* **Classic tiers**: Basic, Standard, Premium
156115
* **v2 tiers**: Basic v2, Standard v2, Premium v2
157116

158117
> [!NOTE]
159-
> In the classic tiers, you must join the [AI Gateway Early update group](configure-service-update-settings.md) to access MCP server features, and access the portal at a feature-specific URL.
118+
> * In the classic tiers, you must join the [AI Gateway Early update group](configure-service-update-settings.md) to access MCP server features, and access the portal at a feature-specific URL.
119+
> * MCP servers aren't currently supported in [workspaces](workspaces-overview.md).
160120
161121
## Related content
162122

@@ -168,4 +128,6 @@ MCP servers in API Management are available in the following service tiers:
168128

169129
* [Expose REST API in API Management as an MCP server](export-rest-mcp-server.md)
170130

171-
* [Expose and govern existing MCP server](expose-existing-mcp-server.md)
131+
* [Expose and govern existing MCP server](expose-existing-mcp-server.md)
132+
133+
* [Secure access to MCP servers](secure-mcp-servers.md)
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
title: Secure access to MCP servers in Azure API Management
3+
description: Learn how secure access to MCP servers managed in Azure API Management.
4+
author: dlepow
5+
ms.service: azure-api-management
6+
ms.topic: concept-article
7+
ms.date: 07/30/2025
8+
ms.author: danlep
9+
ms.collection: ce-skilling-ai-copilot
10+
ms.custom:
11+
---
12+
13+
# Secure access to MCP servers in API Management
14+
15+
[!INCLUDE [api-management-availability-premium-standard-basic-premiumv2-standardv2-basicv2](../../includes/api-management-availability-premium-standard-basic-premiumv2-standardv2-basicv2.md)]
16+
17+
18+
With [MCP server support in API Management](mcp-server-overview.md), you can expose and govern access to MCP servers and their tools. This article describes how to secure access to MCP servers managed in API Management, including both MCP servers exposed from managed REST APIs and existing MCP servers hosted outside of API Management.
19+
20+
You can secure either or both inbound access to the MCP server (from an MCP client to API Management) and outbound access (from API Management to the MCP server backend).
21+
22+
### Secure inbound access
23+
24+
One option to secure inbound access is to configure a policy to validate a JSON web token (JWT) generated using an identity provider in the incoming requests. This ensures that only authorized clients can access the MCP server. Use the generic [validate-jwt](validate-jwt-policy.md) policy, or the [validate-azure-ad-token](validate-azure-ad-token-policy.md) policy when using Microsoft Entra ID, to validate the JWT in the incoming requests.
25+
26+
The following is a basic example of validating a Microsoft Entra ID token presented in an `Authorization` header in the incoming request:
27+
28+
```xml
29+
<validate-azure-ad-token header-name="Authorization" failed-validation-httpcode="401" failed-validation-error-message="Unauthorized. Access token is missing or invalid.">
30+
<client-application-ids>
31+
<application-id>your-client-id</application-id>
32+
</client-application-ids>
33+
</validate-azure-ad-token>
34+
```
35+
36+
For more inbound authorization options and samples, including using OAuth authorization, see:
37+
38+
* [MCP server authorization with Protected Resource Metadata (PRM) sample](https://github.com/blackchoey/remote-mcp-apim-oauth-prm)
39+
40+
* [Secure Remote MCP Servers using Azure API Management (Experimental)](https://github.com/Azure-Samples/remote-mcp-apim-functions-python)
41+
42+
* [MCP client authorization lab](https://github.com/Azure-Samples/AI-Gateway/tree/main/labs/mcp-client-authorization)
43+
44+
> [!CAUTION]
45+
> When you use an MCP server in API Management, incoming headers like **Authorization** aren't automatically passed to your backend API. If your backend needs a token, you can add it as an input parameter in your API definition. Alternatively, use policies like `get-authorization-context` and `set-header` to generate and attach the token, as noted in the following section.
46+
47+
48+
### Secure outbound access
49+
50+
You can use API Management's [credential manager](credentials-overview.md) to securely inject secrets or tokens for calls to a backend API. For example, use the credential manager to obtain and present an access token from an identity provider to access the API called by an MCP server tool.
51+
52+
At a high level, the process is as follows:
53+
54+
1. Register an application in a supported identity provider.
55+
1. Create a credential provider resource in API Management to manage the credentials from the identity provider.
56+
1. Configure a connection to the provider in API Management.
57+
1. Configure `get-authorization-context` and `set-header` policies to fetch the token credentials and present them in an **Authorization** header of the API requests.
58+
59+
For a step-by-step guide to call an example backend API using credentials generated in credential manager, see [Configure credential manager - GitHub](credentials-how-to-github.md).
60+
61+
## Related content
62+
63+
64+
* [Register and discover remote MCP servers in Azure API Center](../api-center/register-discover-mcp-server.md)
65+
66+
* [Expose REST API in API Management as an MCP server](export-rest-mcp-server.md)
67+
68+
* [Expose and govern existing MCP server](expose-existing-mcp-server.md)

includes/api-management-configure-test-mcp-server.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Learn more about configuring policies:
1515
* [Transform and protect your API](../articles/api-management/transform-api.md)
1616
* [Set and edit policies](../articles/api-management/set-edit-policies.md)
1717

18+
> [!IMPORTANT]
19+
> Do not access the response body using `context.Response.Body` within MCP server policies. Doing so triggers response buffering, which interferes with the streaming behavior required by MCP servers and may cause them to malfunction.
20+
1821
To configure policies for the MCP server:
1922

2023
1. In the [Azure portal](https://portal.azure.com), navigate to your API Management instance.
@@ -86,6 +89,7 @@ After adding an MCP server in Visual Studio Code, you can use tools in agent mod
8689
| `401 Unauthorized` error from backend | Authorization header not forwarded | Use `set-header` policy to manually attach token |
8790
| API call works in API Management but fails in agent | Incorrect base URL or missing token | Double-check security policies and endpoint |
8891
| Not able to create MCP server | MCP server capability is not available in Consumption or Developer tier, and must be enabled using [update group](../articles/api-management/configure-service-update-settings.md) in classic Basic, Standard, and Premium tiers | Use a supported classic or v2 tier - see [Prerequisites](#prerequisites) |
92+
| | | |
8993

9094
## Related content
9195

0 commit comments

Comments
 (0)