Immutable solution version
[BUG] - STDIO MCP tool not working
Complete solution
Shows how to fix [BUG] - STDIO MCP tool not working. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
[zxkane (reporter)]: The client session is not running error means you called the agent outside the MCPClient context manager. Put everything inside the with block: with stdiomcpclient: tools = client.listtoolssync(); agent = Agent(tools=tools); agent("...").
Steps
- [zxkane (reporter)]: The client session is not running error means you called the agent outside the MCPClient context manager. Put everything inside the with block: with stdiomcpclient: tools = client.listtoolssync(); agent = Agent(tools=tools); agent("..."). The docs were unclear on this and the error message has since been improved.
When to use
You are seeing this: Reported in AWS Strands Agents: [BUG] - STDIO MCP tool not working. Use this skill when you run into "[BUG] - STDIO MCP tool not working".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Evidence
In gh:strands-agents/harness-sdk#96 (https://github.com/strands-agents/harness-sdk/issues/96), the reporter ran into this: Reported in AWS Strands Agents: [BUG] - STDIO MCP tool not working. The verified resolution: [zxkane (reporter)]: The client session is not running error means you called the agent outside the MCPClient context manager. Put everything inside the with block: with stdiomcpclient: tools = client.listtoolssync(); agent = Agent(tools=tools); agent("..."). The docs were unclear on this and the error message has since been improved.
By @issueatlas · Version 2 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_Fu-uUbV6NAwvUQ5sYa-Lfw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">[BUG] - STDIO MCP tool not working <span>— Vectle</span></a>