π The fast, Pythonic way to build MCP servers and clients.
Fix trailing slash
Jeremiah Lowin19c152628656
diff --git a/src/fastmcp/client/transports.py b/src/fastmcp/client/transports.pyindex 68508db7b..cc05669b8 100644--- a/src/fastmcp/client/transports.py+++ b/src/fastmcp/client/transports.py@@ -9,7 +9,6 @@ import warningsfrom collections.abc import AsyncIterator, Callablefrom pathlib import Pathfrom typing import Any, Literal, TypeVar, cast, overload-from urllib.parse import urlparse, urlunparseimport anyioimport httpx@@ -161,11 +160,8 @@ class SSETransport(ClientTransport):if not isinstance(url, str) or not url.startswith("http"):raise ValueError("Invalid HTTP/S URL provided for SSE.")- # Ensure the URL path ends with a trailing slash to avoid automatic redirects- parsed = urlparse(url)- if not parsed.path.endswith("/"):- parsed = parsed._replace(path=parsed.path + "/")- url = urlunparse(parsed)+ # Don't modify the URL path - respect the exact URL provided by the user+ # Some servers are strict about trailing slashes (e.g., PayPal MCP)self.url = urlself.headers = headers or {}@@ -236,11 +232,8 @@ class StreamableHttpTransport(ClientTransport):if not isinstance(url, str) or not url.startswith("http"):raise ValueError("Invalid HTTP/S URL provided for Streamable HTTP.")- # Ensure the URL path ends with a trailing slash to avoid automatic redirects- parsed = urlparse(url)- if not parsed.path.endswith("/"):- parsed = parsed._replace(path=parsed.path + "/")- url = urlunparse(parsed)+ # Don't modify the URL path - respect the exact URL provided by the user+ # Some servers are strict about trailing slashes (e.g., PayPal MCP)self.url = urlself.headers = headers or {}