Model Context Protocol (MCP) servers allow AI agents to access external tools, data, and systems, greatly extending the capability and power of agents. When you’re ready to expose your MCP servers externally, within your organization or to the world, it’s important that the servers are run in a secure, scalable, and reliable environment. Azure Functions provides such a robust platform for hosting your remote MCP servers, offering high scalability with the Flex Consumption plan, built‑in authentication feature for Microsoft Entra and OAuth, and a serverless billing model.
The platform also offers two hosting options for added flexibility and convenience. The options allow for hosting of MCP servers built with Azure Functions MCP extension or the official MCP SDKs.
Azure Functions MCP Extension (GA)
The MCP extension allows you to build and host servers using Azure Functions programming model, i.e. using triggers and bindings. The MCP tool trigger allows you to focus on implementing tools you want to expose, instead of worrying about handling protocol and server logistics. The MCP extension launched as public preview back in April and is now generally available, with support for .NET, Java, JavaScript, Python, and Typescript.
New features in the extension
Support for streamable-http transport
Support for the newer streamable-http transport is added to the extension. Unless your client specifically requires the older Server-Sent Events (SSE) transport, you should use the streamable-http.
The two transports have different endpoints in the extension:
|
Transport |
Endpoint |
|
Streamable HTTP |
/runtime/webhooks/mcp |
|
Server-Sent Events (SSE) |
/runtime/webhooks/mcp/sse |
Defining server information
You can use the extensions.mcp section in host.json to define MCP server information.
{ "version": "2.0", "extensions": { "mcp": { "instructions": "Some test instructions on how to use the server", "serverName": "TestServer", "serverVersion": "2.0.0", "encryptClientState": true, "messageOptions": { "useAbsoluteUriForEndpoint": false }, "system": { "webhookAuthorizationLevel": "System" } } } }
Built-in server authentication and authorization
The built-in feature implements the requirements of the MCP authorization protocol, such as issuing 401 challenge and hosting the Protected Resource Metadata document. You can configure it to use identity providers like Microsoft Entra for server authentication. In addition to server authenticating, you can also leverage this feature to implement on-behalf-of (OBO) auth flows where the client invokes a tool that accesses some downstream services on-behalf-of the user.
Learn more about the built-in authentication and authorization feature.
Server authentication and OBO auth flow with GetCurrentUser tool.Mavin Build Plugin for Java
For Java applications, the Maven Build Plugin (version 1.40.0) parses and verifies MCP tool annotations during build time. This process automatically generates the correct MCP extension configuration, ensuring that the MCP tool defined by the user is properly set up. The build-time analysis is especially beneficial for Java apps, as it allows developers to utilize the MCP extension without concerns about increased cold start times.
We'll continuously enhance the plugin’s capabilities. Upcoming improvements, such as property type inference, will reduce manual configuration and make it even easier to use the McpToolTrigger.
Get started
Checkout the quickstarts to get an MCP extension server deployed in minutes:
|
C# (.NET) | |
|
Python | |
|
TypeScript (Node.js) | |
|
Java |
References
- Learn more about the MCP extension and tool trigger in official documentations.
Self‑hosted MCP server (public preview)
In addition to the MCP extension, Azure Functions also supports hosting MCP servers implemented with the official SDKs. This is a suitable option for teams that have existing SDK‑based servers or who favor the SDK experience over the Functions programming model. There is no need to modify your server code; you can lift and shift these MCP servers to Azure Functions— which is why they are termed self‑hosted.
The hosting capability supports the following features:
- Stateless servers that use the streamable-http transport. If you need your server to be stateful, consider using the Functions MCP extension for now.
- Servers implemented with Python, TypeScript, C#, or Java MCP SDK.
- Built-in server authentication and authorization like the MCP extension
Hosting requirement
Self-hosted MCP servers are deployed to the Azure Functions platform as custom handlers. You can think of custom handlers as lightweight web servers that receive events from the Functions host.
The only requirement for hosting the MCP server is a file called host.json. Add this file to your project root to tell Functions how to run the server. An example host.json for a Python server looks like:
{
"version": "2.0",
"configurationProfile": "mcp-custom-handler",
"customHandler": {
"description": {
"defaultExecutablePath": "python",
"arguments": ["path to main python script, e.g. hello.py"]
},
"port": "8000"
}
}
Get started
Check out quickstarts to get your self-hosted MCP server deployed in minutes:
|
C# (.NET) | |
|
Python | |
|
TypeScript (Node.js) | |
|
Java |
Coming soon! |
References
- Read the official documentation of self-hosted MCP servers and learn about integrations with Azure services like Foundry and API Center.
- For .NET developers - check out the overview of self-hosted MCP servers from the recent .NET Conference!
We’d love to hear from you!
Let us know your thoughts about hosting remote MCP server on Azure Functions. Does either of the options meet your needs? What other MCP features are you looking for? Let us know what you’d like us to prioritize next!