Skip to content

fix: prevent duplicate MCP server name when editing - #16588

Merged
wangq8 merged 1 commit into
infiniflow:mainfrom
euvre:fix-mcp-edit-duplicate-name
Jul 3, 2026
Merged

wangq8 merged 1 commit into
infiniflow:mainfrom
euvre:fix-mcp-edit-duplicate-name

Conversation

@euvre

@euvre euvre commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR fixes the MCP server update endpoint so that editing a server no longer allows names that conflict with another existing server owned by the same tenant. The creation endpoint already rejects duplicate names; this change applies the same validation to the edit endpoint, while still allowing the server to keep its current name.

Fix #ci

Validate the new MCP server name in the PUT endpoint before updating.
When editing, only reject the new name if it differs from the current one and
already exists for the same tenant.

Fix #ci
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. labels Jul 3, 2026
@coderabbitai

coderabbitai Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The MCP server update handler now performs the duplicate-name validation only when the submitted name differs from the current server name, preventing unnecessary rejection of updates that keep the existing name.

Changes

MCP Server Update Fix

Layer / File(s) Summary
Conditional duplicate name check
api/apps/restful_apis/mcp_api.py
Duplicate-name validation in the PUT update handler now runs only when the new name differs from the current server name.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Poem

A rabbit hopped through server code so fine,
Found a name check that crossed the line,
Now unchanged names don't cause alarm,
No more false errors, no more harm,
Hop, hop, hooray, the fix is mine! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: preventing duplicate MCP server names during editing.
Description check ✅ Passed The description includes the required Summary section and explains the bug, fix, and current-name behavior.
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.

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.

@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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@api/apps/restful_apis/mcp_api.py`:
- Around line 187-190: The MCP server name check in mcp_api.py is race-prone, so
enforce uniqueness at the persistence layer too. Add a unique constraint on the
MCP server model for the (tenant_id, name) pair, then update the create/update
paths in MCPServerService and the MCP API handlers to catch duplicate-key
violations and return the same “Duplicated MCP server name.” error when a
concurrent insert or rename slips past the pre-check.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 12ec144a-f87b-4f0c-a697-e3c7defc3c93

📥 Commits

Reviewing files that changed from the base of the PR and between 9182296 and 414d44e.

📒 Files selected for processing (1)
  • api/apps/restful_apis/mcp_api.py

Comment thread api/apps/restful_apis/mcp_api.py Resolved
@euvre euvre added the ci Continue Integration label Jul 3, 2026
@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (9182296) to head (414d44e).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #16588   +/-   ##
=======================================
  Coverage   93.16%   93.16%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          668      668           
  Misses         29       29           
  Partials       20       20           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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.

@wangq8
wangq8 merged commit 994b603 into infiniflow:main Jul 3, 2026
12 checks passed
xugangqiang pushed a commit to xugangqiang/ragflow that referenced this pull request Jul 3, 2026
xugangqiang pushed a commit to xugangqiang/ragflow that referenced this pull request Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants