Skip to content

feat(mcp): upgrade to MCP SDK v2 #112

Description

@bobbyjohnstx

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

  1. Add @modelcontextprotocol/client dependency
  2. Update imports in src/mcp/index.ts from subpath imports (@modelcontextprotocol/sdk/client/index.js) to the new top-level package
  3. Add versionNegotiation: { mode: "auto" } and listMaxPages: 1_000 to client options
  4. Ensure backward compatibility with MCP servers on older protocol versions
  5. Update error handling to use new error types where applicable
  6. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions