Exception has occurred: MCPClientInitializationError #71
-
Hi, I was trying to run the Example provided in the docs : https://strandsagents.com/0.1.x/user-guide/concepts/tools/mcp-tools/ strands-agent ver: 0.1.3
Error: Exception has occurred: MCPClientInitializationError The above exception was the direct cause of the following exception: File "D:\Projects\tryStrandAgents\mcp-stdio.py", line 11, in Solution please ? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I'm able to replicate this on Windows. Will see what I can find and report back. |
Beta Was this translation helpful? Give feedback.
-
Solution: Windows Compatibility Issue with MCP ClientRoot CauseThe issue you're experiencing is a cross-platform compatibility problem with how Why This HappensOn Linux/macOS (works): uvx awslabs.aws-documentation-mcp-server@latest On Windows (fails):
uvx --from awslabs.aws-documentation-mcp-server@latest awslabs.aws-documentation-mcp-server.exe Immediate SolutionSince you're on Windows, use this corrected version of your code: from mcp import stdio_client, StdioServerParameters
from strands import Agent
from strands.tools.mcp import MCPClient
# Windows-specific args for uvx
stdio_mcp_client = MCPClient(lambda: stdio_client(
StdioServerParameters(
command="uvx",
args=[
"--from",
"awslabs.aws-documentation-mcp-server@latest",
"awslabs.aws-documentation-mcp-server.exe"
]
)
))
# Rest of your code works as expected
with stdio_mcp_client:
tools = stdio_mcp_client.list_tools_sync()
agent = Agent(tools=tools)
result = agent("Hello, how are you?") Cross-Platform AlternativeIf you're working across different operating systems, here's a platform-aware workaround: import platform
from mcp import stdio_client, StdioServerParameters
from strands import Agent
from strands.tools.mcp import MCPClient
def get_platform_args(base_args):
"""Convert base uvx args to platform-specific format"""
if platform.system() == "Windows":
package_name = base_args[0].split("@")[0]
return ["--from"] + base_args + [f"{package_name}.exe"]
return base_args
# Use the platform-aware args
stdio_mcp_client = MCPClient(lambda: stdio_client(
StdioServerParameters(
command="uvx",
args=get_platform_args(["awslabs.aws-documentation-mcp-server@latest"])
)
))
# Rest of your code works as expected
with stdio_mcp_client:
tools = stdio_mcp_client.list_tools_sync()
agent = Agent(tools=tools)
result = agent("Hello, how are you?") Recommended Fix for FrameworkWe should handle this platform difference internally in the The fix would involve:
TestingThis solution has been tested on Windows and resolves the |
Beta Was this translation helpful? Give feedback.
-
New issue for suggested long-term fix: #92 |
Beta Was this translation helpful? Give feedback.
Solution: Windows Compatibility Issue with MCP Client
Root Cause
The issue you're experiencing is a cross-platform compatibility problem with how
uvx
handles package execution on different operating systems. The example in our documentation works on Linux/macOS but fails on Windows due to different command structure requirements.Why This Happens
On Linux/macOS (works):
On Windows (fails):
The same command structure doesn't work because Windows requires:
--from
flag to specify the package source.exe
extension for the executable