MCPcopy Index your code
hub / github.com/codeaashu/claude-code / getClaudeDesktopConfigPath

Function getClaudeDesktopConfigPath

src/utils/claudeDesktop.ts:13–96  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11import { getPlatform, SUPPORTED_PLATFORMS } from './platform.js'
12
13export async function getClaudeDesktopConfigPath(): Promise<string> {
14 const platform = getPlatform()
15
16 if (!SUPPORTED_PLATFORMS.includes(platform)) {
17 throw new Error(
18 `Unsupported platform: ${platform} - Claude Desktop integration only works on macOS and WSL.`,
19 )
20 }
21
22 if (platform === 'macos') {
23 return join(
24 homedir(),
25 'Library',
26 'Application Support',
27 'Claude',
28 'claude_desktop_config.json',
29 )
30 }
31
32 // First, try using USERPROFILE environment variable if available
33 const windowsHome = process.env.USERPROFILE
34 ? process.env.USERPROFILE.replace(/\\/g, '/') // Convert Windows backslashes to forward slashes
35 : null
36
37 if (windowsHome) {
38 // Remove drive letter and convert to WSL path format
39 const wslPath = windowsHome.replace(/^[A-Z]:/, '')
40 const configPath = `/mnt/c${wslPath}/AppData/Roaming/Claude/claude_desktop_config.json`
41
42 // Check if the file exists
43 try {
44 await stat(configPath)
45 return configPath
46 } catch {
47 // File doesn't exist, continue
48 }
49 }
50
51 // Alternative approach - try to construct path based on typical Windows user location
52 try {
53 // List the /mnt/c/Users directory to find potential user directories
54 const usersDir = '/mnt/c/Users'
55
56 try {
57 const userDirs = await readdir(usersDir, { withFileTypes: true })
58
59 // Look for Claude Desktop config in each user directory
60 for (const user of userDirs) {
61 if (
62 user.name === 'Public' ||
63 user.name === 'Default' ||
64 user.name === 'Default User' ||
65 user.name === 'All Users'
66 ) {
67 continue // Skip system directories
68 }
69
70 const potentialConfigPath = join(

Callers 1

Calls 4

getPlatformFunction · 0.85
statFunction · 0.85
readdirFunction · 0.85
logErrorFunction · 0.70

Tested by

no test coverage detected