Enables integration with GitHub Copilot in VS Code, allowing Copilot to interact with the MCP server to save and retrieve code snippets.
Mentions availability of a .NET/C# version of the same MCP server implementation for Azure Functions.
Mentions availability of a Node.js/TypeScript version of the same MCP server implementation for Azure Functions.
Provides a remote MCP server implementation using Python and Azure Functions, allowing for snippet storage and retrieval from Azure Blob Storage.
Getting Started with Remote MCP Servers using Azure Functions (Python)
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.
If you're looking for this sample in more languages check out the .NET/C# and Node.js/TypeScript versions.
Below is the architecture diagram for the Remote MCP Server using Azure Functions:
Prerequisites
- Python version 3.11 or higher
- Azure Functions Core Tools >=
4.0.7030
- Azure Developer CLI
- To use Visual Studio Code to run and debug locally:
Prepare your local environment
An Azure Storage Emulator is needed for this particular sample because we will save and get snippets from blob storage.
- Start Azurite
Note if you use Azurite coming from VS Code extension you need to run
Azurite: Start
now or you will see errors.
Run your MCP Server locally from the terminal
- Change to the src folder in a new terminal window:
- Install Python dependencies:
Note it is a best practice to create a Virtual Environment before doing the
pip install
to avoid dependency issues/collisions, or if you are running in CodeSpaces. See Python Environments in VS Code for more information.
- Start the Functions host locally:
Note by default this will use the webhooks route:
/runtime/webhooks/mcp/sse
. Later we will use this in Azure to set the key on client/host calls:/runtime/webhooks/mcp/sse?code=<system_key>
Connect to the local MCP server from a client/host
VS Code - Copilot agent mode
- Add MCP Server from command palette and add URL to your running Function app's SSE endpoint:
- List MCP Servers from command palette and start the server
- In Copilot chat agent mode enter a prompt to trigger the tool, e.g., select some code and enter this prompt
- When prompted to run the tool, consent by clicking Continue
- When you're done, press Ctrl+C in the terminal window to stop the Functions host process.
MCP Inspector
- In a new terminal window, install and run MCP Inspector
- 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)
- Set the transport type to
SSE
- Set the URL to your running Function app's SSE endpoint and Connect:
Note this step will not work in CodeSpaces. Please move on to Deploy to Remote MCP.
- List Tools. Click on a tool and Run Tool.
Verify local blob storage in Azurite
After testing the snippet save functionality locally, you can verify that blobs are being stored correctly in your local Azurite storage emulator.
Using Azure Storage Explorer
- Open Azure Storage Explorer
- In the left panel, expand Emulator & Attached → Storage Accounts → (Emulator - Default Ports) (Key)
- Navigate to Blob Containers → snippets
- You should see any saved snippets as blob files in this container
- Double-click on any blob to view its contents and verify the snippet data was saved correctly
Using Azure CLI (Alternative)
If you prefer using the command line, you can also verify blobs using Azure CLI with the storage emulator:
This verification step ensures your MCP server is correctly interacting with the local storage emulator and that the blob storage functionality is working as expected before deploying to Azure.
Deploy to Azure for Remote MCP
Run this azd command to provision the function app, with any required Azure resources, and deploy your code:
You can opt-in to a VNet being used in the sample. To do so, do this before azd up
Additionally, API Management can be used for improved security and policies over your MCP Server, and App Service built-in authentication can be used to set up your favorite OAuth provider including Entra.
Connect to your remote MCP server function app from a client
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 or the CLI (az functionapp keys list --resource-group <resource_group> --name <function_app_name>
). Obtain the system key named mcp_extension
.
Connect to remote MCP server in MCP Inspector
For MCP Inspector, you can include the key in the URL:
Connect to remote MCP server in VS Code - GitHub Copilot
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/sse
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 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.
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>
.
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/sse
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:
Redeploy your code
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 function app.
Note
Deployed code files are always overwritten by the latest deployment package.
Clean up resources
When you're done working with your function app and related resources, you can use this command to delete the function app and its related resources from Azure and avoid incurring any further costs:
Helpful Azure Commands
Once your application is deployed, you can use these commands to manage and monitor your application:
Source Code
The function code for the get_snippet
and save_snippet
endpoints are defined in the Python files in the src
directory. The MCP function annotations expose these functions as MCP Server tools.
Here's the actual code from the function_app.py file:
Note that the host.json
file also includes a reference to the experimental bundle, which is required for apps using this feature:
Next Steps
- Add API Management to your MCP server (auth, gateway, policies, more!)
- Add built-in auth to your MCP server
- Enable VNET using VNET_ENABLED=true flag
- Learn more about related MCP efforts from Microsoft
This server cannot be installed
A template for building and deploying custom remote MCP servers on Azure Functions with Python, allowing for saving and retrieving snippets with built-in security using keys and HTTPS.
- Prerequisites
- Prepare your local environment
- Run your MCP Server locally from the terminal
- Connect to the local MCP server from a client/host
- Verify local blob storage in Azurite
- Deploy to Azure for Remote MCP
- Connect to your remote MCP server function app from a client
- Redeploy your code
- Clean up resources
- Helpful Azure Commands
- Source Code
- Next Steps
Related MCP Servers
- -securityFlicense-qualityA Python-based MCP server that dynamically fetches plugin definitions from SuperiorAPIs and auto-generates tool functions based on OpenAPI schemas, enabling seamless integration with API services.Last updated -Python
- -securityAlicense-qualityA cloud-based custom MCP server using Azure Functions that enables saving and retrieving code snippets with secure communication through keys, HTTPS, OAuth, and network isolation options.Last updated -36MIT License
- -securityAlicense-qualityA template repository for creating custom Model Context Protocol (MCP) servers in Python that can be integrated with applications like Claude Desktop or Cursor.Last updated -5PythonMIT License
- -securityAlicense-qualityThis project builds a read-only MCP server. For full read, write, update, delete, and action capabilities and a simplified setup, check out our free CData MCP Server for Azure Data Catalog (beta): https://www.cdata.com/download/download.aspx?sku=GNZK-V&type=betaLast updated -MIT License