From f0ae9305f91aa18f5f71b1bd655c31031131be1a Mon Sep 17 00:00:00 2001 From: Federico Kamelhar Date: Fri, 17 Apr 2026 14:12:33 -0400 Subject: [PATCH] feat(mcp): add strands.mcp as canonical MCP import path 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 #1431. A follow-up will move the implementation into strands.mcp and convert strands.tools.mcp into a deprecated alias. Refs #1431 --- src/strands/mcp/__init__.py | 17 +++++++++++++ tests/strands/mcp/__init__.py | 0 .../strands/mcp/test_canonical_import_path.py | 25 +++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 src/strands/mcp/__init__.py create mode 100644 tests/strands/mcp/__init__.py create mode 100644 tests/strands/mcp/test_canonical_import_path.py diff --git a/src/strands/mcp/__init__.py b/src/strands/mcp/__init__.py new file mode 100644 index 000000000..77daed8a5 --- /dev/null +++ b/src/strands/mcp/__init__.py @@ -0,0 +1,17 @@ +"""Canonical import path for the Model Context Protocol (MCP) integration. + +Model Context Protocol functionality is being promoted from +``strands.tools.mcp`` to this top-level ``strands.mcp`` package because MCP +now spans tools, prompts, resources, tasks, and elicitation -- concepts +that extend beyond ``tools``. + +For now this package is a thin re-export of ``strands.tools.mcp``. A +follow-up change will invert the relationship: the implementation will +live here and ``strands.tools.mcp`` will become a deprecated alias. +Users can safely migrate imports to ``strands.mcp`` today; the public +API is identical and object identity is preserved. +""" + +from ..tools.mcp import MCPAgentTool, MCPClient, MCPTransport, TasksConfig, ToolFilters + +__all__ = ["MCPAgentTool", "MCPClient", "MCPTransport", "TasksConfig", "ToolFilters"] diff --git a/tests/strands/mcp/__init__.py b/tests/strands/mcp/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/strands/mcp/test_canonical_import_path.py b/tests/strands/mcp/test_canonical_import_path.py new file mode 100644 index 000000000..0194d3bee --- /dev/null +++ b/tests/strands/mcp/test_canonical_import_path.py @@ -0,0 +1,25 @@ +"""Tests for the canonical ``strands.mcp`` import path. + +The implementation currently lives in ``strands.tools.mcp``. This test +locks in the contract that ``strands.mcp`` re-exports the same objects so +that users can migrate imports ahead of the follow-up refactor that +moves the implementation. +""" + + +def test_strands_mcp_reexports_public_api() -> None: + import strands.mcp as new + import strands.tools.mcp as old + + assert new.MCPClient is old.MCPClient + assert new.MCPAgentTool is old.MCPAgentTool + assert new.MCPTransport is old.MCPTransport + assert new.TasksConfig is old.TasksConfig + assert new.ToolFilters is old.ToolFilters + + +def test_strands_mcp_all_matches_tools_mcp_all() -> None: + import strands.mcp as new + import strands.tools.mcp as old + + assert sorted(new.__all__) == sorted(old.__all__)