Skip to content

Commit 2b409cd

Browse files
committed
Fix sandbox_proxy.html file location in MCP inspector
1 parent 8cf0ac1 commit 2b409cd

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

server/src/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import mcpProxy from "./mcpProxy.js";
3131
import { randomUUID, randomBytes, timingSafeEqual } from "node:crypto";
3232
import { fileURLToPath } from "url";
3333
import { dirname, join } from "path";
34-
import { readFileSync } from "fs";
34+
import { existsSync, readFileSync } from "fs";
3535

3636
const DEFAULT_MCP_PROXY_LISTEN_PORT = "6277";
3737

@@ -802,7 +802,15 @@ app.get(
802802
(req, res) => {
803803
const __filename = fileURLToPath(import.meta.url);
804804
const __dirname = dirname(__filename);
805-
const filePath = join(__dirname, "..", "static", "sandbox_proxy.html");
805+
806+
// Production: static/ is copied into build/ alongside index.js
807+
let filePath = join(__dirname, "static", "sandbox_proxy.html");
808+
809+
// Dev (tsx): static/ is a sibling of src/, one level up from __dirname
810+
if (!existsSync(filePath)) {
811+
filePath = join(__dirname, "..", "static", "sandbox_proxy.html");
812+
}
813+
806814
let sandboxHtml;
807815

808816
try {

0 commit comments

Comments
 (0)