Skip to content

Commit 7294b11

Browse files
committed
fix: simplify CLAUDE_CONFIG_PATH and add isomorphic-fetch
- Simplify the definition of CLAUDE_CONFIG_PATH for clarity. - Use a conditional operator to handle Windows and macOS paths directly. - Update CURRENT_DIR to derive from import.meta.url more succinctly. - Ensure compatibility with Windows paths by removing leading slashes. - Adjust SERVERS_DIR to correctly reference the updated CURRENT_DIR. - Add `isomorphic-fetch` dependency to package.json and package-lock.json. - Include the corresponding type definitions in devDependencies. - Ensure the integrity and license information is updated in package-lock.json.
1 parent 8af3a98 commit 7294b11

File tree

3 files changed

+42
-41
lines changed

3 files changed

+42
-41
lines changed

creator-server.js

Lines changed: 15 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,49 +8,23 @@ import { z } from "zod";
88
import path from "path";
99
import os from "os";
1010

11-
const CLAUDE_CONFIG_PATH = (() => {
12-
// Detect operating system and set appropriate config path
13-
if (process.platform === "darwin") {
14-
// macOS
15-
return path.join(
16-
os.homedir(),
17-
"Library/Application Support/Claude/claude_desktop_config.json"
18-
);
19-
} else if (process.platform === "win32") {
20-
// Windows
21-
// %APPDATA% resolves to AppData/Roaming
22-
return path.join(
23-
process.env.APPDATA,
24-
"Claude",
25-
"claude_desktop_config.json"
26-
);
27-
} else {
28-
// Linux and others
29-
return path.join(
30-
os.homedir(),
31-
".config",
32-
"Claude",
33-
"claude_desktop_config.json"
34-
);
35-
}
36-
})();
37-
38-
// Fix for file:// URL path handling across platforms
39-
const CURRENT_DIR = (() => {
40-
if (import.meta.url) {
41-
const fileUrl = new URL(import.meta.url);
42-
// Convert URL to proper system path - handles Windows paths correctly
43-
return path.normalize(
11+
const CLAUDE_CONFIG_PATH =
12+
process.platform === "win32"
13+
? path.join(process.env.APPDATA, "Claude", "claude_desktop_config.json") // %APPDATA% resolves to the right location on Windows
14+
: path.join(
15+
os.homedir(),
16+
"Library/Application Support/Claude/claude_desktop_config.json"
17+
);
18+
19+
const CURRENT_DIR = import.meta.url
20+
? path.dirname(
4421
process.platform === "win32"
45-
? fileUrl.pathname.substring(1) // Remove leading slash on Windows
46-
: fileUrl.pathname
47-
);
48-
} else {
49-
return __dirname;
50-
}
51-
})();
22+
? new URL(import.meta.url).pathname.substring(1) // Remove leading slash on Windows
23+
: new URL(import.meta.url).pathname
24+
)
25+
: __dirname;
5226

53-
const SERVERS_DIR = path.join(path.dirname(CURRENT_DIR), "servers");
27+
const SERVERS_DIR = path.join(CURRENT_DIR, "servers");
5428

5529
const TYPESCRIPT_SDK_URL =
5630
"https://github.com/modelcontextprotocol/typescript-sdk";

package-lock.json

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
"dependencies": {
1818
"@google-cloud/bigquery": "^8.0.0",
1919
"@modelcontextprotocol/sdk": "^1.11.2",
20+
"isomorphic-fetch": "^3.0.0",
2021
"node-fetch": "^2.7.0",
2122
"pg": "^8.16.0",
2223
"puppeteer": "^24.8.2",
2324
"zod": "^3.22.4"
2425
},
2526
"devDependencies": {
27+
"@types/isomorphic-fetch": "^0.0.39",
2628
"@types/node": "^20.10.0",
2729
"@types/node-fetch": "^2.6.12",
2830
"@types/pg": "^8.15.1",

0 commit comments

Comments
 (0)