Cross-platform location of Claude Desktop's MCP config file.
()
| 79 | |
| 80 | /** Cross-platform location of Claude Desktop's MCP config file. */ |
| 81 | function claudeDesktopConfigPath(): string { |
| 82 | const home = os.homedir(); |
| 83 | if (process.platform === "darwin") { |
| 84 | return path.join( |
| 85 | home, |
| 86 | "Library", |
| 87 | "Application Support", |
| 88 | "Claude", |
| 89 | "claude_desktop_config.json", |
| 90 | ); |
| 91 | } |
| 92 | if (process.platform === "win32") { |
| 93 | const appData = |
| 94 | process.env.APPDATA || path.join(home, "AppData", "Roaming"); |
| 95 | return path.join(appData, "Claude", "claude_desktop_config.json"); |
| 96 | } |
| 97 | // Linux/WSL — best-effort XDG location; Claude Desktop doesn't have an |
| 98 | // official Linux build, but some forks (e.g. open-source wrappers) use it. |
| 99 | const xdg = process.env.XDG_CONFIG_HOME || path.join(home, ".config"); |
| 100 | return path.join(xdg, "Claude", "claude_desktop_config.json"); |
| 101 | } |
| 102 | |
| 103 | function readJson(filePath: string): Record<string, unknown> | undefined { |
| 104 | try { |