Per PR feedback from cliffhall: - Changed PORT to SERVER_PORT in server/src/index.ts - Changed PORT to CLIENT_PORT in client/bin/client.js - Added parseInt() for CLIENT_PORT consistency - Updated start.js to pass correct env var names This improves clarity by using specific environment variables for server and client ports instead of the generic PORT variable.
58 lines
1.4 KiB
JavaScript
Executable file
58 lines
1.4 KiB
JavaScript
Executable file
#!/usr/bin/env node
|
|
|
|
import { join, dirname } from "path";
|
|
import { fileURLToPath } from "url";
|
|
import handler from "serve-handler";
|
|
import http from "http";
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const distPath = join(__dirname, "../dist");
|
|
|
|
const server = http.createServer((request, response) => {
|
|
const handlerOptions = {
|
|
public: distPath,
|
|
rewrites: [{ source: "/**", destination: "/index.html" }],
|
|
headers: [
|
|
{
|
|
// Ensure index.html is never cached
|
|
source: "index.html",
|
|
headers: [
|
|
{
|
|
key: "Cache-Control",
|
|
value: "no-cache, no-store, max-age=0",
|
|
},
|
|
],
|
|
},
|
|
{
|
|
// Allow long-term caching for hashed assets
|
|
source: "assets/**",
|
|
headers: [
|
|
{
|
|
key: "Cache-Control",
|
|
value: "public, max-age=31536000, immutable",
|
|
},
|
|
],
|
|
},
|
|
],
|
|
};
|
|
|
|
return handler(request, response, handlerOptions);
|
|
});
|
|
|
|
const port = parseInt(process.env.CLIENT_PORT || "6274", 10);
|
|
const host = process.env.HOST || "localhost";
|
|
server.on("listening", () => {
|
|
console.log(
|
|
`🔍 MCP Inspector is up and running at http://${host}:${port} 🚀`,
|
|
);
|
|
});
|
|
server.on("error", (err) => {
|
|
if (err.message.includes(`EADDRINUSE`)) {
|
|
console.error(
|
|
`❌ MCP Inspector PORT IS IN USE at http://${host}:${port} ❌ `,
|
|
);
|
|
} else {
|
|
throw err;
|
|
}
|
|
});
|
|
server.listen(port, host);
|