Skip to main content
Glama
Azure MCP Server on Azure Container Apps

Azure MCP Server on Azure Container Apps

by chikkujimmy

Azure MCP server on Azure Container Apps

A remote Model Context Protocol (MCP) server that lets Claude (or any MCP client) explore, monitor and - if you allow it - operate your own Azure resources, in plain language.

  • Deploy it to your own subscription with one button, the Azure portal, or Azure Cloud Shell - nothing to install locally.

  • Runs as a managed identity: no Azure keys anywhere. Azure RBAC decides what it can see and do.

  • Sign in with Microsoft Entra ID: add it to Claude with just the URL (or use an API key for simple clients).

  • Read-only by default: write actions (start/stop/restart, scale, tags) are off until you turn them on, and every one needs confirm=true and is audit-logged.

  • Generic: works with any resource type through Azure Resource Graph, Azure Monitor, Activity Log, Resource Health, Advisor and Cost Management.

flowchart LR
    U[You] --> C[Claude / VS Code / any MCP client]
    C -- "HTTPS + OAuth (Entra ID)<br/>or API key" --> S
    subgraph RG[Your resource group]
      S[Container App<br/>MCP server /mcp] --- MI[Managed identity]
      S -. logs .-> LA[Log Analytics]
    end
    S -- sign-in --> E[Microsoft Entra ID]
    MI -- "RBAC: Reader (+ optional write roles)" --> ARM[Azure Resource Manager<br/>Resource Graph · Monitor · Cost Management · Advisor]
    ARM --> R[(Your subscriptions<br/>and resources)]

Contents

Related MCP server: Azure SQL MCP Server

Tools

Tool

What it does

list_subscriptions

subscriptions the server can access

list_resource_groups

resource groups with location and tags

resource_graph_query

any KQL query over Azure Resource Graph (all resource types, across subscriptions)

get_resource

full JSON of any resource by ID (API version picked automatically)

list_metric_definitions / get_metrics

Azure Monitor metrics for any resource, with min/max/avg summary

activity_log

who did what, when (by subscription, resource group or resource)

resource_health

is a resource available, degraded or down - and why

advisor_recommendations

Azure Advisor cost / security / reliability / performance advice

cost_summary

month-to-date (or last month) cost by resource group, service, resource...

log_analytics_query

KQL over a Log Analytics workspace (only if LOG_ANALYTICS_WORKSPACE_ID is set)

Write tools (only with ALLOW_WRITE_ACTIONS=true, each needs confirm=true): vm_power_action (start / stop / deallocate / restart), restart_web_app, scale_container_app (min/max replicas), set_tags, remove_tags, resource_action (POST an allow-listed action such as restart on any resource).

Quick deploy

All three options use the prebuilt public image ghcr.io/chikkujimmy/mcp-server-azure-container-apps. You need an Azure subscription where you can create resources; assigning the identity's Reader role needs Owner or User Access Administrator.

Option 1 - Deploy to Azure button

Deploy to Azure

Creates a resource group with a user-assigned managed identity, a Log Analytics workspace, a Container Apps environment (Consumption, scale to zero) and the app with public HTTPS ingress, and gives the identity Reader on the subscription (untick Assign Reader On Subscription to do it yourself, e.g. per resource group).

  1. Leave Auth Mode = apikey for the first deployment (the API key is generated for you).

  2. After it finishes, open the deployment's Outputs: mcpUrl is your server URL, entraRedirectUri is what the Entra app needs.

  3. The API key is in the Container App → Security → Secrets → mcp-api-key (show value).

  4. For Claude, switch to Entra ID: create the app registration (docs/entra-app.md), then redeploy the same template with Auth Mode = entra, the Entra Client Id and Entra Client Secret (and ideally Allowed Users). The template then also creates a small storage account that keeps sign-ins across restarts.

Template source: infra/main.bicep (compiled to infra/azuredeploy.json).

Option 2 - Azure Cloud Shell (one command, does Entra too)

Open Azure Cloud Shell (Bash) and run:

git clone https://github.com/chikkujimmy/mcp-server-azure-container-apps.git
cd mcp-server-azure-container-apps
bash deploy/cloudshell-deploy.sh --auth entra --location eastus

It deploys the template, creates and configures the Entra app registration (redirect URI, mcp.access scope, v2 tokens, client secret), restricts sign-in to you (ALLOWED_USERS), and prints the MCP URL. Secrets are kept in ~/.azure-mcp/<prefix>.secrets (mode 600), never printed. Useful options:

Option

Meaning

--reader-scope subscription|none|rg1,rg2

where the identity gets Reader (default: the subscription)

--subscriptions <id,id>

limit the server to these subscriptions

--allow-writes

register the write tools

--allowed-users <list>

who may sign in (emails / object IDs)

