kanban-zone-mcp-server 0.3.5 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kanban-zone-mcp-server",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "Model Context Protocol server for the Kanban Zone public API",
5
5
  "license": "MIT",
6
6
  "homepage": "https://docs.kanbanzone.io/mcp",
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 converts that HTML to its stored delta (utils/quill.js),
6
- // which preserves inline <code> and multi-line <pre> as of 8.8.0.
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-3]|blockquote|pre|code)\b[^>]*>/i;
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, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
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
- text
18
- .replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>')
19
- .replace(/__([^_]+)__/g, '<strong>$1</strong>')
20
- .replace(/(^|[^*])\*([^*\s][^*]*)\*/g, '$1<em>$2</em>')
21
- .replace(/(^|[^_])_([^_\s][^_]*)_/g, '$1<em>$2</em>')
22
- .replace(/~~([^~]+)~~/g, '<s>$1</s>')
23
- .replace(/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/g, '<a href="$2">$1</a>');
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,3})\s+(.*)$/;
40
- const QUOTE = /^>\s?(.*)$/;
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
- out.push(`<pre>${fence.map(escapeHtml).join('\n')}</pre>`);
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
- if (FENCE.test(line)) {
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
- out.push(`<li>${renderInline((unordered || ordered)[2])}</li>`);
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
 
@@ -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) => {
@@ -324,6 +331,7 @@ const registerCardsTools = server => {
324
331
  title: 'Get card history',
325
332
  description: [
326
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.',
327
335
  '',
328
336
  'Args:',
329
337
  ' - id (string, required): card ObjectId.',
@@ -356,7 +364,7 @@ const registerCardsTools = server => {
356
364
  [
357
365
  `# History (${list.length} events since ${start})`,
358
366
  '',
359
- ...list.map(ev => `- ${ev.createdAt || ev.date || '?'} — ${ev.action || ev.type}`),
367
+ ...list.map(renderHistoryLine),
360
368
  ].join('\n');
361
369
  const { text } = truncateIfNeeded({ items: events, rendered: rerender(events), rerender });
362
370
  return { content: [{ type: 'text', text }], structuredContent: { events } };
@@ -475,4 +483,4 @@ const registerCardsTools = server => {
475
483
  );
476
484
  };
477
485
 
478
- module.exports = { registerCardsTools, renderCardLine, summarizeListResponse };
486
+ module.exports = { registerCardsTools, renderCardLine, renderHistoryLine, summarizeListResponse };