As enterprises adopt agentic AI, the underlying cloud platform plays a critical role. Microsoft Azure, with its rich ecosystem of AI services, serverless computing, and developer tools, is a natural fit for deploying Model Context Protocol (MCP) servers. Microsoft's investment in frameworks like Semantic Kernel and its robust cloud infrastructure provides a powerful toolkit for building and scaling agentic applications.
Integrating with the Azure Ecosystem
The power of MCP on Azure comes from its seamless integration with other Azure services. This creates a cohesive environment for development, deployment, and management.
Azure Functions for Serverless MCP
Azure Functions are a perfect match for hosting MCP tool endpoints. Their serverless, event-driven nature means you only pay for compute when a tool is called, and they scale automatically to handle fluctuating demand from agents.
Azure AI and Semantic Kernel
Agents built with Microsoft's Semantic Kernel are designed to be extensible. MCP provides a standardized way for a Semantic Kernel-based agent to discover and consume external tools hosted on Azure, moving beyond simple plugins to a dynamic, service-oriented architecture.
Example: A Serverless MCP Tool on Azure
Here’s a practical example in Python, inspired by a post from Imaginarium Dev, showing how to create a simple `GetOrderStatus` tool hosted on an Azure Function.
Part 1: The Azure Function MCP Endpoint
This Python code defines an Azure Function that acts as our tool server. It listens for HTTP POST requests at the `/api/tools/call` endpoint.
# 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 simulates how an agent built with Semantic Kernel would make a call to our Azure Function endpoint after deciding a tool is needed.
# 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 combining the standardized MCP pattern with Azure's scalable, serverless infrastructure and its native AI frameworks, developers can build sophisticated, enterprise-ready agentic systems. This approach provides the flexibility, security, and performance needed to move AI agents from experimental prototypes to core business applications.