UNPKG

businessmap-mcp

Version:

MCP server for Businessmap Kanbanize, exposing tools for managing business entities like boards, cards, and columns, facilitating LLM interaction.

109 lines (108 loc) 6.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CardSubtasksToolsController = void 0; const zod_1 = require("zod"); const ApiService_1 = require("../../services/ApiService"); const apiResponseHandler_1 = require("../../utils/apiResponseHandler"); const env_1 = require("../../utils/env"); const htmlFormatter_1 = require("../../utils/htmlFormatter"); class CardSubtasksToolsController { server; constructor(server) { this.server = server; this.registerTools(); } registerTools() { this.registerGetCardSubtasksToolhandler(); this.registerGetCardSubtaskToolhandler(); if (!env_1.env.BUSINESSMAP_READ_ONLY) { this.registerAddCardSubtaskToolhandler(); this.registerAddFormattedCardSubtaskToolhandler(); this.registerUpdateCardSubtaskToolhandler(); this.registerUpdateFormattedCardSubtaskToolhandler(); this.registerDeleteCardSubtaskToolhandler(); } } registerGetCardSubtasksToolhandler() { this.server.tool("get-card-subtasks", "Get a card's subtasks", { cardId: zod_1.z.string().describe("A card id"), }, async ({ cardId }) => { const response = await ApiService_1.apiServices.getCardSubtasks(cardId); return (0, apiResponseHandler_1.handleApiResponse)(response); }); } registerAddCardSubtaskToolhandler() { this.server.tool("add-card-subtask", "Add a subtask to a card", { cardId: zod_1.z.string().describe("A card id"), description: zod_1.z.string().describe("A description the subtask"), }, async ({ cardId, description }) => { const response = await ApiService_1.apiServices.addCardSubtask(cardId, description); return (0, apiResponseHandler_1.handleApiResponse)(response); }); } registerGetCardSubtaskToolhandler() { this.server.tool("get-card-subtask", "Get the details of a subtask for a card", { cardId: zod_1.z.string().describe("A card id"), subtaskId: zod_1.z.string().describe("A subtask id"), }, async ({ cardId, subtaskId }) => { const response = await ApiService_1.apiServices.getCardSubtask(cardId, subtaskId); return (0, apiResponseHandler_1.handleApiResponse)(response); }); } registerUpdateCardSubtaskToolhandler() { this.server.tool("update-card-subtask", "Update the details of a subtask for a card", { cardId: zod_1.z.string().describe("A card id"), subtaskId: zod_1.z.string().describe("A subtask id"), description: zod_1.z.string().describe("A description the subtask"), isFinished: zod_1.z.number().min(0).max(1), }, async ({ cardId, subtaskId, description, isFinished }) => { const response = await ApiService_1.apiServices.updateCardSubtask(cardId, subtaskId, description, isFinished); return (0, apiResponseHandler_1.handleApiResponse)(response); }); } registerDeleteCardSubtaskToolhandler() { this.server.tool("delete-card-subtask", "Delete a subtask for a card", { cardId: zod_1.z.string().describe("A card id"), subtaskId: zod_1.z.string().describe("A subtask id"), }, async ({ cardId, subtaskId }) => { const response = await ApiService_1.apiServices.deleteCardSubtask(cardId, subtaskId); return (0, apiResponseHandler_1.handleApiResponse)(response); }); } /** * Unlike comments, subtasks accept HTML directly in creation and update. * No need to create first and update later - can create directly with formatted HTML. */ registerAddFormattedCardSubtaskToolhandler() { this.server.tool("add-formatted-card-subtask", "Add a formatted subtask to a card with HTML rich formatting. Unlike comments, subtasks accept HTML directly in creation.", { cardId: zod_1.z.string().describe("A card id"), content: zod_1.z.string().describe("Subtask content in plain text or markdown that will be formatted as HTML"), isFinished: zod_1.z.number().min(0).max(1).optional().default(0).describe("Whether the subtask is finished (0 = not finished, 1 = finished)"), }, async ({ cardId, content, isFinished = 0 }) => { // Format content as HTML (subtasks accept HTML directly) const htmlContent = (0, htmlFormatter_1.formatContentToHtml)(content); // Create subtask directly with HTML formatting const response = await ApiService_1.apiServices.addCardSubtask(cardId, htmlContent, undefined, isFinished); return (0, apiResponseHandler_1.handleApiResponse)(response); }); } /** * Update subtask with HTML formatting. * Subtasks accept HTML directly in updates, no need for create-then-update strategy. */ registerUpdateFormattedCardSubtaskToolhandler() { this.server.tool("update-formatted-card-subtask", "Update a subtask with HTML rich formatting. Unlike comments, subtasks accept HTML directly in updates.", { cardId: zod_1.z.string().describe("A card id"), subtaskId: zod_1.z.string().describe("A subtask id"), content: zod_1.z.string().describe("Subtask content in plain text or markdown that will be formatted as HTML"), isFinished: zod_1.z.number().min(0).max(1).optional().describe("Whether the subtask is finished (0 = not finished, 1 = finished)"), }, async ({ cardId, subtaskId, content, isFinished }) => { // Format content as HTML const htmlContent = (0, htmlFormatter_1.formatContentToHtml)(content); // Update subtask with HTML formatting const response = await ApiService_1.apiServices.updateCardSubtask(cardId, subtaskId, htmlContent, isFinished); return (0, apiResponseHandler_1.handleApiResponse)(response); }); } } exports.CardSubtasksToolsController = CardSubtasksToolsController;