minimal-my-items-server
Version:
Minimal Monday.com My Items MCP Server
80 lines (79 loc) • 2.95 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getGroups = getGroups;
const mondayClient_1 = require("../utils/mondayClient");
/**
* Gets all groups from a Monday.com board.
* @param boardId - The board ID to fetch groups from.
* @returns An object with a 'content' array containing a text result with group information.
*/
function getGroups(_a) {
return __awaiter(this, arguments, void 0, function* ({ boardId, }) {
var _b, _c;
const query = `
query ($boardId: [ID!]) {
boards(ids: $boardId) {
groups {
id
title
color
position
}
}
}
`;
try {
const data = yield (0, mondayClient_1.mondayGraphQL)(query, {
boardId: [Number(boardId)],
});
if (!((_c = (_b = data.boards) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.groups)) {
return {
content: [
{
type: "text",
text: `Could not fetch groups for board ${boardId}.`,
},
],
};
}
const groups = data.boards[0].groups;
if (groups.length === 0) {
return {
content: [
{ type: "text", text: `No groups found on board ${boardId}.` },
],
};
}
const groupsList = groups
.sort((a, b) => a.position - b.position)
.map((g) => `- ${g.title} (ID: ${g.id}, Color: ${g.color})`);
return {
content: [
{
type: "text",
text: `Groups on board ${boardId}:\n\n${groupsList.join("\n")}`,
},
],
};
}
catch (error) {
return {
content: [
{
type: "text",
text: `Error fetching groups: ${error.message || error}`,
},
],
};
}
});
}