Repository navigation
fix: prevent duplicate MCP server name when editing - #16588
Conversation
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
📝 WalkthroughWalkthroughThe 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. ChangesMCP Server Update Fix
Estimated code review effort: 1 (Trivial) | ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
api/apps/restful_apis/mcp_api.py
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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