From d56169f5d92ba0853937df5a0603c3f24b8602b2 Mon Sep 17 00:00:00 2001 From: ydflow <314143294+ydflow@users.noreply.github.com> Date: Tue, 29 Sep 2026 17:20:28 +0800 Subject: [PATCH] fix(mcp): keep read-only config loads dry-run safe --- src/__tests__/dry-run-load-path.test.ts | 5 +++++ src/mcp-cmd.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/__tests__/dry-run-load-path.test.ts b/src/__tests__/dry-run-load-path.test.ts index e95e124c1..067201618 100644 --- a/src/__tests__/dry-run-load-path.test.ts +++ b/src/__tests__/dry-run-load-path.test.ts @@ -31,6 +31,7 @@ vi.mock('../utils/reports-branch.js', async (importOriginal) => ({ import { contribute } from '../contribute.js'; import { loadLocalConfigForScope } from '../config.js'; +import { mcpInject, mcpList } from '../mcp-cmd.js'; import { pull } from '../pull.js'; import { push } from '../push.js'; import { recall } from '../recall.js'; @@ -252,6 +253,8 @@ describe('--dry-run through the loaders the commands share (#850)', () => { const LOAD_ONLY_COMMANDS: Array<[string, () => Promise]> = [ ['pull --dry-run', () => pull({ dryRun: true })], ['push --dry-run', () => push({ dryRun: true })], + ['mcp inject --dry-run', () => mcpInject({ dryRun: true })], + ['mcp list', () => mcpList({})], ['status', () => status({})], ['list', () => list(undefined, {})], ]; @@ -286,6 +289,8 @@ describe('--dry-run through the loaders the commands share (#850)', () => { // The issue report located these by code path only; they are run here. const PROJECT_SCOPE_COMMANDS: Array<[string, () => Promise]> = [ ['pull --dry-run', () => pull({ dryRun: true })], + ['mcp inject --dry-run', () => mcpInject({ dryRun: true })], + ['mcp list', () => mcpList({})], ['status', () => status({})], ['list', () => list(undefined, {})], ]; diff --git a/src/mcp-cmd.ts b/src/mcp-cmd.ts index 5f9a3378f..8d0115ccb 100644 --- a/src/mcp-cmd.ts +++ b/src/mcp-cmd.ts @@ -24,7 +24,7 @@ function displayPath(p: string): string { /** Print team MCP servers, their secret requirements, and where they are installed. */ export async function mcpList(_options: GlobalOptions): Promise { - const { localConfig, teamConfig } = await autoDetectInit(); + const { localConfig, teamConfig } = await autoDetectInit(undefined, { dryRun: true }); const resolution = await resolveEntriesFor(mcpEntryReader, localConfig); if (resolution.kind === 'failed') { log.error(describeEntryFailure(resolution.failure)); @@ -95,7 +95,7 @@ function reportChanges(changes: McpChange[]): void { export async function mcpInject( options: GlobalOptions & { dryRun?: boolean; force?: boolean }, ): Promise { - const { localConfig, teamConfig } = await autoDetectInit(); + const { localConfig, teamConfig } = await autoDetectInit(undefined, { dryRun: options.dryRun }); const { changes, wrote, unresolved } = await reconcileMcpForConfig(teamConfig, localConfig, { dryRun: options.dryRun, force: options.force,