Skip to content

Commit 862c22f

Browse files
Kludexfelixweinberger
authored andcommitted
Add overload for deprecation
1 parent 5004eda commit 862c22f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/mcp/client/streamable_http.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
from contextlib import asynccontextmanager
1313
from dataclasses import dataclass
1414
from datetime import timedelta
15+
from typing import Any, overload
16+
from warnings import warn
1517

1618
import anyio
1719
import httpx
@@ -85,13 +87,28 @@ class RequestContext:
8587
class StreamableHTTPTransport:
8688
"""StreamableHTTP client transport implementation."""
8789

90+
@overload
91+
def __init__(self, url: str) -> None: ...
92+
93+
@deprecated("Those parameters are deprecated. Use the url parameter instead.")
94+
@overload
95+
def __init__(
96+
self,
97+
url: str,
98+
headers: dict[str, str] | None = None,
99+
timeout: float | timedelta = 30,
100+
sse_read_timeout: float | timedelta = 60 * 5,
101+
auth: httpx.Auth | None = None,
102+
) -> None: ...
103+
88104
def __init__(
89105
self,
90106
url: str,
91107
headers: dict[str, str] | None = None,
92108
timeout: float | timedelta = 30,
93109
sse_read_timeout: float | timedelta = 60 * 5,
94110
auth: httpx.Auth | None = None,
111+
**deprecated: dict[str, Any],
95112
) -> None:
96113
"""Initialize the StreamableHTTP transport.
97114
@@ -102,6 +119,8 @@ def __init__(
102119
sse_read_timeout: Timeout for SSE read operations.
103120
auth: Optional HTTPX authentication handler.
104121
"""
122+
if deprecated:
123+
warn(f"Deprecated parameters: {deprecated}", DeprecationWarning)
105124
self.url = url
106125
self.headers = headers or {}
107126
self.timeout = timeout.total_seconds() if isinstance(timeout, timedelta) else timeout

0 commit comments

Comments
 (0)