# Source: https://gofastmcp.com/python-sdk/fastmcp-server-tasks-config.md

> ## Documentation Index
> Fetch the complete documentation index at: https://gofastmcp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# config

# `fastmcp.server.tasks.config`

TaskConfig for MCP SEP-1686 background task execution modes.

This module defines the configuration for how tools, resources, and prompts
handle task-augmented execution as specified in SEP-1686.

## Classes

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

Metadata for task-augmented execution requests.

When passed to call\_tool/read\_resource/get\_prompt, signals that
the operation should be submitted as a background task.

**Attributes:**

* `ttl`: Client-requested TTL in milliseconds. If None, uses server default.
* `fn_key`: Docket routing key. Auto-derived from component name if None.

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

Configuration for MCP background task execution (SEP-1686).

Controls how a component handles task-augmented requests:

* "forbidden": Component does not support task execution. Clients must not
  request task augmentation; server returns -32601 if they do.
* "optional": Component supports both synchronous and task execution.
  Client may request task augmentation or call normally.
* "required": Component requires task execution. Clients must request task
  augmentation; server returns -32601 if they don't.

**Methods:**

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

```python  theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
from_bool(cls, value: bool) -> TaskConfig
```

Convert boolean task flag to TaskConfig.

**Args:**

* `value`: True for "optional" mode, False for "forbidden" mode.

**Returns:**

* TaskConfig with appropriate mode.

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

```python  theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
supports_tasks(self) -> bool
```

Check if this component supports task execution.

**Returns:**

* True if mode is "optional" or "required", False if "forbidden".

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

```python  theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
validate_function(self, fn: Callable[..., Any], name: str) -> None
```

Validate that function is compatible with this task config.

Task execution requires:

1. fastmcp\[tasks] to be installed (pydocket)
2. Async functions

Raises ImportError if mode is "optional" or "required" but pydocket
is not installed. Raises ValueError if function is synchronous.

**Args:**

* `fn`: The function to validate (handles callable classes and staticmethods).
* `name`: Name for error messages.

**Raises:**

* `ImportError`: If task execution is enabled but pydocket not installed.
* `ValueError`: If task execution is enabled but function is sync.