Upstream 20260501#19
Merged
andylim-duo merged 15 commits intomainfrom May 4, 2026
Merged
Conversation
…ss 1 directory (modelcontextprotocol#2350) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
…across 1 directory (modelcontextprotocol#2406) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…extprotocol#2366) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Max Isbey <224885523+maxisbey@users.noreply.github.com>
- Add missing blank line after merge_contexts (pre-commit) - Remove try/finally in test to fix branch coverage gap Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Merge upstream
modelcontextprotocol/python-sdkmain (as of 2026-05-01) into our fork, preserving multi-tenant isolation features.Upstream changes included
_meta(Add basic OpenTelemetry tracing for client and server requests modelcontextprotocol/python-sdk#2381)contextvars.Contextpropagation through anyio memory streams (Propagate contextvars.Context through anyio streams without modifying SessionMessage modelcontextprotocol/python-sdk#2298)resourcesparameter onMCPServer— bulk resource init at construction (Addresourcesparameter toMCPServermodelcontextprotocol/python-sdk#2414)dependenciesparameter restored onMCPServer(feat(server): restoredependenciesparameter on MCPServer modelcontextprotocol/python-sdk#2358)is_async_callablereplacesinspect.iscoroutinefunction(Use sharedis_async_callableinstead ofinspect.iscoroutinefunctionmodelcontextprotocol/python-sdk#2389)OAuthClientMetadata(fix(auth): coerce empty-string optional URL fields to None in OAuthClientMetadata modelcontextprotocol/python-sdk#2404), refresh token guidance (SEP-2207: Refresh token guidance modelcontextprotocol/python-sdk#2039)PydanticUserErrorin output schema generation (fix: catch PydanticUserError when generating output schema (pydantic 2.13 compat) modelcontextprotocol/python-sdk#2434)claude-code-reviewworkflow, skipclaude.ymlon@claude reviewcommentsMerge conflict resolutions
Four files had conflicts between upstream's structural changes and our tenant-scoped storage model:
src/mcp/server/lowlevel/server.pytenant_id_varpropagation into the new_handle_request; removed duplicate handler block from conflictsrc/mcp/server/mcpserver/resources/resource_manager.pydict[str | None, dict[str, Resource]]type; added upstream'sresources=constructor parameter with bulk initsrc/mcp/server/mcpserver/tools/tool_manager.pytools=constructor kwargtests/server/mcpserver/resources/test_resource_manager.py_templatesdirect write to useadd_template()Context merging fix
Upstream's context-aware streams propagate the sender's (client-side)
contextvars.Contextto server handlers for OTel trace correlation. This shadowed ourtenant_id_var(set server-side) in the in-memory transport.Fix: Added
merge_contexts(sender, server)insrc/mcp/shared/_context.py— creates a new context using the sender as base with server-side vars overlaid. Server wins on conflict, preventing clients from spoofingtenant_id_var.Documentation updates
docs/multi-tenancy.md— added Context Merging architecture section, security notes onctx.metabeing client-controlled, documented decorator/constructor global-scope limitationsdocs/migration.md— added bug fix entry for context propagation with link to multi-tenancy guideTest plan
merge_contextsunit tests (sender-only, server-only, both, conflict, tenant spoof, empty cases)test_sender_context_and_tenant_id_coexistverifies both client contextvar and servertenant_id_varvisible in handlertest_context_propagationstill passes