Skip to content

Getting the following error when trying to run the cloud_engineer_agent.py directly #1

@zensim

Description

@zensim

Hi,
I am using win 11, vs code and python 311. Could not run the Streamlit so tried running the above py code directly. Getting the exception below. Please advise. Thanks

client failed to initializeunhandled errors in a TaskGroup (1 sub-exception)

  • Exception Group Traceback (most recent call last):
    | File "...venv\Lib\site-packages\strands\tools\mcp\mcp_client.py", line 107, in start
    | self._init_future.result(timeout=120) #30 was original val
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "..\Python311\Lib\concurrent\futures_base.py", line 456, in result
    | return self.__get_result()
    | ^^^^^^^^^^^^^^^^^^^
    | File "..\Python311\Lib\concurrent\futures_base.py", line 401, in __get_result
    | raise self.exception
    | File "..venv\Lib\site-packages\strands\tools\mcp\mcp_client.py", line 223, in async_background_thread
    | async with self.transport_callable() as (read_stream, write_stream, *):
    | File "..\Python311\Lib\contextlib.py", line 222, in aexit
    | await self.gen.athrow(typ, value, traceback)
    | File "...venv\Lib\site-packages\mcp\client\stdio_init
    .py", line 178, in stdio_client
    | async with (
    | File "...venv\Lib\site-packages\anyio_backends_asyncio.py", line 772, in aexit
    | raise BaseExceptionGroup(
    | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
    +-+---------------- 1 ----------------
    | Exception Group Traceback (most recent call last):
    | File "..venv\Lib\site-packages\mcp\client\stdio_init
    .py", line 185, in stdio_client
    | yield read_stream, write_stream
    | File "..venv\Lib\site-packages\strands\tools\mcp\mcp_client.py", line 225, in _async_background_thread
    | async with ClientSession(read_stream, write_stream) as session:
    | File "...venv\Lib\site-packages\mcp\shared\session.py", line 223, in aexit
    | return await self._task_group.aexit(exc_type, exc_val, exc_tb)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "..venv\Lib\site-packages\anyio_backends_asyncio.py", line 772, in aexit
    | raise BaseExceptionGroup(
    | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
    +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    | File "..venv\Lib\site-packages\strands\tools\mcp\mcp_client.py", line 227, in _async_background_thread
    | await session.initialize()
    | File "..venv\Lib\site-packages\mcp\client\session.py", line 133, in initialize
    | result = await self.send_request(
    | ^^^^^^^^^^^^^^^^^^^^^^^^
    | File "..venv\Lib\site-packages\mcp\shared\session.py", line 297, in send_request
    | raise McpError(response_or_error.error)
    | mcp.shared.exceptions.McpError: Connection closed
    +------------------------------------
  • Exception Group Traceback (most recent call last):
    | File "..venv\Lib\site-packages\strands\tools\mcp\mcp_client.py", line 107, in start
    | self._init_future.result(timeout=120) #30 was original val
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "..\Python311\Lib\concurrent\futures_base.py", line 456, in result
    | return self.__get_result()
    | ^^^^^^^^^^^^^^^^^^^
    | File "..\Python311\Lib\concurrent\futures_base.py", line 401, in __get_result
    | raise self.exception
    | File "..venv\Lib\site-packages\strands\tools\mcp\mcp_client.py", line 223, in async_background_thread
    | async with self.transport_callable() as (read_stream, write_stream, *):
    | File "..\Python311\Lib\contextlib.py", line 222, in aexit
    | await self.gen.athrow(typ, value, traceback)
    | File "..venv\Lib\site-packages\mcp\client\stdio_init
    .py", line 178, in stdio_client
    | async with (
    | File "..venv\Lib\site-packages\anyio_backends_asyncio.py", line 772, in aexit
    | raise BaseExceptionGroup(
    | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
    +-+---------------- 1 ----------------
    | Exception Group Traceback (most recent call last):
    | File "..venv\Lib\site-packages\mcp\client\stdio_init
    .py", line 185, in stdio_client
    | yield read_stream, write_stream
    | File "..venv\Lib\site-packages\strands\tools\mcp\mcp_client.py", line 225, in _async_background_thread
    | async with ClientSession(read_stream, write_stream) as session:
    | File "..venv\Lib\site-packages\mcp\shared\session.py", line 223, in aexit
    | return await self._task_group.aexit(exc_type, exc_val, exc_tb)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "..venv\Lib\site-packages\anyio_backends_asyncio.py", line 772, in aexit
    | raise BaseExceptionGroup(
    | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
    +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    | File "..venv\Lib\site-packages\strands\tools\mcp\mcp_client.py", line 227, in _async_background_thread
    | await session.initialize()
    | File "...venv\Lib\site-packages\mcp\client\session.py", line 133, in initialize
    | result = await self.send_request(
    | ^^^^^^^^^^^^^^^^^^^^^^^^
    | File "...venv\Lib\site-packages\mcp\shared\session.py", line 297, in send_request
    | raise McpError(response_or_error.error)
    | mcp.shared.exceptions.McpError: Connection closed
    +------------------------------------

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "...\cloud_engineer_agent.py", line 30, in
aws_docs_mcp_client.start()
File "...venv\Lib\site-packages\strands\tools\mcp\mcp_client.py", line 113, in start
raise MCPClientInitializationError("the client initialization failed") from e
strands.types.exceptions.MCPClientInitializationError: the client initialization failed

Metadata

Metadata

Assignees

No one assigned

    Labels

    Amazon Q development agentGenerate new features or iterate code based on issue descriptions and comments.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions