Skip to content

cannot get response from await session.call_tool() #262

Open

Description

@herrrX

hello, I'm sorry to bother you. I've recently encountered a blocking issue with the MCP client.
I've set up an MCP server, and it runs in Claude successfully. However, when I use the client I set up, the call to the tool result = await session.call_tool() gets stuck and doesn't return a response. But when I use tools = await session.list_tools(), I can retrieve the list of tools.

Through logging within the client file, I'm able to confirm that the tool call has been initiated and executed successfully, and the result is obtained, but the client side can't receive the result. It seems there's an issue with the transmission layer of the protocol. I've been struggling with this for two days and have looked for solutions without success, even after upgrading the system version.

I removed the other logic and only kept the tool invocation. The code is as follows.

Looking forward to your reply.


from mcp import ClientSession, StdioServerParameters, types
from mcp.client.stdio import stdio_client


server_params = StdioServerParameters(  # Create server parameters for stdio connection
    command="uvx",
    args=[
        "--from",
        "git+ssh://xxxx.xx.xxx",
        "server-name"
    ],
    env=None
)

# Optional: create a sampling callback
async def handle_sampling_message(message: types.CreateMessageRequestParams) -> types.CreateMessageResult:
    return types.CreateMessageResult(
        role="assistant",
        content=types.TextContent(
            type="text",
            text="Hello, world! from model",
        ),
        model="gpt-3.5-turbo",
        stopReason="endTurn",
    )

async def run():
    async with stdio_client(server_params) as (read, write):
        async with ClientSession(read, write, sampling_callback=handle_sampling_message) as session:
            # Initialize the connection
            await session.initialize()
            # List available tools
            tools = await session.list_tools()
            # Call a tool
            result = await session.call_tool("query-api-infos", arguments={"api_info_id": "8768555"})
            print(result)

if __name__ == "__main__":
    import asyncio
    asyncio.run(run())

Activity

  1. added
    bugSomething isn't working
    ready for workEnough information for someone to start working on
    P1Significant bug affecting many users, highly requested feature
    and removed
    needs confirmationNeeds confirmation that the PR is actually required or needed.
    on Oct 3, 2025
  2. challenger71498 commented on Dec 26, 2025

    @challenger71498

    Hi @herrrX and everyone who are interested in this issue,

    I encountered the same issue as you did, and realised there are some issues related to this problem.

    TL; DR: Basic issue is from MCP SDK, but to fix the issue completely, ADK must be fixed too.

    MCP SDK Issues

    BaseSession cleanup is being cancelled on __aexit__, leaving all remaining streams to be opened.

    Google ADK Issues

    McpSessionManager does not follow AnyIO's structured concurrency; it may close the taskgroup with task differ to the one which started the taskgroup(especially when an error occured in TaskGroup).

    There is no such timeout for tool call itself, MCP Session only relys on httpx timeout.

    • Whether MCP uses Streaming HTTP or SSE, it requires stream to receive messages. Also both have quite complicate process to handle request and responses.
    • Only relying on httpx timeout when calling tool is dangerous, if a blocking happens in this middleware process, the tool call never gets done(e.g. this issue is the one causes the infinite-hang reguardless of the httpx timeout).
    • A dedicate timeout for tool call is needed. If not, at least we need to set the tool call timeout as same as SSE read timeout, of which default value is 300s.
    • This issue is being resolved with the PR above.

    Concurrency problem on AgentTool: when you call Agent-as-a-tool in parallel with same agent, if one tool finishes the tool call early, corresponding every other tool calls are being failed, due to the early release of shared resource(McpSessionManager).

    • Calling AgentTool in parallel creates multiple runners which is using same agent at the same time.
    • If one tool call is done, the runner closes the whole toolset of the agent it is referencing to.
    • This causes the McpSessionManager to be closed.
    • Since McpSessionManager is closed, other runners referencing this MCP toolset, is all being failed. (It raises ResourceClosedError)
    • Sadly I haven't found a solution to this issue yet.
      • To handle this issue, I need to deep-dive into the runtime of ADK, requires some time.
      • I think we need a reference-count-like structure in Agent to count runners, and cleanup toolsets only if there is no runner working on.. but not sure it is okay to cleanup the toolsets at that point since a new runner might use the agent(e.g. tool call on same tool again).
  3. IgnazioDS commented on Jun 8, 2026

    @IgnazioDS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Significant bug affecting many users, highly requested featurebugSomething isn't workingready for workEnough information for someone to start working on

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions