fix(mcp): filter project scope before dedup

Applied the project-scope filter before connection-equivalence deduplication so a project server can no longer shadow a differently-named but equivalent user server and then be dropped, leaving none.

Fixes #6786
This commit is contained in:
roboomp
2026-07-27 10:31:18 +00:00
parent ab8fb13eea
commit 394eaaeae2
4 changed files with 91 additions and 7 deletions
@@ -154,6 +154,10 @@ async function loadImpl<T>(
continue;
}
if (options.filter && !options.filter(itemWithSource)) {
continue;
}
itemWithSource._source.providerName = provider.displayName;
allItems.push(itemWithSource as T & { _source: SourceMeta; _shadowed?: boolean });
contributedItemCount += 1;
@@ -72,6 +72,12 @@ export interface LoadOptions {
includeDisabled?: boolean;
/** Explicit disabled extension IDs to apply instead of settings. */
disabledExtensions?: string[];
/**
* Drop items before deduplication. Use when a downstream scope filter must
* precede equivalence collapse, so a to-be-filtered item cannot shadow a
* differently-keyed but equivalent survivor. Receives the item's `_source`.
*/
filter?(item: { _source: SourceMeta }): boolean;
}
/**