You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For an end-to-end example of server-initiated SSE disconnection and automatic client reconnection with event replay, see [`ssePollingClient.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/client/src/ssePollingClient.ts).
598
598
599
-
## Tasks (experimental)
600
-
601
-
> [!WARNING]
602
-
> The tasks API is experimental and may change without notice.
603
-
604
-
Task-based execution enables "call-now, fetch-later" patterns for long-running operations (see [Tasks](https://modelcontextprotocol.io/specification/latest/basic/utilities/tasks) in the MCP specification). Instead of returning a result immediately, a tool creates a task that can be polled or resumed later. To use tasks:
605
-
606
-
- Call {@linkcode@modelcontextprotocol/client!experimental/tasks/client.ExperimentalClientTasks#callToolStream | client.experimental.tasks.callToolStream(...)} to start a tool call that may create a task and emit status updates over time.
607
-
- Call {@linkcode@modelcontextprotocol/client!experimental/tasks/client.ExperimentalClientTasks#getTask | client.experimental.tasks.getTask(...)} and {@linkcode@modelcontextprotocol/client!experimental/tasks/client.ExperimentalClientTasks#getTaskResult | getTaskResult(...)} to check status and fetch results after reconnecting.
608
-
609
-
For a full runnable example, see [`simpleTaskInteractiveClient.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/client/src/simpleTaskInteractiveClient.ts).
610
-
611
599
## See also
612
600
613
601
-[`examples/client/`](https://github.com/modelcontextprotocol/typescript-sdk/tree/main/examples/client) — Full runnable client examples
Copy file name to clipboardExpand all lines: docs/server.md
-13Lines changed: 0 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -495,19 +495,6 @@ server.registerTool(
495
495
);
496
496
```
497
497
498
-
## Tasks (experimental)
499
-
500
-
> [!WARNING]
501
-
> The tasks API is experimental and may change without notice.
502
-
503
-
Task-based execution enables "call-now, fetch-later" patterns for long-running operations (see [Tasks](https://modelcontextprotocol.io/specification/latest/basic/utilities/tasks) in the MCP specification). Instead of returning a result immediately, a tool creates a task that can be polled or resumed later. To use tasks:
504
-
505
-
- Provide a {@linkcode@modelcontextprotocol/server!index.TaskStore | TaskStore} implementation that persists task metadata and results (see {@linkcode@modelcontextprotocol/server!index.InMemoryTaskStore | InMemoryTaskStore} for reference).
506
-
- Enable the `tasks` capability when constructing the server.
507
-
- Register tools with {@linkcode@modelcontextprotocol/server!experimental/tasks/mcpServer.ExperimentalMcpServerTasks#registerToolTask | server.experimental.tasks.registerToolTask(...)}.
508
-
509
-
For a full runnable example, see [`simpleTaskInteractive.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/server/src/simpleTaskInteractive.ts).
510
-
511
498
## Shutdown
512
499
513
500
For stateful multi-session HTTP servers, capture the `http.Server` from `app.listen()` so you can stop accepting connections, then close each session transport:
| Interactive Streamable HTTP client | CLI client that exercises tools/resources/prompts, notifications, elicitation, and tasks. |[`src/simpleStreamableHttp.ts`](src/simpleStreamableHttp.ts)|
30
-
| Backwards-compatible client (Streamable HTTP → SSE) | Tries Streamable HTTP first, falls back to legacy SSE on 4xx responses. |[`src/streamableHttpWithSseFallbackClient.ts`](src/streamableHttpWithSseFallbackClient.ts)|
31
-
| SSE polling client (legacy) | Polls a legacy HTTP+SSE server and demonstrates notification handling. |[`src/ssePollingClient.ts`](src/ssePollingClient.ts)|
| Multiple clients in parallel | Connects multiple clients concurrently to the same server. |[`src/multipleClientsParallel.ts`](src/multipleClientsParallel.ts)|
| Interactive Streamable HTTP client | CLI client that exercises tools/resources/prompts, notifications, and elicitation. |[`src/simpleStreamableHttp.ts`](src/simpleStreamableHttp.ts)|
30
+
| Backwards-compatible client (Streamable HTTP → SSE) | Tries Streamable HTTP first, falls back to legacy SSE on 4xx responses. |[`src/streamableHttpWithSseFallbackClient.ts`](src/streamableHttpWithSseFallbackClient.ts)|
31
+
| SSE polling client (legacy) | Polls a legacy HTTP+SSE server and demonstrates notification handling. |[`src/ssePollingClient.ts`](src/ssePollingClient.ts)|
| Multiple clients in parallel | Connects multiple clients concurrently to the same server. |[`src/multipleClientsParallel.ts`](src/multipleClientsParallel.ts)|
0 commit comments