mcp-server-ddd-sample
Version:
A sample of MCP implementation using DDD structure with some APIs call.
39 lines (38 loc) • 1.33 kB
JavaScript
import { BaseToolsController } from "./base/BaseToolsController.js";
export class GeneralToolsController extends BaseToolsController {
generalService;
constructor(server, generalService) {
super(server);
this.generalService = generalService;
}
registerTools() {
this.registerGetPriceToolhandler();
this.registerGetDifficultyAdjustmenthandler();
}
registerGetPriceToolhandler() {
this.server.tool("get-prices", "Get prices for Bitcoin in various currencies", async () => {
const pricesText = await this.generalService.getPrices();
return {
content: [
{
type: "text",
text: pricesText,
},
],
};
});
}
registerGetDifficultyAdjustmenthandler() {
this.server.tool("get-difficulty-adjustment", "Get difficulty adjustment for Bitcoin", async () => {
const difficultyAdjustmentText = await this.generalService.getDifficultyAdjustment();
return {
content: [
{
type: "text",
text: difficultyAdjustmentText,
},
],
};
});
}
}