greenline-works-mcp-server 0.3.4 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/client.js +4 -0
- package/src/markdown.js +54 -16
- package/src/tools/cards.js +19 -5
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -71,6 +71,10 @@ const makeApiRequest = async (endpoint, { method = 'GET', body, query } = {}) =>
|
|
|
71
71
|
headers: {
|
|
72
72
|
'Content-Type': 'application/json',
|
|
73
73
|
Accept: 'application/json',
|
|
74
|
+
// Declares this traffic as MCP-originated so org admins' MCP access controls apply to
|
|
75
|
+
// API-key connections too (the backend gates and audits on it). Presence-only signal —
|
|
76
|
+
// the value is never trusted upstream.
|
|
77
|
+
'X-MCP-Client': 'mcp-server',
|
|
74
78
|
},
|
|
75
79
|
};
|
|
76
80
|
// A multi-tenant host may bind an OAuth bearer token instead of an accessId/secret pair
|
package/src/markdown.js
CHANGED
|
@@ -2,25 +2,42 @@
|
|
|
2
2
|
//
|
|
3
3
|
// The public API takes rich text as an HTML string — POST /comments, POST /tasks and the
|
|
4
4
|
// checklist tasks[] all validate `required|string` on it — so markdown must become HTML here
|
|
5
|
-
// rather than a delta. The server
|
|
6
|
-
//
|
|
5
|
+
// rather than a delta. The server reads that HTML back into the delta it stores, and the markup
|
|
6
|
+
// written here is the subset it reads exactly: inline formats and links, headings, quotes,
|
|
7
|
+
// images, code spans, fenced code with its language, and lists including their depth and their
|
|
8
|
+
// checkboxes. A table has no delta to be read into, so it stays the text it was.
|
|
7
9
|
//
|
|
8
10
|
// Input that already contains HTML is returned untouched, so a client following the documented
|
|
9
11
|
// format is never double-converted.
|
|
10
12
|
|
|
11
|
-
const SUPPORTED_TAG = /<(?:p|br|strong|em|u|s|a|ul|ol|li|h[1-
|
|
13
|
+
const SUPPORTED_TAG = /<(?:p|br|strong|em|u|s|a|ul|ol|li|h[1-6]|blockquote|pre|code|img)\b[^>]*>/i;
|
|
12
14
|
const containsHtml = text => SUPPORTED_TAG.test(text);
|
|
13
15
|
|
|
14
16
|
const escapeHtml = text => text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
15
17
|
|
|
18
|
+
// A bare address is a link to everyone who writes one, but only outside an address we already
|
|
19
|
+
// wrote: the text of a markdown link is not itself a link.
|
|
20
|
+
const LINKED = /(<a\b[^>]*>[\s\S]*?<\/a>)/;
|
|
21
|
+
const BARE_ADDRESS = /(^|[\s(])(https?:\/\/[^\s<)]+[^\s<).,;:!?])/g;
|
|
22
|
+
|
|
23
|
+
const linkBareAddresses = html =>
|
|
24
|
+
html
|
|
25
|
+
.split(LINKED)
|
|
26
|
+
.map(part => (LINKED.test(part) ? part : part.replace(BARE_ADDRESS, '$1<a href="$2">$2</a>')))
|
|
27
|
+
.join('');
|
|
28
|
+
|
|
16
29
|
const renderMarkers = text =>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
30
|
+
linkBareAddresses(
|
|
31
|
+
text
|
|
32
|
+
.replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>')
|
|
33
|
+
.replace(/__([^_]+)__/g, '<strong>$1</strong>')
|
|
34
|
+
.replace(/(^|[^*])\*([^*\s][^*]*)\*/g, '$1<em>$2</em>')
|
|
35
|
+
.replace(/(^|[^_])_([^_\s][^_]*)_/g, '$1<em>$2</em>')
|
|
36
|
+
.replace(/~~([^~]+)~~/g, '<s>$1</s>')
|
|
37
|
+
// Images are matched before links, or the leading ! is left behind as text.
|
|
38
|
+
.replace(/!\[([^\]]*)\]\((https?:\/\/[^)\s]+)\)/g, '<img src="$2" alt="$1"/>')
|
|
39
|
+
.replace(/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/g, '<a href="$2">$1</a>')
|
|
40
|
+
);
|
|
24
41
|
|
|
25
42
|
// Code spans are split out before the other markers so they cannot mangle their contents —
|
|
26
43
|
// `run_a_test` is a name, not italics.
|
|
@@ -36,9 +53,22 @@ const renderInline = text =>
|
|
|
36
53
|
|
|
37
54
|
const UNORDERED = /^(\s*)[-*+]\s+(.*)$/;
|
|
38
55
|
const ORDERED = /^(\s*)\d+[.)]\s+(.*)$/;
|
|
39
|
-
const HEADING = /^(#{1,
|
|
40
|
-
const QUOTE =
|
|
41
|
-
const FENCE = /^\s
|
|
56
|
+
const HEADING = /^(#{1,6})\s+(.*)$/;
|
|
57
|
+
const QUOTE = /^>[\s>]*(.*)$/;
|
|
58
|
+
const FENCE = /^\s*```(\w+)?/;
|
|
59
|
+
const TASK = /^\[([ xX])\]\s+(.*)$/;
|
|
60
|
+
|
|
61
|
+
// Quill carries a list item's depth as its own class, and reads two spaces or a tab as one
|
|
62
|
+
// level. Eight is where the server stops accepting them.
|
|
63
|
+
const INDENT_LEVELS = 8;
|
|
64
|
+
const indentOf = whitespace => {
|
|
65
|
+
const columns = whitespace.replace(/\t/g, ' ').length;
|
|
66
|
+
return Math.min(Math.floor(columns / 2), INDENT_LEVELS);
|
|
67
|
+
};
|
|
68
|
+
const listItem = (indent, attributes, content) => {
|
|
69
|
+
const indented = indent ? ` class="ql-indent-${indent}"` : '';
|
|
70
|
+
return `<li${indented}${attributes}>${content}</li>`;
|
|
71
|
+
};
|
|
42
72
|
|
|
43
73
|
const markdownToHtml = value => {
|
|
44
74
|
if (typeof value !== 'string' || !value.trim()) return value;
|
|
@@ -50,6 +80,7 @@ const markdownToHtml = value => {
|
|
|
50
80
|
let paragraph = [];
|
|
51
81
|
let fenced = false;
|
|
52
82
|
let fence = [];
|
|
83
|
+
let language = '';
|
|
53
84
|
|
|
54
85
|
const closeList = () => {
|
|
55
86
|
if (list) {
|
|
@@ -64,8 +95,10 @@ const markdownToHtml = value => {
|
|
|
64
95
|
}
|
|
65
96
|
};
|
|
66
97
|
const closeFence = () => {
|
|
67
|
-
|
|
98
|
+
const named = language ? ` data-language="${language}"` : '';
|
|
99
|
+
out.push(`<pre${named}>${fence.map(escapeHtml).join('\n')}</pre>`);
|
|
68
100
|
fence = [];
|
|
101
|
+
language = '';
|
|
69
102
|
};
|
|
70
103
|
const openList = kind => {
|
|
71
104
|
if (list !== kind) {
|
|
@@ -76,10 +109,12 @@ const markdownToHtml = value => {
|
|
|
76
109
|
};
|
|
77
110
|
|
|
78
111
|
for (const line of lines) {
|
|
79
|
-
|
|
112
|
+
const fenceMarker = line.match(FENCE);
|
|
113
|
+
if (fenceMarker) {
|
|
80
114
|
closeParagraph();
|
|
81
115
|
closeList();
|
|
82
116
|
if (fenced) closeFence();
|
|
117
|
+
else language = (fenceMarker[1] || '').toLowerCase();
|
|
83
118
|
fenced = !fenced;
|
|
84
119
|
continue;
|
|
85
120
|
}
|
|
@@ -114,7 +149,10 @@ const markdownToHtml = value => {
|
|
|
114
149
|
if (unordered || ordered) {
|
|
115
150
|
closeParagraph();
|
|
116
151
|
openList(unordered ? 'ul' : 'ol');
|
|
117
|
-
|
|
152
|
+
const [, whitespace, content] = unordered || ordered;
|
|
153
|
+
const task = content.match(TASK);
|
|
154
|
+
const checked = task ? ` data-checked="${task[1].toLowerCase() === 'x'}"` : '';
|
|
155
|
+
out.push(listItem(indentOf(whitespace), checked, renderInline(task ? task[2] : content)));
|
|
118
156
|
continue;
|
|
119
157
|
}
|
|
120
158
|
|
package/src/tools/cards.js
CHANGED
|
@@ -8,7 +8,7 @@ const READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true,
|
|
|
8
8
|
const WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true };
|
|
9
9
|
const IDEMPOTENT_WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true };
|
|
10
10
|
|
|
11
|
-
//
|
|
11
|
+
// Card fields arrive nested under CardItem. Older search responses were flat — handle both.
|
|
12
12
|
const renderCardLine = card => {
|
|
13
13
|
const c = (card && card.CardItem) || card || {};
|
|
14
14
|
const id = (card && card._id) || c._id;
|
|
@@ -18,6 +18,13 @@ const renderCardLine = card => {
|
|
|
18
18
|
return `- ${number}**${c.title}** (\`${id}\`)${owner}`;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
+
// History events are `type` (entity.verb) plus the changed `field`; `action` is the deprecated pair
|
|
22
|
+
// still sent by older backends.
|
|
23
|
+
const renderHistoryLine = ev => {
|
|
24
|
+
const what = ev.type ? `${ev.type}${ev.field ? ` (${ev.field})` : ''}` : ev.action;
|
|
25
|
+
return `- ${ev.createdAt || ev.date || '?'} — ${what}`;
|
|
26
|
+
};
|
|
27
|
+
|
|
21
28
|
// The /cards list envelope is { count, totalAvailable, cards, hasMore }; tolerate a bare
|
|
22
29
|
// array or search-style { total, has_more } names too, so pagination metadata stays accurate.
|
|
23
30
|
const summarizeListResponse = (data, page, count) => {
|
|
@@ -234,11 +241,15 @@ const registerCardsTools = server => {
|
|
|
234
241
|
' - owner (string, optional): account email or ObjectId.',
|
|
235
242
|
' - label (string, optional): label name (e.g. "Enhancement") or ObjectId.',
|
|
236
243
|
' - dueAt (string, optional): ISO date or datetime.',
|
|
244
|
+
' - blocked (boolean, optional): true blocks the card, false unblocks it. Unblocking also clears the block reason.',
|
|
245
|
+
' - blockedReason (string, optional): why the card is blocked. Pair it with blocked: true.',
|
|
237
246
|
' - customFields (array, optional): list of { label, value } pairs. `label` matches the custom-field name configured on the board.',
|
|
238
247
|
'',
|
|
239
248
|
'Examples:',
|
|
240
249
|
' - "Reassign card 670... to bob@example.com"',
|
|
241
250
|
' - "Set the due date on card 670... to 2025-06-01"',
|
|
251
|
+
' - "Block card 670... because we are waiting on the vendor"',
|
|
252
|
+
' - "Unblock card 670..."',
|
|
242
253
|
' - "Set the Project Code custom field on card 670... to ABC-123"',
|
|
243
254
|
].join('\n'),
|
|
244
255
|
inputSchema: {
|
|
@@ -249,6 +260,8 @@ const registerCardsTools = server => {
|
|
|
249
260
|
owner: z.string().optional(),
|
|
250
261
|
label: z.string().optional(),
|
|
251
262
|
dueAt: isoDateField.optional(),
|
|
263
|
+
blocked: z.boolean().optional(),
|
|
264
|
+
blockedReason: z.string().max(2000).optional(),
|
|
252
265
|
customFields: z
|
|
253
266
|
.array(
|
|
254
267
|
z.object({
|
|
@@ -318,6 +331,7 @@ const registerCardsTools = server => {
|
|
|
318
331
|
title: 'Get card history',
|
|
319
332
|
description: [
|
|
320
333
|
'Fetch the activity history for a card (column moves, edits, comments, etc.) starting from a date.',
|
|
334
|
+
'Each event has a type (entity.verb, e.g. card.moved, comment.added) and, for updates, the changed field.',
|
|
321
335
|
'',
|
|
322
336
|
'Args:',
|
|
323
337
|
' - id (string, required): card ObjectId.',
|
|
@@ -350,7 +364,7 @@ const registerCardsTools = server => {
|
|
|
350
364
|
[
|
|
351
365
|
`# History (${list.length} events since ${start})`,
|
|
352
366
|
'',
|
|
353
|
-
...list.map(
|
|
367
|
+
...list.map(renderHistoryLine),
|
|
354
368
|
].join('\n');
|
|
355
369
|
const { text } = truncateIfNeeded({ items: events, rendered: rerender(events), rerender });
|
|
356
370
|
return { content: [{ type: 'text', text }], structuredContent: { events } };
|
|
@@ -401,8 +415,8 @@ const registerCardsTools = server => {
|
|
|
401
415
|
'Results are sorted by relevance (best match first).',
|
|
402
416
|
'',
|
|
403
417
|
'Mirror cards: results are returned per (card, board) pair — a card mirrored to two',
|
|
404
|
-
'boards that matches the query appears twice, each with that board\'s
|
|
405
|
-
'owner, and watchers. Use the returned
|
|
418
|
+
'boards that matches the query appears twice, each with that board\'s column, label,',
|
|
419
|
+
'owner, and watchers. Use the returned CardItem.boardPublicId to know which board to act on.',
|
|
406
420
|
'',
|
|
407
421
|
'Args:',
|
|
408
422
|
' - q (string, required): search text, minimum 2 characters.',
|
|
@@ -469,4 +483,4 @@ const registerCardsTools = server => {
|
|
|
469
483
|
);
|
|
470
484
|
};
|
|
471
485
|
|
|
472
|
-
module.exports = { registerCardsTools, renderCardLine, summarizeListResponse };
|
|
486
|
+
module.exports = { registerCardsTools, renderCardLine, renderHistoryLine, summarizeListResponse };
|