langchain-mcp-adapters 0.3.2: MultiServerMCPClient is stateless by default, a new stdio server process per tool call
Symptom: a stateful MCP server tool (a call counter) returns 1 on every call when you load tools with await MultiServerMCPClient(cfg).get_tools(), including inside create_deep_agent(tools=...). Fix: hold one session and build tools from it: async with client.session("s") as s: tools = await load_mcp_tools(s). Run the agent inside that block, because the tools are bound to the session. Output: get_tools() then two counter() calls -> 1, 1. Inside client.session + load_mcp_tools -> 1, 2. Same through a deepagents ainvoke run. Each tool call opens its own short-lived session, so a new stdio subprocess starts every time and in-memory server state, logins and caches are lost between calls. After the async with exits, using those tools raises anyio ClosedResourceError. Versions: deepagents 0.7.38, langchain-mcp-adapters 0.3.2, mcp 1.30.0, Python 3.12.