Skip to content
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

feat: lmprove MCP langflow port selection and error handling #7327

Merged
merged 13 commits into from
Mar 31, 2025

Conversation

edwinjosechittilappilly
Copy link
Collaborator

@edwinjosechittilappilly edwinjosechittilappilly commented Mar 28, 2025

This pull request introduces several improvements to the MCPToolsComponent and MCPSseClient classes, focusing on better error handling, validation, and connection management. The most important changes include adding URL validation, improving connection retry logic, and enhancing error messages.

Improvements to URL validation and connection handling:

Enhancements to MCPToolsComponent:

Additional changes:

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request enhances error handling and URL validation for MCP tools while making minor import adjustments in various test files. Key changes include:

  • Implementation of URL validation, retry mechanisms, and improved logging for server connections.
  • Addition of a new method to discover Langflow instances by scanning environment variables and common ports.
  • Adjustments to import statements in several unit tests for consistency.

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

File Description
src/backend/tests/unit/*.py Minor import adjustments to ensure consistency
src/backend/base/langflow/components/tools/mcp_component.py Added Langflow instance discovery method and enhanced SSE error handling
src/backend/base/langflow/base/mcp/util.py Introduced URL validation and retry logic with improved error messages
Comments suppressed due to low confidence (1)

src/backend/base/langflow/components/tools/mcp_component.py:31

  • [nitpick] Consider renaming 'default_keys' to 'DEFAULT_KEYS' to clearly indicate that it represents a constant configuration.
default_keys: list[str] = ["code", "_type", "mode", "command", "sse_url", "tool_placeholder", "tool_mode", "tool"]

@github-actions github-actions bot added the enhancement New feature or request label Mar 28, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Mar 28, 2025
Copy link

codspeed-hq bot commented Mar 28, 2025

CodSpeed Performance Report

Merging #7327 will improve performances by 40.11%

Comparing fix-mcp-tool-mode (6001734) with main (e82b23f)

Summary

⚡ 2 improvements
✅ 17 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
test_build_flow_invalid_job_id 12.4 ms 8.8 ms +40.11%
test_cancel_nonexistent_build 12.2 ms 8.7 ms +39.47%

@ogabrielluiz ogabrielluiz changed the title feat: lmprove MCP angflow port search and error handling feat: lmprove MCP langflow port search and error handling Mar 28, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Mar 28, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Mar 29, 2025
@edwinjosechittilappilly edwinjosechittilappilly marked this pull request as ready for review March 29, 2025 00:54
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Mar 29, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Mar 29, 2025
@edwinjosechittilappilly
Copy link
Collaborator Author

@phact we might need to improve later for getting the base URL from the requests.

This PR is to improve the error handling as well as improve build config performance preventing further errors.

@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Mar 29, 2025
@edwinjosechittilappilly edwinjosechittilappilly changed the title feat: lmprove MCP langflow port search and error handling feat: lmprove MCP langflow port selection and error handling Mar 29, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Mar 29, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Mar 29, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Mar 30, 2025
Cristhianzl and others added 3 commits March 30, 2025 19:10
… max retries to improve connection handling

🐛 (test_mcp_component.py): fix incorrect exception type in test_connect_timeout method to match expected behavior
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Mar 30, 2025
… better readability and maintainability

🔧 (test_mcp_component.py): refactor test_connect_timeout method for improved error message formatting
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Mar 31, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Mar 31, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Mar 31, 2025
@ogabrielluiz ogabrielluiz added lgtm This PR has been approved by a maintainer and removed lgtm This PR has been approved by a maintainer labels Mar 31, 2025
@ogabrielluiz ogabrielluiz enabled auto-merge March 31, 2025 14:10
@ogabrielluiz ogabrielluiz added this pull request to the merge queue Mar 31, 2025
Merged via the queue into main with commit aea98a4 Mar 31, 2025
42 of 44 checks passed
@ogabrielluiz ogabrielluiz deleted the fix-mcp-tool-mode branch March 31, 2025 15:06
Yukiyukiyeah pushed a commit that referenced this pull request Mar 31, 2025
* langflow port search and error handling

* [autofix.ci] apply automated fixes

* Update mcp_component.py

* Update util.py

* ✨ (test_mcp_component.py): add support for validating URL and setting max retries to improve connection handling
🐛 (test_mcp_component.py): fix incorrect exception type in test_connect_timeout method to match expected behavior

* [autofix.ci] apply automated fixes

* ✅ (test_mcp_component.py): refactor test_connect_to_server method for better readability and maintainability
🔧 (test_mcp_component.py): refactor test_connect_timeout method for improved error message formatting

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: cristhianzl <cristhian.lousa@gmail.com>
QDDCoder pushed a commit to QDDCoder/langflow that referenced this pull request Apr 1, 2025
* commit '6c2ff92ccf083f038d9a97a749b4e0f30a60247a': (255 commits)
  docs: Update documentation and add TAVILY_API_KEY to environment variables (langflow-ai#7366)
  docs: mcp server component and integrations (langflow-ai#7286)
  docs: v1.3 (langflow-ai#7160)
  chore(deps-dev): bump vite from 5.4.14 to 5.4.16 in /src/frontend (langflow-ai#7365)
  fix: add secret key loading functionality to basic templates (langflow-ai#7363)
  docs: platform content (langflow-ai#7091)
  chore: bump langflow and langflow-base for 1.3.0 release (langflow-ai#7362)
  docs: ensure asset paths update on draft rebuilds (langflow-ai#7355)
  fix: Prevent API key banner from displaying when key is unavailable (langflow-ai#7356)
  fix: MCP SSE Model tool mode issue (langflow-ai#7360)
  feat: deprecate Parsing component and replace them in starter projects (langflow-ai#6697)
  fix: fixed the parser component (langflow-ai#7303)
  ref: split ast parsing / class exec loops (langflow-ai#7248)
  feat: Update AgentQL templates (langflow-ai#7165)
  feat: add a unified local vector store (langflow-ai#6995)
  fix: update currentflow to be fetched from Flow Store for icon to be rendered correctly (langflow-ai#7354)
  feat: expose serialization truncation constants in /config route (langflow-ai#7316)
  feat: lmprove MCP langflow port selection and error handling (langflow-ai#7327)
  fix: adds priority sorting for sidebar components and makes LanguageModel appear first (langflow-ai#7322)
  fix: make agent work with new tool mode backend updates (langflow-ai#7314)
  ...

# Conflicts:
#	src/frontend/src/utils/styleUtils.ts

更新到V1.3.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants