secondbrainos-mcp-server 1.0.6 → 1.0.8
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 +42 -15
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -116,6 +116,19 @@ function getNodeModulesPath() {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
/**
|
|
120
|
+
* Read existing Claude Desktop configuration
|
|
121
|
+
*/
|
|
122
|
+
async function readExistingConfig(configPath) {
|
|
123
|
+
try {
|
|
124
|
+
const configData = await fs.readFile(configPath, 'utf8');
|
|
125
|
+
return JSON.parse(configData);
|
|
126
|
+
} catch (error) {
|
|
127
|
+
// If file doesn't exist or is invalid JSON, return empty config
|
|
128
|
+
return {};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
119
132
|
async function main() {
|
|
120
133
|
try {
|
|
121
134
|
// Get command line arguments
|
|
@@ -208,25 +221,39 @@ async function main() {
|
|
|
208
221
|
// Find Node.js executable
|
|
209
222
|
const nodePath = await findNodeExecutable();
|
|
210
223
|
|
|
211
|
-
//
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
+
// Read existing configuration
|
|
225
|
+
const existingConfig = await readExistingConfig(claudeConfigFile);
|
|
226
|
+
|
|
227
|
+
// Ensure mcpServers object exists
|
|
228
|
+
if (!existingConfig.mcpServers) {
|
|
229
|
+
existingConfig.mcpServers = {};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// Check if secondbrainos already exists
|
|
233
|
+
const hadExistingSecondBrainOS = !!existingConfig.mcpServers.secondbrainos;
|
|
234
|
+
|
|
235
|
+
// Add or update the secondbrainos server configuration
|
|
236
|
+
existingConfig.mcpServers.secondbrainos = {
|
|
237
|
+
command: nodePath,
|
|
238
|
+
args: [serverPath],
|
|
239
|
+
env: {
|
|
240
|
+
USER_ID,
|
|
241
|
+
USER_SECRET,
|
|
242
|
+
API_BASE_URL: 'https://api.secondbrainos.com',
|
|
243
|
+
NODE_PATH: getNodeModulesPath()
|
|
224
244
|
}
|
|
225
245
|
};
|
|
226
246
|
|
|
227
247
|
try {
|
|
228
|
-
|
|
229
|
-
|
|
248
|
+
// Write the updated configuration back
|
|
249
|
+
await fs.writeFile(claudeConfigFile, JSON.stringify(existingConfig, null, 2));
|
|
250
|
+
console.log(`Configuration file ${hadExistingSecondBrainOS ? 'updated' : 'created'} at: ${claudeConfigFile}`);
|
|
251
|
+
|
|
252
|
+
// Show summary of configured servers
|
|
253
|
+
const serverCount = Object.keys(existingConfig.mcpServers).length;
|
|
254
|
+
console.log(`\nTotal MCP servers configured: ${serverCount}`);
|
|
255
|
+
console.log('Configured servers:', Object.keys(existingConfig.mcpServers).join(', '));
|
|
256
|
+
|
|
230
257
|
} catch (error) {
|
|
231
258
|
console.error('Error writing configuration file:', error);
|
|
232
259
|
process.exit(1);
|