Skip to content

Commit b580876

Browse files
[autofix.ci] apply automated fixes (attempt 2/3)
1 parent f68b8e4 commit b580876

File tree

6 files changed

+14
-19
lines changed

6 files changed

+14
-19
lines changed

src/backend/base/langflow/api/utils/mcp/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
from langflow.api.utils.mcp.config_utils import (
44
auto_configure_starter_projects_mcp,
55
get_composer_streamable_http_url,
6-
get_project_streamable_http_url,
76
get_project_sse_url,
7+
get_project_streamable_http_url,
88
get_url_by_os,
99
)
1010

1111
__all__ = [
1212
"auto_configure_starter_projects_mcp",
1313
"get_composer_streamable_http_url",
14-
"get_project_streamable_http_url",
1514
"get_project_sse_url",
15+
"get_project_streamable_http_url",
1616
"get_url_by_os",
1717
]

src/backend/base/langflow/api/v1/mcp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ async def _dispatch_streamable_http(
148148
await _streamable_http_manager.handle_request(request.scope, request.receive, request._send) # noqa: SLF001
149149
except HTTPException:
150150
raise
151-
except Exception as exc: # noqa: BLE001
151+
except Exception as exc:
152152
await logger.aexception(f"Error handling Streamable HTTP request: {exc!s}")
153153
raise HTTPException(status_code=500, detail="Internal server error in Streamable HTTP transport") from exc
154154
finally:

src/backend/base/langflow/api/v1/mcp_projects.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ async def list_project_tools(
311311
return await _dispatch_project_streamable_http(project_id, request, auth_user)
312312

313313
metadata = await _build_project_tools_response(project_id, current_user, mcp_enabled=mcp_enabled)
314-
return JSONResponse(content=metadata.model_dump(mode='json'))
314+
return JSONResponse(content=metadata.model_dump(mode="json"))
315315

316316

317317
@router.head("/{project_id}/sse", response_class=HTMLResponse, include_in_schema=False)
@@ -338,9 +338,7 @@ async def _dispatch_project_streamable_http(
338338
except HTTPException:
339339
raise
340340
except Exception as exc:
341-
await logger.aexception(
342-
f"Error handling Streamable HTTP request for project {project_id}: {exc!s}"
343-
)
341+
await logger.aexception(f"Error handling Streamable HTTP request for project {project_id}: {exc!s}")
344342
raise HTTPException(status_code=500, detail="Internal server error in project MCP transport") from exc
345343
finally:
346344
current_request_variables_ctx.reset(request_vars_token)

src/backend/tests/unit/api/v1/test_mcp.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,7 @@ async def test_mcp_sse_get_endpoint_invalid_auth(client: AsyncClient):
8080

8181
# Test the POST / endpoint (handles incoming MCP messages)
8282
async def test_mcp_post_endpoint(
83-
client: AsyncClient,
84-
logged_in_headers,
85-
mock_streamable_http_manager,
86-
mock_ensure_manager_running
83+
client: AsyncClient, logged_in_headers, mock_streamable_http_manager, mock_ensure_manager_running
8784
):
8885
"""Test POST / endpoint successfully handles MCP messages."""
8986
test_message = {"type": "test", "content": "message"}

src/backend/tests/unit/api/v1/test_mcp_projects.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,17 @@ def mock_streamable_http_manager():
7272
"""Mock StreamableHTTPSessionManager used by ProjectMCPServer."""
7373
with patch("langflow.api.v1.mcp_projects.StreamableHTTPSessionManager") as mock_class:
7474
manager_instance = MagicMock()
75-
75+
7676
# Mock the run() method to return an async context manager
7777
async_cm = AsyncContextManagerMock()
7878
manager_instance.run = MagicMock(return_value=async_cm)
79-
79+
8080
# Mock handle_request as an async method (this is what gets called, not handle_post_message)
8181
manager_instance.handle_request = AsyncMock()
82-
82+
8383
# Make the class constructor return our mocked instance
8484
mock_class.return_value = manager_instance
85-
85+
8686
yield manager_instance
8787

8888

src/lfx/src/lfx/services/mcp_composer/service.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ class MCPComposerService(Service):
7373

7474
def __init__(self):
7575
super().__init__()
76-
self.project_composers: dict[str, dict] = {} # project_id -> {process, host, port, streamable_http_url, auth_config}
76+
self.project_composers: dict[
77+
str, dict
78+
] = {} # project_id -> {process, host, port, streamable_http_url, auth_config}
7779
self._start_locks: dict[
7880
str, asyncio.Lock
7981
] = {} # Lock to prevent concurrent start operations for the same project
@@ -1045,9 +1047,7 @@ async def _do_start_project_composer(
10451047

10461048
project_host = auth_config.get("oauth_host") if auth_config else "unknown"
10471049
project_port = auth_config.get("oauth_port") if auth_config else "unknown"
1048-
await logger.adebug(
1049-
f"Starting MCP Composer for project {project_id} on {project_host}:{project_port}"
1050-
)
1050+
await logger.adebug(f"Starting MCP Composer for project {project_id} on {project_host}:{project_port}")
10511051

10521052
# Use a per-project lock to prevent race conditions
10531053
if project_id not in self._start_locks:

0 commit comments

Comments
 (0)