--auth apikey

API-key mode instead of Entra

--min-replicas 1

keep one replica warm (no cold starts, costs more)

Run bash deploy/cloudshell-deploy.sh --help for all options. Re-run it any time to change settings.

Option 3 - Azure portal, click by click

docs/deploy-portal.md walks through every screen: resource group, managed identity, Reader role, Container App with the GHCR image, secrets, and the switch to Entra ID.

Subscriptions and RBAC

The server sees exactly what its managed identity is allowed to see:

  • Reader on a subscription or resource group - all read tools, including cost data.

  • Log Analytics Reader on a workspace - log_analytics_query.

  • Write roles only when write actions are on, scoped as narrowly as possible: Virtual Machine Contributor, Website Contributor, Container Apps Contributor, Tag Contributor - avoid Contributor/Owner.

  • AZURE_SUBSCRIPTION_IDS optionally narrows it to a list of subscriptions.

Least-privilege table and az role assignment commands: docs/rbac.md.

Authentication

There is no unauthenticated mode for a public endpoint: the server refuses to start without AUTH_MODE (none is accepted only when listening on 127.0.0.1 for local development).

Microsoft Entra ID (AUTH_MODE=entra) - recommended

The server is an OAuth 2.1 authorization server for MCP clients (protected-resource metadata, dynamic client registration / client ID metadata documents, PKCE) and hands the actual sign-in to Entra ID. MCP clients therefore need only the URL. You need a single-tenant app registration with:

  • redirect URI (Web): https://<your-app-url>/auth/callback

  • Expose an API: Application ID URI api://<client-id>, scope mcp.access

  • manifest: requestedAccessTokenVersion: 2

  • a client secret

Step by step: docs/entra-app.md (the Cloud Shell script does it for you). Azure calls still run as the managed identity, so restrict who can sign in: ALLOWED_USERS and/or Assignment required on the Enterprise application.

API key (AUTH_MODE=apikey)

Clients send Authorization: Bearer <key>. The key must be 32+ characters and is compared in constant time. Good for VS Code, Claude Code, scripts and testing. Claude.ai / Claude Desktop custom connectors expect OAuth, so use Entra for those.

Connect Claude

Claude.ai and Claude Desktop (custom connectors; availability depends on your Claude plan):

  1. Settings → Connectors → Add custom connector.

  2. Name: Azure; URL: your MCP URL, e.g. https://azmcp-mcp.<something>.<region>.azurecontainerapps.io/mcp. Leave the advanced OAuth client ID / secret empty.

  3. Add → Connect → sign in with your Microsoft account → accept the consent screen.

  4. In a chat, enable the connector from the tools menu and ask away.

(Team/Enterprise: an owner adds the connector under organization settings first.) If the first connect times out, the app may be waking from zero - try again, or set min replicas to 1.

VS Code, Claude Code and other clients

VS Code (.vscode/mcp.json) - Entra mode, VS Code handles the sign-in:

{ "servers": { "azure": { "type": "http", "url": "https://<your-app-url>/mcp" } } }

API-key mode:

{
  "servers": {
    "azure": {
      "type": "http",
      "url": "https://<your-app-url>/mcp",
      "headers": { "Authorization": "Bearer ${input:azure-mcp-key}" }
    }
  },
  "inputs": [ { "id": "azure-mcp-key", "type": "promptString", "description": "Azure MCP API key", "password": true } ]
}

Claude Code: claude mcp add --transport http azure https://<your-app-url>/mcp (then /mcp to sign in), or add --header "Authorization: Bearer <key>" in API-key mode.

Example prompts

  • List all VMs that are stopped but not deallocated. (still billed for compute)

  • Which resources cost the most this month?

  • Show the CPU of my App Service over the last 24 hours.

  • Who deleted something in resource group X yesterday?

  • What does Azure Advisor recommend for cost?

  • Is anything in my subscription unhealthy right now?

  • Find every resource without an owner tag.

  • Restart container app Y. (write actions on - Claude asks you to confirm first)

  • Scale container app Y to 0-2 replicas and tag it env=demo. (write actions on)

Write actions

Off by default. Turn them on with ALLOW_WRITE_ACTIONS=true (template parameter Allow Write Actions, or --allow-writes) and give the identity a role that permits the action.

  • Every write tool requires confirm=true; without it nothing is sent to Azure.

  • Tools carry MCP annotations (readOnlyHint=false, destructiveHint where relevant) so clients ask you before running them.

  • resource_action only accepts actions listed in WRITE_ACTION_ALLOWLIST (default start,stop,restart).

  • Each write is logged as one JSON line (write_action: who, what, parameters, outcome, time) in the container log / Log Analytics.

  • RBAC is the real boundary: without the role, Azure refuses the call no matter what.

Configuration reference

