diff --git a/README.md b/README.md index 7aeba31..109bd36 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ npx @magicuidesign/cli@latest install ### Supported Clients +- [x] vscode - [x] cursor - [x] windsurf - [x] claude diff --git a/src/config.ts b/src/config.ts index 4e725b1..91b0f8a 100644 --- a/src/config.ts +++ b/src/config.ts @@ -39,6 +39,12 @@ export const clientPaths: Record = { ), windsurf: path.join(homeDir, ".codeium", "windsurf", "mcp_config.json"), cursor: path.join(homeDir, ".cursor", "mcp.json"), + vscode: path.join( + baseDir, + vscodePath, + "..", + "settings.json", + ), }; export const createPlatformCommand = (passedArgs: string[]) => { diff --git a/src/types.ts b/src/types.ts index 841db21..098cb37 100644 --- a/src/types.ts +++ b/src/types.ts @@ -3,7 +3,8 @@ export type ValidClient = | "cline" | "roo-cline" | "windsurf" - | "cursor"; + | "cursor" + | "vscode"; export const VALID_CLIENTS: ValidClient[] = [ "claude", @@ -11,6 +12,7 @@ export const VALID_CLIENTS: ValidClient[] = [ "roo-cline", "windsurf", "cursor", + "vscode", ]; export interface ServerConfig { diff --git a/src/utils.ts b/src/utils.ts index bfbecad..9da17f4 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -41,7 +41,7 @@ export function writeConfig(client: ValidClient, config: ClientConfig): void { throw new Error("Invalid mcpServers structure"); } - let existingConfig: ClientConfig = { mcpServers: {} }; + let existingConfig: any = {}; try { if (fs.existsSync(configPath)) { existingConfig = JSON.parse(fs.readFileSync(configPath, "utf8")); @@ -58,5 +58,21 @@ export function writeConfig(client: ValidClient, config: ClientConfig): void { }, }; - fs.writeFileSync(configPath, JSON.stringify(mergedConfig, null, 2)); + const mergedServers = { + ...existingConfig.mcp?.servers, + ...config.mcpServers + }; + + // For VS Code, preserve all existing settings and just update mcp.servers + const finalConfig = client === "vscode" + ? { + ...existingConfig, + mcp: { + ...existingConfig.mcp, + servers: mergedServers + } + } + : mergedConfig; + + fs.writeFileSync(configPath, JSON.stringify(finalConfig, null, 2)); }