Skip to content

fix: MCP component auto reset issue in non Tool Mode#10440

Merged
edwinjosechittilappilly merged 34 commits into
mainfrom
fix-mcp-component-reload-issue
Nov 13, 2025
Merged

fix: MCP component auto reset issue in non Tool Mode#10440
edwinjosechittilappilly merged 34 commits into
mainfrom
fix-mcp-component-reload-issue

Conversation

@edwinjosechittilappilly
Copy link
Copy Markdown
Collaborator

@edwinjosechittilappilly edwinjosechittilappilly commented Oct 29, 2025

This pull request refines the logic for updating the build configuration in the MCPComponent to avoid unnecessary UI updates and improve efficiency when switching servers and handling tool options. The main improvements focus on only resetting or updating tool-related options when the server actually changes, and on better handling of the "Tool Mode" state.

Optimizations for tool dropdown and server switching:

  • Added a fast path to skip unnecessary updates to tool options if the server hasn't changed and options already exist, improving UI responsiveness.
  • Refactored logic to only clear previous tool inputs (remove_non_default_keys) when the server actually changes, preventing unwanted resets.
  • Changed the value refresh for the tool dropdown to only occur if the server changed or there are no cached tools, reducing redundant refreshes.

Code cleanup and logic streamlining:

  • Moved the determination of "Tool Mode" and its usage to a more logical position, ensuring the dropdown visibility is handled consistently. [1] [2]

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced error handling and validation for tool configurations with improved fallback mechanisms.
    • Increased resilience when fetching tool data by preserving visibility state during errors or timeouts.
  • Performance

    • Optimized tool configuration updates to skip unnecessary recomputation when server selection hasn't changed.
    • Improved caching behavior with smarter invalidation logic.

Improves logic for updating tool dropdown options by checking if the server has changed and whether tool mode is active, reducing unnecessary updates. Adds a process_output_item method to parse tool output as JSON when appropriate, enhancing output handling.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Oct 29, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. 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.

Walkthrough

Both files update MCPToolsComponent logic. The Nvidia Remix.json file replaces the implementation with enhanced caching, error handling, and state management. The mcp_component.py file adds optimization flags to reduce unnecessary recomputation in update_build_config and clarifies tool-selection behavior.

Changes

Cohort / File(s) Change Summary
Starter Project Configuration
src/backend/base/langflow/initial_setup/starter_projects/Nvidia Remix.json
Replaced MCPToolsComponent implementation with substantially updated version featuring enhanced caching resilience, improved error handling, expanded method signatures for state management (_ensure_cache_structure, _validate_schema_inputs, update_tool_list, update_build_config), and new helper methods (process_output_item, _preprocess_schema, _get_session_context) for richer tool invocation and output processing. Code hash changed from 81b1338be859 to 2e303f9666c2.
Core Component Logic
src/lfx/src/lfx/components/agents/mcp_component.py
Added fast-path optimization in update_build_config for mcp_server branch using new server_changed and is_in_tool_mode flags to preserve current visibility and options when server hasn't changed. Clarified tool input clearing to only occur on actual server changes, adjusted tool dropdown value refresh behavior, and consolidated decision flow to reduce unnecessary recomputation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

  • The Nvidia Remix.json update involves substantial method enhancements and caching logic changes that require careful verification of error handling paths and state management correctness.
  • The mcp_component.py optimization introduces new conditional flags that affect control flow; verify that the fast-path correctly handles edge cases (missing cache, server changes, tool visibility toggling).
  • Cross-file consistency: ensure the optimization flags and logic in mcp_component.py align with the enhanced implementation expectations in Nvidia Remix.json.

Possibly related PRs

Suggested labels

refactor, lgtm

Suggested reviewers

  • lucaseduoli
  • Adam-Aghili

Pre-merge checks and finishing touches

Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 2 warnings)
Check name Status Explanation Resolution
Test Coverage For New Implementations ❌ Error PR introduces significant changes to MCPComponent without corresponding test files for new functionality or bug fixes. Add test_mcp_component.py with unit tests for update_build_config fast-path, tools_metadata preservation, _tool_cache error handling, and integration tests.
Test Quality And Coverage ⚠️ Warning The PR lacks comprehensive test coverage for MCP component changes including refactored update_build_config method and cache handling logic. Add pytest test file covering update_build_config, remove_non_default_keys, build_output, and cache invalidation with both success and error paths.
Test File Naming And Structure ⚠️ Warning Pull request modifies mcp_component.py and MCPToolsComponent without including any test files following pytest patterns. Add test_mcp_component.py with pytest tests for fast-path optimization, cache invalidation, server change detection, and error handling scenarios.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'fix: MCP component auto reset issue in non Tool Mode' clearly matches the core objective of preventing unnecessary UI resets and improving efficiency in the MCPComponent when handling tool options and server changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Excessive Mock Usage Warning ✅ Passed The pull request contains no test files, making this assessment not applicable. No tests exist to evaluate for excessive mock usage.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions github-actions Bot added the bug Something isn't working label Oct 29, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Oct 29, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Oct 29, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Oct 29, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Nov 12, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Nov 12, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Nov 12, 2025
@edwinjosechittilappilly edwinjosechittilappilly marked this pull request as ready for review November 12, 2025 16:25
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Nov 12, 2025
Copy link
Copy Markdown
Collaborator

@erichare erichare left a comment

Choose a reason for hiding this comment

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

LGTM!

@github-actions github-actions Bot added the lgtm This PR has been approved by a maintainer label Nov 12, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Nov 13, 2025
Updated component_index.json to include new Notion integration components: AddContentToPage, NotionDatabaseProperties, NotionListPages, NotionPageContent, NotionPageCreator, NotionPageUpdate, and NotionSearch. These components provide functionality for interacting with Notion databases and pages, including querying, creating, updating, and retrieving content.
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Nov 13, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Nov 13, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Nov 13, 2025
add Select a tool selector to let dropdown load before interacting
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Nov 13, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Nov 13, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Nov 13, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Nov 13, 2025
Updated the code and code_hash for MCPToolsComponent in Nvidia Remix starter project and synchronized the component_index.json to reflect the latest code and metadata. This ensures consistency and includes recent improvements or fixes to the MCPToolsComponent implementation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants