feat(mcp): move MCP implementation to strands.mcp, deprecate old path (2/3)#2152
Open
fede-kamel wants to merge 2 commits intostrands-agents:mainfrom
Open
feat(mcp): move MCP implementation to strands.mcp, deprecate old path (2/3)#2152fede-kamel wants to merge 2 commits intostrands-agents:mainfrom
fede-kamel wants to merge 2 commits intostrands-agents:mainfrom
Conversation
Introduces a top-level strands.mcp package that re-exports the public API from strands.tools.mcp. Object identity is preserved, so users can migrate `from strands.tools.mcp import X` to `from strands.mcp import X` today with no behavior change. This is the first of two steps for strands-agents#1431. A follow-up will move the implementation into strands.mcp and convert strands.tools.mcp into a deprecated alias. Refs strands-agents#1431
Moves the MCP implementation from strands.tools.mcp to strands.mcp using git-tracked renames. strands.tools.mcp becomes a deprecation alias: - Emits a DeprecationWarning on import pointing to strands.mcp. - Re-exports the public API (object identity preserved). - Registers legacy submodule paths (strands.tools.mcp.mcp_client, etc.) via sys.modules so ``from strands.tools.mcp.mcp_client import X`` continues to resolve to the canonical modules. Follow-up PR will move the tests into tests/strands/mcp, update integration tests, README, and AGENTS.md. Refs strands-agents#1431
This was referenced Apr 17, 2026
fede-kamel
added a commit
to fede-kamel/sdk-python
that referenced
this pull request
Apr 18, 2026
Third and final step for strands-agents#1431. Depends on strands-agents#2152. - Move tests from tests/strands/tools/mcp/ to tests/strands/mcp/ as git-tracked renames with import updates (strands.tools.mcp -> strands.mcp). - Add tests/strands/tools/mcp/test_deprecated_aliases.py covering the DeprecationWarning, public-API identity, and sys.modules submodule aliasing for legacy import paths. - Update the canonical-import-path test to reflect the post-move reality (strands.mcp is canonical; strands.tools.mcp is the alias). - Update tests_integ/mcp/ imports to the new canonical path. - Update README.md (MCP example) and AGENTS.md (TasksConfig snippet). - Update tests/strands/tools/test_registry.py import. Refs strands-agents#1431
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.
Strategy: 3-PR stack for a large refactor
Issue #1431 asks for two things at once: relocating the MCP package AND preserving backwards compatibility. An atomic implementation of both is ~2000 lines of changes (mostly because git can't detect a rename when both paths must keep working). Instead, the work is split into three stacked PRs:
strands.mcpas a pure re-export ofstrands.tools.mcp. Additive only.strands.mcpviagit mv;strands.tools.mcpbecomes asys.modules-based deprecation shim.-M)tests_integ/mcp, README, and AGENTS.md.Each step leaves
mainin a valid state, is independently revertable, and is independently reviewable. The order matters:strands.mcpis part of the public API before the implementation moves.Why
sys.modulesaliasing instead of per-module stub files?A naive implementation would create 5 per-submodule stub
.pyfiles atsrc/strands/tools/mcp/(each doingfrom strands.mcp.<name> import *and emitting aDeprecationWarning). That's semantically identical but has two costs:label-sizefails as advisory.DeprecationWarning.Instead, this PR registers all legacy submodule paths in
sys.modulesfrom a singlestrands/tools/mcp/__init__.py:This means:
.pyfiles can be deleted — git detects the 5 moves as pure renames and the diff collapses to just the import-path adjustments inside the moved files.DeprecationWarningper process (at first legacy import), pointing users to the new path.from strands.tools.mcp.mcp_client import Xstill resolves: Python importsstrands.tools.mcpfirst (running the shim__init__.py, which registers the alias), then findsstrands.tools.mcp.mcp_clientinsys.modules.The full ~1800 lines of implementation still physically move across the package boundary — git's rename detection just displays the move honestly as renames instead of add+delete.
Summary
Second of three stacked PRs for #1431. Depends on #2148.
Moves the MCP implementation files from
strands.tools.mcpintostrands.mcpusing git-tracked renames.strands.tools.mcpbecomes a deprecation alias that:strands.mcp(object identity preserved).DeprecationWarningat package-import time.sys.modulessofrom strands.tools.mcp.mcp_client import Xcontinues to resolve.What this PR does
git mvfor 5 submodule files (mcp_client.py,mcp_agent_tool.py,mcp_types.py,mcp_tasks.py,mcp_instrumentation.py) fromsrc/strands/tools/mcp/→src/strands/mcp/.src/strands/mcp/__init__.pyto use local imports (replacing the pure re-export from feat(mcp): add strands.mcp as canonical MCP import path (1/3) #2148).src/strands/tools/mcp/__init__.pyas asys.modules-aliasing deprecation shim.Backwards-compat guarantees (verified E2E)
from strands.tools.mcp import MCPClient→ works, emitsDeprecationWarning.strands.tools.mcp.MCPClient is strands.mcp.MCPClient→True.from strands.tools.mcp.mcp_client import MCPClient→ works viasys.modulesalias; same object as new path.from strands.tools.mcp import mcp_client→ works viasys.modulesalias.Tests run locally (Python 3.13)
hatch test --python 3.13 tests/hatch fmt --linter --checkmypy ./srcvia hatch-static-analysishatch test tests/strands/mcp/ tests/strands/tools/python demo_new_path.py— spawnstests_integ/mcp/echo_server.pyecho+get_weathercalledpython demo_backcompat.pysys.modulesawslabs.aws-documentation-mcp-serverpython demo_aws_docs_backcompat.py(spawned viauvx)proxy.search.docs.aws.com; real AWS Lambda docs returnedechotool, returned expected stringRefs #1431