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:
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -97,13 +97,14 @@ export async function loadAllMCPConfigs(cwd: string, options?: LoadMCPConfigsOpt
|
||||
const filterExa = options?.filterExa ?? true;
|
||||
const filterBrowser = options?.filterBrowser ?? false;
|
||||
|
||||
// Load MCP servers via capability system
|
||||
const result = await loadCapability<MCPServer>(mcpCapability.id, { cwd });
|
||||
|
||||
// Filter out project-level configs if disabled
|
||||
const servers = enableProjectConfig
|
||||
? result.items
|
||||
: result.items.filter(server => server._source.level !== "project");
|
||||
// Filter project-scoped entries BEFORE the capability layer's equivalence
|
||||
// deduplication so a project server cannot shadow a differently-named but
|
||||
// connection-equivalent user server and then be dropped here, leaving none.
|
||||
const result = await loadCapability<MCPServer>(mcpCapability.id, {
|
||||
cwd,
|
||||
...(enableProjectConfig ? {} : { filter: server => server._source.level !== "project" }),
|
||||
});
|
||||
const servers = result.items;
|
||||
|
||||
// Load user-level disable/force-enable lists. The denylist always wins; the
|
||||
// allowlist overrides a non-writable source config's `enabled: false`.
|
||||
|
||||
Reference in New Issue
Block a user