MCP Server - FastAPI on Azure App Service

by learntocloud

195 downloads Not rated yet MIT license
GitHub

About

# MCP Server - FastAPI on Azure App Service This is a Python implementation of the MCP (Model Context Protocol) server using FastAPI and deployed to Azure App Service, providing multiplication, temperature conversion, and weather tools. ## 🎯 For CTF Users (Quick Start) ### Get Your API Key Register for an API key with…

Details

License
MIT license

Explore

- ✅ No hardcoded secrets - Uses Azure Managed Identity
- ✅ Rate limiting - Prevents abuse at registration and API levels
- ✅ API key lifecycle - Activate/deactivate without deletion
- ✅ Usage tracking - Monitor API key usage patterns
- ✅ Audit logging - Comprehensive logging of auth attempts
- ✅ JSONRPC compliance - Proper error formats for MCP clients

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name MCP Server - FastAPI on Azure App Service
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

- Python 3.11+
- uv for faster dependency management and virtual environment creation
- Node.js & npm (for running MCP Inspector)

API_KEY=$(curl -s -X POST https://your-mcp-server.azurewebsites.net/register \
-H "Content-Type: application/json" \
-d '{"email":"[email protected]","project_name":"CTF Infrastructure"}' \
| jq -r '.api_key')

1. Create a virtual environment:

cd src
uv venv

source .venv/bin/activate # On macOS/Linux

uvicorn main:app --reload

MCP_AUTH_TOKEN="test_token_local_dev" uvicorn main:app --reload

The server will start on http://localhost:8000 by default.

- Azure CLI installed (az)
- Azure Developer CLI installed (azd)
- Azure subscription

1. Login to Azure:

az login
azd auth login

2. Deploy using Azure Developer CLI:


After deployment:

1. Check the application health: https://<your-app>.azurewebsites.net/health
2. View available tools: https://<your-app>.azurewebsites.net/
3. Test registration: https://<your-app>.azurewebsites.net/register
4. Monitor logs in Azure Portal or using Azure CLI

The MCP endpoint will be available at:


https://<your-app>.azurewebsites.net/mcp-server/mcp/

"Missing authorization header"
- Include Authorization: Bearer sk_your_key header
- Check that your API key starts with sk_

"Invalid authentication token"
- Verify your API key is correct
- Check if the key has been deactivated
- Ensure the key hasn't expired (if expiration is enabled)

Check logs:

bash
az webapp log tail --name <app-name> --resource-group <rg-name>

SSH into container:
bash
az webapp ssh --name <app-name> --resource-group <rg-name>

Restart app:
bash
az webapp restart --name <app-name> --resource-group <rg-name>
```

curl -X POST https://your-mcp-server.azurewebsites.net/mcp-server/mcp/ \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "Authorization: Bearer sk_your_api_key_here" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "multiply",
"arguments": {"a": 5, "b": 10}
},
"id": 1
}'
``

- multiply - Multiply two numbers
-
celsius_to_fahrenheit - Convert Celsius to Fahrenheit
-
fahrenheit_to_celsius - Convert Fahrenheit to Celsius
-
get_alerts - Get US weather alerts by state
-
get_forecast` - Get weather forecast by coordinates

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "mcp server - fastapi on azure app service": {
            "mcp-server-learntocloud": {
                "command": "python",
                "args": [
                    "manage_api_keys.py",
                    "list"
                ]
            }
        }
    }
}

McpServers

{
    "mcp-server-learntocloud": {
        "command": "python",
        "args": [
            "manage_api_keys.py",
            "list"
        ]
    }
}

This is a Python implementation of the MCP (Model Context Protocol) server using FastAPI and deployed to Azure App Service, providing multiplication, temperature conversion, and weather tools.

🎯 For CTF Users (Quick Start)

Get Your API Key

Register for an API key with one simple command:

curl -X POST https://your-mcp-server.azurewebsites.net/register \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "project_name": "My CTF Solution",
    "github_repo": "yourusername/your-ctf-fork"
  }'

Response:

{
"api_key": "sk_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6",
"message": "API key created successfully! Save this key securely - it won't be shown again.",
"rate_limit": "1000 requests/hour",
"created": "2024-01-15T10:30:00Z"
}

⚠️ Important: Save your API key securely! It won't be shown again.

Use Your API Key

```bash

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.