---
title: handlers
sidebarTitle: handlers
---

# `fastmcp.server.tasks.handlers`


SEP-1686 task execution handlers.

Handles queuing tool/prompt/resource executions to Docket as background tasks.


## Functions

### `handle_tool_as_task` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/tasks/handlers.py#L27" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
handle_tool_as_task(server: FastMCP, tool_name: str, arguments: dict[str, Any], task_meta: dict[str, Any]) -> mcp.types.CallToolResult
```


Handle tool execution as background task (SEP-1686).

Queues the user's actual function to Docket (preserving signature for DI),
stores raw return values, converts to MCP types on retrieval.

**Args:**
- `server`: FastMCP server instance
- `tool_name`: Name of the tool to execute
- `arguments`: Tool arguments
- `task_meta`: Task metadata from request (contains ttl)

**Returns:**
- Task stub with task metadata in _meta


### `handle_prompt_as_task` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/tasks/handlers.py#L137" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
handle_prompt_as_task(server: FastMCP, prompt_name: str, arguments: dict[str, Any] | None, task_meta: dict[str, Any]) -> mcp.types.GetPromptResult
```


Handle prompt execution as background task (SEP-1686).

Queues the user's actual function to Docket (preserving signature for DI).

**Args:**
- `server`: FastMCP server instance
- `prompt_name`: Name of the prompt to execute
- `arguments`: Prompt arguments
- `task_meta`: Task metadata from request (contains ttl)

**Returns:**
- Task stub with task metadata in _meta


### `handle_resource_as_task` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/tasks/handlers.py#L244" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
handle_resource_as_task(server: FastMCP, uri: str, resource, task_meta: dict[str, Any]) -> mcp.types.ServerResult
```


Handle resource read as background task (SEP-1686).

Queues the user's actual function to Docket.

**Args:**
- `server`: FastMCP server instance
- `uri`: Resource URI
- `resource`: Resource or ResourceTemplate object
- `task_meta`: Task metadata from request (contains ttl)

**Returns:**
- ServerResult with ReadResourceResult stub

