Skip to content

Prepare package slicing by strict namespace refactoring into Client, Schema, and Server - #493

Merged
chr-hertel merged 3 commits into
modelcontextprotocol:mainfrom
chr-hertel:package-slicing
Nov 10, 2026
Merged

chr-hertel merged 3 commits into
modelcontextprotocol:mainfrom
chr-hertel:package-slicing

Conversation

@chr-hertel

@chr-hertel chr-hertel commented Sep 1, 2026 •

Copy link
Copy Markdown
Member

Prepares slicing mcp/sdk into separate packages, see #489

  1. Moved everything below Mcp\Client, Mcp\Schema, or Mcp\Server
  2. Distributed Mcp\Exception into component specific namespaces
  3. Enforced the boundaries with Deptrac (make deptrac, part of the qa job): Schema depends on nothing, Client and Server on Schema only

Besides the namespaces there's one more BC break: getRequestHandlers() moved from ExtensionInterface to the new Mcp\Server\Extension\ServerExtensionInterface, since Schema must not know server handlers. Both are in the CHANGELOG.

SecureUrl lives in Mcp\Schema now, with internal wrappers in Client and Server that throw the package's own exception - not a perfect fit for Schema, but the only shared place until we split.

Deptrac is on 3.0, since 4.x requires Symfony ^6.4 and we still test 5.4.


Next steps, as follow ups:

  • a composer.json per component, with its own dependencies
  • split the packages on release with splitsh, like API Platform does (see the workflow linked below)
  • keep the tests global to this repo

@chr-hertel
chr-hertel requested review from soyuka and a balanced review from Copilot September 1, 2026 20:49
@chr-hertel chr-hertel added the Server Issues & PRs related to the Server component label Sep 1, 2026
@chr-hertel chr-hertel added Client Issues & PRs related to the Client component Schema Issues & PRs related to the Schema component labels Sep 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Numerous tests expect exceptions from the wrong slice, several examples reference invalid namespaces, and Deptrac is not enforced by CI.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Refactors the SDK into distinct Client, Schema, and Server namespaces in preparation for package slicing.

Changes:

  • Moves facades, capabilities, events, exceptions, and shared protocol types into slice-specific namespaces.
  • Updates tests, examples, documentation, and autoloading references.
  • Adds Deptrac boundaries and inspector snapshots.
File summaries
File group Description
src/Client/** Refactors client APIs and exceptions.
src/Schema/** Consolidates shared protocol types and schema exceptions.
src/Server/** Refactors server APIs, capabilities, events, and exceptions.
tests/Unit/** Migrates unit tests and fixtures.
tests/Integration/** Updates integration imports and fixtures.
tests/Conformance/** Updates conformance entry points.
tests/Inspector/** Adds structured-result snapshots.
examples/** Migrates client and server examples.
docs/**, README.md Updates public namespace guidance.
composer.json, deptrac.yaml, phpstan.dist.neon, .gitignore Configures architecture tooling and relocated paths.
Review details

Suppressed comments (1)

docs/client/errors.md:24

  • Client requests throw Mcp\Client\Exception\RequestException. Catching the server-slice sibling will not handle $client->callTool() failures.
  • Files reviewed: 299/423 changed files
  • Comments generated: 43
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/Unit/Client/BuilderTest.php Resolved
Comment thread tests/Unit/Client/ClientTest.php Resolved
Comment thread tests/Unit/Client/ConfigurationTest.php Resolved
Comment thread docs/servers/resources.md Resolved
Comment thread README.md Resolved
Comment thread deptrac.yaml Resolved
Comment thread docs/handlers/index.md Resolved
Comment thread docs/handlers/logging.md Resolved
@chr-hertel
chr-hertel force-pushed the package-slicing branch 4 times, most recently from fc18fd4 to 42859cd Compare September 1, 2026 22:43
@chr-hertel chr-hertel added the breaking change Breaking the Backwards Compatibility Promise label Sep 1, 2026
@chr-hertel chr-hertel added this to the 1.0 milestone Sep 1, 2026
@soyuka

soyuka commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

For splitsh this is how we did on API Platform: https://github.com/api-platform/core/blob/main/.github/workflows/release.yml#L21-L50

Pretty straightforward, not sure how it works on Symfony but AFAIR it was a bit more complex :p. Note that testing may also be a bit of a headache if we allow wider version constraint on one of these packages... +1 to keep tests global to this repo (sometimes its interesting to have component specific tests especially that tests also get published along the source code though it makes things more complicated).

@chr-hertel chr-hertel modified the milestones: 1.0.0, 0.10.0 Nov 8, 2026
@chr-hertel
chr-hertel force-pushed the package-slicing branch 3 times, most recently from 286038e to a73fb33 Compare November 10, 2026 12:16
@chr-hertel
chr-hertel requested a balanced review from Copilot November 10, 2026 12:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unchanged persistent cache keys can reuse discovery objects serialized under old namespaces, causing return-type failures after an upgrade instead of rediscovering capabilities.

1 open issue
43 resolved since last review

And 23 more resolved.

Review effort: Balanced

Move ExtensionInterface::getRequestHandlers() to Mcp\Server\Extension\ServerExtensionInterface,
so Mcp\Schema no longer references Mcp\Server, and move the header agreement tests that need
both packages to the integration suite.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified for the namespace and dependency-boundary changes preparing the PHP SDK package split.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@chr-hertel
chr-hertel merged commit 0aec843 into modelcontextprotocol:main Nov 10, 2026
30 checks passed
@chr-hertel
chr-hertel deleted the package-slicing branch November 10, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Breaking the Backwards Compatibility Promise Client Issues & PRs related to the Client component Schema Issues & PRs related to the Schema component Server Issues & PRs related to the Server component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants