@fruggr/zendesk-mcp-server 2.19.0 → 2.20.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/dist/index.js +122 -47
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -118,13 +118,13 @@ const createLogger = (level) => {
|
|
|
118
118
|
};
|
|
119
119
|
//#endregion
|
|
120
120
|
//#region src/constants.ts
|
|
121
|
-
const CHARACTER_LIMIT = 25e3;
|
|
122
121
|
const positiveIntEnv = (name, fallback) => {
|
|
123
122
|
const raw = process.env[name];
|
|
124
123
|
if (raw === void 0 || raw.trim() === "") return fallback;
|
|
125
124
|
const parsed = Number(raw);
|
|
126
125
|
return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : fallback;
|
|
127
126
|
};
|
|
127
|
+
const CHARACTER_LIMIT = positiveIntEnv("ZENDESK_CHARACTER_LIMIT", 25e3);
|
|
128
128
|
const ARTICLE_RESOURCES_SCAN_MAX_PAGES = positiveIntEnv("ZENDESK_ARTICLE_RESOURCES_SCAN_MAX_PAGES", 20);
|
|
129
129
|
const MAX_ATTACHMENT_BYTES = positiveIntEnv("ZENDESK_MAX_ATTACHMENT_BYTES", 5242880);
|
|
130
130
|
const MAX_EMBEDDED_IMAGE_COUNT = positiveIntEnv("ZENDESK_MAX_EMBEDDED_IMAGES", 10);
|
|
@@ -1214,9 +1214,9 @@ const markdownToHtml = (markdown) => {
|
|
|
1214
1214
|
};
|
|
1215
1215
|
//#endregion
|
|
1216
1216
|
//#region src/utils/formatting.ts
|
|
1217
|
-
const truncateIfNeeded = (text) => {
|
|
1218
|
-
if (text.length <=
|
|
1219
|
-
return `${text.slice(0, CHARACTER_LIMIT)}\n\n--- Response truncated (${text.length} chars, limit ${CHARACTER_LIMIT}).
|
|
1217
|
+
const truncateIfNeeded = (text, advice = "Use pagination or filters to reduce results.") => {
|
|
1218
|
+
if (text.length <= CHARACTER_LIMIT) return text;
|
|
1219
|
+
return `${text.slice(0, CHARACTER_LIMIT)}\n\n--- Response truncated (${text.length} chars, limit ${CHARACTER_LIMIT}). ${advice} ---`;
|
|
1220
1220
|
};
|
|
1221
1221
|
const formatPagination = (meta) => {
|
|
1222
1222
|
const parts = [`Results: ${meta.count}`];
|
|
@@ -1302,8 +1302,14 @@ const formatSlaBlock = (entry) => {
|
|
|
1302
1302
|
for (const m of entry.policy_metrics) lines.push(formatSlaMetric(m));
|
|
1303
1303
|
return `\n\n${lines.join("\n")}`;
|
|
1304
1304
|
};
|
|
1305
|
-
const
|
|
1306
|
-
const
|
|
1305
|
+
const withName = (id, names) => {
|
|
1306
|
+
const n = Number(id);
|
|
1307
|
+
if (n === -1) return "System (-1)";
|
|
1308
|
+
const name = names.get(n);
|
|
1309
|
+
return name ? `${name} (${id})` : String(id);
|
|
1310
|
+
};
|
|
1311
|
+
const formatComment = (comment, authors) => {
|
|
1312
|
+
const lines = [`### ${comment.public ? "Public comment" : "Internal note"} (id ${comment.id}) by ${withName(comment.author_id, authors ?? /* @__PURE__ */ new Map())}`, `*${comment.created_at}*`];
|
|
1307
1313
|
if (comment.attachments?.length) {
|
|
1308
1314
|
const summary = comment.attachments.map((a) => `#${a.id} (${a.content_type})`).join(", ");
|
|
1309
1315
|
lines.push(`Attachments: ${summary}`);
|
|
@@ -1339,12 +1345,6 @@ const AUDIT_FIELD_LABELS = {
|
|
|
1339
1345
|
submitter_id: "submitter",
|
|
1340
1346
|
group_id: "group"
|
|
1341
1347
|
};
|
|
1342
|
-
const withName = (id, names) => {
|
|
1343
|
-
const n = Number(id);
|
|
1344
|
-
if (n === -1) return "System (-1)";
|
|
1345
|
-
const name = names.get(n);
|
|
1346
|
-
return name ? `${name} (${id})` : String(id);
|
|
1347
|
-
};
|
|
1348
1348
|
const renderAuditValue = (field, value, names) => {
|
|
1349
1349
|
if (value === null || value === void 0 || value === "") return "";
|
|
1350
1350
|
const entity = AUDIT_ENTITY_FIELDS[field];
|
|
@@ -1453,9 +1453,9 @@ const formatContentTag = (tag) => `- **${tag.name}** (${tag.id})`;
|
|
|
1453
1453
|
const formatLabel = (label) => `- **${label.name}** (${label.id})`;
|
|
1454
1454
|
const formatUserSegment = (segment) => `- **${segment.name}** (${segment.id}) — ${segment.user_type}${segment.built_in ? " — Built-in" : ""}`;
|
|
1455
1455
|
const formatAttachment = (attachment) => `- **${attachment.file_name}** (${attachment.id}) — ${attachment.content_type} — ${attachment.size} bytes`;
|
|
1456
|
-
const formatList = (items, formatter, meta) => {
|
|
1456
|
+
const formatList = (items, formatter, meta, advice) => {
|
|
1457
1457
|
const text = [meta ? formatPagination(meta) : "", items.map(formatter).join("\n\n")].filter(Boolean).join("\n\n");
|
|
1458
|
-
return truncateIfNeeded(text);
|
|
1458
|
+
return truncateIfNeeded(text, advice);
|
|
1459
1459
|
};
|
|
1460
1460
|
//#endregion
|
|
1461
1461
|
//#region src/utils/pagination.ts
|
|
@@ -1548,7 +1548,7 @@ const fetchArticleMarkdown = async (subdomain, token, id, locale) => {
|
|
|
1548
1548
|
"",
|
|
1549
1549
|
htmlToMarkdown(article.body)
|
|
1550
1550
|
].join("\n");
|
|
1551
|
-
return truncateIfNeeded(text);
|
|
1551
|
+
return truncateIfNeeded(text, "This resource takes no parameters; read a long article one part at a time with get_article_outline then get_article_section.");
|
|
1552
1552
|
};
|
|
1553
1553
|
/**
|
|
1554
1554
|
* Build an article-resources provider. `listPromoted` holds a memoized-promise
|
|
@@ -1794,7 +1794,7 @@ const formatTopology = (data) => {
|
|
|
1794
1794
|
"## Permission groups",
|
|
1795
1795
|
...renderAdminSection(data.permissionGroups.map(formatPermissionGroup), data.permissionGroupsDenied, "_Unavailable: listing permission groups requires Guide-admin / Help Center manager rights, which this token lacks (HTTP 403). To create or edit an article, reuse the permission_group_id of an existing article (get_article)._")
|
|
1796
1796
|
].join("\n");
|
|
1797
|
-
return truncateIfNeeded(text);
|
|
1797
|
+
return truncateIfNeeded(text, "This resource takes no parameters; walk the tree with list_categories and list_sections instead.");
|
|
1798
1798
|
};
|
|
1799
1799
|
/**
|
|
1800
1800
|
* Build a topology provider holding a memoized-promise cache (TTL
|
|
@@ -2025,6 +2025,10 @@ const renderGapVerdict = (report, gapCount, unclassified) => {
|
|
|
2025
2025
|
const allClear = `No gaps: all ${scanned.categories} category/ies and ${scanned.sections} section(s) scanned have a published "${locale}" translation.`;
|
|
2026
2026
|
return unclassified > 0 ? `${allClear} This is not a clean bill of health for the whole tree: ${unclassified} other node(s) could not be classified — see the note below.` : allClear;
|
|
2027
2027
|
};
|
|
2028
|
+
const gapAdvice = (report) => {
|
|
2029
|
+
if (!report.categoryScoped) return "find_translation_gaps takes no pagination parameter; narrow the audit to one branch of the tree with category_id instead.";
|
|
2030
|
+
return report.listingIncomplete ? "find_translation_gaps takes no pagination parameter and this category holds more sections than one page, so the section listing is incomplete: list the rest with list_sections (category_id, following its cursor) and read them with list_section_translations." : "find_translation_gaps takes no pagination parameter, and this audit is already scoped to one category: fix the nodes above with set_category_translation / set_section_translation, then re-run it.";
|
|
2031
|
+
};
|
|
2028
2032
|
const renderGapReport = (report) => {
|
|
2029
2033
|
const { locale, categoryGaps, sectionGaps, scanned, found } = report;
|
|
2030
2034
|
const gapCount = categoryGaps.length + sectionGaps.length;
|
|
@@ -2040,8 +2044,8 @@ const renderGapReport = (report) => {
|
|
|
2040
2044
|
"",
|
|
2041
2045
|
renderGapVerdict(report, gapCount, unclassified),
|
|
2042
2046
|
...unclassified > 0 ? ["", `_Note: ${unclassified} of ${totalFound} node(s) came back without the \`translations\` sideload, so their state is unknown and none of them is reported above (covered: ${scanned.categories}/${found.categories} categories, ${scanned.sections}/${found.sections} sections). Read one of them with list_category_translations / list_section_translations, which query the node directly._`] : [],
|
|
2043
|
-
...report.listingIncomplete ? ["", `_Note: this Help Center has more than 100 categories or sections, so only the first page of each was considered. Narrow the scan with category_id to audit the rest._`] : []
|
|
2044
|
-
].join("\n"));
|
|
2047
|
+
...report.listingIncomplete ? ["", report.categoryScoped ? `_Note: this category holds more than 100 sections, so only the first page was considered. List the rest with list_sections (category_id, following its cursor) and read them with list_section_translations._` : `_Note: this Help Center has more than 100 categories or sections, so only the first page of each was considered. Narrow the scan with category_id to audit the rest._`] : []
|
|
2048
|
+
].join("\n"), gapAdvice(report));
|
|
2045
2049
|
};
|
|
2046
2050
|
const largeArticleHint = (body, sectionCount) => {
|
|
2047
2051
|
if (body.length < 3e3 && sectionCount < 4) return null;
|
|
@@ -2203,7 +2207,7 @@ const createHelpCenterTools = (ctx) => {
|
|
|
2203
2207
|
const text = (largeArticleHint(article.body, parseSections(article.body).length) ?? "") + formatArticle(article) + `\n\n**Available translations**: ${translations.map((t) => t.locale).join(", ")}`;
|
|
2204
2208
|
return { content: [{
|
|
2205
2209
|
type: "text",
|
|
2206
|
-
text: truncateIfNeeded(text)
|
|
2210
|
+
text: truncateIfNeeded(text, "get_article takes no pagination parameter; read a long article one part at a time with get_article_outline then get_article_section.")
|
|
2207
2211
|
}] };
|
|
2208
2212
|
}
|
|
2209
2213
|
},
|
|
@@ -2338,7 +2342,7 @@ const createHelpCenterTools = (ctx) => {
|
|
|
2338
2342
|
const note = scanCostNote(truncated, pagesScanned, cost);
|
|
2339
2343
|
return { content: [{
|
|
2340
2344
|
type: "text",
|
|
2341
|
-
text: truncateIfNeeded(`${header}\n\n${body}${note}
|
|
2345
|
+
text: truncateIfNeeded(`${header}\n\n${body}${note}`, "list_promoted_articles takes no parameters, so this listing cannot be narrowed from the call; read a single article with get_article.")
|
|
2342
2346
|
}] };
|
|
2343
2347
|
}
|
|
2344
2348
|
},
|
|
@@ -2361,7 +2365,7 @@ const createHelpCenterTools = (ctx) => {
|
|
|
2361
2365
|
const translations = await listTranslations(subdomain, token, article_id);
|
|
2362
2366
|
return { content: [{
|
|
2363
2367
|
type: "text",
|
|
2364
|
-
text: formatList(translations, formatTranslationSummary)
|
|
2368
|
+
text: formatList(translations, formatTranslationSummary, void 0, "list_article_translations takes only article_id, so this listing cannot be narrowed from the call; read one locale in full with get_article.")
|
|
2365
2369
|
}] };
|
|
2366
2370
|
}
|
|
2367
2371
|
},
|
|
@@ -2447,7 +2451,7 @@ const createHelpCenterTools = (ctx) => {
|
|
|
2447
2451
|
const translations = await listNodeTranslations(subdomain, token, "sections", section_id);
|
|
2448
2452
|
return { content: [{
|
|
2449
2453
|
type: "text",
|
|
2450
|
-
text: formatList(translations, formatNodeTranslationSummary)
|
|
2454
|
+
text: formatList(translations, formatNodeTranslationSummary, void 0, "list_section_translations takes only section_id, so this listing cannot be narrowed from the call; write one locale with set_section_translation.")
|
|
2451
2455
|
}] };
|
|
2452
2456
|
}
|
|
2453
2457
|
},
|
|
@@ -2470,7 +2474,7 @@ const createHelpCenterTools = (ctx) => {
|
|
|
2470
2474
|
const translations = await listNodeTranslations(subdomain, token, "categories", category_id);
|
|
2471
2475
|
return { content: [{
|
|
2472
2476
|
type: "text",
|
|
2473
|
-
text: formatList(translations, formatNodeTranslationSummary)
|
|
2477
|
+
text: formatList(translations, formatNodeTranslationSummary, void 0, "list_category_translations takes only category_id, so this listing cannot be narrowed from the call; write one locale with set_category_translation.")
|
|
2474
2478
|
}] };
|
|
2475
2479
|
}
|
|
2476
2480
|
},
|
|
@@ -2522,7 +2526,8 @@ const createHelpCenterTools = (ctx) => {
|
|
|
2522
2526
|
categories: allCategories.length,
|
|
2523
2527
|
sections: allSections.length
|
|
2524
2528
|
},
|
|
2525
|
-
listingIncomplete: categoryScope.hasMore || extractPaginationMeta(sectionsRes, allSections.length).has_more
|
|
2529
|
+
listingIncomplete: categoryScope.hasMore || extractPaginationMeta(sectionsRes, allSections.length).has_more,
|
|
2530
|
+
categoryScoped: category_id !== void 0
|
|
2526
2531
|
})
|
|
2527
2532
|
}] };
|
|
2528
2533
|
}
|
|
@@ -2609,7 +2614,7 @@ const createHelpCenterTools = (ctx) => {
|
|
|
2609
2614
|
}
|
|
2610
2615
|
return { content: [{
|
|
2611
2616
|
type: "text",
|
|
2612
|
-
text: formatList(response.permission_groups ?? [], formatPermissionGroup)
|
|
2617
|
+
text: formatList(response.permission_groups ?? [], formatPermissionGroup, void 0, "list_permission_groups takes no parameters, so this listing cannot be narrowed from the call.")
|
|
2613
2618
|
}] };
|
|
2614
2619
|
}
|
|
2615
2620
|
},
|
|
@@ -2847,7 +2852,7 @@ const createHelpCenterTools = (ctx) => {
|
|
|
2847
2852
|
const response = await helpCenterGet(subdomain, token, "/articles/labels");
|
|
2848
2853
|
return { content: [{
|
|
2849
2854
|
type: "text",
|
|
2850
|
-
text: formatList(response.labels ?? [], formatLabel)
|
|
2855
|
+
text: formatList(response.labels ?? [], formatLabel, void 0, "list_labels takes no parameters, so this listing cannot be narrowed from the call.")
|
|
2851
2856
|
}] };
|
|
2852
2857
|
}
|
|
2853
2858
|
},
|
|
@@ -2875,7 +2880,7 @@ const createHelpCenterTools = (ctx) => {
|
|
|
2875
2880
|
}
|
|
2876
2881
|
return { content: [{
|
|
2877
2882
|
type: "text",
|
|
2878
|
-
text: formatList(response.user_segments ?? [], formatUserSegment)
|
|
2883
|
+
text: formatList(response.user_segments ?? [], formatUserSegment, void 0, "list_user_segments takes no parameters, so this listing cannot be narrowed from the call.")
|
|
2879
2884
|
}] };
|
|
2880
2885
|
}
|
|
2881
2886
|
},
|
|
@@ -2902,7 +2907,7 @@ const createHelpCenterTools = (ctx) => {
|
|
|
2902
2907
|
}] };
|
|
2903
2908
|
return { content: [{
|
|
2904
2909
|
type: "text",
|
|
2905
|
-
text: formatList(attachments, formatAttachment)
|
|
2910
|
+
text: formatList(attachments, formatAttachment, void 0, "list_article_attachments takes only article_id, so this listing cannot be narrowed from the call.")
|
|
2906
2911
|
}] };
|
|
2907
2912
|
}
|
|
2908
2913
|
},
|
|
@@ -2981,7 +2986,7 @@ const createHelpCenterTools = (ctx) => {
|
|
|
2981
2986
|
].join("\n");
|
|
2982
2987
|
return { content: [{
|
|
2983
2988
|
type: "text",
|
|
2984
|
-
text: truncateIfNeeded(text)
|
|
2989
|
+
text: truncateIfNeeded(text, format === "markdown" ? "get_article_section takes no pagination parameter, and this single section already exceeds the limit." : "get_article_section takes no pagination parameter; request this section as format=\"markdown\", which renders the same content more compactly than HTML.")
|
|
2985
2990
|
}] };
|
|
2986
2991
|
}
|
|
2987
2992
|
},
|
|
@@ -3185,6 +3190,16 @@ const fetchAllTicketComments = async (subdomain, token, ticketId) => {
|
|
|
3185
3190
|
}
|
|
3186
3191
|
return all;
|
|
3187
3192
|
};
|
|
3193
|
+
const commentPageMeta = (response, itemCount) => extractPaginationMeta({
|
|
3194
|
+
...response.meta && { meta: response.meta },
|
|
3195
|
+
...response.count !== void 0 && { count: response.count }
|
|
3196
|
+
}, itemCount);
|
|
3197
|
+
const offsetPageNote = (response) => response.meta?.after_cursor == null && response.next_page != null ? "\n\n> ⚠ Zendesk paginated this response by offset rather than by cursor, so more comments exist beyond this page and no cursor leads to them. This tool pages by cursor only, and no parameter it accepts reaches the rest: read the remaining comments in Zendesk directly." : "";
|
|
3198
|
+
const commentPageOrder = (comments, sortOrder) => {
|
|
3199
|
+
const first = comments[0]?.created_at ?? "";
|
|
3200
|
+
const last = comments.at(-1)?.created_at ?? "";
|
|
3201
|
+
return (first === last ? sortOrder === "desc" : first > last) ? "newest first" : "oldest first";
|
|
3202
|
+
};
|
|
3188
3203
|
const fetchAttachmentsByIds = async (subdomain, token, ids) => {
|
|
3189
3204
|
const attachments = [];
|
|
3190
3205
|
for (const id of ids) try {
|
|
@@ -3327,21 +3342,29 @@ const collectAuditIds = (audits) => {
|
|
|
3327
3342
|
groupIds: [...groupIds]
|
|
3328
3343
|
};
|
|
3329
3344
|
};
|
|
3345
|
+
const resolveEntityNames = async (subdomain, token, path, key, ids) => {
|
|
3346
|
+
const map = /* @__PURE__ */ new Map();
|
|
3347
|
+
for (const batch of chunk(ids, 100)) try {
|
|
3348
|
+
const res = await zendeskGet(subdomain, token, path, { ids: batch.join(",") });
|
|
3349
|
+
for (const entity of res[key] ?? []) map.set(entity.id, entity.name);
|
|
3350
|
+
} catch {}
|
|
3351
|
+
return map;
|
|
3352
|
+
};
|
|
3353
|
+
const resolveUserNames = (subdomain, token, ids) => resolveEntityNames(subdomain, token, "/users/show_many", "users", ids);
|
|
3330
3354
|
const resolveAuditNames = async (subdomain, token, userIds, groupIds) => {
|
|
3331
|
-
const
|
|
3332
|
-
const map = /* @__PURE__ */ new Map();
|
|
3333
|
-
for (const batch of chunk(ids, 100)) try {
|
|
3334
|
-
const res = await zendeskGet(subdomain, token, path, { ids: batch.join(",") });
|
|
3335
|
-
for (const entity of res[key] ?? []) map.set(entity.id, entity.name);
|
|
3336
|
-
} catch {}
|
|
3337
|
-
return map;
|
|
3338
|
-
};
|
|
3339
|
-
const [users, groups] = await Promise.all([resolve("/users/show_many", "users", userIds), resolve("/groups/show_many", "groups", groupIds)]);
|
|
3355
|
+
const [users, groups] = await Promise.all([resolveUserNames(subdomain, token, userIds), resolveEntityNames(subdomain, token, "/groups/show_many", "groups", groupIds)]);
|
|
3340
3356
|
return {
|
|
3341
3357
|
users,
|
|
3342
3358
|
groups
|
|
3343
3359
|
};
|
|
3344
3360
|
};
|
|
3361
|
+
const resolveCommentAuthors = async (subdomain, token, comments, sideloaded = []) => {
|
|
3362
|
+
const authors = new Map(sideloaded.map((user) => [user.id, user.name]));
|
|
3363
|
+
const missing = [...new Set(comments.map((comment) => comment.author_id))].filter((id) => id > 0 && !authors.has(id));
|
|
3364
|
+
if (missing.length === 0) return authors;
|
|
3365
|
+
for (const [id, name] of await resolveUserNames(subdomain, token, missing)) authors.set(id, name);
|
|
3366
|
+
return authors;
|
|
3367
|
+
};
|
|
3345
3368
|
const DIFF_SKIP_KEYS = /* @__PURE__ */ new Set([
|
|
3346
3369
|
"comment",
|
|
3347
3370
|
"fields",
|
|
@@ -3431,10 +3454,10 @@ const createTicketTools = (ctx) => {
|
|
|
3431
3454
|
namespace: "tickets",
|
|
3432
3455
|
readOnly: true,
|
|
3433
3456
|
title: "Get Zendesk Ticket",
|
|
3434
|
-
description: "Retrieve a Zendesk ticket by ID, including its live SLA state (per-metric stage and breach countdown) when an SLA policy applies, plus its comments if requested. Returns ticket details (subject, status, priority, assignee, tags, description) and optionally all comments/internal notes. The per-ticket Show endpoint exposes no SLA, so the SLA block is resolved via a scoped search and may be absent for a very high-volume requester or a just-updated ticket; SLA targets and policy conditions live in list_sla_policies. This returns the ticket as it stands now; for the history of changes behind that state (who changed what, and when), use get_ticket_history.",
|
|
3457
|
+
description: "Retrieve a Zendesk ticket by ID, including its live SLA state (per-metric stage and breach countdown) when an SLA policy applies, plus its comments if requested. Returns ticket details (subject, status, priority, assignee, tags, description) and optionally all comments/internal notes. The per-ticket Show endpoint exposes no SLA, so the SLA block is resolved via a scoped search and may be absent for a very high-volume requester or a just-updated ticket; SLA targets and policy conditions live in list_sla_policies. This returns the ticket as it stands now; for the history of changes behind that state (who changed what, and when), use get_ticket_history. The comment thread is appended in one block — the first page of comments Zendesk returns, cut past the response character limit — so on a long ticket read it with list_ticket_comments, which pages the comments and returns the newest first.",
|
|
3435
3458
|
inputSchema: z.object({
|
|
3436
3459
|
ticket_id: z.number().int().describe("Ticket ID — the numeric id of the ticket to fetch. Obtain it from search_tickets or list_tickets."),
|
|
3437
|
-
include_comments: z.boolean().default(false).describe("When true, appends the full public comment and internal note thread to the response. Defaults to false to keep the payload small; enable it when you need the conversation, not just the ticket fields.")
|
|
3460
|
+
include_comments: z.boolean().default(false).describe("When true, appends the full public comment and internal note thread to the response. Defaults to false to keep the payload small; enable it when you need the conversation, not just the ticket fields. On a long thread prefer list_ticket_comments — this flag appends one unpaginated block, so comments past Zendesk's first page are absent and the rest is cut at the response character limit.")
|
|
3438
3461
|
}),
|
|
3439
3462
|
annotations: {
|
|
3440
3463
|
readOnlyHint: true,
|
|
@@ -3448,12 +3471,17 @@ const createTicketTools = (ctx) => {
|
|
|
3448
3471
|
const { ticket } = await zendeskGet(subdomain, token, `/tickets/${ticket_id}`);
|
|
3449
3472
|
let text = formatTicket(ticket) + formatSlaBlock(await fetchTicketSla(subdomain, token, ticket));
|
|
3450
3473
|
if (include_comments) {
|
|
3451
|
-
const { comments } = await zendeskGet(subdomain, token, `/tickets/${ticket_id}/comments`, {
|
|
3452
|
-
|
|
3474
|
+
const { comments, users } = await zendeskGet(subdomain, token, `/tickets/${ticket_id}/comments`, {
|
|
3475
|
+
include: "users",
|
|
3476
|
+
include_inline_images: "true"
|
|
3477
|
+
});
|
|
3478
|
+
const authors = await resolveCommentAuthors(subdomain, token, comments ?? [], users);
|
|
3479
|
+
text += `\n\n---\n# Comments\n\n${(comments ?? []).map((comment) => formatComment(comment, authors)).join("\n\n")}`;
|
|
3453
3480
|
}
|
|
3481
|
+
const advice = include_comments ? `get_ticket appends the thread as one unpaginated block; read it page by page with list_ticket_comments (ticket_id: ${ticket_id}, sort_order: "desc") to get the newest comments first.` : "get_ticket takes no pagination or filter parameters, so this response cannot be narrowed from the call.";
|
|
3454
3482
|
return { content: [{
|
|
3455
3483
|
type: "text",
|
|
3456
|
-
text: truncateIfNeeded(text)
|
|
3484
|
+
text: truncateIfNeeded(text, advice)
|
|
3457
3485
|
}] };
|
|
3458
3486
|
}
|
|
3459
3487
|
},
|
|
@@ -3462,7 +3490,7 @@ const createTicketTools = (ctx) => {
|
|
|
3462
3490
|
namespace: "tickets",
|
|
3463
3491
|
readOnly: true,
|
|
3464
3492
|
title: "Get Zendesk Ticket History",
|
|
3465
|
-
description: "Read a ticket's change history — its audit trail — as a chronological, oldest-first timeline of who changed what and when. Each entry shows the actor (name and id) and the channel, then the field changes that update carried (status, priority, assignee, group, tags, custom fields) as before → after, with assignee/requester/group ids resolved to names. Comments appear as one-line presence markers (public comment vs internal note added), not their text — fetch the bodies with get_ticket(include_comments=true). Purely system-generated notification events (trigger emails, collaborator/CC notifications, pushes) are filtered out — note this filters notification delivery, not CC-list edits, which are shown as changes — and an update carrying only such events produces no entry, so the timeline stays a readable narrative rather than a raw log. Use it to answer \"what happened on this ticket?\", \"why was it reassigned?\" or \"when did it go to pending?\", reading oldest-first so the founding context is not missed. Read-only, and cursor-paginated oldest-first: pass the returned cursor to page a long-lived ticket toward its most recent changes.",
|
|
3493
|
+
description: "Read a ticket's change history — its audit trail — as a chronological, oldest-first timeline of who changed what and when. Each entry shows the actor (name and id) and the channel, then the field changes that update carried (status, priority, assignee, group, tags, custom fields) as before → after, with assignee/requester/group ids resolved to names. Comments appear as one-line presence markers (public comment vs internal note added), not their text — fetch the bodies with list_ticket_comments (or get_ticket(include_comments=true) for a short thread). Purely system-generated notification events (trigger emails, collaborator/CC notifications, pushes) are filtered out — note this filters notification delivery, not CC-list edits, which are shown as changes — and an update carrying only such events produces no entry, so the timeline stays a readable narrative rather than a raw log. Use it to answer \"what happened on this ticket?\", \"why was it reassigned?\" or \"when did it go to pending?\", reading oldest-first so the founding context is not missed. Read-only, and cursor-paginated oldest-first: pass the returned cursor to page a long-lived ticket toward its most recent changes.",
|
|
3466
3494
|
inputSchema: z.object({
|
|
3467
3495
|
ticket_id: z.number().int().describe("Ticket ID — the numeric id of the ticket whose change history to read. Obtain it from search_tickets or list_tickets."),
|
|
3468
3496
|
page_size: z.number().int().min(1).max(100).default(100).describe("Audits (ticket updates) per page (1-100, default 100). Each audit is one update to the ticket and may expand to several change lines; audits carrying only system events are dropped, so a page can render fewer entries than this."),
|
|
@@ -3502,6 +3530,53 @@ const createTicketTools = (ctx) => {
|
|
|
3502
3530
|
}] };
|
|
3503
3531
|
}
|
|
3504
3532
|
},
|
|
3533
|
+
{
|
|
3534
|
+
name: "list_ticket_comments",
|
|
3535
|
+
namespace: "tickets",
|
|
3536
|
+
readOnly: true,
|
|
3537
|
+
title: "List Zendesk Ticket Comments",
|
|
3538
|
+
description: "Read a ticket's conversation — public replies and internal notes with their full bodies — one cursor-paginated page at a time, newest comment first. Each entry carries the comment id, the author resolved to a name, the timestamp, whether it is public or internal, and the ids of any attached files. Prefer this over get_ticket(include_comments=true) whenever a thread is long or you only need the latest exchange: get_ticket appends the thread as one unpaginated block and cuts it past the response character limit, which drops the most recent comments first. Keep sort_order \"desc\" (the default) to read the latest reply first and follow the returned cursor to walk further back in time, or pass \"asc\" to replay the conversation forward from the ticket's opening description. For who changed which field and when — without comment bodies — use get_ticket_history; to download the attached files themselves, pass the attachment ids shown here to get_ticket_attachments.",
|
|
3539
|
+
inputSchema: z.object({
|
|
3540
|
+
ticket_id: z.number().int().describe("Ticket ID — the numeric id of the ticket whose conversation to read. Obtain it from search_tickets or list_tickets."),
|
|
3541
|
+
sort_order: z.enum(["asc", "desc"]).default("desc").describe("Chronological direction of the page. \"desc\" (the default) starts at the most recent comment and walks backward in time, which is what you want to see the latest reply; \"asc\" replays the conversation forward, starting from the ticket's opening description — that first comment therefore lands on the last page under \"desc\"."),
|
|
3542
|
+
page_size: z.number().int().min(1).max(100).default(20).describe("Comments per page (1-100, default 20). The default is deliberately small because comment bodies are long and a bigger page risks being cut short by the response character limit; follow the returned cursor rather than raising it."),
|
|
3543
|
+
cursor: z.string().optional().describe("Pagination cursor from a previous response; omit for the first page. Zendesk issues it for the ordering that response used, so after changing sort_order drop the cursor and start again from the first page.")
|
|
3544
|
+
}),
|
|
3545
|
+
annotations: {
|
|
3546
|
+
readOnlyHint: true,
|
|
3547
|
+
destructiveHint: false,
|
|
3548
|
+
idempotentHint: true,
|
|
3549
|
+
openWorldHint: true
|
|
3550
|
+
},
|
|
3551
|
+
handler: async (params) => {
|
|
3552
|
+
const { ticket_id, sort_order, page_size, cursor } = params;
|
|
3553
|
+
const token = await getToken();
|
|
3554
|
+
const response = await zendeskGet(subdomain, token, `/tickets/${ticket_id}/comments`, {
|
|
3555
|
+
...buildCursorParams(page_size, cursor),
|
|
3556
|
+
sort: sort_order === "desc" ? "-created_at" : "created_at",
|
|
3557
|
+
include: "users",
|
|
3558
|
+
include_inline_images: "true"
|
|
3559
|
+
});
|
|
3560
|
+
const comments = response.comments ?? [];
|
|
3561
|
+
const meta = commentPageMeta(response, comments.length);
|
|
3562
|
+
const offsetNote = offsetPageNote(response);
|
|
3563
|
+
if (comments.length === 0) return { content: [{
|
|
3564
|
+
type: "text",
|
|
3565
|
+
text: `${meta.has_more ? `No comments on this page of ticket #${ticket_id}. More available (cursor: ${meta.after_cursor}).` : `No comments to show for ticket #${ticket_id}.`}${offsetNote}`
|
|
3566
|
+
}] };
|
|
3567
|
+
const authors = await resolveCommentAuthors(subdomain, token, comments, response.users);
|
|
3568
|
+
const body = comments.map((comment) => formatComment(comment, authors)).join("\n\n");
|
|
3569
|
+
const text = `${[
|
|
3570
|
+
`# Comments on ticket #${ticket_id} (${commentPageOrder(comments, sort_order)})`,
|
|
3571
|
+
formatPagination(meta),
|
|
3572
|
+
body
|
|
3573
|
+
].join("\n\n")}${offsetNote}`;
|
|
3574
|
+
return { content: [{
|
|
3575
|
+
type: "text",
|
|
3576
|
+
text: truncateIfNeeded(text, page_size > 1 ? `The comments cut here are not reachable through the cursor, which points past this whole page: re-issue with a page_size smaller than ${page_size} to read them.` : "This single comment is longer than the response character limit, so no page small enough exists: read it in Zendesk directly.")
|
|
3577
|
+
}] };
|
|
3578
|
+
}
|
|
3579
|
+
},
|
|
3505
3580
|
{
|
|
3506
3581
|
name: "get_ticket_attachments",
|
|
3507
3582
|
namespace: "tickets",
|
|
@@ -3510,7 +3585,7 @@ const createTicketTools = (ctx) => {
|
|
|
3510
3585
|
description: "Retrieve ticket attachments. Images are embedded inline; other files are listed as text references.",
|
|
3511
3586
|
inputSchema: z.object({
|
|
3512
3587
|
ticket_id: z.number().int().describe("Ticket ID — the numeric id of the ticket whose attachments to fetch. Obtain it from search_tickets or list_tickets."),
|
|
3513
|
-
attachment_ids: z.array(z.number().int()).optional().describe("Attachment IDs to fetch directly (e.g. extracted from a previous get_ticket(include_comments=true) call). When provided, skips the comments fetch entirely. When omitted, all attachments of the ticket are returned.")
|
|
3588
|
+
attachment_ids: z.array(z.number().int()).optional().describe("Attachment IDs to fetch directly (e.g. extracted from a previous list_ticket_comments or get_ticket(include_comments=true) call). When provided, skips the comments fetch entirely. When omitted, all attachments of the ticket are returned.")
|
|
3514
3589
|
}),
|
|
3515
3590
|
annotations: {
|
|
3516
3591
|
readOnlyHint: true,
|
|
@@ -3778,7 +3853,7 @@ const createTicketTools = (ctx) => {
|
|
|
3778
3853
|
const text = incidents.length > 0 ? `# Incidents linked to problem #${problem_id}\n\n${incidents.map(formatTicket).join("\n\n")}` : `No incidents linked to problem #${problem_id}.`;
|
|
3779
3854
|
return { content: [{
|
|
3780
3855
|
type: "text",
|
|
3781
|
-
text: truncateIfNeeded(text)
|
|
3856
|
+
text: truncateIfNeeded(text, "get_linked_incidents takes no pagination or filter parameters, so this response cannot be narrowed from the call.")
|
|
3782
3857
|
}] };
|
|
3783
3858
|
}
|
|
3784
3859
|
},
|
|
@@ -4010,7 +4085,7 @@ const createTicketTools = (ctx) => {
|
|
|
4010
4085
|
const [{ ticket: before }, { result }] = await Promise.all([zendeskGet(subdomain, token, `/tickets/${ticket_id}`), zendeskGet(subdomain, token, `/tickets/${ticket_id}/macros/${macro_id}/apply`)]);
|
|
4011
4086
|
return { content: [{
|
|
4012
4087
|
type: "text",
|
|
4013
|
-
text: truncateIfNeeded(formatMacroPreviewDiff(ticket_id, macro_id, before, result))
|
|
4088
|
+
text: truncateIfNeeded(formatMacroPreviewDiff(ticket_id, macro_id, before, result), "preview_macro_diff takes no pagination or filter parameters; read the macro on its own with list_macros to see every action it carries.")
|
|
4014
4089
|
}] };
|
|
4015
4090
|
}
|
|
4016
4091
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fruggr/zendesk-mcp-server",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.20.0",
|
|
4
4
|
"mcpName": "io.github.fruggr/zendesk-mcp-server",
|
|
5
5
|
"description": "Deep Zendesk MCP server for your AI assistant: search, draft, update and translate Help Center articles and manage Support tickets end to end — comments, triage and image attachments.",
|
|
6
6
|
"type": "module",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"engines": {
|
|
70
70
|
"node": ">=20"
|
|
71
71
|
},
|
|
72
|
-
"packageManager": "pnpm@11.
|
|
72
|
+
"packageManager": "pnpm@11.25.0+sha512.5cde925b4f075f725eb71fbae18a42ffe784524789f19b61c731cb8721ec28aaee160e01a8d5af4fedb2a42cdbf300efe23db356b0d4a17b4d63e11f8ab7c956",
|
|
73
73
|
"dependencies": {
|
|
74
74
|
"@modelcontextprotocol/sdk": "1.30.0",
|
|
75
75
|
"cheerio": "1.2.0",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"zod": "4.4.3"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
|
-
"@biomejs/biome": "2.5.
|
|
91
|
+
"@biomejs/biome": "2.5.11",
|
|
92
92
|
"@semantic-release/changelog": "^7.0.0",
|
|
93
93
|
"@semantic-release/exec": "^7.1.0",
|
|
94
94
|
"@semantic-release/git": "^11.0.0",
|