Skip to content

Commit aa1b6ce

Browse files
committed
Add auth to SseServerParameters and StreamableHttpParameters
1 parent c8bbfc0 commit aa1b6ce

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/mcp/client/session_group.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
from typing import Any, TypeAlias
1717

1818
import anyio
19-
from pydantic import BaseModel
19+
import httpx
20+
from pydantic import BaseModel, ConfigDict
2021
from typing_extensions import Self
2122

2223
import mcp
@@ -30,6 +31,8 @@
3031
class SseServerParameters(BaseModel):
3132
"""Parameters for intializing a sse_client."""
3233

34+
model_config = ConfigDict(arbitrary_types_allowed=True)
35+
3336
# The endpoint URL.
3437
url: str
3538

@@ -42,10 +45,15 @@ class SseServerParameters(BaseModel):
4245
# Timeout for SSE read operations.
4346
sse_read_timeout: float = 60 * 5
4447

48+
# Optional HTTPX authentication handler.
49+
auth: httpx.Auth | None = None
50+
4551

4652
class StreamableHttpParameters(BaseModel):
4753
"""Parameters for intializing a streamablehttp_client."""
4854

55+
model_config = ConfigDict(arbitrary_types_allowed=True)
56+
4957
# The endpoint URL.
5058
url: str
5159

@@ -61,6 +69,9 @@ class StreamableHttpParameters(BaseModel):
6169
# Close the client session when the transport closes.
6270
terminate_on_close: bool = True
6371

72+
# Optional HTTPX authentication handler.
73+
auth: httpx.Auth | None = None
74+
6475

6576
ServerParameters: TypeAlias = StdioServerParameters | SseServerParameters | StreamableHttpParameters
6677

0 commit comments

Comments
 (0)