Building MCP Servers on Azure Functions, Logic Apps and API Management
This lesson explains the three main Azure hosting approaches for MCP servers, which make a capability available to every MCP-capable agent through one standard interface, and when to choose each.
Learning outcomes
After completing this lesson, you will be able to:
- Describe the tools, resources and prompts an MCP server declares.
- Host a custom MCP server on Azure Functions.
- Expose workflows and existing APIs as MCP tools with Logic Apps and API Management.
Anatomy of an MCP server
An MCP server declares tools (functions with JSON Schema inputs), resources (readable data addressed by URI) and prompts (reusable templates). Remote servers use the Streamable HTTP transport and authenticate clients with OAuth 2.0 or Microsoft Entra ID tokens. The official MCP Python SDK provides a compact way to build one, which can run on Azure Functions, Container Apps or App Service. The example uses version 2 of the SDK, in which the server class is MCPServer (version 1 called it FastMCP). A typed return value becomes structured output, and an anticipated failure is raised as ToolError so that its message reaches the model; any other exception is reported to the client only as a generic tool error.
from mcp.server.mcpserver import MCPServer
from mcp.server.mcpserver.exceptions import ToolError
mcp = MCPServer("orders")
@mcp.tool()
def get_order_status(order_id: str) -> dict[str, str]:
'''Return status and expected delivery date for one order.'''
order = orders_db.get(order_id) # read-only lookup with the server's managed identity
if order is None:
raise ToolError(f"order_not_found: no order {order_id}")
return {"order_id": order_id, "status": order.status, "eta": order.eta.isoformat()}
if __name__ == "__main__":
mcp.run(transport="streamable-http", stateless_http=True)The following diagram shows what an MCP server declares and where it runs.

An MCP tool that hides its results
Azure Functions
Azure Functions hosts custom MCP servers in two ways. The MCP extension provides an MCP tool trigger: each function declares a tool name, description and properties, and the Functions host exposes an MCP endpoint that lists and invokes them, with authentication through the function app's keys or built-in authentication with Microsoft Entra ID. Alternatively, a server built with an MCP SDK is self-hosted on Functions. Functions suits custom logic, scales automatically and, on the Flex Consumption plan, integrates with virtual networks to reach private back ends.
MCP servers on Azure Functions
Azure Logic Apps and Azure API Management
Azure Logic Apps Standard can expose workflows as MCP tools, so an agent can trigger a workflow that uses any of the platform's connectors (for example, creating a record in a SaaS application or sending an approval) without writing code. Logic Apps suits integration tasks that are already workflow-shaped.
Azure API Management can expose a managed REST API as an MCP server: selected API operations become MCP tools, and API Management policies (JWT validation, rate limits, IP filtering, logging) apply to every call. Currently, MCP servers built from REST APIs support tools but not resources or prompts. API Management can also front an existing MCP server, such as one on Functions or Logic Apps, to add the same governance. The following table compares the options.
| Option | Code required | Best for |
|---|---|---|
| Azure Functions | Yes, function code | Custom tool logic, event-driven scale |
| Azure Logic Apps Standard | Low code, workflow designer | Tools built from connectors and workflows |
| API Management (REST API as MCP) | None, configuration | Existing REST APIs with consistent policies |
| API Management in front of MCP | None, configuration | Governing servers hosted elsewhere |
Which host for the MCP tool?
Three integration needs
An agent platform team must provide three MCP tools: lookups in an existing order REST API already managed in API Management; a credit-score calculation that does not exist yet; and creation of a case in a SaaS service management product for which a Logic Apps connector exists.
The order lookups are exposed by API Management as an MCP server with no new code. The credit-score calculation is new logic, so it is built as an MCP tool on Azure Functions. Case creation uses a Logic Apps Standard workflow with the connector, exposed as an MCP tool. API Management can then front the Functions and Logic Apps servers to apply the same authentication and logging.
How can an existing REST API be exposed as an MCP server without writing code?
Show answer
Through Azure API Management, which can present the REST API as MCP tools.
Exam Tips
Remember for the exam
- Existing REST API to MCP, no code: API Management.
- New custom tool logic: Azure Functions. Connector-based actions: Logic Apps Standard.
- API Management can govern MCP servers hosted elsewhere.