From bce3a7b8d6c5ac58c20f3b713cd1b750234b7e56 Mon Sep 17 00:00:00 2001 From: Justin Spahr-Summers Date: Mon, 11 Nov 2024 11:10:42 +0000 Subject: [PATCH] Make root package installable/executable --- bin/cli.js | 36 ++++++++++++++++++++++++++++++++++++ package.json | 14 ++++++++++++-- 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100755 bin/cli.js diff --git a/bin/cli.js b/bin/cli.js new file mode 100755 index 0000000..0de8616 --- /dev/null +++ b/bin/cli.js @@ -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); +}); diff --git a/package.json b/package.json index dbdb611..d7dfb4d 100644 --- a/package.json +++ b/package.json @@ -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" } }