Spaces:
Running
Running
Jeremiah Lowin commited on
Commit ·
4546541
1
Parent(s): c0ec675
Fix trailing slash
Browse files
src/fastmcp/client/transports.py
CHANGED
|
@@ -9,7 +9,6 @@ import warnings
|
|
| 9 |
from collections.abc import AsyncIterator, Callable
|
| 10 |
from pathlib import Path
|
| 11 |
from typing import Any, Literal, TypeVar, cast, overload
|
| 12 |
-
from urllib.parse import urlparse, urlunparse
|
| 13 |
|
| 14 |
import anyio
|
| 15 |
import httpx
|
|
@@ -161,11 +160,8 @@ class SSETransport(ClientTransport):
|
|
| 161 |
if not isinstance(url, str) or not url.startswith("http"):
|
| 162 |
raise ValueError("Invalid HTTP/S URL provided for SSE.")
|
| 163 |
|
| 164 |
-
#
|
| 165 |
-
|
| 166 |
-
if not parsed.path.endswith("/"):
|
| 167 |
-
parsed = parsed._replace(path=parsed.path + "/")
|
| 168 |
-
url = urlunparse(parsed)
|
| 169 |
|
| 170 |
self.url = url
|
| 171 |
self.headers = headers or {}
|
|
@@ -236,11 +232,8 @@ class StreamableHttpTransport(ClientTransport):
|
|
| 236 |
if not isinstance(url, str) or not url.startswith("http"):
|
| 237 |
raise ValueError("Invalid HTTP/S URL provided for Streamable HTTP.")
|
| 238 |
|
| 239 |
-
#
|
| 240 |
-
|
| 241 |
-
if not parsed.path.endswith("/"):
|
| 242 |
-
parsed = parsed._replace(path=parsed.path + "/")
|
| 243 |
-
url = urlunparse(parsed)
|
| 244 |
|
| 245 |
self.url = url
|
| 246 |
self.headers = headers or {}
|
|
|
|
| 9 |
from collections.abc import AsyncIterator, Callable
|
| 10 |
from pathlib import Path
|
| 11 |
from typing import Any, Literal, TypeVar, cast, overload
|
|
|
|
| 12 |
|
| 13 |
import anyio
|
| 14 |
import httpx
|
|
|
|
| 160 |
if not isinstance(url, str) or not url.startswith("http"):
|
| 161 |
raise ValueError("Invalid HTTP/S URL provided for SSE.")
|
| 162 |
|
| 163 |
+
# Don't modify the URL path - respect the exact URL provided by the user
|
| 164 |
+
# Some servers are strict about trailing slashes (e.g., PayPal MCP)
|
|
|
|
|
|
|
|
|
|
| 165 |
|
| 166 |
self.url = url
|
| 167 |
self.headers = headers or {}
|
|
|
|
| 232 |
if not isinstance(url, str) or not url.startswith("http"):
|
| 233 |
raise ValueError("Invalid HTTP/S URL provided for Streamable HTTP.")
|
| 234 |
|
| 235 |
+
# Don't modify the URL path - respect the exact URL provided by the user
|
| 236 |
+
# Some servers are strict about trailing slashes (e.g., PayPal MCP)
|
|
|
|
|
|
|
|
|
|
| 237 |
|
| 238 |
self.url = url
|
| 239 |
self.headers = headers or {}
|