SEP-1686: Tasks (#1645) · modelcontextprotocol/python-sdk@c92bb2f

File tree

76 files changed

lines changed

      • simple-task-interactive-client

        • mcp_simple_task_interactive_client

        • mcp_simple_task_interactive

76 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -2512,6 +2512,7 @@ MCP servers declare capabilities during initialization:

25122512

## Documentation

25132513
25142514

- [API Reference](https://modelcontextprotocol.github.io/python-sdk/api/)

2515+

- [Experimental Features (Tasks)](https://modelcontextprotocol.github.io/python-sdk/experimental/tasks/)

25152516

- [Model Context Protocol documentation](https://modelcontextprotocol.io)

25162517

- [Model Context Protocol specification](https://modelcontextprotocol.io/specification/latest)

25172518

- [Officially supported servers](https://github.com/modelcontextprotocol/servers)

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,43 @@

1+

# Experimental Features

2+
3+

!!! warning "Experimental APIs"

4+
5+

The features in this section are experimental and may change without notice.

6+

They track the evolving MCP specification and are not yet stable.

7+
8+

This section documents experimental features in the MCP Python SDK. These features

9+

implement draft specifications that are still being refined.

10+
11+

## Available Experimental Features

12+
13+

### [Tasks](tasks.md)

14+
15+

Tasks enable asynchronous execution of MCP operations. Instead of waiting for a

16+

long-running operation to complete, the server returns a task reference immediately.

17+

Clients can then poll for status updates and retrieve results when ready.

18+
19+

Tasks are useful for:

20+
21+

- **Long-running computations** that would otherwise block

22+

- **Batch operations** that process many items

23+

- **Interactive workflows** that require user input (elicitation) or LLM assistance (sampling)

24+
25+

## Using Experimental APIs

26+
27+

Experimental features are accessed via the `.experimental` property:

28+
29+

```python

30+

# Server-side

31+

@server.experimental.get_task()

32+

async def handle_get_task(request: GetTaskRequest) -> GetTaskResult:

33+

...

34+
35+

# Client-side

36+

result = await session.experimental.call_tool_as_task("tool_name", {"arg": "value"})

37+

```

38+
39+

## Providing Feedback

40+
41+

Since these features are experimental, feedback is especially valuable. If you encounter

42+

issues or have suggestions, please open an issue on the

43+

[python-sdk repository](https://github.com/modelcontextprotocol/python-sdk/issues).