As organizations embrace agentic AI, the choice of cloud platform becomes crucial. Microsoft Azure stands out with its comprehensive suite of AI services, serverless options, and developer resources, making it well-suited for hosting Model Context Protocol (MCP) servers. With strong support for frameworks such as Semantic Kernel and a resilient cloud infrastructure, Azure empowers teams to develop and scale agentic solutions efficiently.
Integrating with the Azure Ecosystem
MCP on Azure excels due to its smooth connectivity with other Azure services, streamlining development, deployment, and management tasks.
Azure Functions for Serverless MCP
Azure Functions are ideal for hosting MCP tool endpoints, offering automatic scaling and pay-per-use compute thanks to their serverless, event-driven architecture.
Azure AI and Semantic Kernel
Agents built with Microsoft's Semantic Kernel are built for extensibility. MCP enables Semantic Kernel agents to find and use external tools on Azure, advancing from basic plugins to a flexible, service-driven framework.
Example: A Serverless MCP Tool on Azure
Here’s a hands-on Python example, based on Imaginarium Dev’s post, for building a basic `GetOrderStatus` tool with Azure Functions.
Part 1: The Azure Function MCP Endpoint
This Python code sets up an Azure Function as our tool server, handling HTTP POST requests sent to the `/api/tools/call` route.
# function_app.py (for Azure Functions)
import azure.functions as func
import logging
import json
app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)
# Mock tool implementation
def get_order_status(order_id: str):
return {"orderId": order_id, "status": "Shipped", "estimatedDelivery": "2025-10-12"}
TOOL_REGISTRY = {
"GetOrderStatus": get_order_status
}
@app.route(route="tools/call")
def call_tool(req: func.HttpRequest) -> func.HttpResponse:
logging.info('MCP tool call received.')
try:
req_body = req.get_json()
tool_name = req_body.get('tool_name')
params = req_body.get('parameters', {})
tool_func = TOOL_REGISTRY.get(tool_name)
if tool_func:
result = tool_func(**params)
return func.HttpResponse(json.dumps({'result': result}), mimetype="application/json")
else:
return func.HttpResponse("Tool not found", status_code=404)
except ValueError:
return func.HttpResponse("Invalid request body", status_code=400)
Part 2: The Semantic Kernel Agent Client
This client code shows how an agent using Semantic Kernel would invoke our Azure Function endpoint when a tool is required.
# agent_client.py
import requests
import os
# Your Azure Function URL would go here
AZURE_FUNCTION_URL = os.environ.get("MCP_FUNCTION_URL")
def invoke_mcp_tool(tool_name: str, **kwargs):
"""Simulates a Semantic Kernel function calling an external tool."""
payload = {
"tool_name": tool_name,
"parameters": kwargs
}
try:
response = requests.post(f"{AZURE_FUNCTION_URL}/api/tools/call", json=payload)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
return {"error": str(e)}
# --- Agent's simulated run ---
prompt = "Can you check the status for order #12345?"
# (LLM planner decides to call the GetOrderStatus tool)
tool_result = invoke_mcp_tool("GetOrderStatus", order_id="12345")
print(tool_result)
Azure: A Robust Foundation for Agentic AI
By integrating the standardized MCP pattern with Azure’s scalable serverless infrastructure and built-in AI frameworks, developers can create advanced, enterprise-grade agentic systems. This method delivers the flexibility, security, and performance required to transition AI agents from early prototypes to essential business solutions.