MCPcopy
hub / github.com/modelcontextprotocol/python-sdk / httpx_client_factory

Function httpx_client_factory

tests/interaction/_connect.py:365–379  ·  view source on GitHub ↗
(
        headers: dict[str, str] | None = None,
        timeout: httpx.Timeout | None = None,
        auth: httpx.Auth | None = None,
    )

Source from the content-addressed store, hash-verified

363 app, _ = build_sse_app(server)
364
365 def httpx_client_factory(
366 headers: dict[str, str] | None = None,
367 timeout: httpx.Timeout | None = None,
368 auth: httpx.Auth | None = None,
369 ) -> httpx.AsyncClient:
370 # The SSE server transport's connect_sse runs the entire MCP session inside the GET
371 # request and only releases its streams after that request observes a disconnect, so the
372 # bridge must let the application drain rather than cancelling at close.
373 return httpx.AsyncClient(
374 transport=StreamingASGITransport(app, cancel_on_close=False),
375 base_url=BASE_URL,
376 headers=headers,
377 timeout=timeout,
378 auth=auth,
379 )
380
381 transport = sse_client(f"{BASE_URL}/sse", httpx_client_factory=httpx_client_factory)
382 async with Client(

Callers 1

sse_clientFunction · 0.50

Calls 1

Tested by

no test coverage detected