1.0.2 — Ensure MCP sampling requests always include `maxTokens`
Main change: MCP sampling spec compliance (maxTokens)
SamplingProvider now always sends a maxTokens value in sampling/createMessage requests.
-
What changed
- In
convertToSamplingRequest(),maxTokensis now set to a default of 8192 when not provided viaExecutionOptions:maxTokens: options?.maxTokens ?? 8192
- In
-
Why it matters
maxTokensis required by the MCP sampling specification. Previously, if callers did not provideoptions.maxTokens, the request could be sent withoutmaxTokens, which can cause MCP clients to reject the request as invalid (often surfaced as invalid-params errors).
-
Impact
- Users: fewer “invalid sampling request parameters” failures when using clients that strictly validate MCP sampling requests.
- Developers: no required code changes. You can still override the limit by passing
maxTokensinexecute(request, { maxTokens }).
Packaging
- Package version updated to 1.0.2 in
package.json.
Breaking changes
- No breaking changes detected in this release. The
maxTokensdefault may change behavior for consumers who previously relied on the MCP client’s implicit defaults whenmaxTokenswas omitted (the request now explicitly caps at 8192 unless overridden).