sublime-mcp 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +69 -0
- package/fallback-tools.json +2462 -0
- package/http.js +43 -0
- package/index.js +143 -0
- package/package.json +33 -0
- package/test_batch.mjs +72 -0
- package/test_fallback_catalog.mjs +111 -0
package/bin/cli.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs/promises');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const prompts = require('prompts');
|
|
6
|
+
|
|
7
|
+
async function main() {
|
|
8
|
+
console.log('Sublime-MCP Agent Configurator');
|
|
9
|
+
|
|
10
|
+
const response = await prompts({
|
|
11
|
+
type: 'text',
|
|
12
|
+
name: 'configFile',
|
|
13
|
+
message: 'Please enter the path to your AI agent\'s configuration file (e.g., ~/.claude/settings.json):',
|
|
14
|
+
validate: async (value) => {
|
|
15
|
+
try {
|
|
16
|
+
// Resolve ~ to the home directory
|
|
17
|
+
const resolvedPath = value.startsWith('~') ? path.join(process.env.HOME || process.env.USERPROFILE, value.slice(1)) : value;
|
|
18
|
+
await fs.access(resolvedPath);
|
|
19
|
+
return true;
|
|
20
|
+
} catch (e) {
|
|
21
|
+
return 'File not found. Please enter a valid path.';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
if (!response.configFile) {
|
|
27
|
+
console.log('Configuration cancelled.');
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const configPath = response.configFile.startsWith('~') ? path.join(process.env.HOME || process.env.USERPROFILE, response.configFile.slice(1)) : response.configFile;
|
|
32
|
+
console.log(Reading configuration file: );
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
const configContent = await fs.readFile(configPath, 'utf-8');
|
|
36
|
+
const config = JSON.parse(configContent);
|
|
37
|
+
|
|
38
|
+
console.log('Successfully parsed configuration file.');
|
|
39
|
+
|
|
40
|
+
// Determine the correct port based on the platform
|
|
41
|
+
const port = process.platform === 'win32' ? 9502 : 9503;
|
|
42
|
+
const mcpEntry = {
|
|
43
|
+
"sublime-mcp": { "type": "sse", "url": http://127.0.0.1:/sse }
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// Add or update the mcpServers entry
|
|
47
|
+
if (!config.mcpServers) {
|
|
48
|
+
config.mcpServers = {};
|
|
49
|
+
}
|
|
50
|
+
config.mcpServers = { ...config.mcpServers, ...mcpEntry };
|
|
51
|
+
|
|
52
|
+
// Write the updated configuration back to the file
|
|
53
|
+
const newConfigContent = JSON.stringify(config, null, 2);
|
|
54
|
+
await fs.writeFile(configPath, newConfigContent, 'utf-8');
|
|
55
|
+
|
|
56
|
+
console.log('Successfully updated the configuration file with the sublime-mcp server.');
|
|
57
|
+
console.log('Please restart your AI agent for the changes to take effect.');
|
|
58
|
+
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.error(Error processing configuration file: );
|
|
61
|
+
console.error('Please ensure the file is a valid JSON file.');
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
main().catch(err => {
|
|
67
|
+
console.error('An error occurred:', err);
|
|
68
|
+
process.exit(1);
|
|
69
|
+
});
|