Skip to content

fix(mcp): make agentic MCP server removal actually delete the row - #14272

Merged
erichare merged 1 commit into
release-1.12.0from
fix/agentic-mcp-remove-uses-delete
Jul 27, 2026
Merged

fix(mcp): make agentic MCP server removal actually delete the row#14272
erichare merged 1 commit into
release-1.12.0from
fix/agentic-mcp-remove-uses-delete

Conversation

@erichare

@erichare erichare commented Jul 27, 2026

Copy link
Copy Markdown
Member

Problem

remove_agentic_mcp_server "removes" the langflow-agentic MCP server by calling update_server with an empty config, under a comment claiming "Empty config removes the server". That has never been true — for either the DB-backed store or the old file-based one:

  • users who had the server are left with a {}-config row (the flag-less call is a full replace), and
  • users who never had it gain a brand-new empty-config row (the call takes the create path when no row exists).

Either way, a broken langflow-agentic entry surfaces in the user's MCP servers list.

Mitigating factor: the helper currently has no callers on main or release-1.12.0 (the agentic-experience disable path was never wired up), so nothing ships the broken behavior today. This fixes the latent utility and pins its semantics before anything wires it up. Found while tracing update_server callers during review of #14005.

Fix

Pass delete=True so the row is actually removed. A user without the server raises HTTPException from the delete path, which the existing per-user except/continue block already handles — and servers_removed now counts only actual removals.

Tests

src/backend/tests/unit/api/utils/test_agentic_mcp.py — real functions against a real SQLite DB, in the style of test_mcp_db_store.py:

  • removal deletes the langflow-agentic row and leaves the user's other servers untouched

  • a user without the server gains no empty-config row, and no error propagates

  • Both tests fail against the unfixed code (verified red) and pass with the fix (verified green)

  • Existing test_mcp_db_store.py suite passes alongside

  • ruff lint/format clean; pre-commit hooks pass

Summary by CodeRabbit

  • Bug Fixes

    • Corrected removal of the agentic MCP server so deleted entries are fully removed.
    • Prevented empty or broken server entries from being created when no matching server exists.
  • Tests

    • Added coverage verifying successful removal while preserving other MCP servers.
    • Added coverage confirming removal is safely ignored when no matching entry exists.

remove_agentic_mcp_server called update_server without delete=True under a
comment claiming "Empty config removes the server". That has never been true:
the flag-less call is a full replace, so users who had the langflow-agentic
server were left with an empty-config row, and users who never had it gained
a brand-new empty-config row (the create path runs when no row exists) —
a broken entry in their MCP servers list either way. The same behavior
existed under the old file-based store (the entry was set to {}).

Pass delete=True so the row is actually removed. For users without the
server, update_server raises HTTPException, which the existing per-user
except/continue block already handles.

The helper currently has no callers (the agentic-experience disable path was
never wired up), so nothing ships the broken behavior today; this fixes the
latent utility and pins the semantics with tests before anyone wires it up.
@erichare erichare added the bug Something isn't working label Jul 27, 2026
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Agentic MCP server removal now explicitly deletes the database row. New async SQLite tests verify removal of the targeted server, preservation of unrelated servers, and no row creation when the target server is absent.

Changes

Agentic MCP deletion

Layer / File(s) Summary
Explicit server-row deletion
src/backend/base/langflow/api/utils/mcp/agentic_mcp.py
Removal passes delete=True with an empty configuration so the agentic MCP server row is deleted explicitly.
Database-backed removal tests
src/backend/tests/unit/api/utils/test_agentic_mcp.py
Async SQLite tests cover deletion of an existing agentic server, preservation of unrelated servers, and no-op behavior when the server is absent.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 9
✅ Passed checks (9 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly states the main change: agentic MCP server removal now deletes the row instead of leaving it behind.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Test Coverage For New Implementations ✅ Passed PR adds test_agentic_mcp.py with two real regression tests for the delete fix, and the filename follows backend test conventions.
Test Quality And Coverage ✅ Passed Two async pytest SQLite-backed tests cover deletion and absent-server no-op behavior, validate real DB state, and match existing repo patterns.
Test File Naming And Structure ✅ Passed test_agentic_mcp.py is a backend unit test with pytest-asyncio cases, descriptive names, setup/teardown, and positive/negative coverage.
Excessive Mock Usage Warning ✅ Passed Mocks are limited to cache/service lookup stubs; the tests exercise real SQLite, update_server, get_server_list, and delete behavior, so no excessive mocking.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/agentic-mcp-remove-uses-delete

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.

@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Jul 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

✅ Test Coverage Advisor

No source changes detected without accompanying tests. Thanks for keeping coverage up! 🎉

Advisory check only — never blocks merge.

@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Jul 27, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/backend/tests/unit/api/utils/test_agentic_mcp.py (1)

16-16: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Drop redundant pytest.mark.asyncio decorators.

Async tests are auto-detected by the repository configuration, so remove the markers and the now-unused pytest import.

Proposed cleanup
-import pytest
...
-@pytest.mark.asyncio
 async def test_remove_agentic_mcp_server_removes_row():
...
-@pytest.mark.asyncio
 async def test_remove_agentic_mcp_server_absent_is_noop():

Based on learnings, pytest-asyncio is configured with asyncio_mode = "auto", so these markers are unnecessary.

Also applies to: 56-56, 85-85

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/backend/tests/unit/api/utils/test_agentic_mcp.py` at line 16, Remove the
redundant pytest.mark.asyncio decorators from the async tests in this file and
delete the now-unused pytest import. Leave the test implementations and async
behavior unchanged.

Source: Learnings

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/backend/tests/unit/api/utils/test_agentic_mcp.py`:
- Line 16: Remove the redundant pytest.mark.asyncio decorators from the async
tests in this file and delete the now-unused pytest import. Leave the test
implementations and async behavior unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 93b29ea6-c4e6-4303-b78f-f96340d230a4

📥 Commits

Reviewing files that changed from the base of the PR and between edfe9dc and 3282b3a.

📒 Files selected for processing (2)
  • src/backend/base/langflow/api/utils/mcp/agentic_mcp.py
  • src/backend/tests/unit/api/utils/test_agentic_mcp.py

@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.41%. Comparing base (8c56958) to head (3282b3a).
⚠️ Report is 5 commits behind head on release-1.12.0.

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##           release-1.12.0   #14272      +/-   ##
==================================================
+ Coverage           61.26%   61.41%   +0.14%     
==================================================
  Files                2347     2346       -1     
  Lines              238587   238339     -248     
  Branches            35590    35585       -5     
==================================================
+ Hits               146180   146365     +185     
+ Misses              90585    90159     -426     
+ Partials             1822     1815       -7     
Flag Coverage Δ
backend 68.09% <ø> (-0.08%) ⬇️
frontend 59.81% <ø> (+0.15%) ⬆️
lfx 60.41% <ø> (+0.30%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...backend/base/langflow/api/utils/mcp/agentic_mcp.py 31.61% <ø> (+12.50%) ⬆️

... and 153 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown
Contributor

Frontend Unit Test Coverage Report

Coverage Summary

Lines Statements Branches Functions
Coverage: 47%
47.15% (67584/143333) 70.09% (9546/13619) 45.92% (1566/3410)

Unit Test Results

Tests Skipped Failures Errors Time
5387 0 💤 0 ❌ 0 🔥 21m 4s ⏱️

@erichare
erichare merged commit 41fe68b into release-1.12.0 Jul 27, 2026
146 of 155 checks passed
@erichare
erichare deleted the fix/agentic-mcp-remove-uses-delete branch July 27, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant