Summary
Upgrade @modelcontextprotocol/sdk from 1.27.1 to v2 (@modelcontextprotocol/client package).
Why
The v2 SDK brings:
- Auto version negotiation (
versionNegotiation: { mode: "auto" })
- Improved error types (
RegistrationRejectedError, SdkHttpError)
listChanged callback pattern
listMaxPages option for paginated resource listing
- Better session recovery for expired connections
Implementation
- Add
@modelcontextprotocol/client dependency
- Update imports in
src/mcp/index.ts from subpath imports (@modelcontextprotocol/sdk/client/index.js) to the new top-level package
- Add
versionNegotiation: { mode: "auto" } and listMaxPages: 1_000 to client options
- Ensure backward compatibility with MCP servers on older protocol versions
- Update error handling to use new error types where applicable
- Test with both stdio and SSE/StreamableHTTP transports
Files
src/mcp/index.ts — main client, imports, transport setup
src/mcp/auth.ts — if auth flow changes
package.json — dependency update
Notes
- The existing
@modelcontextprotocol/sdk@1.27.1 reconnect loop patch (if applied) should be evaluated for removal — v2 may fix it upstream.
- Test with at least one real MCP server (e.g., filesystem) to verify compatibility.
Summary
Upgrade
@modelcontextprotocol/sdkfrom 1.27.1 to v2 (@modelcontextprotocol/clientpackage).Why
The v2 SDK brings:
versionNegotiation: { mode: "auto" })RegistrationRejectedError,SdkHttpError)listChangedcallback patternlistMaxPagesoption for paginated resource listingImplementation
@modelcontextprotocol/clientdependencysrc/mcp/index.tsfrom subpath imports (@modelcontextprotocol/sdk/client/index.js) to the new top-level packageversionNegotiation: { mode: "auto" }andlistMaxPages: 1_000to client optionsFiles
src/mcp/index.ts— main client, imports, transport setupsrc/mcp/auth.ts— if auth flow changespackage.json— dependency updateNotes
@modelcontextprotocol/sdk@1.27.1reconnect loop patch (if applied) should be evaluated for removal — v2 may fix it upstream.