Background task execution for FastMCP servers via the io.modelcontextprotocol/tasks extension (SEP-2663).
Actively maintained. Last release 4 days ago, commits in 24 of the last 26 weeks. A safe choice.
pip install fastmcp-tasksfastmcp-tasks
A complete implementation of background tasks for the Model Context Protocol — the io.modelcontextprotocol/tasks extension defined in SEP-2663.
The MCP tasks extension is a Final SEP, but as of this writing it ships in the ecosystem as a schema and a prose specification — no language SDK provides a working runtime for it. fastmcp-tasks is, to our knowledge, the first: a full server-side implementation of the protocol, built on the durable execution engine (docket) that FastMCP has run in production since v3. If you want to actually run MCP background tasks today, this is the implementation.
What background tasks are
Most tool calls are synchronous: the client sends tools/call and holds the request open until the tool returns. That breaks down for work that takes minutes or hours — a long analysis, a batch job, a slow external API. The tasks extension lets a server answer such a call immediately with a durable task handle, then run the work in the background while the client polls for completion on its own schedule.
The model is poll-based and stateless by construction, which is what makes it survive disconnects, server restarts, and load balancers:
- A client that supports tasks issues a normal
tools/callwith a per-request opt-in. - The server decides whether to run it as a task. If it does, it returns a
CreateTaskResultcarrying a server-generated task id — right away, before the work starts. - The client polls
tasks/getuntil the task reaches a terminal state, then reads the result inlined in the response. tasks/cancelrequests cancellation;tasks/updateanswers any input the task asks for mid-run.
The server owns the task's durable state, so the client can poll across independent requests — from any process, after a crash, through any replica — with no session affinity required.
Usage
Install it as the tasks extra on FastMCP:
uv pip install "fastmcp[tasks]"
Register the extension on your server and mark the tools that may run as tasks. The extension is where the backend is configured — point it at Redis for a distributed deployment, or leave it on the in-memory default for a single process:
from fastmcp import FastMCP
from fastmcp_tasks import TasksExtension
mcp = FastMCP("Analytics")
mcp.add_extension(TasksExtension(url="redis://localhost:6379/0"))
@mcp.tool(task=True)
async def analyze(dataset: str) -> str:
# Long-running work. The client gets a task handle immediately and
# polls for the result; this runs in a background worker.
...