Host your MCP servers on Azure Container Apps
If you're working with AI agents, LLM tools, or building custom extensions for modern AI workflows, you've probably heard of MCP the Model Context Protocol. But what exactly is it, and how can you run your own MCP server in the cloud?
In this article, we’ll break it all down in simple terms and walk through a real-world example: building and deploying a weather server using MCP, FastAPI, and Azure Container Apps.
Now, let’s understand what MCP actually is and how it fits into the AI tooling ecosystem.
What is MCP?
MCP (Model Context Protocol) is a way for AI tools (clients) to connect with external tools or services (servers).
It follows a simple client-server model:
Clients are AI applications (like chat agents or developer tools) that need extra capabilities.
Servers are where those capabilities live like a weather tool, a GitHub integration, or a web search function.
Instead of hardcoding all features into the AI tool itself, MCP lets clients dynamically connect to external, pluggable servers that expose tools in a standard way.
This approach makes AI systems modular, extensible, and interoperable just like plugins for a browser or IDE.
Now, let’s look at why Azure Container Apps is the right place to run these servers in the cloud.
Why Deploy MCP Servers to Azure Container Apps?
Once you have an MCP server that exposes useful tools, the next step is to make it accessible to your AI clients like GitHub Copilot or Claude Desktop over the internet.
To do that reliably, securely, and at scale, Azure Container Apps is an ideal platform.
No Infrastructure to Manage: Run containers without handling servers or VMs.
Automatic Scaling: Scale up or down automatically based on traffic.
Environment-Based Secrets: Securely pass API keys and configs via environment variables.
Public, Secure Endpoints: Instantly get an HTTPS URL for remote client access.
Azure Container Apps gives us a scalable, public, and secure environment but to actually communicate with clients like GitHub Copilot or Claude, our MCP server needs to support a web-compatible transport layer.
That’s where Server-Sent Events (SSE) comes in.
What is the SSE Transport Layer?
SSE is a web-friendly protocol that allows a server to push real-time updates to a client over a single HTTP connection.
Here’s how it fits into MCP:
The client (e.g. VS Code) opens a long-lived HTTP connection to your /sse endpoint.
The server sends tool outputs or messages back through that connection.
Client inputs (like tool calls) are POSTed to a /messages endpoint making this a simple, two-part interaction.
Prepare and Deploy Your MCP Server:
We’ll now deploy a remote MCP server using SSE transport and API key authentication.
Clone the Project Repository:
Understand the Application Structure:
Before deploying, take a quick look at the key files:
weather.py Defines two tools: get_alerts() and get_forecast() using the National Weather Service API.
main.py Wraps the MCP tools in a FastAPI app that exposes an /sse endpoint and supports SSE transport.
api_key_auth.py Secures the API using x-api-key authentication.
Docketfile - Builds and runs the app in a container using Python 3.13 and the uv package manager.
Set Your API Key:
The server uses an environment variable called API_KEYS to control access. You can pass a single key or a comma-separated list.
When deploying, you’ll provide this securely to the container no need to hardcode it in your source code.
Build and Deploy with Azure Container Apps:
Once you're ready, run the following command from the root of your project directory:
This single command will:
Build the container image using the Dockerfile in the repository
Push and deploy the image to Azure Container Apps
Inject your API keys into the container using the --env-vars flag
Once the deployment completes, the Azure CLI will return a public HTTP URL this is the endpoint your MCP clients (like VS Code) will use to connect to your server.
Connect the MCP Server in Visual Studio Code:
Once your server is deployed, the next step is to connect it as a remote MCP server inside Visual Studio Code.
Create or Update mcp.json
In your workspace, create a .vscode/mcp.json file (if it doesn’t exist already) and paste the following configuration:
This tells VS Code to:
Prompt you for the API key when starting the server
Attach it as an x-api-key header in each request to your MCP server
Start the Server:
Inside the mcp.json, you'll see a Start button next to your server entry. Click it to launch the connection.
VS Code will prompt you to enter the API key use one of the keys you set in the API_KEYS environment variable during deployment.
Once connected, the server is ready to handle requests from your AI agent.
Interact Through GitHub Copilot Chat:
Now open GitHub Copilot Chat in Agent mode:
Switch the chat mode to Agent
Ask a question like:
The Copilot agent will call the get_forecast tool exposed by your MCP server, and you’ll get a real, live weather report based on data from the U.S. National Weather Service.
This completes your remote MCP server setup running in the cloud, secured with API keys, and fully connected to your development tools.
Conclusion:
In this guide, we walked through how to host a remote MCP server using Azure Container Apps a scalable, secure, and cost-effective way to serve tools to AI clients like GitHub Copilot.
If you found this useful and want to stay updated on more content around AI and automation, follow me on LinkedIn.
Web3 Marketing | Frontend & Backend Expert | AI Tech Memes, Growth & Marketing
4mowhat an article Aman Panjwani 👏