minimal-my-items-server
Version:
Minimal Monday.com My Items MCP Server
71 lines (70 loc) • 2.69 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.updateTask = updateTask;
const mondayClient_1 = require("../utils/mondayClient");
/**
* Updates a task (item) on a Monday.com board.
* @param boardId - The board ID containing the item.
* @param itemId - The ID of the item to update.
* @param columnValues - Object mapping column IDs to new values.
* @returns An object with a 'content' array containing a text result.
*/
function updateTask(_a) {
return __awaiter(this, arguments, void 0, function* ({ boardId, itemId, columnValues, }) {
const mutation = `
mutation ($boardId: ID!, $itemId: ID!, $columnValues: JSON!) {
change_multiple_column_values(
board_id: $boardId,
item_id: $itemId,
column_values: $columnValues
) {
id
name
}
}
`;
try {
const variables = {
boardId: Number(boardId),
itemId: Number(itemId),
columnValues: JSON.stringify(columnValues),
};
const data = yield (0, mondayClient_1.mondayGraphQL)(mutation, variables);
const item = data.change_multiple_column_values;
if (!item || !item.id) {
return {
content: [
{ type: "text", text: "Failed to update item on the board." },
],
};
}
return {
content: [
{
type: "text",
text: `Updated item '${item.name}' (ID: ${item.id}) on board ${boardId}.`,
},
],
};
}
catch (error) {
return {
content: [
{
type: "text",
text: `Error updating item: ${error.message || error}`,
},
],
};
}
});
}