feat(mcp): move MCP tests + update integ imports + docs (3/3)#2158
Open
fede-kamel wants to merge 3 commits intostrands-agents:mainfrom
Open
feat(mcp): move MCP tests + update integ imports + docs (3/3)#2158fede-kamel wants to merge 3 commits intostrands-agents:mainfrom
fede-kamel wants to merge 3 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
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 was referenced Apr 18, 2026
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.Role of this PR in the stack
Step 2 delivered the semantic move: the implementation lives at
strands.mcpandstrands.tools.mcpis a thinsys.modules-aliasing shim. But it deliberately stopped there to keep its diff honest (pure renames + one shim file). This PR finishes the story by bringing the repo's own tests and documentation in line with the canonical path:test_deprecated_aliases.pysuite lives at the old location (next to the alias it tests), locking in the four backcompat guarantees as regression tests.tests_integ/mcp/swap their imports to the canonical path.Summary
Third and final stacked PR for #1431. Depends on #2152.
Moves the MCP unit tests into
tests/strands/mcp/, adds a dedicated deprecated-aliases test suite at the legacy location, and updates integration tests, README, and AGENTS.md to reference the new canonical import path.What this PR does
tests/strands/tools/mcp/*→tests/strands/mcp/*(7 files, git-detected renames;conftest.py,test_mcp_client.py,test_mcp_agent_tool.py,test_mcp_client_contextvar.py,test_mcp_client_tasks.py,test_mcp_client_tool_provider.py,test_mcp_instrumentation.py) with import-path updates inside each file (strands.tools.mcp→strands.mcp).tests/strands/tools/mcp/test_deprecated_aliases.py— covers the four backcompat guarantees from feat(mcp): move MCP implementation to strands.mcp, deprecate old path (2/3) #2152:DeprecationWarning.strands.mcp.from strands.tools.mcp import mcp_client) resolve viasys.modulesto the canonical modules.from strands.tools.mcp.mcp_client import X) return the same objects as the canonical path.tests/strands/mcp/test_canonical_import_path.py— post-move, the test verifiesstrands.tools.mcpaliasesstrands.mcp(previously the other direction, reflecting the pre-move feat(mcp): add strands.mcp as canonical MCP import path (1/3) #2148 intermediate state).tests_integ/mcp/*imports — 7 files, one-line import swap each, from the legacy path to the canonical path.README.md— the MCP example at line 111 now usesfrom strands.mcp import MCPClient.AGENTS.md— theTasksConfigsnippet now usesfrom strands.mcp import MCPClient, TasksConfig.tests/strands/tools/test_registry.py— internal import swap.Diff size
19 files changed, +149 / -63 per
git diff --stat -M. The moves are git-tracked renames; the only material additions are the newtest_deprecated_aliases.pysuite (~78 lines) and the test-body import updates.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/mcp/ tests/strands/tools/test_registry.pyAWS_DEFAULT_REGION=us-east-1 hatch test tests_integ/mcp/test_mcp_client_tasks.py tests_integ/mcp/test_mcp_output_schema.py tests_integ/mcp/test_mcp_resources.pytests_integ/mcp/echo_server.pypython demo_new_path.pytests_integ/mcp/echo_server.pypython demo_backcompat.pyechotool, returned expected stringNotes for reviewers
test_deprecated_aliases.pyis deliberately placed undertests/strands/tools/mcp/(the legacy location) so it lives alongside the alias it tests. It will move/disappear when the alias is removed in a future release.test_canonical_import_path.pylives under the canonicaltests/strands/mcp/and locks in the identity contract from the canonical direction.test_mcp_client.py,test_mcp_client_structured_content_and_metadata.py,test_mcp_elicitation.py,test_mcp_tool_provider.py) require Bedrock credentials and were not run locally. They're covered by the maintainer CI'sSTRANDS_INTEG_TEST_ROLE. The ad-hoc Agent+MCP smoke tests above use a non-Bedrock model provider via API key to exercise the same code path.Closes #1431