Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bb13dcb

Browse files
committed
docs: document progressToken usage in transport features
Adds documentation explaining how the MCP request progressToken enables request-scoped transport features (CEP-22 oversized transfer and CEP-41 open streams). Covers high-level SDK automatic token creation versus low-level manual request requirements, and recommends resetTimeoutOnProgress for long-running requests.
1 parent 5397979 commit bb13dcb

3 files changed

Lines changed: 75 additions & 0 deletions

File tree

src/content/docs/ts-sdk/transports/nostr-client-transport.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,17 @@ This keeps the active relay set minimal and avoids automatically merging every p
117117
- If the message is a **response** (correlated by the original event ID), it is passed to the MCP client to resolve the pending request.
118118
- If the message is a **notification**, it is emitted through the `onmessage` handler.
119119

120+
## Progress Tokens and Request-Scoped Transport Features
121+
122+
Some transport features are activated per request, not just per transport instance.
123+
124+
- [Oversized Transfer](/ts-sdk/transports/oversized-transfer) uses the MCP request `progressToken` as the CEP-22 transfer identifier.
125+
- [Open Stream](/ts-sdk/transports/open-stream) uses the MCP request `progressToken` as the CEP-41 stream identifier.
126+
127+
When you use the MCP TypeScript SDK through high-level request APIs and provide an `onprogress` callback, the SDK usually creates that token automatically. When you construct raw requests manually, you must provide the token yourself if you want request-scoped progress-based transport features to activate.
128+
129+
For requests that may receive progress notifications over a longer period, `resetTimeoutOnProgress: true` is the recommended client-side setting. On the MCP TypeScript SDK low-level `client.request()` path, that timeout-reset behavior is effective when `onprogress` is also provided.
130+
120131
## Server Discovery and Relay Selection
121132

122133
The client transport accepts a known [`serverPubkey`](contextvm-docs/src/content/docs/ts-sdk/transports/nostr-client-transport.md:28) in multiple forms and can now resolve operational relays automatically when needed.

src/content/docs/ts-sdk/transports/open-stream.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ If your application already has its own request correlation or tracing scheme, y
116116

117117
This is why the helper is usually preferable to assembling the request metadata and session correlation manually.
118118

119+
For consistency with other progress-based transport features such as [Oversized Transfer](/ts-sdk/transports/oversized-transfer), remember that high-level MCP TypeScript SDK usage can usually create the request `progressToken` automatically when `onprogress` is used, while low-level manual requests must provide that token explicitly. On the MCP TypeScript SDK low-level `client.request()` path, `resetTimeoutOnProgress: true` also depends on `onprogress` being provided.
120+
119121
## Enabling Open Stream on Transports
120122

121123
To use CEP-41 across the Nostr transports, enable `openStream` on both the server and the client transport.

src/content/docs/ts-sdk/transports/oversized-transfer.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,66 @@ With defaults:
2222

2323
This means most consumers do not need to configure anything unless they want stricter limits or different relay-size margins.
2424

25+
## Request Activation and `progressToken`
26+
27+
CEP-22 oversized transfer is request-scoped. It is only available for a logical exchange when the originating MCP request includes a `progressToken`, as described in [CEP-22: Oversized Payload Transfer](/spec/ceps/cep-22).
28+
29+
In practice, this matters most on the client side:
30+
31+
- if you use the MCP TypeScript SDK in the normal high-level way and provide an `onprogress` callback, the SDK assigns the `progressToken` automatically
32+
- if you build raw JSON-RPC requests manually or bypass the usual MCP client helpers, you must ensure a `progressToken` is present yourself
33+
- when no `progressToken` is present, oversized transfer cannot activate for that request, so the exchange falls back to ordinary non-fragmented behavior
34+
35+
For the MCP TypeScript SDK's low-level `client.request()` path specifically, `resetTimeoutOnProgress: true` only works when an `onprogress` callback is provided. In that code path the SDK registers the progress handler and manages the request `progressToken` automatically.
36+
37+
This is why oversized transfer usually works transparently for normal MCP client calls, but low-level transport integrations must still understand the request-level activation rule.
38+
39+
### Recommended MCP client usage
40+
41+
When you expect a request may run for a while or may trigger CEP-22 fragmentation, prefer enabling progress handling explicitly:
42+
43+
```typescript
44+
const result = await client.callTool(
45+
{
46+
name: 'long-task',
47+
arguments: {},
48+
},
49+
CallToolResultSchema,
50+
{
51+
onprogress: (progress) => {
52+
console.log(
53+
`${progress.progress}/${progress.total}: ${progress.message}`,
54+
);
55+
},
56+
timeout: 30_000,
57+
resetTimeoutOnProgress: true,
58+
},
59+
);
60+
```
61+
62+
With this pattern:
63+
64+
- the MCP TypeScript SDK creates the `progressToken` automatically
65+
- the application receives ordinary MCP progress updates when they are emitted
66+
- ContextVM transports can also use the same MCP progress channel for CEP-22 transfer frames
67+
68+
### Why `resetTimeoutOnProgress: true` is strongly recommended
69+
70+
CEP-22 frames are carried over MCP `notifications/progress`. That means a valid oversized transfer is itself ongoing request activity, not idle time.
71+
72+
Setting `resetTimeoutOnProgress: true` is therefore strongly recommended because it allows each valid progress notification to extend the request timeout window. Without that, a client may time out a healthy oversized transfer simply because the response is arriving as multiple progress-framed transfer messages before the final JSON-RPC result.
73+
74+
When using the MCP TypeScript SDK, remember that this timeout-reset behavior is tied to `onprogress`. In practice, use both together.
75+
76+
### Low-level transport usage
77+
78+
If you are working below the usual MCP client helpers, such as constructing raw requests for [`NostrClientTransport`](/ts-sdk/transports/nostr-client-transport), treat `progressToken` as part of the activation contract for CEP-22.
79+
80+
- High-level MCP SDK usage with `onprogress` usually handles this automatically.
81+
- Manual raw requests must include the token explicitly in request metadata.
82+
- If you omit it, the transport cannot correlate an oversized transfer session for that exchange.
83+
- For low-level MCP TS SDK `client.request()` calls, `resetTimeoutOnProgress: true` should be paired with `onprogress`; providing your own raw token alone does not enable the SDK-managed timeout reset path.
84+
2585
## When You Would Change It
2686

2787
Most projects should keep the default behavior.
@@ -110,6 +170,8 @@ If an oversized transfer fails, the transport may surface one of these errors:
110170

111171
- Leave oversized transfer enabled unless you have a specific reason not to.
112172
- Keep defaults unless you know your relay environment needs different thresholds.
173+
- Prefer high-level MCP client calls with `onprogress` so the SDK can assign a `progressToken` automatically.
174+
- Set `resetTimeoutOnProgress: true` for requests that may emit progress or trigger CEP-22 oversized transfer.
113175
- Tighten `policy` values if you operate in a more adversarial or resource-constrained environment.
114176
- Refer to [CEP-22: Oversized Payload Transfer](/spec/ceps/cep-22) for protocol-level behavior.
115177

0 commit comments

Comments
 (0)