Skip to content

Commit ac3acbb

Browse files
authored
Merge pull request #1 from jonathanglima/main
fixing /mcp case prefix on langchain
2 parents 7e1b9d3 + 9a58b30 commit ac3acbb

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/mcp/client/sse.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,22 @@ async def sse_reader(
6262
logger.debug(f"Received SSE event: {sse.event}")
6363
match sse.event:
6464
case "endpoint":
65+
url_parsed = urlparse(url)
66+
6567
base_path = re.search(
66-
r"https?://[^/]+/(.+)/sse$", url
68+
r"https?://[^/]+/(.+?)(?:/mcp)?/sse$", url
6769
)
6870
base_path = (
6971
base_path.group(1) if base_path else ""
7072
)
7173
endpoint_url = urljoin(
72-
url, base_path + sse.data
74+
url_parsed.scheme + "://" + url_parsed.netloc,
75+
base_path + sse.data
7376
)
7477
logger.info(
7578
f"Received endpoint URL: {endpoint_url}"
7679
)
7780

78-
url_parsed = urlparse(url)
7981
endpoint_parsed = urlparse(endpoint_url)
8082
if (
8183
url_parsed.netloc != endpoint_parsed.netloc

0 commit comments

Comments
 (0)