@danielma-tic/mondaydotcom-mcp-server
Version:
MCP Server for the Monday.com API, enabling board operations, item management, and more.
171 lines (170 loc) • 5.1 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MondayClient = void 0;
const axios_1 = __importStar(require("axios"));
class MondayClient {
constructor(token) {
this.apiUrl = 'https://api.monday.com/v2';
this.token = token;
}
async query(query, variables = {}) {
try {
const response = await axios_1.default.post(this.apiUrl, { query, variables }, {
headers: {
'Authorization': this.token,
'Content-Type': 'application/json'
}
});
if (response.data.errors) {
throw new Error(response.data.errors[0].message);
}
return response.data.data;
}
catch (error) {
if (error instanceof axios_1.AxiosError) {
throw new Error(`Monday.com API error: ${error.message}`);
}
throw error;
}
}
async getBoard(boardId) {
const query = `
query ($boardId: ID!) {
boards(ids: [$boardId]) {
id
name
groups {
id
title
items {
id
name
column_values {
id
value
text
}
}
}
}
}
`;
const response = await this.query(query, { boardId });
return response.boards[0];
}
async getItems({ boardId, groupId, limit = 10 }) {
var _a;
const query = `
query ($boardId: ID!, $groupId: ID) {
boards(ids: [$boardId]) {
groups(ids: [$groupId]) {
items {
id
name
column_values {
id
value
text
}
}
}
}
}
`;
const response = await this.query(query, { boardId, groupId });
return ((_a = response.boards[0].groups) === null || _a === void 0 ? void 0 : _a[0].items) || [];
}
async createItem({ boardId, groupId, name, columnValues }) {
const query = `
mutation ($boardId: ID!, $groupId: String, $itemName: String!, $columnValues: JSON) {
create_item(
board_id: $boardId
group_id: $groupId
item_name: $itemName
column_values: $columnValues
) {
id
name
column_values {
id
value
text
}
}
}
`;
const response = await this.query(query, {
boardId,
groupId,
itemName: name,
columnValues: JSON.stringify(columnValues)
});
return response.create_item;
}
async createColumn({ boardId, title, type }) {
const query = `
mutation ($boardId: ID!, $title: String!, $columnType: ColumnType!) {
create_column(
board_id: $boardId
title: $title
column_type: $columnType
) {
id
title
type
}
}
`;
const response = await this.query(query, { boardId, title, columnType: type });
return response.create_column;
}
async createGroup({ boardId, name, position }) {
const query = `
mutation ($boardId: ID!, $groupName: String!) {
create_group(
board_id: $boardId
group_name: $groupName
) {
id
title
}
}
`;
const response = await this.query(query, { boardId, groupName: name });
return response.create_group;
}
}
exports.MondayClient = MondayClient;