Skip to content

ImportError: cannot import name 'streamablehttp_client' from 'mcp.client.streamable_http' — mcp 2.0.0 breaking change #119

Description

@HarryKino

Error Traceback

Traceback (most recent call last):
  File "/home/ubuntu/.local/bin/mini-agent", line 4, in <module>
    from mini_agent.cli import main
  File "/home/ubuntu/.local/share/uv/tools/mini-agent/lib/python3.10/site-packages/mini_agent/cli.py", line 37, in <module>
    from mini_agent.tools.mcp_loader import cleanup_mcp_connections, load_mcp_tools_async, set_mcp_timeout_config
  File "/home/ubuntu/.local/share/uv/tools/mini-agent/lib/python3.10/site-packages/mini_agent/tools/mcp_loader.py", line 13, in <module>
    from mcp.client.streamable_http import streamablehttp_client
ImportError: cannot import name 'streamablehttp_client' from 'mcp.client.streamable_http' (/home/ubuntu/.local/share/uv/tools/mini-agent/lib/python3.10/site-packages/mcp/client/streamable_http.py)

Workaround
Pin mcp < 2.0 during installation:

# Uninstall the broken installation
uv tool uninstall mini-agent

# Reinstall with mcp pinned to < 2.0
uv tool install --with "mcp<2.0" git+https://github.com/MiniMax-AI/Mini-Agent.git

# Verify
mini-agent --version
# mini-agent 0.1.0

This successfully resolves the issue and mini-agent runs normally.

Suggested Fix
Option A: Pin mcp upper bound in pyproject.toml (quick fix)

# Before
mcp >= 1.0.0

# After
mcp >= 1.0.0, < 2.0

Option B: Update import and call site for mcp 2.0.0 compatibility (long-term fix)

Update mini_agent/tools/mcp_loader.py:

 #Before
from mcp.client.streamable_http import streamablehttp_client

 #After
from mcp.client.streamable_http import streamable_http_client

Update the _connect_streamable_http call site:

# Before
read_stream, write_stream, _ = await self.exit_stack.enter_async_context(
    streamablehttp_client(
        url=self.url,
        headers=self.headers if self.headers else None,
        timeout=connect_timeout,
        sse_read_timeout=sse_read_timeout,
    )
)

# After
import httpx

http_client = httpx.AsyncClient(
    headers=self.headers if self.headers else None,
    timeout=httpx.Timeout(connect_timeout, read=sse_read_timeout),
)
read_stream, write_stream, _ = await self.exit_stack.enter_async_context(
    streamable_http_client(
        url=self.url,
        http_client=http_client,
    )
)

References

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