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
# Getting Started with Remote MCP Servers using Azure Functions (Python)
18
18
19
-
This is a quickstart template to easily build and deploy a custom remote MCP server to the cloud using Azure Functions with Python. You can clone/restore/run on your local machine with debugging, and `azd up` to have it in the cloud in a couple minutes. The MCP server is secured by design using keys and HTTPS, and allows more options for OAuth using EasyAuth and/or API Management as well as network isolation using VNET.
19
+
This is a quickstart template to easily build and deploy a custom remote MCP server to the cloud using Azure Functions with Python. You can clone/restore/run on your local machine with debugging, and `azd up` to have it in the cloud in a couple minutes. The MCP server is secured by design using keys and HTTPS, and allows more options for OAuth using built-in auth and/or API Management as well as network isolation using VNET.
20
20
21
21
If you're looking for this sample in more languages check out the [.NET/C#](https://github.com/Azure-Samples/remote-mcp-functions-dotnet) and [Node.js/TypeScript](https://github.com/Azure-Samples/remote-mcp-functions-typescript) versions.
22
22
@@ -50,17 +50,20 @@ An Azure Storage Emulator is needed for this particular sample because we will s
50
50
51
51
## Run your MCP Server locally from the terminal
52
52
53
-
1. Change to the src folder in a new terminal window
53
+
1. Change to the src folder in a new terminal window:
54
+
54
55
```shell
55
56
cd src
56
57
```
57
58
58
-
1. Install Python dependencies
59
+
1. Install Python dependencies:
60
+
59
61
```shell
60
62
pip install -r requirements.txt
61
63
```
62
64
63
65
1. Start the Functions host locally:
66
+
64
67
```shell
65
68
func start
66
69
```
@@ -72,9 +75,11 @@ An Azure Storage Emulator is needed for this particular sample because we will s
72
75
### VS Code - Copilot Edits
73
76
74
77
1. **Add MCP Server** from command palette and add URL to your running Function app's SSE endpoint:
78
+
75
79
```shell
76
80
http://0.0.0.0:7071/runtime/webhooks/mcp/sse
77
81
```
82
+
78
83
1. **List MCP Servers** from command palette and start the server
79
84
1. In Copilot chat agent mode enter a prompt to trigger the tool, e.g., select some code and enter this prompt
80
85
@@ -89,6 +94,7 @@ An Azure Storage Emulator is needed for this particular sample because we will s
89
94
```plaintext
90
95
Retrieve snippet1 and apply to newFile.py
91
96
```
97
+
92
98
1. When prompted to run the tool, consent by clicking **Continue**
93
99
94
100
1. When you're done, press Ctrl+C in the terminal window to stop the Functions host process.
@@ -102,11 +108,13 @@ An Azure Storage Emulator is needed for this particular sample because we will s
102
108
```
103
109
104
110
2. CTRL click to load the MCP Inspector web app from the URL displayed by the app (e.g. http://0.0.0.0:5173/#resources)
105
-
3. Set the transport type to `SSE`
111
+
3. Set the transport type to `SSE`
106
112
4. Set the URL to your running Function app's SSE endpoint and **Connect**:
113
+
107
114
```shell
108
115
http://0.0.0.0:7071/runtime/webhooks/mcp/sse
109
116
```
117
+
110
118
5. **List Tools**. Click on a tool and **Run Tool**.
111
119
112
120
## Deploy to Azure for Remote MCP
@@ -123,11 +131,11 @@ You can opt-in to a VNet being used in the sample. To do so, do this before `azd
123
131
azd env set VNET_ENABLED true
124
132
```
125
133
126
-
Additionally, [API Management]() can be used for improved security and policies over your MCP Server, and [App Service built-in authentication](https://learn.microsoft.com/en-us/azure/app-service/overview-authentication-authorization) can be used to set up your favorite OAuth provider including Entra.
134
+
Additionally, [API Management]() can be used for improved security and policies over your MCP Server, and [App Service built-in authentication](https://learn.microsoft.com/azure/app-service/overview-authentication-authorization) can be used to set up your favorite OAuth provider including Entra.
127
135
128
136
### Connect to your function app from a client
129
137
130
-
Your client will need a key in order to invoke the new hosted SSE endpoint, which will be of the form `https://<funcappname>.azurewebsites.net/runtime/webhooks/mcp/sse`. The hosted function requires a system key by default which can be obtained from the [portal](https://learn.microsoft.com/en-us/azure/azure-functions/function-keys-how-to?tabs=azure-portal) or the CLI (`az functionapp keys list --resource-group <resource_group> --name <function_app_name>`). Obtain the system key named `mcp_extension`.
138
+
Your client will need a key in order to invoke the new hosted SSE endpoint, which will be of the form `https://<funcappname>.azurewebsites.net/runtime/webhooks/mcp/sse`. The hosted function requires a system key by default which can be obtained from the [portal](https://learn.microsoft.com/azure/azure-functions/function-keys-how-to?tabs=azure-portal) or the CLI (`az functionapp keys list --resource-group <resource_group> --name <function_app_name>`). Obtain the system key named `mcp_extension`.
131
139
132
140
For MCP Inspector, you can include the key in the URL: `https://<funcappname>.azurewebsites.net/runtime/webhooks/mcp/sse?code=<your-mcp-extension-system-key>`.
133
141
@@ -284,6 +292,6 @@ Note that the `host.json` file also includes a reference to the experimental bun
284
292
## Next Steps
285
293
286
294
- Add [API Management]() to your MCP server
287
-
- Add [EasyAuth]() to your MCP server
295
+
- Add [built-in auth]() to your MCP server
288
296
- Enable VNET using VNET_ENABLED=true flag
289
297
- Learn more about [related MCP efforts from Microsoft]()
0 commit comments