Skip to content

Conversation

@iymh
Copy link

@iymh iymh commented Nov 26, 2025

Description

This PR fixes an issue where updating an MCP server configuration would unintentionally clear existing fields like env and args if they were not included in the request payload.

Reasoning

The endpoint @router.patch("/servers/{server_name}") implies a PATCH operation (partial update). However, the previous implementation performed a full replacement of the configuration object.

This change modifies update_server to merge the new configuration with the existing one, preserving critical fields like env and args when they are not explicitly provided in the update. This aligns the backend behavior with proper PATCH semantics.

CI Fix

Fixed a bash syntax error in typescript_test.yml that occurs when multiple test suites are selected (e.g., @components|@api).

  • The grep pattern contained a pipe | character which was interpreted by bash as a pipe operator because it was unquoted.
  • Added quotes around the variable to ensure it is treated as a string.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed a configuration preservation issue in server updates. When updating an existing server, the system now retains previously configured settings that aren't explicitly modified, preventing unintended loss of environment variables and runtime parameters.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 26, 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

The update_server function in the MCP API now inherits missing fields from the existing server configuration during updates. When updating a server, if the new configuration lacks env or args fields but the existing configuration contains them, those fields are preserved from the previous configuration.

Changes

Cohort / File(s) Summary
Server Update Field Inheritance
src/backend/base/langflow/api/v2/mcp.py
Added conditional logic to inherit env and args fields from existing server configuration when they are absent in the new configuration during update operations

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant API as update_server()
    participant Config as Existing Config
    participant NewConfig as New Config

    User->>API: Send update request
    API->>Config: Retrieve existing server config
    Config-->>API: Return existing config
    
    rect rgb(240, 248, 255)
    Note over API: New inheritance logic
    alt existing.env exists AND new.env missing
        API->>NewConfig: Copy env from existing
    end
    alt existing.args exists AND new.args missing
        API->>NewConfig: Copy args from existing
    end
    end
    
    API->>API: Assign updated config to server list
    API->>API: Refresh and upload files
    API-->>User: Return updated server
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify the conditional logic correctly identifies missing fields in the new configuration
  • Confirm that field inheritance from existing config doesn't cause unintended behavior in edge cases (e.g., when explicitly clearing fields is intended)
  • Check that the rest of the update workflow remains unaffected by these additions

Pre-merge checks and finishing touches

❌ Failed checks (1 error, 2 warnings, 2 inconclusive)
Check name Status Explanation Resolution
Test Coverage For New Implementations ❌ Error No test files found for the PATCH endpoint changes that preserve env and args fields during partial updates. Add test coverage verifying env/args preservation, override behavior, and backward compatibility for the new PATCH semantics.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Test File Naming And Structure ⚠️ Warning PR modifies critical MCP API update function but includes no test files or test coverage for the PATCH semantics implementation and configuration merging logic. Add backend test files using test_*.py naming convention with pytest structure covering partial updates, field preservation, edge cases, and both positive/negative scenarios.
Test Quality And Coverage ❓ Inconclusive Assessment cannot be completed due to inability to access repository code and test files to evaluate implementation changes and test coverage. Repository must be made accessible in sandbox or provide modified mcp.py file, test files for PATCH endpoint, and test output demonstrating coverage.
Excessive Mock Usage Warning ❓ Inconclusive Repository access unavailable to analyze test files for excessive mock usage patterns. Resolve repository access to analyze test infrastructure for mock saturation and verify appropriate mock usage in test files.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately describes the main change: implementing partial updates (PATCH semantics) for MCP server configuration to preserve existing fields like env and args.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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 community Pull Request from an external contributor label Nov 26, 2025
@iymh iymh marked this pull request as ready for review November 26, 2025 11:57
@iymh iymh changed the title Fix MCP server update to support partial updates (PATCH semantics) fix: MCP server update to support partial updates (PATCH semantics) Nov 27, 2025
@github-actions github-actions bot added the bug Something isn't working label Nov 27, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Nov 27, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Nov 27, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Nov 27, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Nov 27, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Nov 27, 2025
@iymh iymh closed this Nov 27, 2025
@iymh iymh deleted the fix/mcp-keep-env-vars branch November 27, 2025 04:42
@iymh
Copy link
Author

iymh commented Nov 27, 2025

Closing this in favor of #10749

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working community Pull Request from an external contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant