Skip to content

Commit dbb7a20

Browse files
Implement SEP-2663 Tasks Extension (#1579)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ed07fdb commit dbb7a20

119 files changed

Lines changed: 8190 additions & 11405 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<!-- Product dependencies .NET Standard -->
2626
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
2727
<PackageVersion Include="Microsoft.Bcl.Memory" Version="$(System10Version)" />
28+
<PackageVersion Include="System.Collections.Immutable" Version="$(System10Version)" />
2829
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="$(System10Version)" />
2930
<PackageVersion Include="System.IO.Pipelines" Version="$(System10Version)" />
3031
<PackageVersion Include="System.Text.Json" Version="$(System10Version)" />

ModelContextProtocol.slnx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@
4545
<Project Path="samples/ChatWithTools/ChatWithTools.csproj" />
4646
<Project Path="samples/EverythingServer/EverythingServer.csproj" />
4747
<Project Path="samples/InMemoryTransport/InMemoryTransport.csproj" />
48-
<Project Path="samples/LongRunningTasks/LongRunningTasks.csproj" />
4948
<Project Path="samples/ProtectedMcpClient/ProtectedMcpClient.csproj" />
5049
<Project Path="samples/ProtectedMcpServer/ProtectedMcpServer.csproj" />
5150
<Project Path="samples/QuickstartClient/QuickstartClient.csproj" />
5251
<Project Path="samples/QuickstartWeatherServer/QuickstartWeatherServer.csproj" />
52+
<Project Path="samples/TasksExtension/TasksExtension.csproj" />
5353
<Project Path="samples/TestServerWithHosting/TestServerWithHosting.csproj" />
5454
</Folder>
5555
<Folder Name="/Solution Items/">

docs/concepts/stateless/stateless.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ In stateless mode, each HTTP request creates and disposes a short-lived `McpServ
568568

569569
## Tasks and session modes
570570

571-
[Tasks](xref:tasks) enable a "call-now, fetch-later" pattern for long-running tool calls. Task support depends on having an <xref:ModelContextProtocol.IMcpTaskStore> configured (`McpServerOptions.TaskStore`), and behavior differs between session modes.
571+
[Tasks](xref:tasks) enable a "call-now, fetch-later" pattern for long-running tool calls. Task support depends on having an <xref:ModelContextProtocol.Server.IMcpTaskStore> configured (`McpServerOptions.TaskStore`), and behavior differs between session modes.
572572

573573
### Stateless mode
574574

@@ -578,9 +578,9 @@ In stateless mode, there is no `SessionId`, so the task store does not apply ses
578578

579579
### Stateful mode
580580

581-
In stateful mode, the `IMcpTaskStore` receives the session's `SessionId` on every operation — `CreateTaskAsync`, `GetTaskAsync`, `ListTasksAsync`, `CancelTaskAsync`, etc. The built-in <xref:ModelContextProtocol.InMemoryMcpTaskStore> enforces session isolation: tasks created in one session cannot be accessed from another.
581+
In stateful mode, the `IMcpTaskStore` receives the session's `SessionId` on every operation — `CreateTaskAsync`, `GetTaskAsync`, `ListTasksAsync`, `CancelTaskAsync`, etc. The built-in <xref:ModelContextProtocol.Server.InMemoryMcpTaskStore> enforces session isolation: tasks created in one session cannot be accessed from another.
582582

583-
Tasks can outlive individual HTTP requests because the tool executes in the background after returning the initial `CreateTaskResult`. Task cleanup is governed by the task's TTL (time-to-live), not by session termination. However, the `InMemoryMcpTaskStore` loses all tasks if the server process restarts. For durable tasks, implement a custom <xref:ModelContextProtocol.IMcpTaskStore> backed by an external store. See [Fault-tolerant task implementations](xref:tasks#fault-tolerant-task-implementations) for guidance.
583+
Tasks can outlive individual HTTP requests because the tool executes in the background after returning the initial `CreateTaskResult`. Task cleanup is governed by the task's TTL (time-to-live), not by session termination. However, the `InMemoryMcpTaskStore` loses all tasks if the server process restarts. For durable tasks, implement a custom <xref:ModelContextProtocol.Server.IMcpTaskStore> backed by an external store. See [Implementing a custom task store](xref:tasks#implementing-a-custom-task-store) for guidance.
584584

585585
### Task cancellation vs request cancellation
586586

@@ -632,7 +632,7 @@ The `EventStreamStore` itself has TTL-based limits (default: 2-hour event expira
632632

633633
### With tasks (experimental)
634634

635-
[Tasks](xref:tasks) are an experimental feature that enables a "call-now, fetch-later" pattern for long-running tool calls. When a client sends a task-augmented `tools/call` request, the server creates a task record in the <xref:ModelContextProtocol.IMcpTaskStore>, starts the tool handler as a fire-and-forget background task, and returns the task ID immediatelythe POST response completes **before the handler starts its real work**.
635+
[Tasks](xref:tasks) are an experimental feature that enables a "call-now, fetch-later" pattern for long-running tool calls. When a client sends a task-augmented `tools/call` request, the server creates a task record in the <xref:ModelContextProtocol.Server.IMcpTaskStore>, starts the tool handler as a fire-and-forget background task, and returns the task ID immediatelythe POST response completes **before the handler starts its real work**.
636636

637637
This means:
638638

0 commit comments

Comments
 (0)