businessmap-mcp
Version:
MCP server for Businessmap Kanbanize, exposing tools for managing business entities like boards, cards, and columns, facilitating LLM interaction.
119 lines (118 loc) • 5.51 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CardToolsController = 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");
class CardToolsController {
server;
constructor(server) {
this.server = server;
this.registerTools();
}
registerTools() {
this.registerGetCardToolhandler();
this.registerGetCardsToolhandler();
if (!env_1.env.BUSINESSMAP_READ_ONLY) {
this.registerCreateCardToolhandler();
this.registerUpdateCardToolhandler();
this.registerDeleteCardToolhandler();
}
}
registerGetCardToolhandler() {
this.server.tool("get-card", "Get the details of a single card", {
cardId: zod_1.z.string().describe("A card id"),
}, async ({ cardId }) => {
const response = await ApiService_1.apiServices.getCard(cardId);
return (0, apiResponseHandler_1.handleApiResponse)(response);
});
}
registerGetCardsToolhandler() {
this.server.tool("get-cards", "Get a list of cards matching some optional criteria", {
state: zod_1.z
.enum(["active", "archived", "discarded"])
.describe("The state value of cards that you want to get. By default it's the active state. Available values: active, archived, discarded")
.default("active"),
board_ids: zod_1.z
.string()
.describe("A list of the board ids for which you want to get the results. Separated by comma. Example: 123,888")
.optional(),
owner_user_ids: zod_1.z
.string()
.describe("A list of the user ids of assignees for which you want to get the results. Separated by comma. Example: 123,888")
.optional(),
card_ids: zod_1.z
.string()
.describe("A list of the card ids that you want to get. Separated by comma. Example: 123,888")
.optional(),
is_blocked: zod_1.z
.number()
.int()
.min(0)
.max(1)
.default(0)
.describe("When set to 1 you will only get blocked cards. When set to 0 you will only get non blocked cards."),
}, async ({ board_ids, is_blocked, owner_user_ids, card_ids, state, }) => {
const response = await ApiService_1.apiServices.getCards({
state,
board_ids,
owner_user_ids,
is_blocked,
card_ids,
});
return (0, apiResponseHandler_1.handleApiResponse)(response);
});
}
registerCreateCardToolhandler() {
this.server.tool("create-card", "Create a card", {
board_id: zod_1.z.number().describe("Board id"),
workflow_id: zod_1.z.number().describe("Workflow id"),
lane_id: zod_1.z.number().describe("Lane id"),
column_id: zod_1.z.number().describe("Column id"),
title: zod_1.z.string().describe("Card title"),
description: zod_1.z.string().describe("Card description"),
priority: zod_1.z.number().describe("Card priority'"),
assignee_ids: zod_1.z
.string()
.describe("Comma-separated list of assignee Ids"),
}, async ({ board_id, title, description, assignee_ids, priority, column_id, lane_id, workflow_id, }) => {
const response = await ApiService_1.apiServices.createCard({
board_id,
workflow_id,
column_id,
lane_id,
title,
description,
priority,
owner_user_id: assignee_ids ? parseInt(assignee_ids.split(',')[0]) : undefined,
});
return (0, apiResponseHandler_1.handleApiResponse)(response);
});
}
registerUpdateCardToolhandler() {
this.server.tool("update-card", "Update an existing card", {
card_id: zod_1.z.string().describe("Board id"),
title: zod_1.z.string().describe("Card title"),
description: zod_1.z.string().describe("Card description"),
column_id: zod_1.z.number().describe("Column id"),
priority: zod_1.z.number().describe("Card priority'"),
lane_id: zod_1.z.number().describe("Lane id"),
assignee_ids: zod_1.z
.string()
.describe("Comma-separated list of assignee Ids"),
}, async ({ card_id, title, description, assignee_ids, priority, column_id, lane_id, }) => {
const response = await ApiService_1.apiServices.updateCard(card_id, title, description, assignee_ids, priority, column_id, lane_id);
return (0, apiResponseHandler_1.handleApiResponse)(response);
});
}
registerDeleteCardToolhandler() {
this.server.tool("delete-card", "Delete a card", {
card_id: zod_1.z.string().describe("A card id"),
}, async ({ card_id }) => {
const response = await ApiService_1.apiServices.deleteCard(card_id);
return (0, apiResponseHandler_1.handleApiResponse)(response);
});
}
}
exports.CardToolsController = CardToolsController;