@onecompiler/onecompiler-mcp-server
Version:
MCP Server for Onecompiler
29 lines (28 loc) • 1.05 kB
JavaScript
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import OnecompilerAPI from "./api.js";
import tools from "./tools.js";
class OnecompilerMCPServer extends McpServer {
_onecompiler;
constructor({ apiKey, environment, provider }) {
super({
name: "onecompiler",
version: "0.0.1",
});
this._onecompiler = new OnecompilerAPI(apiKey, provider, environment);
tools.forEach((tool) => {
this.tool(tool.method, tool.description, tool.parameters.shape, async (arg, _extra) => {
// console.log(`Running tool: ${tool.method} with args: ${JSON.stringify(arg)}`);
const result = await this._onecompiler.run(tool.method, arg);
return {
content: [
{
type: "text",
text: result,
},
],
};
});
});
}
}
export default OnecompilerMCPServer;