Browse Source

Merge pull request #1552 from RooVetGit/mcp-home-dir

fix: update MCP servers directory path for platform compatibility
Matt Rubens 10 months ago
parent
commit
d6a9e0fbe9
1 changed files with 15 additions and 2 deletions
  1. 15 2
      src/core/webview/ClineProvider.ts

+ 15 - 2
src/core/webview/ClineProvider.ts

@@ -2077,11 +2077,24 @@ export class ClineProvider implements vscode.WebviewViewProvider {
 	// MCP
 	// MCP
 
 
 	async ensureMcpServersDirectoryExists(): Promise<string> {
 	async ensureMcpServersDirectoryExists(): Promise<string> {
-		const mcpServersDir = path.join(os.homedir(), "Documents", "Cline", "MCP")
+		// Get platform-specific application data directory
+		let mcpServersDir: string
+		if (process.platform === "win32") {
+			// Windows: %APPDATA%\Roo-Code\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 {
 		try {
 			await fs.mkdir(mcpServersDir, { recursive: true })
 			await fs.mkdir(mcpServersDir, { recursive: true })
 		} catch (error) {
 		} 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(os.homedir(), ".roo-code", "mcp")
 		}
 		}
 		return mcpServersDir
 		return mcpServersDir
 	}
 	}