Skip to content

Conversation

@iymh
Copy link

@iymh iymh commented Nov 27, 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 in src/backend/base/langflow/api/v2/mcp.py 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.

Summary by CodeRabbit

  • Bug Fixes
    • Server configuration updates now preserve existing environment and argument settings when not explicitly modified in the update request.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 27, 2025

Walkthrough

The update_server function in the MCP API now preserves env and args configuration fields from the previous server configuration when they are not provided in the new server configuration payload during update operations.

Changes

Cohort / File(s) Summary
MCP Server Configuration Preservation
src/backend/base/langflow/api/v2/mcp.py
Modified update_server to copy env and args from existing configuration if present and omitted from new server config payload

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Verify the conditional logic correctly identifies when fields should be preserved vs. overridden
  • Confirm the change applies only to update operations and doesn't affect server creation or deletion flows

Pre-merge checks and finishing touches

Important

Pre-merge checks failed

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

❌ Failed checks (1 warning, 4 inconclusive)
Check name Status Explanation Resolution
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 Coverage For New Implementations ❓ Inconclusive Unable to access repository structure to verify test coverage for changes to the update_server function's partial update behavior. Provide git diff showing all changed files and confirm whether test files were added or modified to cover the fix.
Test Quality And Coverage ❓ Inconclusive Repository is inaccessible in sandbox; cannot verify test existence, coverage, or adherence to async testing patterns for MCP server partial update functionality. Provide access to modified mcp.py file and related test files to assess whether partial update logic and field preservation are adequately tested.
Test File Naming And Structure ❓ Inconclusive Unable to access repository to verify test files for MCP server update functionality were created or modified. Ensure repository is accessible and provide test directory structure, existing test files, and confirmation of new test coverage for partial update functionality.
Excessive Mock Usage Warning ❓ Inconclusive Repository clone failed, preventing analysis of test files for excessive mock usage patterns in the MCP server implementation. Repository access is required to examine test files, analyze mock object patterns, and verify appropriate mock scoping to external dependencies only.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing MCP server update to support partial updates, which aligns with the core objective of preserving existing fields during partial configuration updates.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 community Pull Request from an external contributor 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 marked this pull request as ready for review November 27, 2025 04:48
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Nov 27, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/backend/base/langflow/api/v2/mcp.py (1)

245-249: Consider implementing complete PATCH semantics for all fields.

The selective preservation of env and args correctly solves the immediate issue described in the PR. However, this implementation only merges these two specific fields. A complete PATCH implementation would merge all fields from the existing configuration with the incoming one, preserving any omitted fields.

If other configuration fields exist (e.g., command, disabled, timeout), they would still be lost when not included in the update payload. Consider whether a full merge is more appropriate:

 else:
     existing_config = server_list["mcpServers"].get(server_name, {})
-    if "env" in existing_config and "env" not in server_config:
-        server_config["env"] = existing_config["env"]
-    if "args" in existing_config and "args" not in server_config:
-        server_config["args"] = existing_config["args"]
-
-    server_list["mcpServers"][server_name] = server_config
+    # Merge existing config with new config (new values override existing)
+    merged_config = {**existing_config, **server_config}
+    server_list["mcpServers"][server_name] = merged_config

This approach would preserve all existing fields unless explicitly overridden. If the current selective approach is intentional (e.g., only env and args are complex fields users typically want preserved), then the current implementation is appropriate.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0ddfed3 and ce56d0a.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • src/backend/base/langflow/api/v2/mcp.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/backend/**/*.py

📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)

src/backend/**/*.py: Use FastAPI async patterns with await for async operations in component execution methods
Use asyncio.create_task() for background tasks and implement proper cleanup with try/except for asyncio.CancelledError
Use queue.put_nowait() for non-blocking queue operations and asyncio.wait_for() with timeouts for controlled get operations

Files:

  • src/backend/base/langflow/api/v2/mcp.py
src/backend/base/langflow/api/**/*.py

📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)

Backend API endpoints should be organized by version (v1/, v2/) under src/backend/base/langflow/api/ with specific modules for features (chat.py, flows.py, users.py, etc.)

Files:

  • src/backend/base/langflow/api/v2/mcp.py

@iymh
Copy link
Author

iymh commented Nov 27, 2025

It was fixed in 1.7.0, so Close

@iymh iymh closed this Nov 27, 2025
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