From 102a996875d25ea968b8287674a10fba6f1b094c Mon Sep 17 00:00:00 2001 From: hannesrudolph Date: Mon, 10 Mar 2025 15:18:19 -0600 Subject: [PATCH] fix: update MCP servers directory path for platform compatibility --- src/core/webview/ClineProvider.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts index 72cf56d35b..7f7ffa0683 100644 --- a/src/core/webview/ClineProvider.ts +++ b/src/core/webview/ClineProvider.ts @@ -1971,11 +1971,24 @@ export class ClineProvider implements vscode.WebviewViewProvider { // MCP async ensureMcpServersDirectoryExists(): Promise { - const mcpServersDir = path.join(os.homedir(), "Documents", "Cline", "MCP") + // Get platform-specific application data directory + let mcpServersDir: string + if (process.platform === "win32") { + // Windows: %APPDATA%\Cline\MCP + mcpServersDir = path.join(os.homedir(), "AppData", "Roaming", "Roo-Code", "MCP") + } else if (process.platform === "darwin") { + // macOS: ~/Documents/Cline/MCP + mcpServersDir = path.join(os.homedir(), "Documents", "Cline", "MCP") + } else { + // Linux: ~/.local/share/Cline/MCP + mcpServersDir = path.join(os.homedir(), ".local", "share", "Roo-Code", "MCP") + } + try { await fs.mkdir(mcpServersDir, { recursive: true }) } catch (error) { - return "~/Documents/Cline/MCP" // in case creating a directory in documents fails for whatever reason (e.g. permissions) - this is fine since this path is only ever used in the system prompt + // Fallback to a relative path if directory creation fails + return path.join("~", ".roo-code", "mcp") } return mcpServersDir }