-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Tighten the public API surface: root exports, listen types, dead-code removal #3203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
maxisbey
wants to merge
1
commit into
main
Choose a base branch
from
api-surface-cleanup
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,5 +2,4 @@ | |
|
|
||
| from .cli import app | ||
|
|
||
| if __name__ == "__main__": # pragma: no cover | ||
| app() | ||
| __all__ = ["app"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 The breaking change moving the lowlevel
Contextclass from the publicmcp.server.contextmodule to the privatemcp.server._contextmodule is not documented indocs/migration.md, even though the PR description states it is. AGENTS.md requires all breaking changes to be documented there — please add a short migration entry (grouped with the existing lowlevel-server/context sections) noting the class is now private and thatfrom mcp.server.context import ContextraisesImportError.Extended reasoning...
What the bug is. This PR moves the lowlevel server
Contextclass out of the publicmcp.server.contextmodule into a new privatemcp.server._contextmodule. That is a breaking change: any code doingfrom mcp.server.context import Contextnow raisesImportError. The PR description explicitly claims this is covered: "Yes, all documented indocs/migration.md: ...mcp.server.context.Contextis now private" — but no such entry exists in the guide.Verification. Grepping the post-PR
docs/migration.mdfor_context,Context is now private, and related phrases finds nothing. The PR's migration.md edits are only: theSamplingRoletable row, theMCPServertop-level export note, the newStreamableHTTPError/ResumptionError/get_session_id()section, theNoBackChannelErrorexport note, and — at lines 2780–2783 — the removal of themcp.server.context.Context.log()mention from the SEP-2577 deprecated-logging list. That removed mention also confirms the class was documented public surface before this PR: the guide referenced it as live API, and the PR deleted the reference rather than documenting the move.Why this matters. AGENTS.md states: "Breaking changes (including those softened by a backwards-compatibility shim) must be documented in
docs/migration.md." This is an explicit repo-mandated requirement, and the guide already carries intra-v2 pre-release notes (since 2.0.0b2,since 2.0.0rc1), so "Context never existed in v1" does not excuse the omission. Notably, the three other removals in this same PR (SamplingRole;StreamableHTTPError/ResumptionError/get_session_id()) each received a dedicated migration section — the omission looks like an oversight, not a policy decision, and the author's own PR description shows the entry was intended.Concrete walk-through. (1) A v2-RC user has middleware or tests importing
from mcp.server.context import Context(a public, documented path before this PR — the migration guide itself referencedmcp.server.context.Context.log()). (2) They upgrade past this PR. (3) The import raisesImportError. (4) They opendocs/migration.md— the canonical record of every breaking change per AGENTS.md — and search forContextormcp.server.context: no entry explains the class moved tomcp.server._contextor that it is now private. They are left to bisect the SDK source.Mitigating factors considered. One verifier noted the class's own new docstring says "Private for now:
ServerRunnerdoes not construct it", so real-world importers are likely rare, and the fix is docs-only. That argues for lower impact, but the repo's own instructions make documenting breaking changes inmigration.mda hard requirement, and the PR affirmatively (and incorrectly) claims compliance — this is not a stale-description case, since the entry was clearly intended and simply never written.How to fix. Add a short section to
docs/migration.md(grouped near the existing lowlevel-Server/context sections, e.g. after theRequestContextsplit section) stating: the lowlevelContextclass moved frommcp.server.contextto the privatemcp.server._contextmodule and is no longer public API;from mcp.server.context import Contextnow raisesImportError;ServerRequestContextand the middleware types (CallNext,HandlerResult,ServerMiddleware) inmcp.server.contextare unchanged; handlers receive aServerRequestContext, which is the supported surface.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
migration.md is for breaking changes from v1 to v2. this class wasn't in v1 so there's no reason for it to be in migration.md