Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 12, 2025

Addresses performance feedback on #10988: imports were being executed on every server check iteration.

Changes

  • Moved MCPStdioClient and MCPStreamableHttpClient imports from check_server inner function to parent get_servers function
  • Imports now execute once per endpoint call instead of N times (once per configured MCP server)
async def get_servers(...):
    import asyncio
    from lfx.base.mcp.util import MCPStdioClient, MCPStreamableHttpClient  # ← moved here
    
    server_list = await get_server_list(...)
    
    async def check_server(server_name: str) -> dict:
        # imports removed from here
        mcp_stdio_client = MCPStdioClient()
        mcp_streamable_http_client = MCPStreamableHttpClient()
        ...
    
    tasks = [check_server(server) for server in server_list["mcpServers"]]

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 12, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI changed the title [WIP] Update imports for mcp-proxy process leak fix Move MCP client imports out of loop iteration in get_servers Dec 12, 2025
Copilot AI requested a review from phact December 12, 2025 17:08
@phact phact marked this pull request as ready for review December 12, 2025 17:23
@phact phact merged commit 6a86414 into fix-mcp-proxy-process-leak Dec 12, 2025
1 check passed
@phact phact deleted the copilot/sub-pr-10988 branch December 12, 2025 17:24
github-merge-queue bot pushed a commit that referenced this pull request Dec 12, 2025
* fix leak

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

* Move MCP client imports out of loop iteration in get_servers (#10993)

* Initial plan

* Move MCPStdioClient and MCPStreamableHttpClient imports to get_servers function

Co-authored-by: phact <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: phact <[email protected]>

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Edwin Jose <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: phact <[email protected]>
Co-authored-by: Adam Aghili <[email protected]>
Adam-Aghili added a commit that referenced this pull request Dec 12, 2025
* fix leak

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

* Move MCP client imports out of loop iteration in get_servers (#10993)

* Initial plan

* Move MCPStdioClient and MCPStreamableHttpClient imports to get_servers function

Co-authored-by: phact <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: phact <[email protected]>

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Edwin Jose <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: phact <[email protected]>
Co-authored-by: Adam Aghili <[email protected]>
Adam-Aghili added a commit that referenced this pull request Dec 12, 2025
* fix: mcp-proxy process leak (#10988)

* fix leak

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

* Move MCP client imports out of loop iteration in get_servers (#10993)

* Initial plan

* Move MCPStdioClient and MCPStreamableHttpClient imports to get_servers function

Co-authored-by: phact <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: phact <[email protected]>

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Edwin Jose <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: phact <[email protected]>
Co-authored-by: Adam Aghili <[email protected]>

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

---------

Co-authored-by: Sebastián Estévez <[email protected]>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Edwin Jose <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: phact <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants