diff --git a/packages/mcpplugin/src/microsoft_teams/mcpplugin/transport.py b/packages/mcpplugin/src/microsoft_teams/mcpplugin/transport.py index 83ece8d8..d7736b9b 100644 --- a/packages/mcpplugin/src/microsoft_teams/mcpplugin/transport.py +++ b/packages/mcpplugin/src/microsoft_teams/mcpplugin/transport.py @@ -9,7 +9,7 @@ import httpx from mcp.client.sse import sse_client -from mcp.client.streamable_http import streamable_http_client +from mcp.client.streamable_http import create_mcp_http_client, streamable_http_client ValueOrFactory = Union[str, Callable[[], Union[str, Awaitable[str]]]] @@ -31,12 +31,8 @@ async def create_streamable_http_transport( else: resolved_headers[key] = str(value) - if resolved_headers: - async with httpx.AsyncClient(headers=resolved_headers) as http_client: - async with streamable_http_client(url, http_client=http_client) as (read_stream, write_stream, _): - yield read_stream, write_stream - else: - async with streamable_http_client(url) as (read_stream, write_stream, _): + async with create_mcp_http_client(headers=resolved_headers or None) as http_client: + async with streamable_http_client(url, http_client=http_client) as (read_stream, write_stream, _): yield read_stream, write_stream