Skip to content

Commit 036a783

Browse files
author
gitName
committed
review comments
1 parent dc98f0b commit 036a783

File tree

4 files changed

+25
-46
lines changed

4 files changed

+25
-46
lines changed

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

Lines changed: 25 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,26 @@ description: Learn how to expose a REST API in Azure API Management as an MCP se
44
author: dlepow
55
ms.service: azure-api-management
66
ms.topic: how-to
7-
ms.date: 05/12/2025
7+
ms.date: 05/18/2025
88
ms.author: danlep
99
---
1010

1111
# Expose REST API in API Management as an MCP server
1212

1313
[!INCLUDE [api-management-premium-standard-basic](../../includes/api-management-availability-premium-standard-basic.md)]
1414

15-
<!-- Currently only the **Premium**, **Standard**, and **Basic** tiers of API Management support MCP servers.
16-
17-
Document need an IcM for SKUv2 --
18-
19-
Need to use the GenAI release group -->
2015

2116
In API Management, you can expose a REST API managed in API Management as a remote [Model Context Protocol (MCP)](https://www.anthropic.com/news/model-context-protocol) server. You can expose one or more of the API operations as tools that MCP clients can call using the MCP protocol.
2217

2318
Using API Management to expose remote MCP servers provides centralized control over authentication, authorization, and monitoring. It simplifies the process of exposing APIs as MCP servers while helping to mitigate common security risks and ensuring scalability.
2419

2520
> [!NOTE]
26-
> This feature is currently in preview. It's being released first to the **AI Gateway Early** [update group](configure-service-update-settings.md).
21+
> This feature is currently in preview. It's being released first to the **AI Gateway Early** [update group](configure-service-update-settings.md).
2722
2823
In this article, you learn how to:
2924

3025
* Expose a REST API in API Management as an MCP server
26+
* Configure policies for the MCP server
3127
* Test the generated MCP server from an MCP client
3228

3329
[!INCLUDE [about-mcp-servers](../api-center/includes/about-mcp-servers.md)]
@@ -38,13 +34,19 @@ In this article, you learn how to:
3834
+ Make sure that your instance manages a REST API that you'd like to expose as an MCP server. To import a sample API, see [Import and publish your first API](import-and-publish.md).
3935
> [!NOTE]
4036
> Only HTTP APIs from API Management can be exposed as MCP servers.
41-
+ To test the MCP server, you can use a tool like [MCP Inspector](https://modelcontextprotocol.io/docs/tools/inspector) or Visual Studio Code with access to [GitHub Copilot](https://code.visualstudio.com/docs/copilot/setup).
37+
+ To test the MCP server, you can use Visual Studio Code with access to [GitHub Copilot](https://code.visualstudio.com/docs/copilot/setup).
4238

43-
[!INCLUDE [api-management-navigate-to-instance.md](../../includes/api-management-navigate-to-instance.md)]
4439

4540
## Expose API as an MCP server
4641

47-
1. In the portal, under **APIs**, select **MCP Servers** > **+ Create new MCP Server**.
42+
43+
1. In the Azure portal, access the MCP server preview at the following URL:
44+
45+
```
46+
https://portal.azure.com/?Microsoft_Azure_ApiManagement=mcp
47+
```
48+
1. Navigate to your API Management instance.
49+
1. In the left menu, select **APIs** > **MCP Servers** > **+ Create new MCP Server**.
4850
1. In **API**, select a REST API to expose as an MCP server.
4951
1. Select one or more **API Operations** to expose as tools. You can select all operations or only specific operations.
5052
1. Select **Create**.
@@ -58,56 +60,28 @@ The MCP server is created and the API operations are exposed as tools. The MCP s
5860
5961
## Configure policies for the MCP server
6062
61-
You can configure one or more API Management [policies](api-management-howto-policies.md) for the MCP server. The policies are applied to all API operations exposed as tools in the MCP server and can be used to control access, authentication, and other aspects of the tool.
63+
Configure one or more API Management [policies](api-management-howto-policies.md) to help manage the MCP server. The policies are applied to all API operations exposed as tools in the MCP server and can be used to control access, authentication, and other aspects of the tools.
6264
63-
For a tutorial on how to configure policies, see [Transform and protect your API](transform.md).
65+
For a tutorial on how to configure policies, see [Transform and protect your API](transform-api.md).
6466
6567
To configure policies for the MCP server:
6668
6769
1. In the portal, under **APIs**, select **MCP Servers**.
6870
1. Select the MCP server you created.
6971
1. In the left menu, under **MCP**, select **Policies**.
70-
1. In the policy editor, add or edit the policies you want to apply to the MCP server's tools. The policies are defined in XML format. For example, you can add an inbound policy to add an API Management subscription key for all requests to the MCP server. Substitute `your-subscription-key` with an actual subscription key configured in your API Management instance.
72+
1. In the policy editor, add or edit the policies you want to apply to the MCP server's tools. The policies are defined in XML format. For example, you can add a policy to limit calls to the MCP server's tools (in this example, 5 calls per 30 second per client IP address).
7173
7274
```xml
73-
<set-header name="Ocp-Apim-Subscription-Key" exists-action="override">
74-
<value>your-subscription-key</value>
75-
</set-header>
75+
<rate-limit-by-key calls="5" renewal-period="30" counter-key="@(context.Request.IpAddress)" remaining-calls-variable-name="remainingCallsPerIP" />
7676
```
7777
78-
:::image type="content" source="media/export-rest-mcp-server/mcp-server-policies.png" alt-text="Screenshot of the policy editor for an MCP server.":::
78+
:::image type="content" source="media/export-rest-mcp-server/mcp-server-policies-small.png" alt-text="Screenshot of the policy editor for an MCP server." lightbox="media/export-rest-mcp-server/mcp-server-policies.png":::
7979
8080
## Test and use the MCP server
8181
82-
To verify that the MCP server is working, you can use a tool like MCP Inspector or Visual Studio Code to send requests to the MCP server tools. The following sections provide basic instructions.
83-
84-
### MCP inspector
85-
86-
To use MCP inspector:
87-
88-
1. Start the MCP Inspector by running the following command in a terminal:
82+
To verify that the MCP server is working, you can use Visual Studio Code to send requests to the MCP server tools.
8983
90-
```bash
91-
npx @modelcontextprotocol/inspector
92-
```
93-
1. Navigate to the local URL of the MCP Inspector that's displayed in the console.
94-
95-
1. In the browser, enter the following settings:
96-
97-
| **Setting** | **Description** |
98-
|------------------------|-----------------------------------------------------------------------------------------------------|
99-
| **Transport Type** | Select **SSE**. |
100-
| **URL** | Enter the MCP server URL that's configured in API Management. Example: `https://<apim-service-name>.azure-api.net/<api-name>-mcp/sse` (for SSE endpoint) or `https://<apim-service-name>.azure-api.net/<api-name>-mcp/mcp` (for MCP endpoint) |
101-
| **Authentication** | Optionally, provide credentials of the underlying API if necessary in API Management. For example, if a subscription key is required, enter `Ocp-Apim-Subscription-Key` in **Header Name**, and provide the key value in **Bearer token**. |
102-
1. Select **Connect** to connect to the MCP server.
103-
1. In **Tools**, select **List Tools**, and select a tool configured in the MCP server.
104-
1. Enter any required parameters for the tool, and select **Run Tool** to run the tool. The results are displayed in the **Tool Result** pane.
105-
106-
:::image type="content" source="media/export-rest-mcp-server/test-mcp-inspector.png" alt-text="Screenshot of testing an MCP server tool in MCP Inspector.":::
107-
108-
### Visual Studio Code
109-
110-
In Visual Studio Code, you can use GitHub Copilot chat in agent mode (preview) to add the MCP server and use the tools. For background about MCP servers in Visual Studio Code, see [Use MCP Servers in VS Code (Preview)](https://code.visualstudio.com/docs/copilot/chat/mcp-servers).
84+
In Visual Studio Code, use GitHub Copilot chat in agent mode (preview) to add the MCP server and use the tools. For background about MCP servers in Visual Studio Code, see [Use MCP Servers in VS Code (Preview)](https://code.visualstudio.com/docs/copilot/chat/mcp-servers).
11185
11286
To add the MCP server in Visual Studio Code:
11387
@@ -123,7 +97,10 @@ To add the MCP server in Visual Studio Code:
12397
12498
:::image type="content" source="media/export-rest-mcp-server/mcp-servers-visual-studio-code.png" alt-text="Screenshot of MCP servers configured in Visual Studio Code.":::
12599
126-
You can add fields to the JSON configuration for settings such as authentication headers. Learn more about the [configuration format](https://code.visualstudio.com/docs/copilot/chat/mcp-servers#_configuration-format)
100+
Add fields to the JSON configuration for settings such as authentication header. The following example shows the configuration for an API Management subscription key passed in a header as in input value. Learn more about the [configuration format](https://code.visualstudio.com/docs/copilot/chat/mcp-servers#_configuration-format)
101+
102+
:::image type="content" source="media/export-rest-mcp-server/mcp-server-with-header-visual-studio-code.png" alt-text="Screenshot of authentication header configuration for an MCP server":::
103+
127104
128105
After adding an MCP server, you can use tools in agent mode.
129106
@@ -151,5 +128,7 @@ After adding an MCP server, you can use tools in agent mode.
151128
152129
* [MCP client authorization lab](https://github.com/Azure-Samples/AI-Gateway/tree/main/labs/mcp-client-authorization)
153130
131+
* [Use the Azure API Management extension for VS Code to import and manage APIs](visual-studio-code-tutorial.md)
132+
154133
* [Register and discover remote MCP servers in Azure API Center](../api-center/register-discover-mcp-server.md)
155134
59 KB
Loading
13.4 KB
Loading
5.04 KB
Loading

0 commit comments

Comments
 (0)