@onecompiler/onecompiler-mcp-server
Version:
MCP Server for Onecompiler
40 lines (39 loc) • 1.34 kB
JavaScript
import { codeExec } from "./functions.js";
import { Environment, Provider } from "./types.js";
class OnecompilerAPI {
apiKey;
baseUrl;
provider;
constructor(apiKey, provider, environment) {
this.apiKey = apiKey;
this.provider = provider;
if (provider === Provider.rapidapi) {
this.baseUrl = "https://onecompiler-apis.p.rapidapi.com";
}
else {
switch (environment) {
case Environment.local:
this.baseUrl = "http://localhost:3000";
break;
case Environment.sandbox:
this.baseUrl = "https://sandbox.onecompiler.com";
break;
case Environment.production:
default:
this.baseUrl = "https://onecompiler.com";
}
}
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async run(method, arg) {
if (method === "codeExec") {
// console.log(`Running codeExec with args: ${JSON.stringify(arg)}`);
const output = await codeExec(arg, this.apiKey, this.baseUrl, this.provider);
return output;
}
else {
throw new Error("Invalid method " + method);
}
}
}
export default OnecompilerAPI;