Skip to content

Commit f9baa82

Browse files
authored
Merge pull request #6 from modelcontextprotocol/ken/headers
Add header support for sse_client
2 parents 4cbf815 + 4f0abd1 commit f9baa82

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

mcp_python/client/sse.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import logging
22
from contextlib import asynccontextmanager
3+
from typing import Any
34
from urllib.parse import urljoin, urlparse
45

56
import anyio
@@ -18,7 +19,7 @@ def remove_request_params(url: str) -> str:
1819

1920

2021
@asynccontextmanager
21-
async def sse_client(url: str, timeout: float = 5, sse_read_timeout: float = 60 * 5):
22+
async def sse_client(url: str, headers: dict[str, Any] | None = None, timeout: float = 5, sse_read_timeout: float = 60 * 5):
2223
"""
2324
Client transport for SSE.
2425
@@ -36,7 +37,7 @@ async def sse_client(url: str, timeout: float = 5, sse_read_timeout: float = 60
3637
async with anyio.create_task_group() as tg:
3738
try:
3839
logger.info(f"Connecting to SSE endpoint: {remove_request_params(url)}")
39-
async with httpx.AsyncClient() as client:
40+
async with httpx.AsyncClient(headers=headers) as client:
4041
async with aconnect_sse(
4142
client,
4243
"GET",

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "mcp-python"
7-
version = "0.1.2"
7+
version = "0.1.3"
88
description = "Model Context Protocol implementation for Python"
99
readme = "README.md"
1010
requires-python = ">=3.8"

0 commit comments

Comments
 (0)