Skip to content

Running into an ImportError when executing the MCP client in examples/servers/simple-tool #1101

Closed
@Lando-Loeper-Neew-Ventures

Description

Initial Checks

Description

I wanted to test my MCP server the same way in the examples/servers/simple-tool however running the MCP client script I run into:

ImportError: cannot import name 'ClientSession' from partially initialized module 'mcp.client.session' (mos│
t likely due to a circular import)

Any help appreciated

Example Code

import asyncio
from mcp.client.session import ClientSession
from mcp.client.stdio import StdioServerParameters, stdio_client


async def main():
    async with stdio_client(
        StdioServerParameters(command="uv", args=["run", "mcp-simple-tool"])
    ) as (read, write):
        async with ClientSession(read, write) as session:
            await session.initialize()

            # List available tools
            tools = await session.list_tools()
            print(tools)

            # Call the fetch tool
            result = await session.call_tool("fetch", {"url": "https://example.com"})
            print(result)


asyncio.run(main())

Python & MCP Python SDK

Python Version: 3.13.5
Python SDK: 1.10.1
uv: 0.7.19

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions