fix: install native Cursor hook and MCP config (#1543)

* fix: install native cursor hook and MCP config

* fix: avoid false healthy stdio mcp probes
This commit is contained in:
Affaan Mustafa
2026-04-21 18:35:21 -04:00
committed by GitHub
parent 8c422a76f4
commit 92e0c7e9ff
8 changed files with 249 additions and 52 deletions

View File

@@ -122,6 +122,15 @@ function runTests() {
)),
'Should preserve non-rule Cursor platform files'
);
assert.ok(
plan.operations.some(operation => (
operation.sourceRelativePath === '.mcp.json'
&& operation.destinationPath === path.join(projectRoot, '.cursor', 'mcp.json')
&& operation.kind === 'merge-json'
&& operation.strategy === 'merge-json'
)),
'Should materialize Cursor MCP config at the native project path'
);
assert.ok(
plan.operations.some(operation => (
operation.sourceRelativePath === '.cursor/rules/common-agents.md'

View File

@@ -93,6 +93,9 @@ function runTests() {
const hooksJson = plan.operations.find(operation => (
normalizedRelativePath(operation.sourceRelativePath) === '.cursor/hooks.json'
));
const mcpJson = plan.operations.find(operation => (
normalizedRelativePath(operation.sourceRelativePath) === '.mcp.json'
));
const preserved = plan.operations.find(operation => (
normalizedRelativePath(operation.sourceRelativePath) === '.cursor/rules/common-coding-style.md'
));
@@ -100,6 +103,10 @@ function runTests() {
assert.ok(hooksJson, 'Should preserve non-rule Cursor platform config files');
assert.strictEqual(hooksJson.strategy, 'preserve-relative-path');
assert.strictEqual(hooksJson.destinationPath, path.join(projectRoot, '.cursor', 'hooks.json'));
assert.ok(mcpJson, 'Should materialize a Cursor MCP config from the shared root MCP config');
assert.strictEqual(mcpJson.kind, 'merge-json');
assert.strictEqual(mcpJson.strategy, 'merge-json');
assert.strictEqual(mcpJson.destinationPath, path.join(projectRoot, '.cursor', 'mcp.json'));
assert.ok(preserved, 'Should include flattened Cursor rule scaffold operations');
assert.strictEqual(preserved.strategy, 'flatten-copy');
@@ -201,6 +208,14 @@ function runTests() {
)),
'Should preserve non-rule Cursor platform config files'
);
assert.ok(
plan.operations.some(operation => (
normalizedRelativePath(operation.sourceRelativePath) === '.mcp.json'
&& operation.kind === 'merge-json'
&& operation.destinationPath === path.join(projectRoot, '.cursor', 'mcp.json')
)),
'Should materialize a project-level Cursor MCP config'
);
assert.ok(
!plan.operations.some(operation => (
operation.destinationPath === path.join(projectRoot, '.cursor', 'rules', 'README.mdc')

View File

@@ -138,11 +138,19 @@ function runTests() {
assert.ok(fs.existsSync(path.join(projectDir, '.cursor', 'agents', 'architect.md')));
assert.ok(fs.existsSync(path.join(projectDir, '.cursor', 'commands', 'plan.md')));
assert.ok(fs.existsSync(path.join(projectDir, '.cursor', 'hooks.json')));
assert.ok(fs.existsSync(path.join(projectDir, '.cursor', 'mcp.json')));
assert.ok(fs.existsSync(path.join(projectDir, '.cursor', 'hooks', 'session-start.js')));
assert.ok(fs.existsSync(path.join(projectDir, '.cursor', 'scripts', 'lib', 'utils.js')));
assert.ok(fs.existsSync(path.join(projectDir, '.cursor', 'skills', 'tdd-workflow', 'SKILL.md')));
assert.ok(fs.existsSync(path.join(projectDir, '.cursor', 'skills', 'coding-standards', 'SKILL.md')));
const hooksConfig = readJson(path.join(projectDir, '.cursor', 'hooks.json'));
const mcpConfig = readJson(path.join(projectDir, '.cursor', 'mcp.json'));
assert.strictEqual(hooksConfig.version, 1);
assert.ok(hooksConfig.hooks.sessionStart, 'Should keep Cursor sessionStart hooks');
assert.ok(mcpConfig.mcpServers.github, 'Should install shared MCP servers into Cursor');
assert.ok(mcpConfig.mcpServers.context7, 'Should include bundled documentation MCPs');
const statePath = path.join(projectDir, '.cursor', 'ecc-install-state.json');
const state = readJson(statePath);
const normalizedProjectDir = fs.realpathSync(projectDir);
@@ -163,6 +171,35 @@ function runTests() {
}
})) passed++; else failed++;
if (test('installs Cursor MCP config by merging bundled servers into an existing mcp.json', () => {
const homeDir = createTempDir('install-apply-home-');
const projectDir = createTempDir('install-apply-project-');
try {
const cursorRoot = path.join(projectDir, '.cursor');
fs.mkdirSync(cursorRoot, { recursive: true });
fs.writeFileSync(path.join(cursorRoot, 'mcp.json'), JSON.stringify({
mcpServers: {
custom: {
command: 'node',
args: ['custom-mcp.js'],
},
},
}, null, 2));
const result = run(['--target', 'cursor', 'typescript'], { cwd: projectDir, homeDir });
assert.strictEqual(result.code, 0, result.stderr);
const mcpConfig = readJson(path.join(projectDir, '.cursor', 'mcp.json'));
assert.ok(mcpConfig.mcpServers.custom, 'Should preserve existing custom Cursor MCP servers');
assert.ok(mcpConfig.mcpServers.github, 'Should merge bundled GitHub MCP server');
assert.ok(mcpConfig.mcpServers.playwright, 'Should merge bundled Playwright MCP server');
} finally {
cleanup(homeDir);
cleanup(projectDir);
}
})) passed++; else failed++;
if (test('installs Antigravity configs and writes install-state', () => {
const homeDir = createTempDir('install-apply-home-');
const projectDir = createTempDir('install-apply-project-');