Step by step guide to implement an Azure Function App as a remote MCP server, test it in GitHub Copilot in VS Code
Introduction
In the evolving landscape of AI-driven applications, the ability to seamlessly connect large language models (LLMs) with external tools and data sources is becoming a cornerstone of intelligent system design. Model Context Protocol (MCP) — a specification that enables AI agents to discover and invoke tools dynamically, based on context.
While MCP is powerful, implementing it from scratch can be daunting !!! That’s where Azure Functions comes in handy. With its event-driven, serverless architecture, Azure Functions now supports a preview extension for MCP, allowing developers to build remote MCP servers that are scalable, secure, and cloud-native.
Further, In VS Code, GitHub Copilot Chat in Agent Mode can connect to your deployed Azure Function App acting as an MCP server. This connection allows Copilot to leverage the tools and services exposed by your function app.
Why Use Azure Functions for MCP?
- Serverless Simplicity: Deploy MCP endpoints without managing infrastructure.
- Secure by Design: Leverage HTTPS, system keys, and OAuth via EasyAuth or API Management.
- Language Flexibility: Build in .NET, Python, or Node.js using QuickStart templates.
- AI Integration: Enable GitHub Copilot, VS Code, or other AI agents to invoke your tools via SSE endpoints.
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:
- Visual Studio Code
- Azure Functions extension
An storage emulator is needed when developing azure function app in VScode. you can deploy Azurite extension in VScode to meet this requirement.
Press enter or click to view image in full size
You can run the Azurite in VS Code as shown below.
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\Extensions\Microsoft\Azure Storage Emulator> .\azurite.exe
Press enter or click to view image in full size
alternatively, you can also run Azurite in docker container as shown below.
docker run -p 10000:10000 -p 10001:10001 -p 10002:10002 \
mcr.microsoft.com/azure-storage/azurite
For more information about setting up Azurite, visit Use Azurite emulator for local Azure Storage development | Microsoft Learn
Github Repositories
Following Github repos are needed to setup this PoC.
Repository for MCP server using Azure Function App
https://github.com/mafzal786/mcp-azure-functions-python.git
Repository for AI Foundry agent as MCP Client
https://github.com/mafzal786/ai-foundry-agent-with-remote-mcp-using-azure-functionapp.git
Clone the repository
Run the following command to clone the repository to start building your MCP server using Azure function app.
git clone https://github.com/mafzal786/mcp-azure-functions-python.git
Run the MCP server in VS Code
Once cloned. Open the folder in VS Code. Create a virtual environment in VS Code. Change directory to “src” in a new terminal window, install the python dependencies and start the function host locally as shown below.
cd src
pip install -r requirements.txt
func start
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>
Press enter or click to view image in full size
MCP Inspector
In a new terminal window, install and run MCP Inspector.
npx @modelcontextprotocol/inspector
Click to load the MCP inspector. Also provide the generated proxy session token.
http://127.0.0.1:6274/#resources
In the URL type and click “Connect”:
http://localhost:7071/runtime/webhooks/mcp/sse
Once connected, click List Tools under Tools and select “hello_mcp” tool and click “Run Tool” for testing as shown below.
Press enter or click to view image in full size
Select another tool such as get_stockprice and run it as shown below.
Press enter or click to view image in full size
Deploy Function App to Azure from VS Code
For deploying function app to azure from vs code, make sure you have Azure Tools extension enabled in VS Code. To learn more about Azure Tools extension, visit the following Azure Extensions
if your VS code environment is not setup for Azure development, follow Configure Visual Studio Code for Azure development with .NET — .NET | Microsoft Learn
Once Azure Tools are setup, sign in to Azure account with Azure Tools
Press enter or click to view image in full size
Once Sign-in is completed, you should be able to see all of your existing resources in the Resources view. These resources can be managed directly in VS Code.
Look for Function App in Resource, right click and click “Deploy to Function App”.
Press enter or click to view image in full size
If you already have it deployed, you will get the following pop-up. Click “Deploy”
Press enter or click to view image in full size
This will start deploying your function app to Azure. In VS Code, Azure tab will display the following.
Press enter or click to view image in full size
Once the deployment is completed, you can view the function app and all the tools in Azure portal under function app as shown below.
Press enter or click to view image in full size
Get the mcp_extension key from Functions → App Keys in Function App.
Press enter or click to view image in full size
This mcp_extension key would be needed in mcp.json file in VS code, if you would like to test the MCP server using Github Copilot in VS Code. Your entries in mcp.json file will look like as below for example.
{
"inputs": [
{
"type": "promptString",
"id": "functions-mcp-extension-system-key",
"description": "Azure Functions MCP Extension System Key",
"password": true
},
{
"type": "promptString",
"id": "functionapp-name",
"description": "Azure Functions App Name"
}
],
"servers": {
"remote-mcp-function": {
"type": "sse",
"url": "https://${input:functionapp-name}.azurewebsites.net/runtime/webhooks/mcp/sse",
"headers": {
"x-functions-key": "${input:functions-mcp-extension-system-key}"
}
},
"local-mcp-function": {
"type": "sse",
"url": "http://0.0.0.0:7071/runtime/webhooks/mcp/sse"
}
}
}
Test Azure Function MCP Server in MCP Inspector
Launch MCP Inspector and provide the Azure Function in MCP inspector URL. Provide authentication as shown below. Bearer token is mcp_extension key.
Testing an MCP server with GitHub Copilot
Testing an MCP server with GitHub Copilot involves configuring and utilizing the server within your development environment to provide enhanced context and capabilities to Copilot Chat.
Steps to Test an MCP Server with GitHub Copilot:
Ensure Agent Mode is Enabled:
Open Copilot Chat in Visual Studio Code and select “Agent” mode. This mode allows Copilot to interact with external tools and services, including MCP servers.
Add the MCP Server:
- Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P) and run the command MCP: Add Server.
Press enter or click to view image in full size
- Follow the prompts to configure the server. You can choose to add it to your workspace settings (creating a .vscode/mcp.json file) . Select HTTP or Server-Sent events
Press enter or click to view image in full size
Specify the URL and click Enter
Press enter or click to view image in full size
Provide a name of your choice
Press enter or click to view image in full size
Select scope as Global or workspace. I selected Workspace
Press enter or click to view image in full size
This will generate mcp.json file in .vscode or create a new entry if mcp.json already exists as shown below. Click Start to “start” the server. Also make sure your Azure function app is locally running with func start command.
Press enter or click to view image in full size
Now Type the prompt as shown below.
Press enter or click to view image in full size
Try another tool as below.
Press enter or click to view image in full size
VS code terminal output for reference.
Press enter or click to view image in full size
Testing an MCP server with Claude Desktop
Claude Desktop is a standalone AI application that allows users to interact with Claude AI models directly from their desktop, providing a seamless and efficient experience. you can download Claude desktop at Download Claude
In this article, I have added another tool to utilize to test your MCP server running in Azure Function app.
Modify claude_desktop_config.json with the following. you can find this file in window environment at C:\Users\<username>\AppData\Roaming\Claude
{ "mcpServers": { "my mcp": { "command": "npx", "args": [ "mcp-remote", "http://localhost:7071/runtime/webhooks/mcp/sse" ] } } }
Note: If claude_desktop_config.json does not exists, click on setting in Claude desktop under user and visit developer tab.
You will see you MCP server in Claude Desktop as shown below.
Press enter or click to view image in full size
Type the prompt such as “What is the stock price of Tesla” . After submitting, you will notice that it is invoking the tool “get_stockprice” from the MCP server running locally and configured in the .json earlier. Click Allow once or Allow always as shown below.
Following output will be displayed.
Press enter or click to view image in full size
Now lets try weather related prompt. As you can see, it has invoked “get_weatheralerts” tool from MCP server.
Press enter or click to view image in full size
Azure AI Foundry agent as MCP Client
Use the following Github repo to set up Azure AI Foundry agent as MCP client.
git clone https://github.com/mafzal786/ai-foundry-agent-with-remote-mcp-using-azure-functionapp.git
Open the code in VS code and follow the instructions mentioned in README.md file at Github repo. Once you execute the code, following output will show up in VS code.
Press enter or click to view image in full size
In this code, message is hard coded. Change the content to “what is weather advisory for Florida” and rerun the program. It will call get_weatheralerts tool and output will look like as below.
Press enter or click to view image in full size
Conclusion
The integration of Model Context Protocol (MCP) with Azure Functions marks a pivotal step in democratizing AI agent development. By leveraging Azure’s serverless architecture, developers can now build remote MCP servers that scale automatically, integrate seamlessly with other Azure services, and expose modular tools to intelligent agents like GitHub Copilot.
This setup not only simplifies the deployment and management of MCP servers but also enhances the developer experience — allowing tools to be invoked contextually by AI agents in environments like VS Code, GitHub Codespaces, or Copilot Studio[2]. Whether you’re building a tool to query logs, calculate metrics, or manage data, Azure Functions provides the flexibility, security, and scalability needed to bring your AI-powered workflows to life.
As the MCP spec continues to evolve, and GitHub Copilot expands its agentic capabilities, this architecture positions you to stay ahead — offering a robust foundation for cloud-native AI tooling that’s both powerful and future-proof.