@samanhappy/mcphub 0.0.4 → 0.0.5

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 +8 -10
  2. package/package.json +2 -2
package/bin/cli.js CHANGED
@@ -6,26 +6,24 @@
6
6
  import { spawn } from 'child_process';
7
7
  import path from 'path';
8
8
  import { fileURLToPath } from 'url';
9
+ import fs from 'fs';
9
10
 
10
11
  const __filename = fileURLToPath(import.meta.url);
11
12
  const __dirname = path.dirname(__filename);
12
13
 
13
14
  // Get the path to the build directory
14
15
  const buildPath = path.resolve(__dirname, '../dist');
16
+ const indexPath = path.join(buildPath, 'index.js');
15
17
 
16
- // Handle the 'node dist/index.js' command format
17
- const args = process.argv.slice(2);
18
- let scriptPath = path.join(buildPath, 'index.js');
19
-
20
- // If the command includes 'node dist/index.js', use provided arguments
21
- if (args.length >= 2 && args[0] === 'node' && args[1].includes('index.js')) {
22
- scriptPath = args[1].startsWith('/') ? args[1] : path.join(process.cwd(), args[1]);
23
- // Remove 'node' and script path from arguments
24
- args.splice(0, 2);
18
+ // Check if the index.js file exists
19
+ if (!fs.existsSync(indexPath)) {
20
+ console.error(`Error: Could not find ${indexPath}`);
21
+ console.error('Please make sure you have built the project with "npm run build" first.');
22
+ process.exit(1);
25
23
  }
26
24
 
27
25
  // Start the server with provided arguments
28
- const server = spawn('node', [scriptPath, ...args], {
26
+ const server = spawn('node', [indexPath, ...process.argv.slice(2)], {
29
27
  stdio: 'inherit',
30
28
  shell: true
31
29
  });
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@samanhappy/mcphub",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "A hub server for mcp servers",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
7
7
  "bin": {
8
- "mcphub": "./bin/cli.js"
8
+ "mcphub": "bin/cli.js"
9
9
  },
10
10
  "files": [
11
11
  "dist",