Skip to content

Commit 25cc419

Browse files
committed
add cursor support
Signed-off-by: nick powell <nickjaypowell@gmail.com>
1 parent 526d83a commit 25cc419

File tree

2 files changed

+128
-0
lines changed

2 files changed

+128
-0
lines changed

src/cmd/cmd.ts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
} from '../server/transport.js';
88
import { ClaudeConfigManager } from '../platform/claude/config.js';
99
import { VSCodeConfigManager } from '../platform/vscode/config.js';
10+
import { CursorConfigManager } from '../platform/cursor/config.js';
1011

1112
export const cmd = () => {
1213
const exe = yargs(hideBin(process.argv));
@@ -129,6 +130,69 @@ export const cmd = () => {
129130
);
130131
});
131132

133+
exe.command('cursor', 'Manage Cursor integration', (yargs) => {
134+
return yargs
135+
.command(
136+
'enable',
137+
'Enable ArgoCD MCP server in Cursor',
138+
(yargs) => {
139+
return yargs
140+
.option('workspace', {
141+
type: 'boolean',
142+
description: 'Install in current workspace directory'
143+
})
144+
.option('url', {
145+
type: 'string',
146+
description: 'ArgoCD base URL (falls back to ARGOCD_BASE_URL env var)'
147+
})
148+
.option('token', {
149+
type: 'string',
150+
description: 'ArgoCD API token (falls back to ARGOCD_API_TOKEN env var)'
151+
});
152+
},
153+
async ({ workspace, url, token }) => {
154+
const manager = new CursorConfigManager(workspace);
155+
try {
156+
console.log(`Configuration file: ${manager.getConfigPath()}`);
157+
const wasEnabled = await manager.enable(validateUrl(url), validateToken(token));
158+
if (wasEnabled) {
159+
console.log('✓ ArgoCD MCP server configuration updated in Cursor');
160+
} else {
161+
console.log('✓ ArgoCD MCP server enabled in Cursor');
162+
}
163+
} catch (error) {
164+
console.error('Failed to enable ArgoCD MCP server:', (error as Error).message);
165+
process.exit(1);
166+
}
167+
}
168+
)
169+
.command(
170+
'disable',
171+
'Disable ArgoCD MCP server in Cursor',
172+
(yargs) => {
173+
return yargs.option('workspace', {
174+
type: 'boolean',
175+
description: 'Install in current workspace directory'
176+
});
177+
},
178+
async ({ workspace }) => {
179+
const manager = new CursorConfigManager(workspace);
180+
try {
181+
console.log(`Configuration file: ${manager.getConfigPath()}`);
182+
const wasEnabled = await manager.disable();
183+
if (wasEnabled) {
184+
console.log('✓ ArgoCD MCP server disabled in Cursor');
185+
} else {
186+
console.log('ArgoCD MCP server was not enabled');
187+
}
188+
} catch (error) {
189+
console.error('Failed to disable ArgoCD MCP server:', (error as Error).message);
190+
process.exit(1);
191+
}
192+
}
193+
);
194+
});
195+
132196
exe.command('vscode', 'Manage VS Code integration', (yargs) => {
133197
return yargs
134198
.command(

src/platform/cursor/config.ts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { join } from 'path';
2+
import { homedir } from 'os';
3+
import { ConfigManager, MCPConfig } from '../base.js';
4+
5+
interface CursorServerConfig {
6+
type: string;
7+
command: string;
8+
args: string[];
9+
env?: Record<string, string>;
10+
}
11+
12+
// Cursor-specific key
13+
const serversKey = 'mcpServers';
14+
15+
interface CursorConfig extends MCPConfig {
16+
[serversKey]: Record<string, CursorServerConfig>;
17+
}
18+
19+
export class CursorConfigManager extends ConfigManager<CursorConfig, CursorServerConfig> {
20+
protected configPath: string;
21+
22+
constructor(workspace?: boolean) {
23+
super();
24+
25+
if (workspace) {
26+
this.configPath = join(process.cwd(), '.cursor', 'mcp.json');
27+
} else {
28+
const home = homedir();
29+
const platform = process.platform;
30+
31+
switch (platform) {
32+
case 'darwin':
33+
this.configPath = join(home, '.cursor', 'mcp.json');
34+
break;
35+
case 'win32':
36+
this.configPath = join(home, '.cursor', 'mcp.json');
37+
break;
38+
case 'linux':
39+
this.configPath = join(home, '.cursor', 'mcp.json');
40+
break;
41+
default:
42+
throw new Error(`platform not supported: ${platform}`);
43+
}
44+
}
45+
}
46+
47+
protected getServersKey() {
48+
return serversKey;
49+
}
50+
51+
protected createServerConfig(baseUrl: string, apiToken: string): CursorServerConfig {
52+
const serverConfig: CursorServerConfig = {
53+
type: 'stdio',
54+
command: 'npx',
55+
args: ['argocd-mcp@latest', 'stdio'],
56+
env: {
57+
ARGOCD_BASE_URL: baseUrl,
58+
ARGOCD_API_TOKEN: apiToken
59+
}
60+
};
61+
62+
return serverConfig;
63+
}
64+
}

0 commit comments

Comments
 (0)