How to build long-running MCP ... Note

How to build long-running MCP tools on Azure Functions

Customers building servers with Azure Functions and the MCP extension face challenges with tools that exceed client-imposed timeouts. Current MCP tools operate in a request/response model, which is unsuitable for multi-step or long-running operations. When tool calls take too long, clients time out, causing the agent to perceive a failure while the underlying task may continue. A new MCP Tasks extension aims to standardize asynchronous handling of long-running work. This extension allows servers to respond with a task handle, enabling clients to poll for status and manage the task lifecycle. However, the Tasks extension requires broad ecosystem support from both clients and SDKs. Until this is widely available, a pattern using Durable Functions can be implemented for long-running tasks. This pattern involves two exposed tools: one to start a task and another to retrieve its status. The starting tool returns an inline result if completed within a budget, or a workflow ID if still running. The status retrieval tool takes the workflow ID and reports the task's current state, including a recommended polling interval. With the Tasks extension, the model will simplify as clients will directly manage task lifecycles, eliminating the agent's need to manage identifiers like workflow IDs. Developers are encouraged to try the provided Durable Functions sample.