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