diff --git a/bin/cli.js b/bin/cli.js index 0de8616fb..77d6e52a9 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -6,20 +6,24 @@ 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"); +// Get command line arguments +const [, , command, ...mcpServerArgs] = process.argv; + +const inspectorServerPath = join(__dirname, "../server/build/index.js"); + +// Path to the client entry point +const inspectorClientPath = join(__dirname, "../client/bin/cli.js"); console.log("Starting MCP inspector..."); const { result } = concurrently( [ { - command: `node ${serverPath}`, + command: `node ${inspectorServerPath}${command ? ` --env ${command}` : ""}${mcpServerArgs.length ? ` --args "${mcpServerArgs.join(" ")}"` : ""}`, name: "server", }, { - command: `node ${clientPath}`, + command: `node ${inspectorClientPath}`, name: "client", }, ], diff --git a/client/package.json b/client/package.json index 40fa35ac2..3c937385a 100644 --- a/client/package.json +++ b/client/package.json @@ -1,7 +1,6 @@ { "name": "@modelcontextprotocol/inspector-client", - "version": "0.1.0", - "private": true, + "version": "0.1.5", "description": "Client-side application for the Model Context Protocol inspector", "license": "MIT", "author": "Anthropic, PBC (https://anthropic.com)", diff --git a/client/src/App.tsx b/client/src/App.tsx index 8ae2068f1..73a337aea 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -186,9 +186,13 @@ const App = () => { }, [args]); useEffect(() => { - fetch("http://localhost:3000/default-environment") + fetch("http://localhost:3000/config") .then((response) => response.json()) - .then((data) => setEnv(data)) + .then((data) => { + setEnv(data.defaultEnvironment); + setCommand(data.defaultCommand); + setArgs(data.defaultArgs); + }) .catch((error) => console.error("Error fetching default environment:", error), ); diff --git a/package-lock.json b/package-lock.json index 090645e09..aadcba169 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,18 +1,20 @@ { "name": "@modelcontextprotocol/inspector", - "version": "0.1.0", + "version": "0.1.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@modelcontextprotocol/inspector", - "version": "0.1.0", + "version": "0.1.4", "license": "MIT", "workspaces": [ "client", "server" ], "dependencies": { + "@modelcontextprotocol/inspector-client": "0.1.0", + "@modelcontextprotocol/inspector-server": "0.1.0", "concurrently": "^9.0.1" }, "bin": { diff --git a/package.json b/package.json index f1550fa47..651b11483 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,6 @@ { "name": "@modelcontextprotocol/inspector", - "version": "0.1.0", - "private": true, + "version": "0.1.5", "description": "Model Context Protocol inspector", "license": "MIT", "author": "Anthropic, PBC (https://anthropic.com)", @@ -33,6 +32,8 @@ "prettier-fix": "prettier --write ." }, "dependencies": { + "@modelcontextprotocol/inspector-client": "0.1.0", + "@modelcontextprotocol/inspector-server": "0.1.0", "concurrently": "^9.0.1" }, "devDependencies": { diff --git a/server/package.json b/server/package.json index a2b111232..296b6a07f 100644 --- a/server/package.json +++ b/server/package.json @@ -1,7 +1,6 @@ { "name": "@modelcontextprotocol/inspector-server", - "version": "0.1.0", - "private": true, + "version": "0.1.5", "description": "Server-side application for the Model Context Protocol inspector", "license": "MIT", "author": "Anthropic, PBC (https://anthropic.com)", diff --git a/server/src/index.ts b/server/src/index.ts index 5030fdc9b..c8f2c74a9 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -1,5 +1,6 @@ #!/usr/bin/env node +import { parseArgs } from "node:util"; import cors from "cors"; import EventSource from "eventsource"; @@ -16,6 +17,14 @@ import mcpProxy from "./mcpProxy.js"; // eslint-disable-next-line @typescript-eslint/no-explicit-any (global as any).EventSource = EventSource; +const { values } = parseArgs({ + args: process.argv.slice(2), + options: { + env: { type: "string", default: "" }, + args: { type: "string", default: "" }, + }, +}); + const app = express(); app.use(cors()); @@ -97,11 +106,16 @@ app.post("/message", async (req, res) => { } }); -app.get("/default-environment", (req, res) => { +app.get("/config", (req, res) => { try { - res.json(getDefaultEnvironment()); + const defaultEnvironment = getDefaultEnvironment(); + res.json({ + defaultEnvironment, + defaultCommand: values.env, + defaultArgs: values.args, + }); } catch (error) { - console.error("Error in /default-environment route:", error); + console.error("Error in /config route:", error); res.status(500).json(error); } });