diff --git a/mcp_python/client/sse.py b/mcp_python/client/sse.py index 918fa96..93d026d 100644 --- a/mcp_python/client/sse.py +++ b/mcp_python/client/sse.py @@ -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", diff --git a/pyproject.toml b/pyproject.toml index 9710bec..9b01f45 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "mcp-python" -version = "0.1.2" +version = "0.1.3" description = "Model Context Protocol implementation for Python" readme = "README.md" requires-python = ">=3.8"