Integrations
Offers a similar MCP server implementation available in .NET/C# for developers preferring that ecosystem.
Supports running Azure Storage Emulator through Docker during local development for testing blob storage operations.
Supports development in GitHub Codespaces for a ready-to-use development environment without local setup.
Getting Started with Remote MCP Servers using Azure Functions (Node.js/TypeScript)
This is a quickstart template to easily build and deploy a custom remote MCP server to the cloud using Azure functions. 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.
Watch the video overview
If you're looking for this sample in more languages check out the .NET/C# and Python versions.
Below is the architecture diagram for the Remote MCP Server using Azure Functions:
Prerequisites
- Node.js version 18 or higher
- Azure Functions Core Tools >=
4.0.7030
- Azure Developer CLI
- To use Visual Studio Code to run and debug locally:
- Docker to run Azurite, the Azure Storage Emulator (optional)
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 AzuriteCopy
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
- Install dependenciesCopy
- Build the projectCopy
- Start the Functions host locally:Copy
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>
Use the local MCP server from within a client/host
VS Code - Copilot Edits
- Add MCP Server from command palette and add URL to your running Function app's SSE endpoint:Copy
- Select HTTP (Server-Sent-Events) for the type of MCP server to add.
- Enter the URL to your running function app's SSE endpoint
- Enter the server ID. (This can be any name you want)
- Choose if you want to run this in your User settings (available to all apps for you) or to your Workspace settings (available to this app, only)
- List MCP Servers from command palette and start the server. The previous step may have already started your local server. If so, you can skip this step.
- In Copilot chat agent mode enter a prompt to trigger the tool, e.g., select some code and enter this promptCopyCopyCopy
- When prompted to run the tool, consent by clicking Continue
- When you're done, press Ctrl+C in the terminal window to stop the
func.exe
host process, and List MCP Servers from command palette and stop the local server.
MCP Inspector
- In a new terminal window, install and run MCP InspectorCopy
- If you stopped your function app previously, start the Functions host locally:Copy
- 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:Copy
- List Tools. Click on a tool and Run Tool.
- When you're done, press Ctrl+C in the terminal window to stop the
func.exe
host process, and press Ctrl+C in the terminal window to stop the@modelcontextprotocol/inspector
host process.
Deploy to Azure for Remote MCP
Optionally, you can opt-in to a VNet being used in the sample. (If you choose this, do this before azd up
)
Run this azd command to provision the function app, with any required Azure resources, and deploy your code:
Note 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 set the key as the x-functions-key
header in mcp.json
, and you would use https://<funcappname>.azurewebsites.net/runtime/webhooks/mcp/sse
for the URL. The following example is from the mcp.json
file included in this repository and uses an input to prompt you to provide the key when you start the server from VS Code. Your mcp.json
file looks like this:
- Click Start on the server
remote-mcp-function
, inside themcp.json
file: - Enter the name of the function app that you created in the Azure Portal, when prompted by VS Code.
- Enter the
Azure Functions MCP Extension System Key
into the prompt. You can copy this from the Azure portal for your function app by going to the Functions menu item, then App Keys, and copying themcp_extension
key from the System Keys. - In Copilot chat agent mode enter a prompt to trigger the tool, e.g., select some code and enter this promptCopyCopyCopy
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:
Source Code
The function code for the getSnippet
and saveSnippet
endpoints are defined in the TypeScript files in the src
directory. The MCP function annotations expose these functions as MCP Server tools.
This shows the code for a few MCP server examples (get string, get object, save object):
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 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.
Related MCP Servers
- AsecurityAlicenseAqualityA MCP server for managing and storing code snippets in various programming languages, allowing users to create, list, and delete snippets via a standardized interface.Last updated -34JavaScriptMIT License
- -securityAlicense-qualityAn MCP server to create secure code sandbox environment for executing code within Docker containers.Last updated -69GoMIT License
- -securityFlicense-qualityA personal MCP server for securely storing and accessing API keys across projects using the macOS Keychain, letting AI assistants and applications retrieve credentials through natural language.Last updated -10TypeScript
- -securityAlicense-qualityAn MCP server for interacting with Azure. Contains some common Compute and Networking actions, and extensible to add many more.Last updated -PythonApache 2.0