@khanglvm/tool-hub-mcp 1.1.2 → 1.1.4

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/package.json +6 -6
  2. package/postinstall.js +49 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanglvm/tool-hub-mcp",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "Serverless MCP Aggregator - Reduce AI context token consumption by 38%",
5
5
  "bin": {
6
6
  "tool-hub-mcp": "./cli.js"
@@ -14,11 +14,11 @@
14
14
  "postinstall": "node postinstall.js"
15
15
  },
16
16
  "optionalDependencies": {
17
- "@khanglvm/tool-hub-mcp-darwin-arm64": "1.1.2",
18
- "@khanglvm/tool-hub-mcp-darwin-x64": "1.1.2",
19
- "@khanglvm/tool-hub-mcp-linux-x64": "1.1.2",
20
- "@khanglvm/tool-hub-mcp-linux-arm64": "1.1.2",
21
- "@khanglvm/tool-hub-mcp-win32-x64": "1.1.2"
17
+ "@khanglvm/tool-hub-mcp-darwin-arm64": "1.1.4",
18
+ "@khanglvm/tool-hub-mcp-darwin-x64": "1.1.4",
19
+ "@khanglvm/tool-hub-mcp-linux-x64": "1.1.4",
20
+ "@khanglvm/tool-hub-mcp-linux-arm64": "1.1.4",
21
+ "@khanglvm/tool-hub-mcp-win32-x64": "1.1.4"
22
22
  },
23
23
  "keywords": [
24
24
  "mcp",
package/postinstall.js CHANGED
@@ -153,6 +153,7 @@ async function main() {
153
153
  // Skip if platform binary already installed via optionalDependencies
154
154
  if (hasPlatformBinary()) {
155
155
  console.log('tool-hub-mcp: Binary found from optionalDependencies ✓');
156
+ createBinSymlink(BINARY_NAME);
156
157
  return;
157
158
  }
158
159
 
@@ -185,6 +186,7 @@ async function main() {
185
186
  }
186
187
 
187
188
  console.log('tool-hub-mcp: Binary downloaded and installed ✓');
189
+ createBinSymlink(binaryName);
188
190
 
189
191
  } catch (error) {
190
192
  console.error(`tool-hub-mcp: Failed to download binary: ${error.message}`);
@@ -194,4 +196,51 @@ async function main() {
194
196
  }
195
197
  }
196
198
 
199
+ /**
200
+ * Create .bin symlink for the CLI wrapper.
201
+ * This is needed because npm sometimes doesn't create symlinks properly
202
+ * when packages are installed via npx or when optionalDependencies are used.
203
+ */
204
+ function createBinSymlink(binaryName) {
205
+ try {
206
+ const fs = require('fs');
207
+ const path = require('path');
208
+
209
+ // Find the .bin directory (usually at node_modules/.bin)
210
+ let binDir = null;
211
+ const searchLevels = ['node_modules/.bin', '../.bin', '../../.bin', '.bin'];
212
+
213
+ for (const dir of searchLevels) {
214
+ const testPath = path.join(__dirname, dir);
215
+ // Check if path exists or if we can create it
216
+ const parentDir = path.dirname(testPath);
217
+ if (fs.existsSync(parentDir)) {
218
+ // Create .bin directory if it doesn't exist
219
+ if (!fs.existsSync(testPath)) {
220
+ fs.mkdirSync(testPath, { recursive: true });
221
+ }
222
+ binDir = testPath;
223
+ break;
224
+ }
225
+ }
226
+
227
+ if (!binDir) {
228
+ // .bin directory doesn't exist, might be in a global install
229
+ return;
230
+ }
231
+
232
+ const linkPath = path.join(binDir, binaryName);
233
+ const targetPath = path.join(__dirname, 'cli.js');
234
+
235
+ // Create symlink if it doesn't exist
236
+ if (!fs.existsSync(linkPath)) {
237
+ fs.symlinkSync(targetPath, linkPath);
238
+ console.log('tool-hub-mcp: Created .bin symlink ✓');
239
+ }
240
+ } catch (err) {
241
+ // Log error but don't fail
242
+ console.log('tool-hub-mcp: Could not create .bin symlink:', err.message);
243
+ }
244
+ }
245
+
197
246
  main();