Skip to content

1.0.2 — Ensure MCP sampling requests always include `maxTokens`

Choose a tag to compare

@tobrien tobrien released this 08 Feb 08:08
· 6 commits to main since this release
5f210c7

Main change: MCP sampling spec compliance (maxTokens)

SamplingProvider now always sends a maxTokens value in sampling/createMessage requests.

  • What changed

    • In convertToSamplingRequest(), maxTokens is now set to a default of 8192 when not provided via ExecutionOptions:
      • maxTokens: options?.maxTokens ?? 8192
  • Why it matters

    • maxTokens is required by the MCP sampling specification. Previously, if callers did not provide options.maxTokens, the request could be sent without maxTokens, 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 maxTokens in execute(request, { maxTokens }).

Packaging

  • Package version updated to 1.0.2 in package.json.

Breaking changes

  • No breaking changes detected in this release. The maxTokens default may change behavior for consumers who previously relied on the MCP client’s implicit defaults when maxTokens was omitted (the request now explicitly caps at 8192 unless overridden).