Description
Checks
- I have updated to the lastest minor and patch version of Strands
- I have checked the documentation and this is not expected behavior
- I have searched ./issues and there are no duplicates of my issue
Strands Version
0.1.4
Python Version
3.13
Operating System
Windows and macOs
Installation Method
pip
Steps to Reproduce
- Initiate any stdio_mcp_client with npx.
For example, use the npx example server for graph memory (anthropic)
`
from strands import Agent
from strands_tools import http_request
from strands.models import BedrockModel
from mcp import stdio_client, StdioServerParameters
from strands import Agent
from strands.tools.mcp import MCPClient
import logging
SYSTEM_PROMPT = """
You're great at remembering stuff from users
"""
stdio_mcp_client = MCPClient(lambda: stdio_client(
StdioServerParameters(command="npx", args=["-y", "@modelcontextprotocol/server-memory"])
))
with stdio_mcp_client:
# Get the tools from the MCP server
tools = stdio_mcp_client.list_tools_sync()
# Create an agent with these tools
agent = Agent(model=bedrock_model,tools=tools,system_prompt=SYSTEM_PROMPT)
Example usage
if name == "main":
print("\n📁 Memory Master Assistant Agent 📁\n")
print("How can I help you?")
print("Type 'exit' to quit.")
# Interactive loop
while True:
try:
user_input = input("\n> ")
if user_input.lower() == "exit":
print("\nGoodbye! 👋")
break
response = agent(
user_input,
)
# Extract and print only the relevant content from the specialized agent's response
content = str(response)
print(content)
except KeyboardInterrupt:
print("\n\nExecution interrupted. Exiting...")
break
except Exception as e:
print(f"\nAn error occurred: {str(e)}")
print("Please try with a different question.")`
- Trigger a prompt to let the agent invoke the tool, for example:
I'm Ricardo, remember this
Expected Behavior
Invoke the tool without issues.
Actual Behavior
An exception is raised
File "/home/xxxx/desarrollo/strands2/.venv/lib/python3.13/site-packages/strands/tools/mcp/mcp_agent_tool.py", line 83, in invoke
return self.mcp_client.call_tool_sync(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
tool_use_id=tool["toolUseId"], name=self.tool_name, arguments=tool["input"]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/home/xxxx/desarrollo/strands2/.venv/lib/python3.13/site-packages/strands/tools/mcp/mcp_client.py", line 183, in call_tool_sync
raise MCPClientInitializationError("the client session is not running")
strands.types.exceptions.MCPClientInitializationError: the client session is not running
This happens with any MCP Server that is ran via npx.
Additional Context
No response
Possible Solution
No response
Related Issues
No response