From 8e5ab564b9d40efcee24ba9c41aa055a49dd6a01 Mon Sep 17 00:00:00 2001 From: Calum Murray Date: Wed, 2 Jul 2025 10:45:31 -0400 Subject: [PATCH] cleanup: remove mcp sse url optimization Signed-off-by: Calum Murray --- llama_stack/providers/utils/tools/mcp.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/llama_stack/providers/utils/tools/mcp.py b/llama_stack/providers/utils/tools/mcp.py index 9ca457ec0..f32743225 100644 --- a/llama_stack/providers/utils/tools/mcp.py +++ b/llama_stack/providers/utils/tools/mcp.py @@ -6,9 +6,7 @@ from collections.abc import AsyncGenerator from contextlib import _AsyncGeneratorContextManager, asynccontextmanager -from pathlib import PurePosixPath from typing import Any, cast -from urllib.parse import unquote, urlparse import httpx from mcp import ClientSession @@ -70,17 +68,11 @@ async def streamable_http_client_wrapper(endpoint: str, headers: dict[str, str]) def get_client_wrapper(endpoint: str, headers: dict[str, str]) -> _AsyncGeneratorContextManager[ClientSession, Any]: - path = PurePosixPath(unquote(urlparse(endpoint).path)) - if path.parts[-1] != "sse": - try: - return streamable_http_client_wrapper(endpoint, headers) - except AuthenticationRequiredError as e: - raise e # since this was an authentication error, we want to surface that instead of trying with SSE - except Exception: - return sse_client_wrapper(endpoint, headers) - else: - # most SSE MCP servers are served at endpoints ending in /sse, so default to the SSE client wrapper - # if the endpoint is explicitly an SSE endpoint + try: + return streamable_http_client_wrapper(endpoint, headers) + except AuthenticationRequiredError as e: + raise e # since this was an authentication error, we want to surface that instead of trying with SSE + except Exception: return sse_client_wrapper(endpoint, headers)