MCP Server Hosting
Overview
The Enterprise Kit provides two hosting patterns for deploying custom MCP servers into your Azure environment. Both include Bicep infrastructure modules, application scaffolding, and automatic integration with the Foundry Toolbox ecosystem. Once deployed, servers are registered in the Private Tool Catalog (API Center) and become available to agents through the Toolbox consumer endpoint.
Hosting Patterns
| Pattern | Platform | Best For | Key Features |
|---|---|---|---|
| Azure Functions | Flex Consumption | Event-driven, lightweight tools | FastMCP + SSE transport, @register_tool decorator, function key + Entra dual-auth, auto-scale to zero |
| Container Apps | Azure Container Apps | Stateful, VNet-isolated workloads | FastAPI + JSON-RPC 2.0 + SSE, sidecar pattern, VNet internal-only ingress, liveness/readiness probes, OTel to App Insights |
Infrastructure (Bicep Modules)
Three Bicep modules support MCP hosting:
| Module | Path | Resources Provisioned |
|---|---|---|
function-mcp.bicep | adapters/hosting/azure-functions/infra/ | Function App (Flex Consumption), Storage Account, App Insights, User-Assigned Managed Identity |
container-app-mcp.bicep | adapters/hosting/container-apps/infra/ | Container App, ACR, Container Apps Environment, Managed Identity, App Insights |
api-center.bicep | infra/bicep/modules/ | Azure API Center — Private Tool Catalog for MCP server discovery, RBAC, metadata schema |
Authentication (5 Foundry Methods)
The MCPAuthProvider in sdk-starters/python/mcp_auth_provider.py implements all five Foundry MCP authentication methods with automatic token caching (5-minute buffer) and Key Vault credential rotation:
| Method | Use Case | Environment |
|---|---|---|
| Key-Based | API key / PAT stored in Foundry project connection | Dev only |
| Entra Agent Identity | Per-agent scoped token with auto-request | All |
| Entra Project Managed Identity | Shared MI across all agents in project (recommended default) | All (recommended) |
| OAuth Identity Passthrough | Delegated user consent with retry flow | All |
| Unauthenticated | Public or VNet-isolated servers only | Dev only |
Production environments restrict auth to entra_project_mi and entra_agent_identity only (ZT-15).
Endpoint Resolution
The ToolboxEndpointResolver handles consumer vs. developer endpoint resolution with version pinning and APIM gateway URL rewriting:
| Endpoint Type | URL Pattern | Use Case |
|---|---|---|
| Consumer | {endpoint}/toolboxes/{name}/mcp?api-version=v1 | Production agents (uses default version) |
| Developer | {endpoint}/toolboxes/{name}/versions/{ver}/mcp?api-version=v1 | CI/CD testing with version pinning |
Deployment Workflow
- Write tools — Use the
@register_tooldecorator in either template - Deploy infrastructure — Run the appropriate Bicep module (Functions for lightweight, Container Apps for stateful/VNet-isolated)
- Register in catalog — Run
scripts/register-mcp-servers.pyto register in the Private Tool Catalog (API Center) - Wire to Toolbox — Configure in the agent's toolbox YAML with auth method and allowed tools
- Verify — Auth is auto-resolved by
MCPAuthProviderbased on connection config
Security Controls
MCP hosting is governed by ZT-15 (MCP Security):
- Transport: TLS 1.2+, VNet internal-only ingress, no CORS, POST-only (JSON-RPC 2.0), 1MB request limit
- Gateway (APIM): IP filtering (RFC 1918 only), rate limiting (60 RPM per tool, 200 RPM per agent), header sanitization, circuit breaker (5 consecutive failures)
- Authentication: Production restricted to Entra-based methods only
- Monitoring: OTel spans to App Insights, KQL fleet dashboard queries
Project Structure
| Path | Purpose |
|---|---|
adapters/hosting/azure-functions/ | Azure Functions MCP server template + Bicep |
adapters/hosting/container-apps/ | Container Apps MCP server template + Dockerfile + Bicep |
infra/bicep/modules/api-center.bicep | Private Tool Catalog (API Center) module |
sdk-starters/python/mcp_auth_provider.py | Unified MCP auth abstraction (5 methods) |
sdk-starters/python/toolbox_endpoint_resolver.py | Consumer vs. developer endpoint resolution |
scripts/register-mcp-servers.py | Catalog registration script |
Next Steps
- Review MCP Adapters — 7 pre-built adapters for enterprise systems
- Set up MCP Fleet Governance — Toolbox lifecycle, policies, and monitoring
- Configure Zero Trust Controls — ZT-07, ZT-12, ZT-15 for MCP security