Lesson 2 of 5 Building Tool Ecosystems with MCP

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.

The anatomy of an MCP server. It declares tools, which are functions with JSON Schema inputs, resources, which are readable data addressed by URI, and prompts, which are reusable templates. A remote server uses the Streamable HTTP transport and authenticates clients with OAuth 2.0 or Microsoft Entra ID tokens. It can run on Azure Functions, Container Apps or App Service, and API Management can expose or front it.
One server can serve many kinds of client.
Spot the bug

An MCP tool that hides its results

Exam skills 2.3.2

Find the lines in this MCP Python SDK version 2 server that cause the problems described.

Log in to try this activity Interactive activities are free with an account.

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.

True or false

MCP servers on Azure Functions

Exam skills 2.3.2

Check how Azure Functions hosts MCP servers.

Log in to try this activity Interactive activities are free with an account.

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.

OptionCode requiredBest for
Azure FunctionsYes, function codeCustom tool logic, event-driven scale
Azure Logic Apps StandardLow code, workflow designerTools built from connectors and workflows
API Management (REST API as MCP)None, configurationExisting REST APIs with consistent policies
API Management in front of MCPNone, configurationGoverning servers hosted elsewhere
Sort into groups

Which host for the MCP tool?

Exam skills 2.3.2

Choose where each new MCP tool should be built.

Log in to try this activity Interactive activities are free with an account.
Worked example

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.

Check yourself

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.