diff --git a/AGENTS.md b/AGENTS.md index e257f15..1e62981 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -55,7 +55,7 @@ test/ binaryDiscovery.test.ts Real executable discovery on PATH (13 tests) initializeProject.test.ts Status display, agents file classification, formatError (69 tests) managedLifecycle.test.ts Managed install with real file I/O (26 tests) - mcpConfig.test.ts MCP config with real temp directories (15 tests) + mcpConfig.test.ts MCP config with real temp directories (16 tests) managedInstall.test.ts Managed Update compares latest vs managed binary (10 tests) mcpRegister.test.ts Native MCP definition helper for binary path (6 tests) statusRefresh.test.ts Status and MCP refresh order after input change (1 test) diff --git a/src/mcp/config.ts b/src/mcp/config.ts index 6113230..3ff2b1e 100644 --- a/src/mcp/config.ts +++ b/src/mcp/config.ts @@ -177,18 +177,8 @@ function withPatchloomEntry( } function hasPatchloomEntry(kind: McpTargetKind, config: Record): boolean { - if (usesMcpServersKey(kind)) { - const modern = objectValue(config.mcpServers); - if (typeof modern.patchloom === "object" && modern.patchloom !== null) { - return true; - } - if (kind === "cursor-workspace") { - const legacy = objectValue(config.servers); - return typeof legacy.patchloom === "object" && legacy.patchloom !== null; - } - return false; - } - const root = objectValue(config.servers); + const key = usesMcpServersKey(kind) ? "mcpServers" : "servers"; + const root = objectValue(config[key]); return typeof root.patchloom === "object" && root.patchloom !== null; } diff --git a/test/unit/mcpConfig.test.ts b/test/unit/mcpConfig.test.ts index 0db0c36..c046bb0 100644 --- a/test/unit/mcpConfig.test.ts +++ b/test/unit/mcpConfig.test.ts @@ -200,6 +200,31 @@ test("configureMcpTargets creates both vscode and cursor configs", async () => { }); }); +test("inspectMcpTargets does not treat Cursor servers-only file as configured", async () => { + await withTempDir(async (workspace) => { + const cursorDir = path.join(workspace, ".cursor"); + await fs.mkdir(cursorDir, { recursive: true }); + await fs.writeFile( + path.join(cursorDir, "mcp.json"), + JSON.stringify({ servers: { patchloom: { command: "patchloom", args: ["mcp-server"] } } }), + "utf8" + ); + + const targets = await inspectMcpTargets({ + workspaceFolderPath: workspace, + homeDir: workspace, + readFile: async (filePath) => { + try { return await fs.readFile(filePath, "utf8"); } catch { return undefined; } + } + }); + + const cursorTarget = targets.find((t) => t.kind === "cursor-workspace"); + assert.ok(cursorTarget); + assert.equal(cursorTarget.exists, true); + assert.equal(cursorTarget.configured, false, "Cursor only loads mcpServers"); + }); +}); + test("inspectMcpTargets reads configured status from real files", async () => { await withTempDir(async (workspace) => { const vscodeDir = path.join(workspace, ".vscode");