kanban-zone-mcp-server 0.3.5 → 0.4.0
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/README.md +6 -2
- package/package.json +1 -1
- package/src/constants.js +2 -1
- package/src/format.js +4 -0
- package/src/markdown.js +54 -16
- package/src/schemas.js +33 -0
- package/src/tools/attachments.js +126 -0
- package/src/tools/cards.js +38 -14
- package/src/tools/index.js +4 -0
- package/src/tools/links.js +171 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[Model Context Protocol](https://modelcontextprotocol.io/) server that lets AI assistants (Claude Desktop, Claude Code, Cursor, VS Code, Windsurf, and any MCP client) drive your [Kanban Zone](https://kanbanzone.com) workspace via the public API.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
33 tools across boards, cards, comments, links, attachments, checklists, tasks, and labels. The only delete is unlinking two cards.
|
|
6
6
|
|
|
7
7
|
**Two ways to connect.** The **hosted server** at `https://mcp.kanbanzone.io/mcp` is the recommended option for every client, Claude Desktop included — paste the URL, sign in with your Kanban Zone account, done. Nothing to install, no API key to manage, and you always get the current tool set. The **local install** (this npm package) runs the same server on your own machine over stdio — for stdio-only clients, unattended setups like CI where a browser sign-in isn't possible, restricted networks, or developing against a fork.
|
|
8
8
|
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
- Inspect a card's history and time-in-column metrics.
|
|
14
14
|
- Create, get, and update labels.
|
|
15
15
|
- Add comments.
|
|
16
|
+
- Link cards as parent and child or predecessor and successor, change a link's type, and unlink them.
|
|
17
|
+
- List a card's attachments and get a download link for one.
|
|
16
18
|
- Create, update, and list checklists — including bulk task creation in a single call.
|
|
17
19
|
- Create, update, and move tasks.
|
|
18
20
|
|
|
@@ -78,7 +80,7 @@ The server validates the key on startup. A missing or malformed value (no `:` se
|
|
|
78
80
|
|
|
79
81
|
## Tools
|
|
80
82
|
|
|
81
|
-
|
|
83
|
+
33 tools, all prefixed with `kanbanzone_`:
|
|
82
84
|
|
|
83
85
|
| Group | Tools |
|
|
84
86
|
| --- | --- |
|
|
@@ -86,6 +88,8 @@ The server validates the key on startup. A missing or malformed value (no `:` se
|
|
|
86
88
|
| **Boards** | `list_boards`, `get_board`, `list_board_columns`, `list_board_labels`, `list_board_members`, `list_board_custom_fields` |
|
|
87
89
|
| **Cards** | `create_card`, `list_cards`, `get_card`, `update_card`, `move_card`, `get_card_history`, `get_card_metrics`, `search_cards` |
|
|
88
90
|
| **Comments** | `create_comment`, `list_card_comments` |
|
|
91
|
+
| **Links** | `list_card_links`, `create_card_link`, `update_card_link`, `delete_card_link` |
|
|
92
|
+
| **Attachments** | `list_card_attachments`, `get_card_attachment` |
|
|
89
93
|
| **Checklists** | `create_checklist`, `update_checklist`, `list_card_checklists` |
|
|
90
94
|
| **Tasks** | `create_task`, `update_task`, `move_task` |
|
|
91
95
|
| **Labels** | `create_label`, `get_label`, `update_label` |
|
package/package.json
CHANGED
package/src/constants.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const { version: SERVER_VERSION } = require('../package.json');
|
|
2
|
+
|
|
1
3
|
const DEFAULT_BASE_URL = 'https://integrations.kanbanzone.io/v1';
|
|
2
4
|
|
|
3
5
|
// List tools that exceed this halve their results and return a `truncated` note,
|
|
@@ -8,7 +10,6 @@ const DEFAULT_PAGE_SIZE = 20;
|
|
|
8
10
|
const MAX_PAGE_SIZE = 100;
|
|
9
11
|
|
|
10
12
|
const SERVER_NAME = 'kanban-zone-mcp-server';
|
|
11
|
-
const SERVER_VERSION = '0.3.4';
|
|
12
13
|
|
|
13
14
|
const REQUEST_TIMEOUT_MS = 30000;
|
|
14
15
|
|
package/src/format.js
CHANGED
|
@@ -20,6 +20,9 @@ const RICH_TEXT_HELP =
|
|
|
20
20
|
|
|
21
21
|
const toJsonString = value => JSON.stringify(value, null, 2);
|
|
22
22
|
|
|
23
|
+
// A card number reads as "#302", an ObjectId as itself.
|
|
24
|
+
const cardLabel = ref => (/^\d+$/.test(ref) ? `#${ref}` : ref);
|
|
25
|
+
|
|
23
26
|
// Caller passes the full rendered string and a `rerender(items)` callback so we can
|
|
24
27
|
// shrink the items array and re-render until we're under CHARACTER_LIMIT.
|
|
25
28
|
const truncateIfNeeded = ({ items, rendered, rerender }) => {
|
|
@@ -45,5 +48,6 @@ module.exports = {
|
|
|
45
48
|
ResponseFormat,
|
|
46
49
|
responseFormatField,
|
|
47
50
|
toJsonString,
|
|
51
|
+
cardLabel,
|
|
48
52
|
truncateIfNeeded,
|
|
49
53
|
};
|
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/schemas.js
CHANGED
|
@@ -20,10 +20,43 @@ const isoDateField = z.string().refine(value => !Number.isNaN(Date.parse(value))
|
|
|
20
20
|
message: 'Must be an ISO-8601 date or datetime string',
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
+
// The link and attachment endpoints name a card by its number as well as its ObjectId.
|
|
24
|
+
const CARD_REF_HELP = 'card number (e.g. 302) or card ObjectId';
|
|
25
|
+
const CARD_REF_PATTERN = /^#?(\d+|[a-f0-9]{24})$/i;
|
|
26
|
+
const CARD_REF_MESSAGE = 'Must be a card number (e.g. 302) or a 24-character ObjectId';
|
|
27
|
+
|
|
28
|
+
// A card's link: …/b/<board publicId>/c/<number>, optionally followed by a slug of its title.
|
|
29
|
+
const CARD_LINK_PATTERN = /\/b\/([A-Za-z0-9]{6,12})\/c\/(\d+)/;
|
|
30
|
+
|
|
31
|
+
const cardRefField = z
|
|
32
|
+
.union([z.number().int().min(1), z.string().regex(CARD_REF_PATTERN, CARD_REF_MESSAGE)])
|
|
33
|
+
.describe(`The ${CARD_REF_HELP}.`);
|
|
34
|
+
|
|
35
|
+
const cardLocatorField = z
|
|
36
|
+
.union([
|
|
37
|
+
z.number().int().min(1),
|
|
38
|
+
z.string().regex(CARD_REF_PATTERN, CARD_REF_MESSAGE),
|
|
39
|
+
z.string().regex(CARD_LINK_PATTERN, 'Must be a card link ending in /b/<board>/c/<number>'),
|
|
40
|
+
])
|
|
41
|
+
.describe(`The ${CARD_REF_HELP}, or the card's link.`);
|
|
42
|
+
|
|
43
|
+
const cardRef = value => String(value).replace(/^#/, '');
|
|
44
|
+
|
|
45
|
+
// A link also names the board it was opened on, which picks the copy of a mirrored card.
|
|
46
|
+
const resolveCardLocator = value => {
|
|
47
|
+
const link = typeof value === 'string' && value.match(CARD_LINK_PATTERN);
|
|
48
|
+
return link ? { ref: link[2], board: link[1] } : { ref: cardRef(value), board: undefined };
|
|
49
|
+
};
|
|
50
|
+
|
|
23
51
|
module.exports = {
|
|
24
52
|
objectIdField,
|
|
25
53
|
boardPublicIdField,
|
|
26
54
|
pageField,
|
|
27
55
|
countField,
|
|
28
56
|
isoDateField,
|
|
57
|
+
CARD_REF_HELP,
|
|
58
|
+
cardRefField,
|
|
59
|
+
cardLocatorField,
|
|
60
|
+
cardRef,
|
|
61
|
+
resolveCardLocator,
|
|
29
62
|
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
const { makeApiRequest, safeRun } = require('../client');
|
|
2
|
+
const { responseFormatField, ResponseFormat, toJsonString, truncateIfNeeded, cardLabel } = require('../format');
|
|
3
|
+
const { CARD_REF_HELP, cardRefField, cardRef, objectIdField } = require('../schemas');
|
|
4
|
+
|
|
5
|
+
const READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true };
|
|
6
|
+
|
|
7
|
+
const LINK_SOURCES = { GOOGLE: 'Google Drive', DROPBOX: 'Dropbox', ONEDRIVE: 'OneDrive', BOX: 'Box', URL: 'web' };
|
|
8
|
+
|
|
9
|
+
const MB = 1024 * 1024;
|
|
10
|
+
const formatSize = bytes => (bytes < MB ? `${Math.max(1, Math.round(bytes / 1024))} KB` : `${(bytes / MB).toFixed(1)} MB`);
|
|
11
|
+
|
|
12
|
+
// "PDF file, 2.3 MB" for an uploaded file, "Google Drive link" for a linked one.
|
|
13
|
+
const describeKind = attachment => {
|
|
14
|
+
if (attachment.source !== 'S3') return `${LINK_SOURCES[attachment.source] || attachment.source} link`;
|
|
15
|
+
return attachment.fileSize ? `${attachment.type} file, ${formatSize(attachment.fileSize)}` : `${attachment.type} file`;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// Signed download links are long and expire within the hour, so lists leave them out.
|
|
19
|
+
const withoutLinks = ({ url, thumbnail, ...attachment }) => attachment;
|
|
20
|
+
|
|
21
|
+
const renderAttachmentLine = attachment => {
|
|
22
|
+
const added = attachment.createdAt ? `, added ${attachment.createdAt.slice(0, 10)}` : '';
|
|
23
|
+
const by = attachment.owner ? ` by ${attachment.owner}` : '';
|
|
24
|
+
return `- **${attachment.name}** — ${describeKind(attachment)}${added}${by} (\`${attachment._id}\`)`;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const registerAttachmentsTools = server => {
|
|
28
|
+
server.registerTool(
|
|
29
|
+
'kanbanzone_list_card_attachments',
|
|
30
|
+
{
|
|
31
|
+
title: "List a card's attachments",
|
|
32
|
+
description: [
|
|
33
|
+
"List the files and links in a card's Attachments section, oldest first: name, kind, size, who",
|
|
34
|
+
'added it and when, and its id. Download links are left out; get one with',
|
|
35
|
+
'kanbanzone_get_card_attachment.',
|
|
36
|
+
'',
|
|
37
|
+
'Args:',
|
|
38
|
+
` - card (string | number, required): ${CARD_REF_HELP}.`,
|
|
39
|
+
' - response_format ("markdown" | "json").',
|
|
40
|
+
'',
|
|
41
|
+
'Examples:',
|
|
42
|
+
' - "What files are attached to card 302?"',
|
|
43
|
+
].join('\n'),
|
|
44
|
+
inputSchema: {
|
|
45
|
+
card: cardRefField,
|
|
46
|
+
response_format: responseFormatField,
|
|
47
|
+
},
|
|
48
|
+
annotations: READ,
|
|
49
|
+
},
|
|
50
|
+
async ({ card, response_format }) =>
|
|
51
|
+
safeRun(async () => {
|
|
52
|
+
const ref = cardRef(card);
|
|
53
|
+
const data = await makeApiRequest(`/cards/${ref}/attachments`);
|
|
54
|
+
const attachments = (data.attachments || []).map(withoutLinks);
|
|
55
|
+
|
|
56
|
+
if (response_format === ResponseFormat.JSON) {
|
|
57
|
+
return {
|
|
58
|
+
content: [{ type: 'text', text: toJsonString(attachments) }],
|
|
59
|
+
structuredContent: { attachments },
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
if (!attachments.length) {
|
|
63
|
+
return {
|
|
64
|
+
content: [{ type: 'text', text: `Card ${cardLabel(ref)} has no attachments.` }],
|
|
65
|
+
structuredContent: { attachments },
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const rerender = list =>
|
|
70
|
+
[
|
|
71
|
+
`# Attachments on card ${cardLabel(ref)} (${list.length})`,
|
|
72
|
+
'',
|
|
73
|
+
...list.map(renderAttachmentLine),
|
|
74
|
+
].join('\n');
|
|
75
|
+
const { text } = truncateIfNeeded({ items: attachments, rendered: rerender(attachments), rerender });
|
|
76
|
+
return { content: [{ type: 'text', text }], structuredContent: { attachments } };
|
|
77
|
+
})
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
server.registerTool(
|
|
81
|
+
'kanbanzone_get_card_attachment',
|
|
82
|
+
{
|
|
83
|
+
title: 'Get a download link for an attachment',
|
|
84
|
+
description: [
|
|
85
|
+
"Get the download link of one of a card's attachments. An uploaded file gets a signed link that",
|
|
86
|
+
'works for about an hour; Google Drive, Dropbox, Box, OneDrive and web links come back as they',
|
|
87
|
+
'are. The file itself is not returned.',
|
|
88
|
+
'',
|
|
89
|
+
'Args:',
|
|
90
|
+
` - card (string | number, required): ${CARD_REF_HELP}.`,
|
|
91
|
+
' - attachment (string, required): attachment ObjectId, as listed by kanbanzone_list_card_attachments.',
|
|
92
|
+
'',
|
|
93
|
+
'Examples:',
|
|
94
|
+
' - "Give me a link to the contract on card 302"',
|
|
95
|
+
].join('\n'),
|
|
96
|
+
inputSchema: {
|
|
97
|
+
card: cardRefField,
|
|
98
|
+
attachment: objectIdField,
|
|
99
|
+
},
|
|
100
|
+
annotations: READ,
|
|
101
|
+
},
|
|
102
|
+
async ({ card, attachment }) =>
|
|
103
|
+
safeRun(async () => {
|
|
104
|
+
const ref = cardRef(card);
|
|
105
|
+
const data = await makeApiRequest(`/cards/${ref}/attachments`);
|
|
106
|
+
const found = (data.attachments || []).find(item => item._id === attachment.toLowerCase());
|
|
107
|
+
if (!found) {
|
|
108
|
+
return {
|
|
109
|
+
isError: true,
|
|
110
|
+
content: [
|
|
111
|
+
{ type: 'text', text: `Not found: card ${cardLabel(ref)} has no attachment ${attachment}.` },
|
|
112
|
+
],
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const expiry =
|
|
117
|
+
found.source === 'S3' ? '\n\nThe link works for about an hour; get a new one when it expires.' : '';
|
|
118
|
+
return {
|
|
119
|
+
content: [{ type: 'text', text: `**${found.name}** (${describeKind(found)}): ${found.url}${expiry}` }],
|
|
120
|
+
structuredContent: found,
|
|
121
|
+
};
|
|
122
|
+
})
|
|
123
|
+
);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
module.exports = { registerAttachmentsTools };
|
package/src/tools/cards.js
CHANGED
|
@@ -2,7 +2,16 @@ const { z } = require('zod');
|
|
|
2
2
|
const { makeApiRequest, safeRun } = require('../client');
|
|
3
3
|
const { responseFormatField, ResponseFormat, toJsonString, truncateIfNeeded, RICH_TEXT_HELP } = require('../format');
|
|
4
4
|
const { richTextBody } = require('../markdown');
|
|
5
|
-
const {
|
|
5
|
+
const {
|
|
6
|
+
objectIdField,
|
|
7
|
+
boardPublicIdField,
|
|
8
|
+
pageField,
|
|
9
|
+
countField,
|
|
10
|
+
isoDateField,
|
|
11
|
+
CARD_REF_HELP,
|
|
12
|
+
cardLocatorField,
|
|
13
|
+
resolveCardLocator,
|
|
14
|
+
} = require('../schemas');
|
|
6
15
|
|
|
7
16
|
const READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true };
|
|
8
17
|
const WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true };
|
|
@@ -18,6 +27,21 @@ const renderCardLine = card => {
|
|
|
18
27
|
return `- ${number}**${c.title}** (\`${id}\`)${owner}`;
|
|
19
28
|
};
|
|
20
29
|
|
|
30
|
+
// GET /cards/{id} nests the card under CardItem.
|
|
31
|
+
const renderCard = data => {
|
|
32
|
+
const c = data.CardItem || data;
|
|
33
|
+
const number = c.number !== undefined ? `#${c.number} ` : '';
|
|
34
|
+
const description = c.description ? `\n- **description**: ${c.description}` : '';
|
|
35
|
+
return `# ${number}${c.title}\n- **id**: ${data._id}${description}`;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// History events are `type` (entity.verb) plus the changed `field`; `action` is the deprecated pair
|
|
39
|
+
// still sent by older backends.
|
|
40
|
+
const renderHistoryLine = ev => {
|
|
41
|
+
const what = ev.type ? `${ev.type}${ev.field ? ` (${ev.field})` : ''}` : ev.action;
|
|
42
|
+
return `- ${ev.createdAt || ev.date || '?'} — ${what}`;
|
|
43
|
+
};
|
|
44
|
+
|
|
21
45
|
// The /cards list envelope is { count, totalAvailable, cards, hasMore }; tolerate a bare
|
|
22
46
|
// array or search-style { total, has_more } names too, so pagination metadata stays accurate.
|
|
23
47
|
const summarizeListResponse = (data, page, count) => {
|
|
@@ -106,7 +130,7 @@ const registerCardsTools = server => {
|
|
|
106
130
|
' - columns (string, optional): comma-separated column ObjectIds to restrict to.',
|
|
107
131
|
' - owner (string, optional): account ObjectId or email — only cards owned by this person.',
|
|
108
132
|
' - label (string, optional): label ObjectId or description string.',
|
|
109
|
-
' - days_since_last_update (number, optional): only cards
|
|
133
|
+
' - days_since_last_update (number, optional): only cards updated within the last N days.',
|
|
110
134
|
' - include_archived (boolean, optional): include archived cards.',
|
|
111
135
|
' - number (number, optional): fetch a single card by its #N number.',
|
|
112
136
|
' - page (number, optional, default 1).',
|
|
@@ -191,18 +215,19 @@ const registerCardsTools = server => {
|
|
|
191
215
|
{
|
|
192
216
|
title: 'Get a card',
|
|
193
217
|
description: [
|
|
194
|
-
'Fetch one card by its ObjectId.',
|
|
218
|
+
'Fetch one card by its number, ObjectId or link.',
|
|
195
219
|
'',
|
|
196
220
|
'Args:',
|
|
197
|
-
|
|
198
|
-
' - board (string, optional): board publicId — required for mirror cards to disambiguate.',
|
|
221
|
+
` - id (string | number, required): ${CARD_REF_HELP}, or the card's link, which ends in /b/<board>/c/<number>.`,
|
|
222
|
+
' - board (string, optional): board publicId — required for mirror cards to disambiguate. A link already names it.',
|
|
199
223
|
' - response_format ("markdown" | "json").',
|
|
200
224
|
'',
|
|
201
225
|
'Examples:',
|
|
202
|
-
' - "Show me card
|
|
226
|
+
' - "Show me card 28407"',
|
|
227
|
+
' - "Review this card: <a card link>"',
|
|
203
228
|
].join('\n'),
|
|
204
229
|
inputSchema: {
|
|
205
|
-
id:
|
|
230
|
+
id: cardLocatorField,
|
|
206
231
|
board: boardPublicIdField.optional(),
|
|
207
232
|
response_format: responseFormatField,
|
|
208
233
|
},
|
|
@@ -210,11 +235,9 @@ const registerCardsTools = server => {
|
|
|
210
235
|
},
|
|
211
236
|
async ({ id, board, response_format }) =>
|
|
212
237
|
safeRun(async () => {
|
|
213
|
-
const
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
? toJsonString(data)
|
|
217
|
-
: `# ${data.title}\n- **id**: ${data._id}${data.description ? `\n- **description**: ${data.description}` : ''}`;
|
|
238
|
+
const card = resolveCardLocator(id);
|
|
239
|
+
const data = await makeApiRequest(`/cards/${card.ref}`, { query: { board: board || card.board } });
|
|
240
|
+
const text = response_format === ResponseFormat.JSON ? toJsonString(data) : renderCard(data);
|
|
218
241
|
return { content: [{ type: 'text', text }], structuredContent: data };
|
|
219
242
|
})
|
|
220
243
|
);
|
|
@@ -324,6 +347,7 @@ const registerCardsTools = server => {
|
|
|
324
347
|
title: 'Get card history',
|
|
325
348
|
description: [
|
|
326
349
|
'Fetch the activity history for a card (column moves, edits, comments, etc.) starting from a date.',
|
|
350
|
+
'Each event has a type (entity.verb, e.g. card.moved, comment.added) and, for updates, the changed field.',
|
|
327
351
|
'',
|
|
328
352
|
'Args:',
|
|
329
353
|
' - id (string, required): card ObjectId.',
|
|
@@ -356,7 +380,7 @@ const registerCardsTools = server => {
|
|
|
356
380
|
[
|
|
357
381
|
`# History (${list.length} events since ${start})`,
|
|
358
382
|
'',
|
|
359
|
-
...list.map(
|
|
383
|
+
...list.map(renderHistoryLine),
|
|
360
384
|
].join('\n');
|
|
361
385
|
const { text } = truncateIfNeeded({ items: events, rendered: rerender(events), rerender });
|
|
362
386
|
return { content: [{ type: 'text', text }], structuredContent: { events } };
|
|
@@ -475,4 +499,4 @@ const registerCardsTools = server => {
|
|
|
475
499
|
);
|
|
476
500
|
};
|
|
477
501
|
|
|
478
|
-
module.exports = { registerCardsTools, renderCardLine, summarizeListResponse };
|
|
502
|
+
module.exports = { registerCardsTools, renderCardLine, renderHistoryLine, summarizeListResponse };
|
package/src/tools/index.js
CHANGED
|
@@ -2,6 +2,8 @@ const { registerOrganizationTools } = require('./organization');
|
|
|
2
2
|
const { registerBoardsTools } = require('./boards');
|
|
3
3
|
const { registerCardsTools } = require('./cards');
|
|
4
4
|
const { registerCommentsTools } = require('./comments');
|
|
5
|
+
const { registerLinksTools } = require('./links');
|
|
6
|
+
const { registerAttachmentsTools } = require('./attachments');
|
|
5
7
|
const { registerChecklistsTools } = require('./checklists');
|
|
6
8
|
const { registerTasksTools } = require('./tasks');
|
|
7
9
|
const { registerLabelsTools } = require('./labels');
|
|
@@ -11,6 +13,8 @@ const registerAllTools = server => {
|
|
|
11
13
|
registerBoardsTools(server);
|
|
12
14
|
registerCardsTools(server);
|
|
13
15
|
registerCommentsTools(server);
|
|
16
|
+
registerLinksTools(server);
|
|
17
|
+
registerAttachmentsTools(server);
|
|
14
18
|
registerChecklistsTools(server);
|
|
15
19
|
registerTasksTools(server);
|
|
16
20
|
registerLabelsTools(server);
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
const { z } = require('zod');
|
|
2
|
+
const { makeApiRequest, safeRun } = require('../client');
|
|
3
|
+
const { responseFormatField, ResponseFormat, toJsonString, truncateIfNeeded, cardLabel } = require('../format');
|
|
4
|
+
const { CARD_REF_HELP, cardRefField, cardRef } = require('../schemas');
|
|
5
|
+
|
|
6
|
+
const READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true };
|
|
7
|
+
const WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true };
|
|
8
|
+
const IDEMPOTENT_WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true };
|
|
9
|
+
const DESTRUCTIVE = { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: true };
|
|
10
|
+
|
|
11
|
+
const linkTypeField = z
|
|
12
|
+
.enum(['parent', 'child', 'predecessor', 'successor'])
|
|
13
|
+
.describe("What to_card becomes to card: 'parent' makes it card's parent, 'predecessor' puts it before card.");
|
|
14
|
+
|
|
15
|
+
const TYPE_ARG = " - type (string, required): what to_card becomes to card: 'parent', 'child', 'predecessor' or 'successor'.";
|
|
16
|
+
|
|
17
|
+
const describeLink = (ref, link) => `Card #${link.card} is now the ${link.type} of card ${cardLabel(ref)}.`;
|
|
18
|
+
|
|
19
|
+
const registerLinksTools = server => {
|
|
20
|
+
server.registerTool(
|
|
21
|
+
'kanbanzone_list_card_links',
|
|
22
|
+
{
|
|
23
|
+
title: "List a card's links to other cards",
|
|
24
|
+
description: [
|
|
25
|
+
'List the cards a card is linked to, by number, with the type of each link: what the other card',
|
|
26
|
+
'is to this one (parent, child, predecessor or successor). Links to web pages are not included.',
|
|
27
|
+
'',
|
|
28
|
+
'Args:',
|
|
29
|
+
` - card (string | number, required): ${CARD_REF_HELP}.`,
|
|
30
|
+
' - response_format ("markdown" | "json").',
|
|
31
|
+
'',
|
|
32
|
+
'Examples:',
|
|
33
|
+
' - "What is card 302 linked to?"',
|
|
34
|
+
' - "Which cards have to be done before card 302?"',
|
|
35
|
+
].join('\n'),
|
|
36
|
+
inputSchema: {
|
|
37
|
+
card: cardRefField,
|
|
38
|
+
response_format: responseFormatField,
|
|
39
|
+
},
|
|
40
|
+
annotations: READ,
|
|
41
|
+
},
|
|
42
|
+
async ({ card, response_format }) =>
|
|
43
|
+
safeRun(async () => {
|
|
44
|
+
const ref = cardRef(card);
|
|
45
|
+
const data = await makeApiRequest(`/cards/${ref}/links`);
|
|
46
|
+
const links = data.links || [];
|
|
47
|
+
|
|
48
|
+
if (response_format === ResponseFormat.JSON) {
|
|
49
|
+
return { content: [{ type: 'text', text: toJsonString(links) }], structuredContent: { links } };
|
|
50
|
+
}
|
|
51
|
+
if (!links.length) {
|
|
52
|
+
return {
|
|
53
|
+
content: [{ type: 'text', text: `Card ${cardLabel(ref)} has no links to other cards.` }],
|
|
54
|
+
structuredContent: { links },
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const rerender = list =>
|
|
59
|
+
[
|
|
60
|
+
`# Links on card ${cardLabel(ref)} (${list.length})`,
|
|
61
|
+
'',
|
|
62
|
+
...list.map(link => `- ${link.type}: #${link.card}`),
|
|
63
|
+
].join('\n');
|
|
64
|
+
const { text } = truncateIfNeeded({ items: links, rendered: rerender(links), rerender });
|
|
65
|
+
return { content: [{ type: 'text', text }], structuredContent: { links } };
|
|
66
|
+
})
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
server.registerTool(
|
|
70
|
+
'kanbanzone_create_card_link',
|
|
71
|
+
{
|
|
72
|
+
title: 'Link two cards',
|
|
73
|
+
description: [
|
|
74
|
+
'Link a card to another card in the organization, on the same board or another one. The other card',
|
|
75
|
+
"gets the opposite link: parent and child, predecessor and successor. Needs edit access to both cards'",
|
|
76
|
+
'boards. Two cards can be linked only once; change the type with kanbanzone_update_card_link.',
|
|
77
|
+
'',
|
|
78
|
+
'Args:',
|
|
79
|
+
` - card (string | number, required): ${CARD_REF_HELP}.`,
|
|
80
|
+
` - to_card (string | number, required): the card to link to, as a ${CARD_REF_HELP}.`,
|
|
81
|
+
TYPE_ARG,
|
|
82
|
+
'',
|
|
83
|
+
'Examples:',
|
|
84
|
+
' - "Make card 305 the parent of card 302" (card 302, to_card 305, type parent)',
|
|
85
|
+
' - "Card 410 has to be done before card 412" (card 412, to_card 410, type predecessor)',
|
|
86
|
+
].join('\n'),
|
|
87
|
+
inputSchema: {
|
|
88
|
+
card: cardRefField,
|
|
89
|
+
to_card: cardRefField,
|
|
90
|
+
type: linkTypeField,
|
|
91
|
+
},
|
|
92
|
+
annotations: WRITE,
|
|
93
|
+
},
|
|
94
|
+
async ({ card, to_card, type }) =>
|
|
95
|
+
safeRun(async () => {
|
|
96
|
+
const ref = cardRef(card);
|
|
97
|
+
const data = await makeApiRequest(`/cards/${ref}/links`, {
|
|
98
|
+
method: 'POST',
|
|
99
|
+
body: { toCard: cardRef(to_card), type },
|
|
100
|
+
});
|
|
101
|
+
return { content: [{ type: 'text', text: describeLink(ref, data) }], structuredContent: data };
|
|
102
|
+
})
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
server.registerTool(
|
|
106
|
+
'kanbanzone_update_card_link',
|
|
107
|
+
{
|
|
108
|
+
title: 'Change the type of a card link',
|
|
109
|
+
description: [
|
|
110
|
+
"Change what a linked card is to this card. The other card's side of the link changes to the",
|
|
111
|
+
'opposite type.',
|
|
112
|
+
'',
|
|
113
|
+
'Args:',
|
|
114
|
+
` - card (string | number, required): ${CARD_REF_HELP}.`,
|
|
115
|
+
` - to_card (string | number, required): the linked card, as a ${CARD_REF_HELP}.`,
|
|
116
|
+
TYPE_ARG,
|
|
117
|
+
'',
|
|
118
|
+
'Examples:',
|
|
119
|
+
' - "Card 305 should be a child of card 302, not its parent" (card 302, to_card 305, type child)',
|
|
120
|
+
].join('\n'),
|
|
121
|
+
inputSchema: {
|
|
122
|
+
card: cardRefField,
|
|
123
|
+
to_card: cardRefField,
|
|
124
|
+
type: linkTypeField,
|
|
125
|
+
},
|
|
126
|
+
annotations: IDEMPOTENT_WRITE,
|
|
127
|
+
},
|
|
128
|
+
async ({ card, to_card, type }) =>
|
|
129
|
+
safeRun(async () => {
|
|
130
|
+
const ref = cardRef(card);
|
|
131
|
+
const data = await makeApiRequest(`/cards/${ref}/links/${cardRef(to_card)}`, {
|
|
132
|
+
method: 'PATCH',
|
|
133
|
+
body: { type },
|
|
134
|
+
});
|
|
135
|
+
return { content: [{ type: 'text', text: describeLink(ref, data) }], structuredContent: data };
|
|
136
|
+
})
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
server.registerTool(
|
|
140
|
+
'kanbanzone_delete_card_link',
|
|
141
|
+
{
|
|
142
|
+
title: 'Unlink two cards',
|
|
143
|
+
description: [
|
|
144
|
+
'Remove the link between two cards, from both of them. Only the link goes; both cards stay.',
|
|
145
|
+
'',
|
|
146
|
+
'Args:',
|
|
147
|
+
` - card (string | number, required): ${CARD_REF_HELP}.`,
|
|
148
|
+
` - to_card (string | number, required): the linked card, as a ${CARD_REF_HELP}.`,
|
|
149
|
+
'',
|
|
150
|
+
'Examples:',
|
|
151
|
+
' - "Card 305 no longer has anything to do with card 302"',
|
|
152
|
+
].join('\n'),
|
|
153
|
+
inputSchema: {
|
|
154
|
+
card: cardRefField,
|
|
155
|
+
to_card: cardRefField,
|
|
156
|
+
},
|
|
157
|
+
annotations: DESTRUCTIVE,
|
|
158
|
+
},
|
|
159
|
+
async ({ card, to_card }) =>
|
|
160
|
+
safeRun(async () => {
|
|
161
|
+
const ref = cardRef(card);
|
|
162
|
+
const toRef = cardRef(to_card);
|
|
163
|
+
await makeApiRequest(`/cards/${ref}/links/${toRef}`, { method: 'DELETE' });
|
|
164
|
+
return {
|
|
165
|
+
content: [{ type: 'text', text: `Unlinked card ${cardLabel(ref)} and card ${cardLabel(toRef)}.` }],
|
|
166
|
+
};
|
|
167
|
+
})
|
|
168
|
+
);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
module.exports = { registerLinksTools };
|