Skip to content

Commit 196f2f8

Browse files
committed
Use serve to create npm package for the client
1 parent a0d8ec1 commit 196f2f8

File tree

3 files changed

+130
-15
lines changed

3 files changed

+130
-15
lines changed

client/bin/cli.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env node
2+
3+
import { join, dirname } from "path";
4+
import { fileURLToPath } from "url";
5+
import handler from "serve-handler";
6+
import http from "http";
7+
8+
const __dirname = dirname(fileURLToPath(import.meta.url));
9+
const distPath = join(__dirname, "../dist");
10+
11+
const server = http.createServer((request, response) => {
12+
return handler(request, response, { public: distPath });
13+
});
14+
15+
const port = process.env.PORT || 3000;
16+
server.listen(port, () => {
17+
console.log(`MCP inspector client running at http://localhost:${port}`);
18+
});

client/package.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,19 @@
77
"homepage": "https://modelcontextprotocol.github.io",
88
"bugs": "https://github.com/modelcontextprotocol/inspector/issues",
99
"type": "module",
10+
"bin": {
11+
"mcp-inspector-client": "./bin/cli.js"
12+
},
13+
"files": [
14+
"bin",
15+
"dist"
16+
],
1017
"scripts": {
1118
"dev": "vite",
1219
"build": "tsc -b && vite build",
1320
"lint": "eslint .",
14-
"preview": "vite preview"
21+
"preview": "vite preview",
22+
"prepare": "npm run build"
1523
},
1624
"dependencies": {
1725
"@modelcontextprotocol/sdk": "*",
@@ -25,6 +33,7 @@
2533
"lucide-react": "^0.447.0",
2634
"react": "^18.3.1",
2735
"react-dom": "^18.3.1",
36+
"serve-handler": "^6.1.6",
2837
"tailwind-merge": "^2.5.3",
2938
"tailwindcss-animate": "^1.0.7",
3039
"zod": "^3.23.8"
@@ -34,6 +43,7 @@
3443
"@types/node": "^22.7.5",
3544
"@types/react": "^18.3.10",
3645
"@types/react-dom": "^18.3.0",
46+
"@types/serve-handler": "^6.1.4",
3747
"@vitejs/plugin-react": "^4.3.2",
3848
"autoprefixer": "^10.4.20",
3949
"eslint": "^9.11.1",

package-lock.json

Lines changed: 101 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)