Support custom httpx client creation (#752)
This commit is contained in:
parent
7c8ad510b7
commit
10cf0f78a8
1 changed files with 16 additions and 5 deletions
|
|
@ -19,7 +19,7 @@ from anyio.abc import TaskGroup
|
|||
from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream
|
||||
from httpx_sse import EventSource, ServerSentEvent, aconnect_sse
|
||||
|
||||
from mcp.shared._httpx_utils import create_mcp_http_client
|
||||
from mcp.shared._httpx_utils import McpHttpClientFactory, create_mcp_http_client
|
||||
from mcp.shared.message import ClientMessageMetadata, SessionMessage
|
||||
from mcp.types import (
|
||||
ErrorData,
|
||||
|
|
@ -430,6 +430,7 @@ async def streamablehttp_client(
|
|||
timeout: timedelta = timedelta(seconds=30),
|
||||
sse_read_timeout: timedelta = timedelta(seconds=60 * 5),
|
||||
terminate_on_close: bool = True,
|
||||
httpx_client_factory: McpHttpClientFactory = create_mcp_http_client,
|
||||
auth: httpx.Auth | None = None,
|
||||
) -> AsyncGenerator[
|
||||
tuple[
|
||||
|
|
@ -464,7 +465,7 @@ async def streamablehttp_client(
|
|||
try:
|
||||
logger.info(f"Connecting to StreamableHTTP endpoint: {url}")
|
||||
|
||||
async with create_mcp_http_client(
|
||||
async with httpx_client_factory(
|
||||
headers=transport.request_headers,
|
||||
timeout=httpx.Timeout(
|
||||
transport.timeout.seconds, read=transport.sse_read_timeout.seconds
|
||||
|
|
|
|||
Loading…
Reference in a new issue