forked from pollinations/pollinations
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-claude-mcp.js
More file actions
executable file
·76 lines (68 loc) · 2.16 KB
/
install-claude-mcp.js
File metadata and controls
executable file
·76 lines (68 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env node
import fs from "fs";
import path from "path";
import os from "os";
// Determine the Claude Desktop config file path based on the operating system
const getConfigPath = () => {
switch (os.platform()) {
case "darwin": // macOS
return path.join(
os.homedir(),
"Library",
"Application Support",
"Claude",
"claude_desktop_config.json",
);
case "win32": // Windows
return path.join(
os.homedir(),
"AppData",
"Roaming",
"Claude",
"claude_desktop_config.json",
);
default: // Linux and others
return path.join(
os.homedir(),
".config",
"Claude",
"claude_desktop_config.json",
);
}
};
const configPath = getConfigPath();
console.log(`Claude Desktop config path: ${configPath}`);
// Read existing config or create a new one
let config = {};
try {
const configData = fs.readFileSync(configPath, "utf8");
config = JSON.parse(configData);
console.log("Existing Claude Desktop config found");
} catch (error) {
console.log("Creating new Claude Desktop config");
}
// Ensure mcpServers section exists
config.mcpServers = config.mcpServers || {};
// Add or update the pollinations MCP server configuration
config.mcpServers.pollinations = {
command: "npx",
args: ["@pollinations/model-context-protocol"],
disabled: false,
alwaysAllow: [],
};
// Write the updated config back to the file
const configDir = path.dirname(configPath);
try {
if (!fs.existsSync(configDir)) {
fs.mkdirSync(configDir, { recursive: true });
console.log(`Created directory: ${configDir}`);
}
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
console.log(
`Pollinations MCP server installed in Claude Desktop config at ${configPath}`,
);
console.log("Please restart Claude Desktop to apply the changes");
} catch (error) {
console.error(`Failed to write config: ${error.message}`);
process.exit(1);
}