Skip to content

Commit 7ca1530

Browse files
committed
Clarify Tasks opt-in and per-tool task_support scope
Make explicit that a plain tools/call is unchanged - only a call carrying a `task` field becomes a task - and document that per-tool gating on the declared `ToolExecution.task_support` is not enforced by this reference extension.
1 parent 42d6900 commit 7ca1530

2 files changed

Lines changed: 24 additions & 11 deletions

File tree

examples/stories/tasks/README.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,20 @@ uv run python -m stories.tasks.client --http
3434
## Caveats
3535

3636
This is a reference implementation for the extension API, not a production task
37-
runtime. The tool runs to completion inline (so a task is observed as
38-
`completed` immediately), and the augmented call returns a normal
39-
`CallToolResult` with the task id in `_meta` rather than the spec's
40-
`CreateTaskResult` — the `tools/call` result schema admits only
41-
`CallToolResult | InputRequiredResult` (see `TODO(L56)` in `mcp.server.runner`),
42-
so returning `CreateTaskResult` would require extending the methods-layer
43-
validation maps. The lifecycle runs through the dedicated `tasks/*` methods instead.
37+
runtime. A plain `tools/call` (no `task` field) is unchanged — only a call the
38+
client explicitly augments with a `task` field becomes a task. Three deliberate
39+
simplifications:
40+
41+
- The tool runs to completion inline, so a task is observed as `completed`
42+
immediately (no detached/background execution, no TTL eviction).
43+
- The augmented call returns a normal `CallToolResult` with the task id in
44+
`_meta` rather than the spec's `CreateTaskResult` — the `tools/call` result
45+
schema admits only `CallToolResult | InputRequiredResult` (see `TODO(L56)` in
46+
`mcp.server.runner`), so returning `CreateTaskResult` would require extending
47+
the methods-layer validation maps. The lifecycle runs through the dedicated
48+
`tasks/*` methods instead.
49+
- Any tool may be task-augmented on request; per-tool gating on the declared
50+
`ToolExecution.task_support` (`forbidden`/`optional`/`required`) is not enforced.
4451

4552
## Spec
4653

src/mcp/server/tasks.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
This module demonstrates the *interceptive* half of the extension API. A `Tasks`
1111
instance:
1212
13-
- overrides `intercept_tool_call` to branch on `params.task`: a plain call
14-
passes through untouched; a task-augmented call still runs the tool, but its
15-
result is recorded under a task id and returned with that id stamped into
16-
`_meta["io.modelcontextprotocol/related-task"]`, and
13+
- overrides `intercept_tool_call` to branch on `params.task`: a call WITHOUT a
14+
`task` field passes through untouched (it is a normal blocking call), so
15+
plain `tools/call` behaviour is unchanged. Only a call the client explicitly
16+
augments with a `task` field is recorded under a task id and returned with
17+
that id stamped into `_meta["io.modelcontextprotocol/related-task"]`, and
1718
- overrides `methods` to serve `tasks/get`, `tasks/result`, `tasks/cancel`,
1819
and `tasks/list` so a client can poll status and fetch the payload.
1920
@@ -24,6 +25,11 @@
2425
2526
- The tool runs to completion inline, so a task is observed as `completed`
2627
immediately (no detached/background execution, no TTL eviction).
28+
- Any tool may be task-augmented when the client sends a `task` field; per-tool
29+
gating on the declared `ToolExecution.task_support`
30+
(`forbidden`/`optional`/`required`) is not enforced. A production extension
31+
would reject a `task`-augmented call to a `forbidden` tool and a plain call
32+
to a `required` one.
2733
- A task-augmented `tools/call` returns a normal `CallToolResult` (with the
2834
task id in `_meta`) rather than the spec's `CreateTaskResult`. The wire
2935
schema for `tools/call` only admits `CallToolResult | InputRequiredResult`

0 commit comments

Comments
 (0)