Env var

Default

Meaning

AUTH_MODE

(required)

entra or apikey (none only on 127.0.0.1)

MCP_API_KEY

API key, 32+ characters (apikey mode)

ENTRA_TENANT_ID, ENTRA_CLIENT_ID, ENTRA_CLIENT_SECRET

Entra app registration (entra mode)

JWT_SIGNING_KEY

32+ random characters; signs the server's own tokens (entra mode); keep stable

ENTRA_SCOPE

mcp.access

scope name exposed by the app registration

ALLOWED_USERS

(anyone who can sign in)

comma-separated emails / UPNs / object IDs

OAUTH_STATE_STORAGE_ACCOUNT

storage account for sign-in state (survives restarts)

OAUTH_ALLOWED_REDIRECT_URIS

Claude, VS Code, localhost

extra client redirect URIs (* wildcards)

PUBLIC_BASE_URL

the Container App URL

set when using a custom domain

AZURE_CLIENT_ID

client ID of the user-assigned managed identity

AZURE_SUBSCRIPTION_IDS

(all visible)

comma-separated allow-list of subscriptions

ALLOW_WRITE_ACTIONS

false

register the write tools

WRITE_ACTION_ALLOWLIST

start,stop,restart

actions resource_action may POST

LOG_ANALYTICS_WORKSPACE_ID

enables log_analytics_query

MAX_ROWS

200

row cap for list-style results

DISABLED_TOOL_MODULES

comma-separated tool modules to skip (e.g. insights)

LOG_LEVEL

INFO

Security notes

  • Public endpoint, always authenticated. Only /healthz is open (it returns {"status":"ok"} and nothing else).

  • Azure access = the managed identity's roles. Start with Reader; add write roles narrowly. Everyone allowed to sign in shares those permissions, so use ALLOWED_USERS and/or Assignment required.

  • No secrets in the image or repo. Secrets live in Container Apps secrets; Azure access uses the managed identity.

  • Read-only by default, confirm=true and an action allow-list for writes, JSON audit log for every write.

  • Resource IDs are validated (format, no path tricks, allowed subscriptions) before any Azure call; errors are returned as short messages without stack traces.

  • Prompt injection: resource names, tags and log lines are data from your environment and can contain text aimed at the model. Keep writes off unless you need them, and read the confirmation prompts.

  • Rotate the Entra client secret before it expires; rotate the API key by updating the secret and restarting the revision.

  • Want it off the internet? Container Apps supports internal ingress in a VNet - then only clients inside your network can reach it (Claude.ai's cloud connectors can't).

Add your own tools

Drop a Python file in server/tools/ with a register(mcp) function - it is picked up automatically. See server/tools/README.md.

Cost

With the defaults (Consumption plan, 0.25 vCPU / 0.5 GiB, scale to zero) a personal setup usually stays within the Container Apps monthly free grant; Log Analytics charges for ingested logs beyond its free allowance (this server logs very little) and the optional storage account costs cents. Keeping one replica always on (minReplicas=1) costs a few dollars a month or more depending on region. Check the Azure pricing calculator for your region.

Teardown

Delete the resource group - that removes the app, environment, identity, logs and storage:

az group delete -n rg-azure-mcp

Also delete the Entra app registration (Entra ID → App registrations) and any role assignments you made outside the resource group (subscription → Access control (IAM) → Role assignments; orphaned ones show as Identity not found).

Local development

Optional - the server runs anywhere Python 3.11+ runs (Linux, macOS, Windows). With uv:

az login                                   # local runs use your Azure CLI sign-in instead of a managed identity
cd server
# stdio, for a local MCP client:
MCP_TRANSPORT=stdio uv run --with-requirements requirements.txt app.py
# or HTTP on localhost without auth:
MCP_HOST=127.0.0.1 AUTH_MODE=none uv run --with-requirements requirements.txt app.py   # http://127.0.0.1:8000/mcp

Without uv: python -m venv .venv, activate it, pip install -r server/requirements.txt, then python server/app.py with the same environment variables (on Windows set them with set / $env:).

Tests (Azure is mocked; no subscription needed):

pip install -r server/requirements.txt -r requirements-dev.txt
pytest -q

Build the image yourself: docker build -t azure-mcp . - or let the GitHub Actions workflow publish it to GHCR on every push to main and on v* tags.

License

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables Claude Desktop to use MCP tools hosted in Azure Container Apps, secured with Microsoft Entra ID sign-in, and provides hello and whoami tools to confirm connectivity and the signed-in Microsoft account.
      Apache 2.0
    • A
      license
      Not graded
      quality
      C
      maintenance
      Connects AI assistants directly to Azure so users can manage infrastructure, resources, costs, security, and identities through plain-English conversation using their own Entra ID/RBAC permissions.
      MIT