impact-ui-mcp-server 1.0.1 → 1.0.3

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.
@@ -28,6 +28,10 @@ your-project/
28
28
  npm install impact-ui impact-ui-mcp-server
29
29
  ```
30
30
 
31
+ **Package Names:**
32
+ - `impact-ui` - The UI library
33
+ - `impact-ui-mcp-server` - The MCP server (published to npm)
34
+
31
35
  ## Windsurf Configuration
32
36
 
33
37
  Since Windsurf needs absolute paths, use this configuration:
@@ -29,72 +29,124 @@ let config;
29
29
  let impactUiPathToUse = impactUiPath;
30
30
 
31
31
  if (useNpm) {
32
- // Check if package is installed
33
- let packagePath;
32
+ // Check if package is installed (try both scoped and unscoped names)
33
+ let packageFound = false;
34
+ let packageName = "impact-ui-mcp-server";
35
+
34
36
  try {
35
- packagePath = execSync("npm list @impact-analytics/impact-ui-mcp-server --json", { encoding: "utf-8", stdio: "pipe" });
37
+ const packagePath = execSync("npm list impact-ui-mcp-server --json", { encoding: "utf-8", stdio: "pipe" });
36
38
  const packageInfo = JSON.parse(packagePath);
37
- if (!packageInfo.dependencies || !packageInfo.dependencies["@impact-analytics/impact-ui-mcp-server"]) {
38
- console.log("\n⚠️ Package not found. Install it first:");
39
- console.log(" npm install @impact-analytics/impact-ui-mcp-server\n");
40
- process.exit(1);
39
+ if (packageInfo.dependencies && packageInfo.dependencies["impact-ui-mcp-server"]) {
40
+ packageFound = true;
41
41
  }
42
42
  } catch (error) {
43
- console.log("\n⚠️ Package not found. Install it first:");
44
- console.log(" npm install @impact-analytics/impact-ui-mcp-server\n");
45
- process.exit(1);
46
- }
47
-
48
- // Get the absolute path to Impact UI
49
- if (!impactUiPathToUse) {
50
- console.log("\n❓ Please provide the path to your Impact UI repository:");
51
- console.log(" node generate-cursor-config.js --npm --impact-ui-path=/path/to/impact-ui\n");
52
- process.exit(1);
43
+ // Try scoped version
44
+ try {
45
+ const packagePath = execSync("npm list @impact-analytics/impact-ui-mcp-server --json", { encoding: "utf-8", stdio: "pipe" });
46
+ const packageInfo = JSON.parse(packagePath);
47
+ if (packageInfo.dependencies && packageInfo.dependencies["@impact-analytics/impact-ui-mcp-server"]) {
48
+ packageFound = true;
49
+ packageName = "@impact-analytics/impact-ui-mcp-server";
50
+ }
51
+ } catch (error2) {
52
+ // Package not found, but continue - user might install it later
53
+ }
53
54
  }
54
55
 
55
- // Verify the path exists
56
- if (!existsSync(impactUiPathToUse)) {
57
- console.log(`\n❌ Path does not exist: ${impactUiPathToUse}\n`);
58
- process.exit(1);
56
+ // For npm packages, use ${workspaceFolder} variables (Cursor supports these)
57
+ // Try to detect actual structure, otherwise use most common structure
58
+ const cwd = process.cwd();
59
+ let mcpServerPath = "${workspaceFolder}/frontend/node_modules/impact-ui-mcp-server/src/index.js";
60
+ let impactUiPath = "${workspaceFolder}/frontend/node_modules/impact-ui";
61
+
62
+ // Check actual structure to determine which path to use
63
+ const frontendMcpPath = resolve(cwd, "frontend", "node_modules", "impact-ui-mcp-server", "src", "index.js");
64
+ const rootMcpPath = resolve(cwd, "node_modules", "impact-ui-mcp-server", "src", "index.js");
65
+
66
+ if (existsSync(frontendMcpPath)) {
67
+ // Packages are in frontend/node_modules
68
+ mcpServerPath = "${workspaceFolder}/frontend/node_modules/impact-ui-mcp-server/src/index.js";
69
+ impactUiPath = "${workspaceFolder}/frontend/node_modules/impact-ui";
70
+ } else if (existsSync(rootMcpPath)) {
71
+ // Packages are in root node_modules
72
+ mcpServerPath = "${workspaceFolder}/node_modules/impact-ui-mcp-server/src/index.js";
73
+ impactUiPath = "${workspaceFolder}/node_modules/impact-ui";
59
74
  }
60
-
61
- if (!existsSync(resolve(impactUiPathToUse, "frontend"))) {
62
- console.log(`\n❌ Frontend directory not found at: ${resolve(impactUiPathToUse, "frontend")}\n`);
63
- process.exit(1);
75
+
76
+ // Check for scoped package name
77
+ const frontendScopedMcpPath = resolve(cwd, "frontend", "node_modules", "@impact-analytics", "impact-ui-mcp-server", "src", "index.js");
78
+ const rootScopedMcpPath = resolve(cwd, "node_modules", "@impact-analytics", "impact-ui-mcp-server", "src", "index.js");
79
+
80
+ if (existsSync(frontendScopedMcpPath)) {
81
+ mcpServerPath = "${workspaceFolder}/frontend/node_modules/@impact-analytics/impact-ui-mcp-server/src/index.js";
82
+ } else if (existsSync(rootScopedMcpPath)) {
83
+ mcpServerPath = "${workspaceFolder}/node_modules/@impact-analytics/impact-ui-mcp-server/src/index.js";
64
84
  }
65
85
 
66
86
  config = {
67
87
  "mcp.servers": {
68
88
  "impact-ui": {
69
89
  "command": "node",
70
- "args": [
71
- "./node_modules/@impact-analytics/impact-ui-mcp-server/src/index.js"
72
- ],
90
+ "args": [mcpServerPath],
73
91
  "cwd": "${workspaceFolder}",
74
92
  "env": {
75
- "IMPACT_UI_PATH": impactUiPathToUse
93
+ "IMPACT_UI_NODE_MODULES": impactUiPath
76
94
  }
77
95
  }
78
96
  }
79
97
  };
80
98
 
81
- console.log("\n📦 NPM Package Configuration\n");
99
+ console.log("\n📦 NPM Package Configuration (with ${workspaceFolder} variables)\n");
100
+ if (!packageFound) {
101
+ console.log("⚠️ Note: Package not detected in current directory.");
102
+ console.log(" Make sure to install: npm install impact-ui-mcp-server\n");
103
+ }
82
104
  } else {
83
- // Local development configuration
84
- const mcpServerPath = resolve(__dirname);
85
- const indexPath = resolve(__dirname, "src/index.js");
105
+ // For npm packages (when run from a project), use ${workspaceFolder} variables
106
+ // Try to detect if we're in a project with node_modules
107
+ const cwd = process.cwd();
108
+ let mcpServerPath = "${workspaceFolder}/frontend/node_modules/impact-ui-mcp-server/src/index.js";
109
+ let impactUiPath = "${workspaceFolder}/frontend/node_modules/impact-ui";
110
+
111
+ // Check actual structure to determine which path to use
112
+ const frontendMcpPath = resolve(cwd, "frontend", "node_modules", "impact-ui-mcp-server", "src", "index.js");
113
+ const rootMcpPath = resolve(cwd, "node_modules", "impact-ui-mcp-server", "src", "index.js");
114
+
115
+ if (existsSync(frontendMcpPath)) {
116
+ // Packages are in frontend/node_modules
117
+ mcpServerPath = "${workspaceFolder}/frontend/node_modules/impact-ui-mcp-server/src/index.js";
118
+ impactUiPath = "${workspaceFolder}/frontend/node_modules/impact-ui";
119
+ } else if (existsSync(rootMcpPath)) {
120
+ // Packages are in root node_modules
121
+ mcpServerPath = "${workspaceFolder}/node_modules/impact-ui-mcp-server/src/index.js";
122
+ impactUiPath = "${workspaceFolder}/node_modules/impact-ui";
123
+ }
124
+
125
+ // Check for scoped package name
126
+ const frontendScopedMcpPath = resolve(cwd, "frontend", "node_modules", "@impact-analytics", "impact-ui-mcp-server", "src", "index.js");
127
+ const rootScopedMcpPath = resolve(cwd, "node_modules", "@impact-analytics", "impact-ui-mcp-server", "src", "index.js");
128
+
129
+ if (existsSync(frontendScopedMcpPath)) {
130
+ mcpServerPath = "${workspaceFolder}/frontend/node_modules/@impact-analytics/impact-ui-mcp-server/src/index.js";
131
+ } else if (existsSync(rootScopedMcpPath)) {
132
+ mcpServerPath = "${workspaceFolder}/node_modules/@impact-analytics/impact-ui-mcp-server/src/index.js";
133
+ }
86
134
 
87
135
  config = {
88
136
  "mcp.servers": {
89
137
  "impact-ui": {
90
138
  "command": "node",
91
- "args": [indexPath],
92
- "cwd": mcpServerPath
139
+ "args": [mcpServerPath],
140
+ "cwd": "${workspaceFolder}",
141
+ "env": {
142
+ "IMPACT_UI_NODE_MODULES": impactUiPath
143
+ }
93
144
  }
94
145
  }
95
146
  };
96
147
 
97
- console.log("\n🏠 Local Development Configuration\n");
148
+ console.log("\n📦 NPM Package Configuration (with ${workspaceFolder} variables)\n");
149
+ console.log("💡 Detected package structure and using ${workspaceFolder} variables for Cursor.\n");
98
150
  }
99
151
 
100
152
  console.log("Add this to your Cursor settings.json:\n");
@@ -109,5 +161,6 @@ console.log("🔄 Restart Cursor IDE after adding the configuration\n");
109
161
 
110
162
  if (useNpm) {
111
163
  console.log("📝 Note: Make sure to install the package first:");
112
- console.log(" npm install @impact-analytics/impact-ui-mcp-server\n");
164
+ console.log(" npm install impact-ui-mcp-server\n");
165
+ console.log("💡 The configuration uses ${workspaceFolder} variables which Cursor resolves automatically.\n");
113
166
  }
@@ -56,20 +56,43 @@ if (useNpm) {
56
56
  process.exit(1);
57
57
  }
58
58
 
59
+ // For npm packages, detect structure and use appropriate paths
60
+ const cwd = process.cwd();
61
+ let mcpServerPath = "./node_modules/impact-ui-mcp-server/src/index.js";
62
+ let impactUiNodeModules = null;
63
+
64
+ // Check actual structure
65
+ const frontendMcpPath = resolve(cwd, "frontend", "node_modules", "impact-ui-mcp-server", "src", "index.js");
66
+ const rootMcpPath = resolve(cwd, "node_modules", "impact-ui-mcp-server", "src", "index.js");
67
+
68
+ if (existsSync(frontendMcpPath)) {
69
+ mcpServerPath = "./frontend/node_modules/impact-ui-mcp-server/src/index.js";
70
+ impactUiNodeModules = "./frontend/node_modules/impact-ui";
71
+ } else if (existsSync(rootMcpPath)) {
72
+ mcpServerPath = "./node_modules/impact-ui-mcp-server/src/index.js";
73
+ impactUiNodeModules = "./node_modules/impact-ui";
74
+ }
75
+
59
76
  config = {
60
77
  "mcpServers": {
61
78
  "impact-ui": {
62
79
  "command": "node",
63
- "args": [
64
- "./node_modules/impact-ui-mcp-server/src/index.js"
65
- ],
66
- "cwd": "${workspaceFolder}",
67
- "env": {
68
- "IMPACT_UI_PATH": impactUiPathToUse
69
- }
80
+ "args": [mcpServerPath],
81
+ "cwd": "${workspaceFolder}"
70
82
  }
71
83
  }
72
84
  };
85
+
86
+ // Add environment variable if impact-ui is in node_modules
87
+ if (impactUiNodeModules) {
88
+ config.mcpServers["impact-ui"].env = {
89
+ "IMPACT_UI_NODE_MODULES": impactUiNodeModules
90
+ };
91
+ } else if (impactUiPathToUse) {
92
+ config.mcpServers["impact-ui"].env = {
93
+ "IMPACT_UI_PATH": impactUiPathToUse
94
+ };
95
+ }
73
96
 
74
97
  console.log("\n📦 NPM Package Configuration\n");
75
98
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impact-ui-mcp-server",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "MCP Server for Impact UI Library - Provides AI access to component documentation and code examples",
5
5
  "type": "module",
6
6
  "main": "src/index.js",