pass in args

This commit is contained in:
Ashwin Bhat
2024-11-19 11:42:11 -08:00
parent abff2486c1
commit c1a56810fb
3 changed files with 32 additions and 10 deletions

View File

@@ -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);
}
});