Skip to content

Commit 88410f8

Browse files
cliffhallclaude
andcommitted
fix(everything): keep live tasks until their TTL; acknowledge any cancel; bound minted names
Copilot round 7 on #5131: - At MAX_TASKS a new task is refused with a tool error instead of evicting a live one, since the extension lets a server discard a task only after its TTL. - tasks/cancel acknowledges a known task whatever its status (cancellation is cooperative); a finished task stays as it ended. - Minted resources count their name and URI against the byte budget, and gzip-file-as-resource bounds its name at 255 characters. - features.md names the async task tools' full requirements; the sequentialthinking README's era sentence is completed. Part of #4852 Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: cliffhall <[email protected]>
1 parent 8eea6d9 commit 88410f8

9 files changed

Lines changed: 101 additions & 54 deletions

File tree

‎.changeset/everything-modern-era.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"@modelcontextprotocol/server-everything": minor
33
---
44

5-
Serve the 2026-07-28 protocol revision alongside the 2025 era (#4852), over stdio (`serveStdio`) and Streamable HTTP (one `/mcp` endpoint: `createMcpHandler` for 2026-07-28 requests, the existing sessionful transport for 2025-era clients). New for 2026-07-28 clients: `server/discover`, multi-round-trip requests (`input_required`) for the elicitation, sampling and roots tools, `subscriptions/listen` change notifications, cache hints (`ttlMs` / `cacheScope`), and the tasks extension (`io.modelcontextprotocol/tasks`, advertised under `capabilities.extensions`), on which `simulate-research-query`, `trigger-sampling-request-async` and `trigger-elicitation-request-async` return. New tools on both eras: `trigger-multi-step-elicitation` (`requestState` across rounds), `trigger-log-messages` (per-request log levels), `trigger-list-changed`, `trigger-resource-update`, and `get-header-params` (`x-mcp-header` and JSON Schema 2020-12 schemas). `toggle-simulated-logging` and `toggle-subscriber-updates` are offered to 2025-era clients only, labelled deprecated with the roots, sampling and logging tools. For 2025-era clients: `get-roots-list` asks the client for its roots on every call; a failed sampling, elicitation or roots request is reported as `Fulfilling input required by 'tools/call' failed: <message>`; a read of a dynamic resource with an invalid id is answered `-32602` with the URI in `data`; and the toggle tools' messages and the subscription acknowledgements no longer name a session id. The HTTP+SSE transport prints a deprecation warning on start.
5+
Serve the 2026-07-28 protocol revision alongside the 2025 era (#4852), over stdio (`serveStdio`) and Streamable HTTP (one `/mcp` endpoint: `createMcpHandler` for 2026-07-28 requests, the existing sessionful transport for 2025-era clients). New for 2026-07-28 clients: `server/discover`, multi-round-trip requests (`input_required`) for the elicitation, sampling and roots tools, `subscriptions/listen` change notifications, cache hints (`ttlMs` / `cacheScope`), and the tasks extension (`io.modelcontextprotocol/tasks`, advertised under `capabilities.extensions`), on which `simulate-research-query`, `trigger-sampling-request-async` and `trigger-elicitation-request-async` return. New tools on both eras: `trigger-multi-step-elicitation` (`requestState` across rounds), `trigger-log-messages` (per-request log levels), `trigger-list-changed`, `trigger-resource-update`, and `get-header-params` (`x-mcp-header` and JSON Schema 2020-12 schemas). `toggle-simulated-logging` and `toggle-subscriber-updates` are offered to 2025-era clients only, labelled deprecated with the roots, sampling and logging tools. For 2025-era clients: `get-roots-list` asks the client for its roots on every call; a failed sampling, elicitation or roots request is reported as `Fulfilling input required by 'tools/call' failed: <message>`; a read of a dynamic resource with an invalid id is answered `-32602` with the URI in `data`; and the toggle tools' messages and the subscription acknowledgements no longer name a session id. `gzip-file-as-resource` limits its `name` argument to 255 characters. The HTTP+SSE transport prints a deprecation warning on start.

‎src/everything/__tests__/modern.test.ts‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -666,12 +666,33 @@ describe("minted resources", () => {
666666

667667
it("refuses one resource larger than the whole byte budget", () => {
668668
expect(() =>
669-
mintBlobResource("huge", "text/plain", "A".repeat(MAX_MINTED_BYTES + 1)),
669+
mintBlobResource("huge", "text/plain", "A".repeat(MAX_MINTED_BYTES)),
670670
).toThrow(
671-
`Cannot keep huge for later reading: its ${MAX_MINTED_BYTES + 1} bytes of content exceed the ${MAX_MINTED_BYTES}-byte limit for minted resources`,
671+
/^Cannot keep huge for later reading: its \d+ bytes exceed the \d+-byte limit for minted resources$/,
672672
);
673673
});
674674

675+
it("counts a resource's name and URI against the byte budget", async () => {
676+
// Two resources whose content alone fits, but not with their names.
677+
const name = "n".repeat(1024);
678+
const blob = "A".repeat(MAX_MINTED_BYTES / 2 - 1024);
679+
const first = mintBlobResource(name, "text/plain", blob).uri;
680+
mintBlobResource(name, "text/plain", blob);
681+
session = await connectModern();
682+
await expect(
683+
session.client.readResource({ uri: first }),
684+
).rejects.toMatchObject({ code: -32602 });
685+
});
686+
687+
it("refuses a gzip-file-as-resource name longer than it will keep", async () => {
688+
session = await connectModern();
689+
const result = await session.client.callTool({
690+
name: "gzip-file-as-resource",
691+
arguments: { name: "n".repeat(256), data: DATA_URI },
692+
});
693+
expect(result.isError).toBe(true);
694+
});
695+
675696
it("keeps at most MAX_MINTED_BYTES of content, dropping the oldest", async () => {
676697
const half = "A".repeat(MAX_MINTED_BYTES / 2);
677698
const first = mintBlobResource("first", "text/plain", half).uri;

‎src/everything/__tests__/surface.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,8 @@ describe("tools/list", () => {
579579
},
580580
"name": {
581581
"default": "README.md.gz",
582-
"description": "Name of the output file",
582+
"description": "Name of the output file (at most 255 characters)",
583+
"maxLength": 255,
583584
"type": "string",
584585
},
585586
"outputType": {

‎src/everything/__tests__/tasks.test.ts‎

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,27 @@ describe("the extension", () => {
148148
},
149149
);
150150

151-
it("keeps at most MAX_TASKS, dropping the oldest", async () => {
151+
it("refuses a new task at MAX_TASKS, keeping every live one until its TTL", async () => {
152152
peer = await rawClient(TASKS);
153153
const first = await peer.call("simulate-research-query", { topic: "t" });
154154
for (let i = 1; i < MAX_TASKS; i++) {
155155
await peer.call("simulate-research-query", { topic: "t" });
156156
}
157+
const refused = await peer.call("simulate-research-query", { topic: "t" });
158+
expect(refused).toMatchObject({
159+
isError: true,
160+
content: [
161+
{
162+
text: `The server is already running ${MAX_TASKS} tasks, its limit. Try again once one has expired.`,
163+
},
164+
],
165+
});
157166
expect((await peer.get(first.taskId as string)).status).toBe("working");
158-
await peer.call("simulate-research-query", { topic: "t" });
159-
const response = await peer.request("tasks/get", { taskId: first.taskId });
160-
expect(response.error).toMatchObject({ code: -32602 });
167+
// Once the tasks expire, there is room again.
168+
advance(first.ttlMs as number);
169+
expect(
170+
(await peer.call("simulate-research-query", { topic: "t" })).resultType,
171+
).toBe("task");
161172
});
162173

163174
it("refuses a topic longer than it will keep", async () => {
@@ -444,7 +455,7 @@ describe("simulate-research-query", () => {
444455
expect((await peer.get(created.taskId as string)).status).toBe("working");
445456
});
446457

447-
it("stays cancelled once the client cancels it, and refuses a second cancel", async () => {
458+
it("stays cancelled once the client cancels it, and acknowledges a second cancel", async () => {
448459
peer = await rawClient(TASKS);
449460
const created = await peer.call("simulate-research-query", { topic: "t" });
450461
const taskId = created.taskId as string;
@@ -456,24 +467,21 @@ describe("simulate-research-query", () => {
456467
status: "cancelled",
457468
statusMessage: "Cancelled by the client",
458469
});
459-
const again = await peer.request("tasks/cancel", { taskId });
460-
expect(again.error).toMatchObject({
461-
code: -32602,
462-
message: expect.stringContaining("is already cancelled"),
470+
expect(await peer.result("tasks/cancel", { taskId })).toMatchObject({
471+
resultType: "complete",
463472
});
473+
expect((await peer.get(taskId)).status).toBe("cancelled");
464474
});
465475

466-
it("refuses to cancel a completed task", async () => {
476+
it("acknowledges a cancel of a completed task, which stays completed", async () => {
467477
peer = await rawClient(TASKS);
468478
const created = await peer.call("simulate-research-query", { topic: "t" });
479+
const taskId = created.taskId as string;
469480
advance(STAGE_DURATION * STAGES.length);
470-
const response = await peer.request("tasks/cancel", {
471-
taskId: created.taskId,
472-
});
473-
expect(response.error).toMatchObject({
474-
code: -32602,
475-
message: expect.stringContaining("is already completed"),
481+
expect(await peer.result("tasks/cancel", { taskId })).toMatchObject({
482+
resultType: "complete",
476483
});
484+
expect((await peer.get(taskId)).status).toBe("completed");
477485
});
478486
});
479487

‎src/everything/docs/features.md‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ The server serves two protocol eras from one process, over stdio and over Stream
1616

1717
Each feature below is marked **both**, **2026-07-28** or **2025-era**. Roots, sampling and logging are deprecated as of 2026-07-28 (SEP-2577), as is the HTTP+SSE transport; they stay available and are labelled deprecated in their descriptions.
1818

19-
| Feature | 2026-07-28 | 2025-era |
20-
| --- | --- | --- |
21-
| Discovery | `server/discover` | `initialize` |
22-
| Client input (elicitation, sampling, roots) | in-band: the tool returns `input_required`, the client retries | the SDK's legacy shim sends real server-to-client requests for the same handler |
23-
| State across rounds | `requestState`, signed and expiring | the same, replayed by the shim |
24-
| Change notifications | on a `subscriptions/listen` stream the client opened | unsolicited, or after `resources/subscribe` |
25-
| Log level | per request, `_meta` `io.modelcontextprotocol/logLevel` (none named: no logs) | per session, `logging/setLevel` |
26-
| Tasks | the `io.modelcontextprotocol/tasks` extension | not served |
27-
| Cache hints | `ttlMs` / `cacheScope` on lists, reads and `server/discover` | not sent |
28-
| `x-mcp-header` | mirrored into `Mcp-Param-*` headers over Streamable HTTP | not mirrored |
19+
| Feature | 2026-07-28 | 2025-era |
20+
| ------------------------------------------- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
21+
| Discovery | `server/discover` | `initialize` |
22+
| Client input (elicitation, sampling, roots) | in-band: the tool returns `input_required`, the client retries | the SDK's legacy shim sends real server-to-client requests for the same handler |
23+
| State across rounds | `requestState`, signed and expiring | the same, replayed by the shim |
24+
| Change notifications | on a `subscriptions/listen` stream the client opened | unsolicited, or after `resources/subscribe` |
25+
| Log level | per request, `_meta` `io.modelcontextprotocol/logLevel` (none named: no logs) | per session, `logging/setLevel` |
26+
| Tasks | the `io.modelcontextprotocol/tasks` extension | not served |
27+
| Cache hints | `ttlMs` / `cacheScope` on lists, reads and `server/discover` | not sent |
28+
| `x-mcp-header` | mirrored into `Mcp-Param-*` headers over Streamable HTTP | not mirrored |
2929

3030
## Tools
3131

@@ -44,14 +44,14 @@ Each feature below is marked **both**, **2026-07-28** or **2025-era**. Roots, sa
4444
- `toggle-simulated-logging` (tools/toggle-simulated-logging.ts), **2025-era**, deprecated: Starts or stops simulated, random‑leveled logging for the connection. Respects the level the client set with `logging/setLevel`.
4545
- `toggle-subscriber-updates` (tools/toggle-subscriber-updates.ts), **2025-era**, deprecated: Starts or stops simulated resource update notifications for URIs the connection has subscribed to with `resources/subscribe`.
4646
- `trigger-elicitation-request` (tools/trigger-elicitation-request.ts), **both**: Asks for a form of every field type form-mode elicitation supports (strings, numbers, booleans, enums, and format validation) with a multi-round-trip request, and returns the resulting action/content. Needs client form-mode elicitation: `elicitation.form`, or an `elicitation` object that declares neither mode.
47-
- `trigger-elicitation-request-async` (tools/trigger-elicitation-request-async.ts), **2026-07-28**: Runs as a task whose `input_required` status carries a form elicitation; the client answers with `tasks/update` and the task completes with a summary. Needs a client that declares the tasks extension.
47+
- `trigger-elicitation-request-async` (tools/trigger-elicitation-request-async.ts), **2026-07-28**: Runs as a task whose `input_required` status carries a form elicitation; the client answers with `tasks/update` and the task completes with a summary. Needs a client that declares the tasks extension and form-mode elicitation.
4848
- `trigger-list-changed` (tools/trigger-list-changed.ts), **both**: Sends `notifications/<list>/list_changed` for `tools`, `prompts` or `resources`: on 2026-07-28 to each `subscriptions/listen` stream that asked for that list, on a 2025-era connection unsolicited.
4949
- `trigger-log-messages` (tools/trigger-log-messages.ts), **both**, deprecated: Sends one log message at each level during the call. A 2026-07-28 request gets those at or above the level its `_meta` names (none if it names none); a 2025-era client those at or above its `logging/setLevel` level.
5050
- `trigger-long-running-operation` (tools/trigger-long-running-operation.ts), **both**: Simulates a multi-step operation over a given `duration` and number of `steps`; reports progress via `notifications/progress` when a `progressToken` is provided by the client.
5151
- `trigger-multi-step-elicitation` (tools/trigger-multi-step-elicitation.ts), **both**: Asks for a name, then for a favorite color addressed by that name, carrying the first answer to the second round in `requestState`. The state is HMAC-signed and expires after ten minutes; a tampered or expired one is refused with `-32602`. A blank name or a color that is not a choice is asked again. Needs form-mode elicitation.
5252
- `trigger-resource-update` (tools/trigger-resource-update.ts), **both**: Sends `notifications/resources/updated` for a URI: on 2026-07-28 to each listen stream whose `resourceSubscriptions` name it, on a 2025-era connection once the client has subscribed to it.
5353
- `trigger-sampling-request` (tools/trigger-sampling-request.ts), **both**, deprecated: Asks the client's LLM for a completion with a multi-round-trip request, using the provided `prompt` and `maxTokens`; returns the LLM's response payload. Needs client capability `sampling`.
54-
- `trigger-sampling-request-async` (tools/trigger-sampling-request-async.ts), **2026-07-28**, deprecated: Runs as a task whose `input_required` status carries a sampling request; the client answers with `tasks/update` and the task completes with the result. Needs a client that declares the tasks extension.
54+
- `trigger-sampling-request-async` (tools/trigger-sampling-request-async.ts), **2026-07-28**, deprecated: Runs as a task whose `input_required` status carries a sampling request; the client answers with `tasks/update` and the task completes with the result. Needs a client that declares the tasks extension and sampling.
5555
- `trigger-url-elicitation` (tools/trigger-url-elicitation.ts), **both**: Directs the user to a URL (URL-mode elicitation). On 2026-07-28 the elicitation comes in-band (`input_required`), with no `elicitationId`. On a 2025-era connection it issues an `elicitation/create` request in URL mode with an `elicitationId`, or throws MCP error `-32042` (`UrlElicitationRequiredError`) when `errorPath=true`. On the error path the prerequisite elicitation it returns points at a different URL than the failing request (`https://modelcontextprotocol.io`); when the client satisfies it and retries the same call, the retry ignores `errorPath` and proceeds via the request path, so the client does not loop on the same error. The retry marker is one-shot per `(url, elicitationId)` on the connection: it is cleared on the recognized retry, so re-running the error path with identical arguments without an intervening prerequisite is treated as a retry and proceeds. Needs client capability `elicitation.url`.
5656

5757
On a 2025-era connection the tools that need a client capability are registered only for a client that declared it at `initialize`. On 2026-07-28 they are always listed, because the capabilities arrive with each request, and the SDK refuses a call whose embedded request the client did not declare (`-32021`).
@@ -94,6 +94,6 @@ Logging is deprecated as of 2026-07-28 (SEP-2577) and remains available on both
9494
- `tasks/update`: the client's `inputResponses` to the outstanding input requests;
9595
- `tasks/cancel`: stop a task that has not finished.
9696

97-
A task tool called by a client whose request does not declare the extension, or the capability its task asks for input with (`sampling` for `trigger-sampling-request-async`, form-mode `elicitation` for `trigger-elicitation-request-async`), is refused with `-32021` (missing required client capability), naming what is missing in `data.requiredCapabilities`; so is a `tasks/*` request from a client without the extension. An unknown or expired task and a cancel of a finished task are refused with `-32602`. An update's answers to requests that are not outstanding (never issued, already answered, or sent while the task is not waiting for input) are ignored, as the extension asks. Each input request a task makes has its own key, never reused once answered, so a request asked again after an answer that does not fit gets a new key (`form-2`, `sampling-2`). The process keeps at most 100 tasks, dropping the oldest first. The task id is a server-minted UUID, so a task lives across requests (each 2026-07-28 HTTP request is served by a fresh server instance) and is reached only through its handle. A task's progress is computed from the clock when it is read, so nothing runs in the background.
97+
A task tool called by a client whose request does not declare the extension, or the capability its task asks for input with (`sampling` for `trigger-sampling-request-async`, form-mode `elicitation` for `trigger-elicitation-request-async`), is refused with `-32021` (missing required client capability), naming what is missing in `data.requiredCapabilities`; so is a `tasks/*` request from a client without the extension. An unknown or expired task is refused with `-32602`. A `tasks/cancel` is acknowledged whatever the task's status (cancellation is cooperative), and a finished task stays as it ended. An update's answers to requests that are not outstanding (never issued, already answered, or sent while the task is not waiting for input) are ignored, as the extension asks. Each input request a task makes has its own key, never reused once answered, so a request asked again after an answer that does not fit gets a new key (`form-2`, `sampling-2`). The process keeps at most 100 tasks, each until its TTL; at that limit a new task is refused with a tool error. The task id is a server-minted UUID, so a task lives across requests (each 2026-07-28 HTTP request is served by a fresh server instance) and is reached only through its handle. A task's progress is computed from the clock when it is read, so nothing runs in the background.
9898

9999
The 2025-11-25 core task methods (`tasks/result`, `tasks/list`, task-augmented requests) are not served: SDK v2 removed the experimental layer they were built on.

0 commit comments

Comments
 (0)