Skip to content

Reject duplicate and blank MCP server entries - #23

Closed
lukiod wants to merge 1 commit into
dotflow-io:masterfrom
lukiod:fix-mcp-server-duplicate-entries
Closed

lukiod wants to merge 1 commit into
dotflow-io:masterfrom
lukiod:fix-mcp-server-duplicate-entries

Conversation

@lukiod

@lukiod lukiod commented Aug 15, 2026 •

Copy link
Copy Markdown

Description

  • src/features/settings/mcpServerList.ts — Updated addServer to trim whitespace from the input command, reject empty or whitespace-only strings, and detect exact duplicates using Array.includes on the trimmed value. Returns the existing list unchanged on no-op.
  • test/mcpServerList.test.ts — Added 3 new unit tests covering: duplicate rejection (exact match and with extra whitespace), whitespace trimming before append, and blank/whitespace-only input rejection.

Motivation and Context

addServer() appended entries unconditionally, allowing the same MCP server command to be registered multiple times. Each duplicate caused pycodeloop serve to receive an extra --mcp flag, spawning the server twice — doubling tool registrations, log noise, and resource usage. Blank inputs were also accepted without validation.

Closes #10.

Types of changes

  • Bug fix (change that fixes an issue)
  • New feature (change which adds functionality)
  • Documentation

Checklist

  • I have performed a self-review of my own code
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the CHANGELOG
  • I have updated the documentation accordingly

addServer() appended unconditionally, so adding the same command
twice spawned the server twice (pycodeloop serve received a
duplicate --mcp flag) -- extra tool registrations, log noise, and
resource usage. Also allowed blank/whitespace-only entries.

Trims and checks against the existing list before appending; a
duplicate or blank input is now a no-op.

Fixes dotflow-io#10

@FernandoCelmer FernandoCelmer left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🔍 Code Review

Code issues found: 2

# Severity Comment
1 [Blocking] Dedup check misses whitespace-padded existing entries
2 [Blocking] No-op path returns original array reference

Comment thread src/features/settings/mcpServerList.ts
Comment thread src/features/settings/mcpServerList.ts
@FernandoCelmer FernandoCelmer added the bug Something isn't working label Aug 15, 2026
@FernandoCelmer

Copy link
Copy Markdown
Member

Thanks a lot for taking the time on this, @lukiod! Turns out this landed just after #12 merged an equivalent fix for addServer's trim/dedupe/blank-rejection (plus a matching fix on removeServer's side). Closing this one as covered, but really appreciate you spotting and fixing the duplicate-registration issue independently — good find!

@lukiod
lukiod deleted the fix-mcp-server-duplicate-entries branch August 16, 2026 14:36
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.

MCP server list allows duplicate entries with no validation

2 participants