diff --git a/mcp-server/package.json b/mcp-server/package.json index 2d3d9e9..984e0e5 100644 --- a/mcp-server/package.json +++ b/mcp-server/package.json @@ -5,7 +5,8 @@ "type": "module", "main": "dist/index.js", "scripts": { - "build": "esbuild src/index.ts --bundle --platform=node --target=node18 --format=esm --outfile=dist/index.js --external:@modelcontextprotocol/* --external:ws --external:express --external:class-transformer --external:class-validator --external:reflect-metadata --external:pino --external:pino-pretty --external:js-yaml", + "build": "esbuild src/index.ts --bundle --platform=node --target=node18 --format=esm --outfile=dist/index.js --external:@modelcontextprotocol/* --external:ws --external:express --external:class-transformer --external:class-validator --external:reflect-metadata --external:pino --external:pino-pretty --external:js-yaml && npm run copy-static", + "copy-static": "node -e \"require('fs').cpSync('src/static', 'dist/static', { recursive: true })\"", "build:types": "tsc --emitDeclarationOnly --outDir dist", "build:full": "npm run build && npm run build:types", "start": "node dist/index.js", diff --git a/mcp-server/src/ReplServer.ts b/mcp-server/src/ReplServer.ts index 26e23ed..892364c 100644 --- a/mcp-server/src/ReplServer.ts +++ b/mcp-server/src/ReplServer.ts @@ -1,4 +1,6 @@ import express from "express"; +import path from "path"; +import { fileURLToPath } from "url"; import { PluginBridge } from "./PluginBridge"; import { ExecuteCodePluginTask } from "./tasks/ExecuteCodePluginTask"; import { createLogger } from "./logger"; @@ -31,7 +33,6 @@ export class ReplServer { */ private setupMiddleware(): void { this.app.use(express.json()); - this.app.use(express.static("public")); // for serving static files if needed } /** @@ -40,7 +41,10 @@ export class ReplServer { private setupRoutes(): void { // serve the main REPL interface this.app.get("/", (req, res) => { - res.send(this.getReplHtml()); + const __filename = fileURLToPath(import.meta.url); + const __dirname = path.dirname(__filename); + const htmlPath = path.join(__dirname, 'static', 'repl.html'); + res.sendFile(htmlPath); }); // API endpoint for executing code @@ -74,231 +78,7 @@ export class ReplServer { }); } - /** - * Generates the HTML content for the REPL interface. - * - * Creates a simple web page with a resizable textarea for code input, - * an execute button, and a results display area using jQuery. - */ - private getReplHtml(): string { - return ` - -
- - -