Skip to content

duplicate-ServerId startup error doesn't distinguish which lsp_servers entries conflict #237

Description

@bug-ops

Description

When two [[lsp_servers]] entries resolve to the same ServerId (e.g. both share language_id = "rust" and neither sets a distinguishing name), mcpls correctly hard-fails at startup per the #228 per-tool-routing design. However the error message names both conflicting entries only by their (identical) ServerId, which is unhelpful when that's exactly the thing they collided on.

Reproduction Steps

  1. Create a config with two [[lsp_servers]] entries, both language_id = "rust", neither with a name:
    [workspace]
    roots = ["/path/to/rust/project"]
    
    [[lsp_servers]]
    language_id = "rust"
    command = "rust-analyzer"
    file_patterns = ["**/*.rs"]
    
    [[lsp_servers]]
    language_id = "rust"
    command = "rust-analyzer"
    args = ["--dummy-second-instance"]
    file_patterns = ["**/*.rs"]
  2. Run mcpls --config <that file>
  3. Observe the startup error.

Expected Behavior

Error message should let the user tell the two conflicting [[lsp_servers]] entries apart, e.g. by TOML array index, command, or args — something beyond the shared ServerId string that caused the conflict in the first place.

Actual Behavior

Error: server error

Caused by:
    invalid configuration: duplicate server id 'rust' in this workspace (used by both the 'rust' and 'rust' language entries); add a unique `name` to each `[[lsp_servers]]` entry

Both halves of "used by both the 'rust' and 'rust' language entries" are identical, giving no way to identify which two of N configured entries are the actual conflict when a config has more than two [[lsp_servers]] entries for different languages.

Environment

Logs / Evidence

Reproduced live against a fresh build of the current main branch; see reproduction steps above for the exact config and resulting error text.

Metadata

Metadata

Assignees

Labels

P3Low: cosmetic, edge case unlikely in practicebugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions