Skip to content

feat(mcp): replace hand-rolled HTTP with SDK streamable_http_client#3491

Open
Hundao wants to merge 1 commit intoadenhq:mainfrom
Hundao:feat/streamable-http-mcp-client
Open

feat(mcp): replace hand-rolled HTTP with SDK streamable_http_client#3491
Hundao wants to merge 1 commit intoadenhq:mainfrom
Hundao:feat/streamable-http-mcp-client

Conversation

@Hundao
Copy link
Collaborator

@Hundao Hundao commented Feb 4, 2026

Description

Replace the hand-rolled httpx-based HTTP implementation in MCPClient with the MCP SDK's streamable_http_client, making the HTTP transport spec-compliant and unifying both STDIO and HTTP code paths.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)

Related Issues

Fixes #3152 (Step 1 — Transport Protocol)

Changes Made

  • Replace httpx.Client + hand-rolled JSON-RPC with MCP SDK's streamable_http_client + ClientSession
  • Unify STDIO and HTTP transports to share the same session-based tool listing, invocation, and cleanup logic
  • Auto-append /mcp to URLs without a path (matches FastMCP's default Streamable HTTP endpoint)
  • Remove import httpx top-level dependency
  • Properly close httpx.AsyncClient in _cleanup_async() (SDK does not auto-close a provided client)
  • Add 15 unit tests (test_mcp_client.py) covering URL handling, validation, unified interface, cleanup, and config
  • Add 7 integration tests (test_mcp_client_integration.py) with an in-process FastMCP server over real HTTP

Testing

  • Unit tests pass (cd core && pytest tests/test_mcp_client.py) — 15/15
  • Integration tests pass (cd core && pytest tests/test_mcp_client_integration.py) — 7/7
  • Lint passes (ruff check)
  • Format passes (ruff format --check)
  • Manual E2E testing with two example agents:
    • web_research_agent (STDIO transport) — searched topic + sent email via hive-tools MCP
    • place_finder_agent (HTTP transport) — searched places via Google Maps MCP at https://mapstools.googleapis.com/mcp

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Screenshots (if applicable)

E2E: web_research_agent (STDIO transport)

image

E2E: place_finder_agent (HTTP transport → Google Maps MCP)

image

Use the MCP SDK's streamable_http_client for spec-compliant Streamable
HTTP transport, unifying both STDIO and HTTP paths to share the same
ClientSession-based tool listing, invocation, and cleanup logic.

- Remove httpx dependency and hand-rolled JSON-RPC calls
- Auto-append /mcp to URLs without a path (FastMCP default)
- Add unit tests (15) and integration tests (7) for the HTTP transport
@Hundao Hundao requested a review from TimothyZhang7 February 4, 2026 09:21
Copy link
Collaborator

@TimothyZhang7 TimothyZhang7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Make HTTP MCP client spec-compliant (Streamable HTTP transport)

2 participants