Skip to content

Commit eb0a1f2

Browse files
committed
APIM doc draft w/ VSCode
1 parent 1c86d8f commit eb0a1f2

File tree

5 files changed

+52
-5
lines changed

5 files changed

+52
-5
lines changed

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

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ 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/06/2025
7+
ms.date: 05/12/2025
88
ms.author: danlep
99
---
1010

@@ -22,14 +22,15 @@ In this article, you learn how to:
2222
* Expose a REST API in API Management as an MCP server
2323
* Test the generated MCP server
2424

25+
[!INCLUDE [about-mcp-servers](../api-center/includes/about-mcp-servers.md)]
2526

2627
## Prerequisites
2728

2829
+ Complete the following quickstart: [Create an Azure API Management instance](get-started-create-service-instance.md).
2930
+ 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).
3031
> [!NOTE]
3132
> Only expose HTTP APIs from API Management can be exposed as MCP servers.
32-
+ To test the MCP server, you can use a tool like [MCP Inspector](https://modelcontextprotocol.io/docs/tools/inspector)
33+
+ 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).
3334

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

@@ -50,7 +51,9 @@ The MCP server is created and the API operations are exposed as tools. The MCP s
5051

5152
## Test and use the MCP server
5253

53-
To verify that the MCP server is working, you can use a tool like MCP Inspector to send requests to the server's `sse` endpoint.
54+
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.
55+
56+
### MCP inspector
5457

5558
To use MCP inspector:
5659

@@ -65,15 +68,59 @@ To use MCP inspector:
6568
| **Setting** | **Description** |
6669
|------------------------|-----------------------------------------------------------------------------------------------------|
6770
| **Transport Type** | Select **SSE**. |
68-
| **URL** | Enter the MCP server URL that's configured in API Management. |
69-
| **Authentication** | Optionally, provide credentials of the underlying API if required 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**. |
71+
| **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) |
72+
| **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**. |
7073
1. Select **Connect** to connect to the MCP server.
7174
1. In **Tools**, select **List Tools**, and select a tool configured in the MCP server.
7275
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.
7376
7477
:::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.":::
7578
79+
### Visual Studio Code
80+
81+
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).
82+
83+
To add the MCP server in Visual Studio Code:
84+
85+
1. Use the **MCP: Add Server** command from the Command Palette. When prompted, provide the following information:
86+
87+
1. Select the server type: **HTTP (HTTP or Server Sent Events)**.
88+
1. Enter the **URL of the MCP server** 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)
89+
1. Enter a **server ID** of your choice.
90+
1. Select whether to save the configuration to your **workspace settings** or **user settings**.
91+
* **Workspace settings** - The server configuration is saved to a `.vscode/mcp.json` file only available in the current workspace.
92+
93+
* **User settings** - The server configuration is added to your global `settings.json` file and is available in all workspaces. The configuration looks similar to the following:
94+
95+
:::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.":::
96+
97+
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)
98+
99+
After adding an MCP server, you can use tools in agent mode.
100+
101+
1. In GitHub Copilot chat, select **Agent** mode and select the **Tools** button to see available tools.
102+
103+
:::image type="content" source="media/export-rest-mcp-server/tools-button-visual-studio-code.png" alt-text="Screenshot of Tools button in chat.":::
104+
105+
1. Select one or more tools from the MCP server to be available in the chat.
106+
107+
:::image type="content" source="media/export-rest-mcp-server/select-tools-visual-studio-code.png" alt-text="Screenshot of selecting tools in Visual Studio Code.":::
108+
109+
1. Enter a prompt in the chat to invoke the tool. For example, if you selected a tool to get information about an order, you can ask the agent about an order.
110+
111+
```copilot-prompt
112+
Get order information for order ID 2
113+
```
114+
115+
Select **Continue** to see the results. The agent uses the tool to call the MCP server and returns the results in the chat.
116+
117+
:::image type="content" source="media/export-rest-mcp-server/chat-results-visual-studio-code.png" alt-text="Screenshot of chat results in Visual Studio Code.":::
118+
76119
## Related content
77120
121+
* [Python sample: Secure remote MCP servers using Azure API Management (experimental)](https://github.com/Azure-Samples/remote-mcp-apim-functions-python)
122+
123+
* [MCP client authorization lab](https://github.com/Azure-Samples/AI-Gateway/tree/main/labs/mcp-client-authorization)
124+
78125
* [Register and discover remote MCP servers in Azure API Center](../api-center/register-discover-mcp-server.md)
79126
16.4 KB
Loading
39.2 KB
Loading
30.4 KB
Loading
21.7 KB
Loading

0 commit comments

Comments
 (0)