Uh oh!
There was an error while loading. Please reload this page.
fix: add | undefined to transport option callbacks for exactOptionalPropertyTypes - #1855
Conversation
…ertyTypes support Optional properties sessionIdGenerator, onsessioninitialized, and onsessionclosed in WebStandardStreamableHTTPServerTransportOptions need the | undefined union to support TypeScript projects with exactOptionalPropertyTypes: true. Fixesmodelcontextprotocol#1397
🦋 Changeset detectedLatest commit: b8cd277 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@modelcontextprotocol/client@modelcontextprotocol/server@modelcontextprotocol/express@modelcontextprotocol/fastify@modelcontextprotocol/hono@modelcontextprotocol/nodecommit: |
felixweinberger
left a comment
There was a problem hiding this comment.
Hi thanks for this - could you add a changeset please? (patch should be enough)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Christian-Sidak
commented
Apr 10, 2026
@felixweinberger changeset has been added (gentle-planets-rest.md, patch for @modelcontextprotocol/server). Should be good to go -- thanks! |
Christian-Sidak
commented
Apr 15, 2026
@felixweinberger just checking if this looks good now with the changeset added. All checks are passing. Thanks! |
Christian-Sidak
commented
Apr 25, 2026
Friendly bump, @felixweinberger -- changeset was added in the prior commit. All checks are passing. Happy to adjust anything if needed. |
Christian-Sidak
commented
May 3, 2026
Friendly bump, @felixweinberger -- the changeset was added in the April 10 commit. All checks are passing. Happy to adjust if needed. |
Uh oh!
There was an error while loading. Please reload this page.
Summary
Adds
| undefinedto optional callback type properties inWebStandardStreamableHTTPServerTransportOptionsto support TypeScript projects usingexactOptionalPropertyTypes: true.Fixes#1397
Changes
WebStandardStreamableHTTPServerTransportOptions(packages/server/src/server/streamableHttp.ts):sessionIdGenerator?: (() => string) | undefinedonsessioninitialized?: ((sessionId: string) => void | Promise<void>) | undefinedonsessionclosed?: ((sessionId: string) => void | Promise<void>) | undefinedCorresponding private fields on the class and the test helper interface are updated to match.
Why
Without this fix, users with
exactOptionalPropertyTypes: trueget:This is the standard TypeScript pattern for
exactOptionalPropertyTypescompatibility. TheTransportinterface in@modelcontextprotocol/corealready follows this pattern -- this PR brings the server transport options in line.Testing
tsc --noEmitpasses for bothpackages/coreandpackages/server