You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!-- 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 -->
20
15
21
16
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.
22
17
23
18
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.
24
19
25
20
> [!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).
27
22
28
23
In this article, you learn how to:
29
24
30
25
* Expose a REST API in API Management as an MCP server
26
+
* Configure policies for the MCP server
31
27
* Test the generated MCP server from an MCP client
@@ -38,13 +34,19 @@ In this article, you learn how to:
38
34
+ 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).
39
35
> [!NOTE]
40
36
> 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).
1. In the left menu, select **APIs** > **MCP Servers** > **+ Create new MCP Server**.
48
50
1. In **API**, select a REST API to expose as an MCP server.
49
51
1. Select one or more **API Operations** to expose as tools. You can select all operations or only specific operations.
50
52
1. Select **Create**.
@@ -58,56 +60,28 @@ The MCP server is created and the API operations are exposed as tools. The MCP s
58
60
59
61
## Configure policies for the MCP server
60
62
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.
62
64
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).
64
66
65
67
To configure policies for the MCP server:
66
68
67
69
1. In the portal, under **APIs**, select **MCP Servers**.
68
70
1. Select the MCP server you created.
69
71
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).
:::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":::
79
79
80
80
## Test and use the MCP server
81
81
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.
89
83
90
-
```bash
91
-
npx @modelcontextprotocol/inspector
92
-
```
93
-
1. Navigate to the local URL of the MCP Inspector that's displayed in the console.
| **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).
111
85
112
86
To add the MCP server in Visual Studio Code:
113
87
@@ -123,7 +97,10 @@ To add the MCP server in Visual Studio Code:
123
97
124
98
:::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.":::
125
99
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
+
127
104
128
105
After adding an MCP server, you can use tools in agent mode.
129
106
@@ -151,5 +128,7 @@ After adding an MCP server, you can use tools in agent mode.
0 commit comments