Make root package installable/executable

This commit is contained in:
Justin Spahr-Summers
2024-11-11 11:10:42 +00:00
parent 196f2f801d
commit bce3a7b8d6
2 changed files with 48 additions and 2 deletions

36
bin/cli.js Executable file
View File

@@ -0,0 +1,36 @@
#!/usr/bin/env node
import { join, dirname } from "path";
import { fileURLToPath } from "url";
import concurrently from "concurrently";
const __dirname = dirname(fileURLToPath(import.meta.url));
// Paths to the server and client entry points
const serverPath = join(__dirname, "../server/build/index.js");
const clientPath = join(__dirname, "../client/bin/cli.js");
console.log("Starting MCP inspector...");
const { result } = concurrently(
[
{
command: `node ${serverPath}`,
name: "server",
},
{
command: `node ${clientPath}`,
name: "client",
},
],
{
prefix: "name",
killOthers: ["failure", "success"],
restartTries: 3,
},
);
result.catch((err) => {
console.error("An error occurred:", err);
process.exit(1);
});

View File

@@ -7,6 +7,14 @@
"homepage": "https://modelcontextprotocol.github.io",
"bugs": "https://github.com/modelcontextprotocol/inspector/issues",
"type": "module",
"bin": {
"mcp-inspector": "./bin/cli.js"
},
"files": [
"bin",
"client/dist",
"server/build"
],
"workspaces": [
"client",
"server"
@@ -18,11 +26,13 @@
"build": "npm run build-server && npm run build-client",
"start-server": "cd server && npm run start",
"start-client": "cd client && npm run preview",
"start": "concurrently \"npm run start-server\" \"npm run start-client\"",
"start": "./bin/cli.js",
"prepare": "npm run build",
"prettier-fix": "prettier --write ."
},
"devDependencies": {
"concurrently": "^9.0.1",
"prettier": "3.3.3"
"prettier": "3.3.3",
"@types/node": "^22.7.5"
}
}