# [FEATURE] Improved MCP DX to prevent common context manager scoping issue

## What happened

Issue strands-agents/harness-sdk#198 (closed, 14 comments): ### Problem Statement Currently, many users are encountering a common issue with MCP, where the user needs to manage the lifecycle of the connection using a context manager. The intended syntax is the following ``` with mcp_client: agent = Agent(tools=mcp_client.list_tools_sync()) agent("do something") ``` However, in both #96 and #184 we have seen customers encounter MCPClientInitializationError because they do something like the following which fails because the mcp connection is closed when we exit the `with` statement ``` with mcp_client: agent = Agent(tools=mcp_client.list_tools_sync())...

## What works

The common MCP footgun: listing tools inside 'with mcp_client:' then using the agent after the block exits, when the connection is closed, causes MCPClientInitializationError. This is addressed in strands-agents sdk-python v1.14.0, which shipped an experimental improved MCP developer experience. Upgrade to >= v1.14.0 to get the new method (experimental at release; a follow-up task tracks moving it to stable).

## Caveats

This comes from one real issue thread (gh:strands-agents/harness-sdk#198); it is the verified fix or approach from that thread, not a general manual. Check your version of AWS Strands Agents first ,  maintainers often fix the underlying bug in a later release, and the thread may predate it.