UNPKG

@netglade/mcp-sandbox

Version:
41 lines (40 loc) 914 B
import c from "@e2b/code-interpreter"; const b = async ({ command: n, apiKey: o, envs: r = {}, timeoutMs: a = 1e3 * 60 * 10 }) => { console.log("Creating sandbox..."); const t = await c.create("base", { timeoutMs: a, apiKey: o }), e = `https://${t.getHost(3e3)}`; return console.log("Starting mcp server..."), await t.commands.run( `npx -y supergateway --base-url ${e} --port 3000 --cors --stdio "${n}"`, { envs: r, background: !0, onStdout: (s) => { console.log(s); }, onStderr: (s) => { console.log(s); } } ), console.log("MCP server started at:", e + "/sse"), new d(t); }; class d { sandbox; constructor(o) { this.sandbox = o; } getUrl() { if (!this.sandbox) throw new Error("Sandbox not initialized"); return `https://${this.sandbox.getHost(3e3)}/sse`; } } export { b as startMcpSandbox };