( pluginServers: Record<string, ScopedMcpServerConfig>, manualServers: Record<string, ScopedMcpServerConfig>, )
| 221 | * where both actually launch the same underlying process/connection. |
| 222 | */ |
| 223 | export function dedupPluginMcpServers( |
| 224 | pluginServers: Record<string, ScopedMcpServerConfig>, |
| 225 | manualServers: Record<string, ScopedMcpServerConfig>, |
| 226 | ): { |
| 227 | servers: Record<string, ScopedMcpServerConfig> |
| 228 | suppressed: Array<{ name: string; duplicateOf: string }> |
| 229 | } { |
| 230 | // Map signature -> server name so we can report which server a dup matches |
| 231 | const manualSigs = new Map<string, string>() |
| 232 | for (const [name, config] of Object.entries(manualServers)) { |
| 233 | const sig = getMcpServerSignature(config) |
| 234 | if (sig && !manualSigs.has(sig)) manualSigs.set(sig, name) |
| 235 | } |
| 236 | |
| 237 | const servers: Record<string, ScopedMcpServerConfig> = {} |
| 238 | const suppressed: Array<{ name: string; duplicateOf: string }> = [] |
| 239 | const seenPluginSigs = new Map<string, string>() |
| 240 | for (const [name, config] of Object.entries(pluginServers)) { |
| 241 | const sig = getMcpServerSignature(config) |
| 242 | if (sig === null) { |
| 243 | servers[name] = config |
| 244 | continue |
| 245 | } |
| 246 | const manualDup = manualSigs.get(sig) |
| 247 | if (manualDup !== undefined) { |
| 248 | logForDebugging( |
| 249 | `Suppressing plugin MCP server "${name}": duplicates manually-configured "${manualDup}"`, |
| 250 | ) |
| 251 | suppressed.push({ name, duplicateOf: manualDup }) |
| 252 | continue |
| 253 | } |
| 254 | const pluginDup = seenPluginSigs.get(sig) |
| 255 | if (pluginDup !== undefined) { |
| 256 | logForDebugging( |
| 257 | `Suppressing plugin MCP server "${name}": duplicates earlier plugin server "${pluginDup}"`, |
| 258 | ) |
| 259 | suppressed.push({ name, duplicateOf: pluginDup }) |
| 260 | continue |
| 261 | } |
| 262 | seenPluginSigs.set(sig, name) |
| 263 | servers[name] = config |
| 264 | } |
| 265 | return { servers, suppressed } |
| 266 | } |
| 267 | |
| 268 | /** |
| 269 | * Filter claude.ai connectors, dropping any whose signature matches an enabled |
no test coverage detected