mirror of
https://github.com/aljazceru/mcp-python-sdk.git
synced 2025-12-19 14:54:24 +01:00
Add header support for sse_client
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import logging
|
||||
from contextlib import asynccontextmanager
|
||||
from typing import Any
|
||||
from urllib.parse import urljoin, urlparse
|
||||
|
||||
import anyio
|
||||
@@ -18,7 +19,7 @@ def remove_request_params(url: str) -> str:
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def sse_client(url: str, timeout: float = 5, sse_read_timeout: float = 60 * 5):
|
||||
async def sse_client(url: str, headers: dict[str, Any] | None = None, timeout: float = 5, sse_read_timeout: float = 60 * 5):
|
||||
"""
|
||||
Client transport for SSE.
|
||||
|
||||
@@ -36,7 +37,7 @@ async def sse_client(url: str, timeout: float = 5, sse_read_timeout: float = 60
|
||||
async with anyio.create_task_group() as tg:
|
||||
try:
|
||||
logger.info(f"Connecting to SSE endpoint: {remove_request_params(url)}")
|
||||
async with httpx.AsyncClient() as client:
|
||||
async with httpx.AsyncClient(headers=headers) as client:
|
||||
async with aconnect_sse(
|
||||
client,
|
||||
"GET",
|
||||
|
||||
Reference in New Issue
Block a user