Skip to content

Conversation

@KKonstantinov
Copy link
Contributor

@KKonstantinov KKonstantinov commented Dec 10, 2025

Proof of Concept: v2 monorepo, package split

Motivation and Context

v1 of the sdk shipped both client and server in the same package, introducing extra dependencies to users who have a single concern (client or server only). Client and server packages are now split, depending on a shared core package.

Additionally, v1 exported all files as the public API of the SDK, limiting the SDK ability to iterate internally while keeping backwards compatibility. Barrel files are now introduced as the single entrypoint to the SDK and defining the public API of the SDK.

How Has This Been Tested?

Unit, integration tests

Breaking Changes

v2

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 10, 2025

Open in StackBlitz

pnpm add https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/sdk-client@1279
pnpm add https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/sdk-server@1279

commit: 60de202

@KKonstantinov KKonstantinov added the v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes label Dec 10, 2025
@KKonstantinov KKonstantinov self-assigned this Dec 10, 2025
Copy link
Contributor

@felixweinberger felixweinberger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way we can break this PR up somehow so that this is more reviewable? E.g. with using git mv to preserve history and provenance of files? As it is it'll be quite hard to verify correctness of the split.

@KKonstantinov
Copy link
Contributor Author

KKonstantinov commented Dec 12, 2025

EDITs:

  • Provenance / history retained (except 3-4 files, will review them and bring it to them as well)
  • Dropped Node v18
  • Dropped CommonJS (ESM only)
  • Removed tsgo - that's running TS v7 - switched to tsc for our current typescript version
  • Bumped the ts version
  • Added eslint import rules to tidy up imports
  • cleaned-up package.json files - client-sdk and server-sdk ship with the minimum required dependencies (as opposed to v1, which shipped server deps if you were only interested in the client and vice versa
  • introduce catalogs for reusing dep versions
  • bundling tool change - tsdown as per @mattzcarey
  • ... might be more, will add as quite tired after this one :)

TODOs still:

  • *.md - readme updates
  • test(18) check - no code change, repository config -> needs to be removed as required check from branch rulesets, and replaced with test(20)

@KKonstantinov KKonstantinov added this to the v2 milestone Dec 12, 2025
@KKonstantinov KKonstantinov linked an issue Dec 12, 2025 that may be closed by this pull request
23 tasks
@modelcontextprotocol modelcontextprotocol deleted a comment from sonarqubecloud bot Dec 16, 2025
@KKonstantinov KKonstantinov linked an issue Dec 16, 2025 that may be closed by this pull request
@KKonstantinov KKonstantinov linked an issue Dec 16, 2025 that may be closed by this pull request
@mattzcarey
Copy link
Contributor

I would push against removing tsgo from the check script. As we move to a monorepo it will be much much faster than tsc.

"node": ">=20",
"pnpm": ">=10.24.0"
},
"packageManager": "[email protected]",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont hate this move. I like that we wont have to use turborepo or nx, at least initially. But it should be noted this will be a big dev ex change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we would need to update the README and the contribution guidelines

Comment on lines +18 to +19
export * from './validation/ajv-provider.js';
export * from './validation/cfworker-provider.js';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these have to be exported in the package.json. otherwise they will both get included on import.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really we should use shims for this in the package.json and not have separate modules. similarly to this. mswjs/msw#2640

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also feels pretty weird that this is a package. imo these tests should live in either client or server depending on what they are testing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could have some test helpers but they would live in common.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this one felt weird to me as well and haven't spent a lot of time thinking about it.

Let's think how we want it and refactor in a separate PR.

@KKonstantinov
Copy link
Contributor Author

I would push against removing tsgo from the check script. As we move to a monorepo it will be much much faster than tsc.

We could bring it back, but I did experience some issues with it. In theory it should work with typescript v5, but there are some weird stuff going on. FWIW, did not feel the speed diff on this big of a codebase, but let's bring it back in another PR if we want it

@changeset-bot
Copy link

changeset-bot bot commented Dec 18, 2025

🦋 Changeset detected

Latest commit: 60de202

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@modelcontextprotocol/sdk-client Patch
@modelcontextprotocol/sdk-server Patch

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

Copy link
Contributor

@felixweinberger felixweinberger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome refactor, looking great. THANK YOU for taking the time to ensure git history is preserved - that made it MUCH easier to review 95% of this PR as the vast majority of this PR is just shuffling around imports for the new structure.

I peppered with comments, but most of them are questions I had as I was working through so I don't forget - not asks for modifications. Please ignore comments except this one for the next hour or so while I investigate and try to answer my own questions.

Some things I wanted to discuss for sure though:

  1. We use ! type checker overrides a lot in this PR. Is this an indication of behavior change or we've somehow tightened tsconfig so we have to do this to satisfy the linter and these are pre-existing problems?
    Addressed, we tightened our type checks and this has no runtime effect. If anything it's good to make it explicit so we can periodically fix it.

  2. I think we missed one test file test/experimental/tasks/stores/in-memory.test.ts - there are 59 tests less in this version than in the current main, and this file contains exactly 59 tests.

  3. We're creating a lot of packages and package.json files - my expectation was that we'd have 3 max: client, server, core. Is this typical? Are we adding complexity for either users or ourselves by doing this?
    Addressed, welcome to Typescript 2025. Minimize dependencies we force people to import.

  4. Why change to pnpm? What's the advantage of this? Are we making it more difficult for people to install the SDK? Is this a DevX improvement? I have no intuition of what this change means, is this a drop in replacement for npm?
    Addressed, this provides us a lot of utilities for monorepo dev with multiple packages that npm doesn't support. It's also included with corepack via Node anyway, so minimal Dev friction for contributors, zero change for consumers of the SDK.

  5. Did you (or some agent 😄) potentially verify that the examples all still work as written here? Or is that something we still need to do?

import { TaskCreationParams, Request } from '../../../../src/types.js';
import { QueuedMessage } from '../../../../src/experimental/tasks/interfaces.js';

describe('InMemoryTaskStore', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did we miss this set of tests in the refactor?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we missed this test - Ran a comparison of all tests before and after:

Before: 1495 tests total
After: 1436 tests total

This file has 59 tests by my count:

npx vitest run test/experimental/tasks/stores/in-memory.test.ts

...

Test Files  1 passed (1)
    Tests  59 passed (59)
 Start at  17:42:14
 Duration  140ms (transform 39ms, setup 14ms, collect 37ms, tests 9ms, environment 0ms, prepare 5ms)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably bring this back

@felixweinberger
Copy link
Contributor

felixweinberger commented Dec 18, 2025

Noting down some follow-ups to this PR we'll want to do as a note to self:

  • Highlight change to pnpm in CONTRIBUTING.md - i.e. enable corepack if haven't already
  • Call out v1.x and main specifically.
  • Update CONTRIBUTING.md with guidance around what to use as base branch
  • Update README with a note right up top that we're working on v2, use the README and docs from v1.x by default.
  • Update release.yaml on the v1.x branch. Will note it in my follow-ups comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ESM only (if feasible) Publish separate client and server packages SDK V2

3 participants