Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9048a26
Add initial MRTR support
halter73 Mar 20, 2026
e788171
Remove AsyncLocal
halter73 Mar 20, 2026
1fe273d
Add MrtrProtocolTests
halter73 Mar 20, 2026
441c895
Remove Channel
halter73 Mar 21, 2026
e1bd3f6
Eliminate some code smells
halter73 Mar 21, 2026
3c30338
Remove internal MRTR members from mockable base classes
halter73 Mar 21, 2026
e81a4ec
Add ExperimentalProtocolVersion opt-in for MRTR
halter73 Mar 21, 2026
3cafe8d
Add low-level MRTR server API and documentation
halter73 Mar 21, 2026
9d20c02
Add MRTR tests: concurrent requests, cancellation, and no old-style w…
halter73 Mar 21, 2026
7ad4702
Fix stateless IncompleteResultException and add stateless MRTR tests
halter73 Mar 21, 2026
5db2419
Add MRTR sections to elicitation, sampling, and roots docs
halter73 Mar 21, 2026
a755a54
Split MrtrContext.cs into one class per file
halter73 Mar 21, 2026
80417c0
Add per-session MRTR flow limiting tests via message filters
halter73 Mar 21, 2026
5845866
Remove stateless check from ClientSupportsMrtr and flow protocol vers…
halter73 Mar 21, 2026
6435257
Add stateless MRTR doc pattern coverage tests
halter73 Mar 21, 2026
5487d0a
Add session DELETE mid-MRTR tests and fix disposal cleanup
halter73 Mar 21, 2026
0bec44e
Improve MRTR thread-safety, cancellation, and shutdown
halter73 Mar 23, 2026
d32295c
Fix net472 build: use generic TaskCompletionSource<bool>
halter73 Mar 23, 2026
d917c80
Add deferred task creation with DeferTaskCreation + CreateTaskAsync
halter73 Mar 23, 2026
b4dd962
Add deferred task creation docs, revert MrtrContext to dictionary flo…
halter73 Mar 23, 2026
7e65a72
Test MRTR-to-IncompleteResult transition and simplify AwaitMrtrHandle…
halter73 Mar 23, 2026
350d326
Add MRTR-native backcompat: resolve IncompleteResultException via leg…
halter73 Mar 23, 2026
33d0db4
Fix MrtrProtocolTests assertion for backcompat error message
halter73 Mar 23, 2026
34f974b
Add edge-case tests for MRTR backward compatibility and experimental …
halter73 Mar 23, 2026
d1bd8ad
Make IsMrtrSupported reflect low-level API availability
halter73 Mar 23, 2026
898684d
Reorganize MRTR tests by what they actually test
halter73 Mar 23, 2026
e1474b4
Add integration tests and fix test forward-compatibility
halter73 Mar 24, 2026
b9bd0db
Add ServerMessageTracker to verify MRTR tests use experimental mode
halter73 Mar 24, 2026
1fff8c5
Route SendRequestAsync through outgoing filters and add MRTR mode ver…
halter73 Mar 25, 2026
27badfe
Consolidate and tighten MRTR test coverage
halter73 Mar 25, 2026
fd2d71e
Fix StreamClientSessionTransport swallowing caller-triggered cancella…
halter73 Mar 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions docs/concepts/elicitation/elicitation.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,82 @@ Here's an example implementation of how a console application might handle elici

[!code-csharp[](samples/client/Program.cs?name=snippet_ElicitationHandler)]

### Multi Round-Trip Requests (MRTR)

When both the client and server opt in to the experimental [MRTR](xref:mrtr) protocol, elicitation requests are handled via incomplete result / retry instead of a direct JSON-RPC request. This is transparent — the existing `ElicitAsync` API works identically regardless of whether MRTR is active.

#### High-level API

No code changes are needed. `ElicitAsync` automatically uses MRTR when both sides have opted in, and falls back to legacy JSON-RPC requests otherwise:

```csharp
// This code works the same with or without MRTR — the SDK handles it transparently.
var result = await server.ElicitAsync(new ElicitRequestParams
{
Message = "Please confirm the action",
RequestedSchema = new()
{
Properties = new Dictionary<string, ElicitRequestParams.PrimitiveSchemaDefinition>
{
["confirm"] = new ElicitRequestParams.BooleanSchema
{
Description = "Confirm the action"
}
}
}
}, cancellationToken);
```

#### Low-level API

For stateless servers or scenarios requiring manual control, throw <xref:ModelContextProtocol.Protocol.IncompleteResultException> with an elicitation input request. On retry, read the client's response from <xref:ModelContextProtocol.Protocol.RequestParams.InputResponses>:

```csharp
[McpServerTool, Description("Tool that elicits via low-level MRTR")]
public static string ElicitWithMrtr(
McpServer server,
RequestContext<CallToolRequestParams> context)
{
// On retry, process the client's elicitation response
if (context.Params!.InputResponses?.TryGetValue("user_input", out var response) is true)
{
var elicitResult = response.ElicitationResult;
return elicitResult?.Action == "accept"
? $"User accepted: {elicitResult.Content?.FirstOrDefault().Value}"
: "User declined.";
}

if (!server.IsMrtrSupported)
{
return "This tool requires MRTR support.";
}

// First call — request user input
throw new IncompleteResultException(
inputRequests: new Dictionary<string, InputRequest>
{
["user_input"] = InputRequest.ForElicitation(new ElicitRequestParams
{
Message = "Please confirm the action",
RequestedSchema = new()
{
Properties = new Dictionary<string, ElicitRequestParams.PrimitiveSchemaDefinition>
{
["confirm"] = new ElicitRequestParams.BooleanSchema
{
Description = "Confirm the action"
}
}
}
})
},
requestState: "awaiting-confirmation");
}
```

> [!TIP]
> See [Multi Round-Trip Requests (MRTR)](xref:mrtr) for the full protocol details, including multiple round trips, concurrent input requests, and the compatibility matrix.

### URL Elicitation Required Error

When a tool cannot proceed without first completing a URL-mode elicitation (for example, when third-party OAuth authorization is needed), and calling `ElicitAsync` is not practical (for example in <xref: ModelContextProtocol.AspNetCore.HttpServerTransportOptions.Stateless> is enabled disabling server-to-client requests), the server may throw a <xref:ModelContextProtocol.UrlElicitationRequiredException>. This is a specialized error (JSON-RPC error code `-32042`) that signals to the client that one or more URL-mode elicitations must be completed before the original request can be retried.
Expand Down
2 changes: 2 additions & 0 deletions docs/concepts/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Install the SDK and build your first MCP client and server.
| [Progress tracking](progress/progress.md) | Learn how to track progress for long-running operations through notification messages. |
| [Cancellation](cancellation/cancellation.md) | Learn how to cancel in-flight MCP requests using cancellation tokens and notifications. |
| [Pagination](pagination/pagination.md) | Learn how to use cursor-based pagination when listing tools, prompts, and resources. |
| [Tasks](tasks/tasks.md) | Learn how to create and manage long-running tool call tasks. |
| [Multi Round-Trip Requests (MRTR)](mrtr/mrtr.md) | Learn how servers request client input during tool execution using incomplete results and retries. |

### Client Features

Expand Down
Loading
Loading