Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
271a230
fix leak
phact Dec 12, 2025
3330537
[autofix.ci] apply automated fixes
autofix-ci[bot] Dec 12, 2025
b31d8c9
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Dec 12, 2025
8161a6e
[autofix.ci] apply automated fixes (attempt 3/3)
autofix-ci[bot] Dec 12, 2025
cf2b417
Merge branch 'main' into fix-mcp-proxy-process-leak
edwinjosechittilappilly Dec 12, 2025
0943672
[autofix.ci] apply automated fixes
autofix-ci[bot] Dec 12, 2025
55ca4a0
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Dec 12, 2025
c581ba1
[autofix.ci] apply automated fixes (attempt 3/3)
autofix-ci[bot] Dec 12, 2025
6a86414
Move MCP client imports out of loop iteration in get_servers (#10993)
Copilot Dec 12, 2025
ebe11ac
[autofix.ci] apply automated fixes
autofix-ci[bot] Dec 12, 2025
647ad2f
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Dec 12, 2025
75d9a66
Merge branch 'main' into fix-mcp-proxy-process-leak
Adam-Aghili Dec 12, 2025
248794e
[autofix.ci] apply automated fixes
autofix-ci[bot] Dec 12, 2025
8722a2a
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Dec 12, 2025
afb25ad
[autofix.ci] apply automated fixes (attempt 3/3)
autofix-ci[bot] Dec 12, 2025
8683731
Merge branch 'main' into fix-mcp-proxy-process-leak
Adam-Aghili Dec 12, 2025
227cc95
[autofix.ci] apply automated fixes
autofix-ci[bot] Dec 12, 2025
4e69254
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Dec 12, 2025
fae2360
[autofix.ci] apply automated fixes (attempt 3/3)
autofix-ci[bot] Dec 12, 2025
2fc6cc1
Merge branch 'main' into fix-mcp-proxy-process-leak
Adam-Aghili Dec 12, 2025
5691b1a
[autofix.ci] apply automated fixes
autofix-ci[bot] Dec 12, 2025
03f8f60
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Dec 12, 2025
87d54c9
[autofix.ci] apply automated fixes (attempt 3/3)
autofix-ci[bot] Dec 12, 2025
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
12 changes: 12 additions & 0 deletions src/backend/base/langflow/api/v2/mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ async def get_servers(
"""Get the list of available servers."""
import asyncio

from lfx.base.mcp.util import MCPStdioClient, MCPStreamableHttpClient

server_list = await get_server_list(current_user, session, storage_service, settings_service)

if not action_count:
Expand All @@ -150,10 +152,15 @@ async def get_servers(
# Check all of the tool counts for each server concurrently
async def check_server(server_name: str) -> dict:
server_info: dict[str, str | int | None] = {"name": server_name, "mode": None, "toolsCount": None}
# Create clients that we control so we can clean them up after
mcp_stdio_client = MCPStdioClient()
mcp_streamable_http_client = MCPStreamableHttpClient()
try:
mode, tool_list, _ = await update_tools(
server_name=server_name,
server_config=server_list["mcpServers"][server_name],
mcp_stdio_client=mcp_stdio_client,
mcp_streamable_http_client=mcp_streamable_http_client,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. I say we get this in for v1.7.

Let's add a follow up to the update_tools function that reminds us to refactor how it creates clients, so nobody can call it in the future without cleanup.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a good point Jordan

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot can you think of a clean refactor where it cleans up after itself?

)
server_info["mode"] = mode.lower()
server_info["toolsCount"] = len(tool_list)
Expand Down Expand Up @@ -199,6 +206,11 @@ async def check_server(server_name: str) -> dict:
else:
await logger.aexception(f"Error checking server {server_name}: {e}")
server_info["error"] = f"Error loading server: {e}"
finally:
# Always disconnect clients to prevent mcp-proxy process leaks
# These clients spawn subprocesses that need to be explicitly terminated
await mcp_stdio_client.disconnect()
await mcp_streamable_http_client.disconnect()
return server_info

# Run all server checks concurrently
Expand Down
2 changes: 1 addition & 1 deletion src/lfx/src/lfx/_assets/component_index.json

Large diffs are not rendered by default.

Loading