@sanlim/mempool-mcp-server
Version:
A sample of MCP implementation using DDD structure with some APIs call.
35 lines (34 loc) • 1.44 kB
JavaScript
import { z } from "zod";
import { BaseToolsController } from "./base/BaseToolsController.js";
export class MiningToolsController extends BaseToolsController {
miningService;
constructor(server, miningService) {
super(server);
this.miningService = miningService;
}
registerTools() {
this.registerGetMiningPoolsHandler();
this.registerGetMiningPoolHandler();
this.registerGetMiningBlocksFees24hHandler();
}
registerGetMiningPoolsHandler() {
this.server.tool("get-mining-pools", "Returns mining pools info", async () => {
const text = await this.miningService.getMiningPools();
return { content: [{ type: "text", text }] };
});
}
registerGetMiningPoolHandler() {
this.server.tool("get-mining-pool", "Returns info for a specific mining pool", {
poolId: z.string().describe("The poolId to get info for"),
}, async ({ poolId }) => {
const text = await this.miningService.getMiningPool({ poolId });
return { content: [{ type: "text", text }] };
});
}
registerGetMiningBlocksFees24hHandler() {
this.server.tool("get-mining-blocks-fees-24h", "Returns mining blocks fees for the last 24h", async () => {
const text = await this.miningService.getMiningBlocksFees24h();
return { content: [{ type: "text", text }] };
});
}
}