Skip to content

fix: MCP SSE cannot list tool #7420

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions src/backend/base/langflow/base/mcp/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,22 +153,9 @@
parsed = urlparse(url)
if not parsed.scheme or not parsed.netloc:
return False, "Invalid URL format. Must include scheme (http/https) and host."

async with httpx.AsyncClient() as client:
try:
# First try a HEAD request to check if server is reachable
response = await client.head(url, timeout=5.0)
if response.status_code >= HTTP_ERROR_STATUS_CODE:
return False, f"Server returned error status: {response.status_code}"

except httpx.TimeoutException:
return False, "Connection timed out. Server may be down or unreachable."
except httpx.NetworkError:
return False, "Network error. Could not reach the server."
else:
return True, ""

except (httpx.HTTPError, ValueError, OSError) as e:
# must not use client.head to validate the url, as SSE will keep the transport open and become timeout
return True, ""

Check failure on line 157 in src/backend/base/langflow/base/mcp/util.py

View workflow job for this annotation

GitHub Actions / Ruff Style Check (3.13)

Ruff (TRY300)

src/backend/base/langflow/base/mcp/util.py:157:13: TRY300 Consider moving this statement to an `else` block
except ValueError as e:
return False, f"URL validation error: {e!s}"

async def pre_check_redirect(self, url: str | None) -> str | None:
Expand Down
Loading