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 built-in auth and/or [API Management](https://aka.ms/mcp-remote-apim-auth) 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.
20
+
21
+
The MCP server is configured with [built-in authentication](https://learn.microsoft.com/en-us/azure/app-service/overview-authentication-authorization) using Microsoft Entra as the identity provider.
22
+
23
+
You can also use [API Management](https://learn.microsoft.com/azure/api-management/secure-mcp-servers) to secure the server, as well as network isolation using VNET.
20
24
21
25
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
26
@@ -157,6 +161,12 @@ In the root directory, create a new [azd](https://aka.ms/azd) environment. This
157
161
azd env new <reource-group-name>
158
162
```
159
163
164
+
Configure VS Code as an allowed client application to request access tokens from Microsoft Entra:
165
+
166
+
```shell
167
+
azd env set PRE_AUTHORIZED_CLIENT_IDS aebc6443-996d-45c2-90f0-388ff96faa56
168
+
```
169
+
160
170
Run this azd command to provision the function app, with any required Azure resources, and deploy your code:
161
171
162
172
```shell
@@ -169,30 +179,14 @@ You can opt-in to a VNet being used in the sample. To do so, do this before `azd
169
179
azd env set VNET_ENABLED true
170
180
```
171
181
172
-
Additionally, [API Management](https://aka.ms/mcp-remote-apim-auth) 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.
173
-
174
-
## Connect to your *remote* MCP server function app from a client
175
-
176
-
Your client will need a key in order to invoke the new hosted MCP endpoint, which will be of the form `https://<funcappname>.azurewebsites.net/runtime/webhooks/mcp`. 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`.
177
-
178
-
### Connect to remote MCP server in MCP Inspector
179
-
For MCP Inspector, you can include the key in the URL:
Additionally, [API Management](https://aka.ms/mcp-remote-apim-auth) can be used for improved security and policies over your MCP Server.
183
183
184
184
### Connect to remote MCP server in VS Code - GitHub Copilot
185
-
For GitHub Copilot within VS Code, you should instead set the key as the `x-functions-key` header in `mcp.json`, and you would just use `https://<funcappname>.azurewebsites.net/runtime/webhooks/mcp` for the URL. The following example uses an input and will prompt you to provide the key when you start the server from VS Code. Note [mcp.json](.vscode/mcp.json) has already been included in this repo and will be picked up by VS Code. Click Start on the server to be prompted for values including `functionapp-name` (in your /.azure/*/.env file) and `functions-mcp-extension-system-key` which can be obtained from CLI command above or API Keys in the portal for the Function App.
185
+
For GitHub Copilot within VS Code, you would just use `https://<funcappname>.azurewebsites.net/runtime/webhooks/mcp` for the URL. Note [mcp.json](.vscode/mcp.json) has already been included in this repo and will be picked up by VS Code. Click Start on the server to be prompted for values including `functionapp-name` (in your /.azure/*/.env file). The server is configured with buit-in MCP auth, so you'll be asked to login as well.
186
186
187
187
```json
188
188
{
189
189
"inputs": [
190
-
{
191
-
"type": "promptString",
192
-
"id": "functions-mcp-extension-system-key",
193
-
"description": "Azure Functions MCP Extension System Key",
194
-
"password": true
195
-
},
196
190
{
197
191
"type": "promptString",
198
192
"id": "functionapp-name",
@@ -202,10 +196,7 @@ For GitHub Copilot within VS Code, you should instead set the key as the `x-func
@@ -215,32 +206,6 @@ For GitHub Copilot within VS Code, you should instead set the key as the `x-func
215
206
}
216
207
```
217
208
218
-
For MCP Inspector, you can include the key in the URL: `https://<funcappname>.azurewebsites.net/runtime/webhooks/mcp?code=<your-mcp-extension-system-key>`.
219
-
220
-
For GitHub Copilot within VS Code, you should instead set the key as the `x-functions-key` header in `mcp.json`, and you would just use `https://<funcappname>.azurewebsites.net/runtime/webhooks/mcp` for the URL. The following example uses an input and will prompt you to provide the key when you start the server from VS Code:
221
-
222
-
```json
223
-
{
224
-
"inputs": [
225
-
{
226
-
"type": "promptString",
227
-
"id": "functions-mcp-extension-system-key",
228
-
"description": "Azure Functions MCP Extension System Key",
You can run the `azd up`command as many times as you need to both provision your Azure resources and deploy code updates to your functionapp.
@@ -256,6 +221,15 @@ When you're done working with your function app and related resources, you can u
256
221
azd down
257
222
```
258
223
224
+
## Troubleshooting
225
+
226
+
| Error | Solution |
227
+
|---|---|
228
+
| `deployment was partially successful` / `KuduSpecializer` restart during `azd up` | This is a transient error. Run `azd deploy` to retry just the deployment step. |
229
+
| Connection refused | Ensure Azurite is running (`docker run -p 10000:10000 -p 10001:10001 -p 10002:10002 mcr.microsoft.com/azure-storage/azurite`) |
230
+
| API version not supported by Azurite | Pull the latest Azurite image (`docker pull mcr.microsoft.com/azure-storage/azurite`) then restart Azurite and the app |
231
+
232
+
259
233
## Helpful Azure Commands
260
234
261
235
Once your application is deployed, you can use these commands to manage and monitor your application:
0 commit comments