What is Azure-MCP-Server?
Azure-MCP-Server is a FastAPI-based Model Context Protocol (MCP) server designed for Azure Container Apps, providing weather-related tools such as alerts and forecasts through a secure API-key-protected Server-Sent Events (SSE) interface.
How to use Azure-MCP-Server?
To use Azure-MCP-Server, clone the repository, set up the virtual environment, install dependencies, set your API key, and run the server. A sample Python client is included for command-line interaction.
Key features of Azure-MCP-Server?
- Provides weather alerts and forecasts via SSE.
- Secure API key authentication.
- Integration with MCP-compatible clients like Visual Studio Code.
Use cases of Azure-MCP-Server?
- Real-time weather alerts for specific US states.
- Weather forecasts based on geographic coordinates.
- Integration with custom scripts for automated weather data retrieval.
FAQ from Azure-MCP-Server?
- What programming language is used?
The server is built using Python 3.11 or later.
- How do I deploy it to Azure?
Use the Azure CLI command provided in the documentation to deploy the server to Azure Container Apps.
- What should I do if I encounter errors?
Check the troubleshooting section in the documentation for common issues and solutions.
Azure Container Apps remote MCP server example
This MCP server uses SSE transport and is authenticated with an API key.
Project Overview
This project is a FastAPI-based Model Context Protocol (MCP) server designed for Azure Container Apps. It provides weather-related tools (such as alerts and forecasts) via a secure, API-key-protected Server-Sent Events (SSE) interface. The server is intended for integration with MCP-compatible clients, such as Visual Studio Code or custom scripts.
Setup Instructions
- Clone the repository:
git clone https://github.com/KRVaghani/Azure-MCP-Server.git cd Azure-MCP-Server
- Install prerequisites:
- Python 3.11 or later
- uv
- Set up the virtual environment and dependencies:
uv venv uv sync
- Set the API key:
export API_KEYS=devkey # or your chosen key
- Run the server:
uv run fastapi dev main.py
Client Usage
A sample Python client (model_request_client.py
) is included for command-line interaction:
python model_request_client.py
- Enter your API key (default: devkey)
- Choose a tool:
get_alerts
(by US state) orget_forecast
(by latitude/longitude) - Enter the required parameters
- The server response will be displayed in your terminal
API Endpoints
/sse
(GET): Main SSE endpoint for MCP protocol communication. Requiresx-api-key
header./messages
(SSE): Used internally for message streaming (session-based).
Example curl Test
curl -H "x-api-key: devkey" http://localhost:8000/sse
Troubleshooting
- If you see
ModuleNotFoundError
, ensure your virtual environment is activated and dependencies are installed. - If the client hangs, check that the server is running and the API key matches.
- For pip issues in the venv, run:
python -m ensurepip --upgrade python -m pip install --upgrade pip
Contributing
Pull requests are welcome! Please open an issue first to discuss major changes.
License
MIT License (add LICENSE file if needed)
Running locally
Prerequisites:
- Python 3.11 or later
- uv
Run the server locally:
uv venv
uv sync
# linux/macOS
export API_KEYS=<AN_API_KEY>
# windows
set API_KEYS=<AN_API_KEY>
uv run fastapi dev main.py
VS Code MCP configuration (mcp.json):
{
"inputs": [
{
"type": "promptString",
"id": "weather-api-key",
"description": "Weather API Key",
"password": true
}
],
"servers": {
"weather-sse": {
"type": "sse",
"url": "http://localhost:8000/sse",
"headers": {
"x-api-key": "${input:weather-api-key}"
}
}
}
}
Deploy to Azure Container Apps
az containerapp up -g <RESOURCE_GROUP_NAME> -n weather-mcp --environment mcp -l westus --env-vars API_KEYS=<AN_API_KEY> --source .
If the deployment is successful, the Azure CLI returns the URL of the app. You can use this URL to connect to the server from Visual Studio Code.
If the deployment fails, try again after updating the CLI and the Azure Container Apps extension:
az upgrade
az extension add -n containerapp --upgrade