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.
Files changed (2) hide show
  1. package/bin/cli.js +42 -15
  2. 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
- // Create the Claude Desktop configuration
212
- const configContent = {
213
- mcpServers: {
214
- secondbrainos: {
215
- command: nodePath,
216
- args: [serverPath],
217
- env: {
218
- USER_ID,
219
- USER_SECRET,
220
- API_BASE_URL: 'https://api.secondbrainos.com',
221
- NODE_PATH: getNodeModulesPath()
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
- await fs.writeFile(claudeConfigFile, JSON.stringify(configContent, null, 2));
229
- console.log(`Configuration file created at: ${claudeConfigFile}`);
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "secondbrainos-mcp-server",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Second Brain OS MCP Server for Claude Desktop",
5
5
  "type": "module",
6
6
  "main": "build/index.js",