@insforge/install 0.0.18 → 0.0.20

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/dist/index.js +37 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -6,7 +6,9 @@ import {
6
6
  writeConfig
7
7
  } from "./utils.js";
8
8
  import { execSync } from 'child_process';
9
-
9
+ import os from 'os';
10
+ import path from 'path';
11
+
10
12
  import yargs from "yargs";
11
13
  import { hideBin } from "yargs/helpers";
12
14
 
@@ -56,17 +58,41 @@ import {
56
58
 
57
59
  // Handle different config structures for different clients
58
60
  if (argv.client === "claude-code") {
59
- // Directly write to config file for Claude Code
60
- if (!config.mcpServers) config.mcpServers = {};
61
- config.mcpServers[name] = {
62
- command: "npx",
63
- args: ["-y", "@insforge/mcp@latest"],
64
- env: {
65
- API_KEY: envVars.API_KEY,
66
- API_BASE_URL: envVars.API_BASE_URL
61
+ // Use Claude CLI for Claude Code
62
+ const homeDir = os.homedir();
63
+ const isWindows = process.platform === 'win32';
64
+ const claudePath = isWindows
65
+ ? path.join(homeDir, '.claude', 'local', 'claude.exe')
66
+ : path.join(homeDir, '.claude', 'local', 'claude');
67
+
68
+ const envArgs = Object.entries(envVars)
69
+ .filter(([key]) => key !== 'CLIENT_NAME')
70
+ .map(([key, value]) => `-e ${key}=${value}`)
71
+ .join(' ');
72
+
73
+ try {
74
+ // First try to remove existing insforge MCP if it exists
75
+ try {
76
+ execSync(`"${claudePath}" mcp remove ${name}`, {
77
+ stdio: 'pipe',
78
+ shell: true
79
+ });
80
+ logger.info("Removed existing insforge MCP installation.");
81
+ } catch (removeError) {
82
+ // It's okay if remove fails - the MCP might not exist
83
+ logger.info("No existing insforge MCP found");
67
84
  }
68
- };
69
- writeConfig(config, argv.client);
85
+
86
+ // Now add the MCP server
87
+ const command = `"${claudePath}" mcp add ${name} ${envArgs} -- npx -y @insforge/mcp@latest`;
88
+ logger.info("Adding insforge MCP server...");
89
+ execSync(command, {
90
+ stdio: 'inherit',
91
+ shell: true
92
+ });
93
+ } catch (error) {
94
+ throw new Error(`Failed to add MCP server via Claude CLI: ${error.message}`);
95
+ }
70
96
  } else if (argv.client === "codex") {
71
97
  // Use Codex CLI for Codex
72
98
  const envArgs = Object.entries(envVars)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@insforge/install",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
4
4
  "description": "CLI tool for installing Insforge MCP servers across different AI clients",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",