@get-technology-inc/jamf-docs-mcp-server 1.0.0 → 1.2.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 +61 -139
- package/dist/completions.d.ts +13 -0
- package/dist/completions.d.ts.map +1 -0
- package/dist/completions.js +31 -0
- package/dist/completions.js.map +1 -0
- package/dist/constants.d.ts +123 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +187 -17
- package/dist/constants.js.map +1 -1
- package/dist/index.js +46 -6
- package/dist/index.js.map +1 -1
- package/dist/prompts/compare-versions.d.ts +7 -0
- package/dist/prompts/compare-versions.d.ts.map +1 -0
- package/dist/prompts/compare-versions.js +56 -0
- package/dist/prompts/compare-versions.js.map +1 -0
- package/dist/prompts/index.d.ts +6 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +12 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/setup-guide.d.ts +7 -0
- package/dist/prompts/setup-guide.d.ts.map +1 -0
- package/dist/prompts/setup-guide.js +53 -0
- package/dist/prompts/setup-guide.js.map +1 -0
- package/dist/prompts/troubleshoot.d.ts +7 -0
- package/dist/prompts/troubleshoot.d.ts.map +1 -0
- package/dist/prompts/troubleshoot.js +52 -0
- package/dist/prompts/troubleshoot.js.map +1 -0
- package/dist/resources/index.d.ts +13 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +121 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/schemas/index.d.ts +29 -63
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +35 -16
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/output.d.ts +63 -0
- package/dist/schemas/output.d.ts.map +1 -0
- package/dist/schemas/output.js +63 -0
- package/dist/schemas/output.js.map +1 -0
- package/dist/services/cache.d.ts +37 -12
- package/dist/services/cache.d.ts.map +1 -1
- package/dist/services/cache.js +141 -41
- package/dist/services/cache.js.map +1 -1
- package/dist/services/metadata.d.ts +78 -0
- package/dist/services/metadata.d.ts.map +1 -0
- package/dist/services/metadata.js +362 -0
- package/dist/services/metadata.js.map +1 -0
- package/dist/services/scraper.d.ts +3 -2
- package/dist/services/scraper.d.ts.map +1 -1
- package/dist/services/scraper.js +170 -145
- package/dist/services/scraper.js.map +1 -1
- package/dist/services/search-suggestions.d.ts +27 -0
- package/dist/services/search-suggestions.d.ts.map +1 -0
- package/dist/services/search-suggestions.js +193 -0
- package/dist/services/search-suggestions.js.map +1 -0
- package/dist/services/tokenizer.d.ts +17 -1
- package/dist/services/tokenizer.d.ts.map +1 -1
- package/dist/services/tokenizer.js +122 -66
- package/dist/services/tokenizer.js.map +1 -1
- package/dist/tools/get-article.d.ts +1 -1
- package/dist/tools/get-article.d.ts.map +1 -1
- package/dist/tools/get-article.js +145 -70
- package/dist/tools/get-article.js.map +1 -1
- package/dist/tools/get-toc.d.ts +1 -1
- package/dist/tools/get-toc.d.ts.map +1 -1
- package/dist/tools/get-toc.js +107 -47
- package/dist/tools/get-toc.js.map +1 -1
- package/dist/tools/list-products.d.ts +1 -1
- package/dist/tools/list-products.d.ts.map +1 -1
- package/dist/tools/list-products.js +42 -13
- package/dist/tools/list-products.js.map +1 -1
- package/dist/tools/search.d.ts +1 -1
- package/dist/tools/search.d.ts.map +1 -1
- package/dist/tools/search.js +142 -69
- package/dist/tools/search.js.map +1 -1
- package/dist/transport/http.d.ts +12 -0
- package/dist/transport/http.d.ts.map +1 -0
- package/dist/transport/http.js +297 -0
- package/dist/transport/http.js.map +1 -0
- package/dist/transport/index.d.ts +13 -0
- package/dist/transport/index.d.ts.map +1 -0
- package/dist/transport/index.js +40 -0
- package/dist/transport/index.js.map +1 -0
- package/dist/types.d.ts +12 -18
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/doc-type.d.ts +9 -0
- package/dist/utils/doc-type.d.ts.map +1 -0
- package/dist/utils/doc-type.js +16 -0
- package/dist/utils/doc-type.js.map +1 -0
- package/dist/utils/progress.d.ts +13 -0
- package/dist/utils/progress.d.ts.map +1 -0
- package/dist/utils/progress.js +18 -0
- package/dist/utils/progress.js.map +1 -0
- package/dist/utils/sanitize.d.ts +30 -0
- package/dist/utils/sanitize.d.ts.map +1 -0
- package/dist/utils/sanitize.js +57 -0
- package/dist/utils/sanitize.js.map +1 -0
- package/dist/utils/url.d.ts +11 -0
- package/dist/utils/url.d.ts.map +1 -0
- package/dist/utils/url.js +23 -0
- package/dist/utils/url.js.map +1 -0
- package/package.json +8 -5
|
@@ -3,8 +3,114 @@
|
|
|
3
3
|
* Retrieve the full content of a specific Jamf documentation article.
|
|
4
4
|
*/
|
|
5
5
|
import { GetArticleInputSchema } from '../schemas/index.js';
|
|
6
|
-
import {
|
|
6
|
+
import { reportProgress } from '../utils/progress.js';
|
|
7
|
+
import { ArticleOutputSchema } from '../schemas/output.js';
|
|
8
|
+
import { ResponseFormat, OutputMode, TOKEN_CONFIG } from '../constants.js';
|
|
7
9
|
import { fetchArticle } from '../services/scraper.js';
|
|
10
|
+
import { sanitizeMarkdownText, sanitizeMarkdownUrl, getSafeErrorMessage } from '../utils/sanitize.js';
|
|
11
|
+
function formatBreadcrumb(breadcrumb) {
|
|
12
|
+
if (breadcrumb === undefined || breadcrumb.length === 0) {
|
|
13
|
+
return '';
|
|
14
|
+
}
|
|
15
|
+
return `*${breadcrumb.join(' > ')}*\n\n`;
|
|
16
|
+
}
|
|
17
|
+
function formatMetadata(product, version, lastUpdated, tokenInfo) {
|
|
18
|
+
const meta = [];
|
|
19
|
+
if (product !== undefined && product !== '') {
|
|
20
|
+
meta.push(`**Product**: ${product}`);
|
|
21
|
+
}
|
|
22
|
+
if (version !== undefined && version !== '') {
|
|
23
|
+
meta.push(`**Version**: ${version}`);
|
|
24
|
+
}
|
|
25
|
+
if (lastUpdated !== undefined && lastUpdated !== '') {
|
|
26
|
+
meta.push(`**Last Updated**: ${lastUpdated}`);
|
|
27
|
+
}
|
|
28
|
+
meta.push(`**Tokens**: ${tokenInfo.tokenCount.toLocaleString()}/${tokenInfo.maxTokens.toLocaleString()}`);
|
|
29
|
+
if (tokenInfo.truncated) {
|
|
30
|
+
meta.push('*(truncated)*');
|
|
31
|
+
}
|
|
32
|
+
return meta.length > 0 ? `${meta.join(' | ')}\n\n` : '';
|
|
33
|
+
}
|
|
34
|
+
function formatSectionsList(sections, tokenInfo) {
|
|
35
|
+
if (sections.length === 0 || !tokenInfo.truncated) {
|
|
36
|
+
return '';
|
|
37
|
+
}
|
|
38
|
+
let result = '\n\n---\n\n## Available Sections\n\n';
|
|
39
|
+
for (const section of sections.slice(0, 15)) {
|
|
40
|
+
const indent = ' '.repeat(Math.max(0, section.level - 1));
|
|
41
|
+
result += `${indent}- **${section.title}** (~${String(section.tokenCount)} tokens)\n`;
|
|
42
|
+
}
|
|
43
|
+
if (sections.length > 15) {
|
|
44
|
+
result += `\n*...and ${String(sections.length - 15)} more sections*\n`;
|
|
45
|
+
}
|
|
46
|
+
result += '\n*Use `section` parameter to retrieve a specific section.*\n';
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
function formatRelatedArticles(articles) {
|
|
50
|
+
if (articles === undefined || articles.length === 0) {
|
|
51
|
+
return '';
|
|
52
|
+
}
|
|
53
|
+
let result = '\n\n---\n\n## Related Articles\n\n';
|
|
54
|
+
for (const related of articles) {
|
|
55
|
+
result += `- [${sanitizeMarkdownText(related.title)}](${sanitizeMarkdownUrl(related.url)})\n`;
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
function formatFooter(url, tokenInfo, compact = false) {
|
|
60
|
+
const safeUrl = sanitizeMarkdownUrl(url);
|
|
61
|
+
if (compact) {
|
|
62
|
+
return `\n---\n*[Source](${safeUrl}) | ${tokenInfo.tokenCount} tokens${tokenInfo.truncated ? ' (truncated)' : ''}*\n`;
|
|
63
|
+
}
|
|
64
|
+
let result = '\n\n---\n\n';
|
|
65
|
+
result += `*Source: [${sanitizeMarkdownText(url)}](${safeUrl})*\n`;
|
|
66
|
+
result += `*${tokenInfo.tokenCount.toLocaleString()} tokens`;
|
|
67
|
+
if (tokenInfo.truncated) {
|
|
68
|
+
result += ` (truncated from original, max: ${tokenInfo.maxTokens.toLocaleString()})`;
|
|
69
|
+
}
|
|
70
|
+
result += '*\n';
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Format article in compact mode
|
|
75
|
+
*/
|
|
76
|
+
function formatArticleAsCompact(article, tokenInfo) {
|
|
77
|
+
let markdown = `# ${article.title}\n\n`;
|
|
78
|
+
// Compact metadata
|
|
79
|
+
const meta = [];
|
|
80
|
+
if (article.product !== undefined && article.product !== '') {
|
|
81
|
+
meta.push(article.product);
|
|
82
|
+
}
|
|
83
|
+
if (article.version !== undefined && article.version !== '') {
|
|
84
|
+
meta.push(`v${article.version}`);
|
|
85
|
+
}
|
|
86
|
+
if (meta.length > 0) {
|
|
87
|
+
markdown += `*${meta.join(' | ')}*\n\n`;
|
|
88
|
+
}
|
|
89
|
+
// Content
|
|
90
|
+
markdown += article.content;
|
|
91
|
+
// Compact footer
|
|
92
|
+
markdown += formatFooter(article.url, tokenInfo, true);
|
|
93
|
+
return markdown;
|
|
94
|
+
}
|
|
95
|
+
function formatArticleAsMarkdown(article, tokenInfo, sections, options) {
|
|
96
|
+
let markdown = '';
|
|
97
|
+
markdown += formatBreadcrumb(article.breadcrumb);
|
|
98
|
+
markdown += `# ${article.title}\n\n`;
|
|
99
|
+
markdown += formatMetadata(article.product, article.version, article.lastUpdated, tokenInfo);
|
|
100
|
+
if (options.section !== undefined && options.section !== '') {
|
|
101
|
+
markdown += `*Showing section: "${options.section}"*\n\n`;
|
|
102
|
+
}
|
|
103
|
+
markdown += '---\n\n';
|
|
104
|
+
markdown += article.content;
|
|
105
|
+
if (options.section === undefined || options.section === '') {
|
|
106
|
+
markdown += formatSectionsList(sections, tokenInfo);
|
|
107
|
+
}
|
|
108
|
+
if (options.includeRelated === true) {
|
|
109
|
+
markdown += formatRelatedArticles(article.relatedArticles);
|
|
110
|
+
}
|
|
111
|
+
markdown += formatFooter(article.url, tokenInfo);
|
|
112
|
+
return markdown;
|
|
113
|
+
}
|
|
8
114
|
const TOOL_NAME = 'jamf_docs_get_article';
|
|
9
115
|
const TOOL_DESCRIPTION = `Retrieve the full content of a specific Jamf documentation article.
|
|
10
116
|
|
|
@@ -14,8 +120,10 @@ a clean, readable format. Works with any article from docs.jamf.com or learn.jam
|
|
|
14
120
|
Args:
|
|
15
121
|
- url (string, required): Full URL of the article (must be from docs.jamf.com or learn.jamf.com)
|
|
16
122
|
- section (string, optional): Extract only a specific section by title or ID (e.g., "Prerequisites", "Configuration")
|
|
123
|
+
- summaryOnly (boolean, optional): Return only article summary and outline instead of full content (default: false). Token-efficient way to preview an article
|
|
17
124
|
- includeRelated (boolean, optional): Include links to related articles (default: false)
|
|
18
125
|
- maxTokens (number, optional): Maximum tokens in response 100-20000 (default: 5000)
|
|
126
|
+
- outputMode ('full' | 'compact'): Output detail level (default: 'full'). Use 'compact' for brief output
|
|
19
127
|
- responseFormat ('markdown' | 'json'): Output format (default: 'markdown')
|
|
20
128
|
|
|
21
129
|
Returns:
|
|
@@ -63,13 +171,14 @@ export function registerGetArticleTool(server) {
|
|
|
63
171
|
title: 'Get Jamf Documentation Article',
|
|
64
172
|
description: TOOL_DESCRIPTION,
|
|
65
173
|
inputSchema: GetArticleInputSchema,
|
|
174
|
+
outputSchema: ArticleOutputSchema,
|
|
66
175
|
annotations: {
|
|
67
176
|
readOnlyHint: true,
|
|
68
177
|
destructiveHint: false,
|
|
69
178
|
idempotentHint: true,
|
|
70
179
|
openWorldHint: true
|
|
71
180
|
}
|
|
72
|
-
}, async (args) => {
|
|
181
|
+
}, async (args, extra) => {
|
|
73
182
|
// Parse and validate input
|
|
74
183
|
const parseResult = GetArticleInputSchema.safeParse(args);
|
|
75
184
|
if (!parseResult.success) {
|
|
@@ -80,12 +189,14 @@ export function registerGetArticleTool(server) {
|
|
|
80
189
|
}
|
|
81
190
|
const params = parseResult.data;
|
|
82
191
|
try {
|
|
83
|
-
|
|
192
|
+
await reportProgress(extra, 0, 100);
|
|
84
193
|
const article = await fetchArticle(params.url, {
|
|
85
194
|
includeRelated: params.includeRelated,
|
|
86
|
-
|
|
195
|
+
summaryOnly: params.summaryOnly,
|
|
196
|
+
...(params.section !== undefined && { section: params.section }),
|
|
87
197
|
maxTokens: params.maxTokens ?? TOKEN_CONFIG.DEFAULT_MAX_TOKENS
|
|
88
198
|
});
|
|
199
|
+
await reportProgress(extra, 70, 100);
|
|
89
200
|
const { tokenInfo, sections } = article;
|
|
90
201
|
// Build response
|
|
91
202
|
const response = {
|
|
@@ -94,86 +205,50 @@ export function registerGetArticleTool(server) {
|
|
|
94
205
|
tokenInfo,
|
|
95
206
|
sections
|
|
96
207
|
};
|
|
97
|
-
|
|
208
|
+
const structuredContent = {
|
|
209
|
+
title: article.title,
|
|
210
|
+
url: article.url,
|
|
211
|
+
content: article.content,
|
|
212
|
+
...(article.product !== undefined ? { product: article.product } : {}),
|
|
213
|
+
...(article.version !== undefined ? { version: article.version } : {}),
|
|
214
|
+
...(article.lastUpdated !== undefined ? { lastUpdated: article.lastUpdated } : {}),
|
|
215
|
+
...(article.breadcrumb !== undefined ? { breadcrumb: article.breadcrumb } : {}),
|
|
216
|
+
sections: sections.map(s => ({
|
|
217
|
+
id: s.id,
|
|
218
|
+
title: s.title,
|
|
219
|
+
level: s.level,
|
|
220
|
+
tokenCount: s.tokenCount
|
|
221
|
+
})),
|
|
222
|
+
truncated: tokenInfo.truncated
|
|
223
|
+
};
|
|
98
224
|
if (params.responseFormat === ResponseFormat.JSON) {
|
|
225
|
+
await reportProgress(extra, 100, 100);
|
|
99
226
|
return {
|
|
100
227
|
content: [{
|
|
101
228
|
type: 'text',
|
|
102
229
|
text: JSON.stringify(response, null, 2)
|
|
103
|
-
}]
|
|
230
|
+
}],
|
|
231
|
+
structuredContent
|
|
104
232
|
};
|
|
105
233
|
}
|
|
106
|
-
// Markdown format
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
// Metadata including token info
|
|
115
|
-
const meta = [];
|
|
116
|
-
if (article.product) {
|
|
117
|
-
meta.push(`**Product**: ${article.product}`);
|
|
118
|
-
}
|
|
119
|
-
if (article.version) {
|
|
120
|
-
meta.push(`**Version**: ${article.version}`);
|
|
121
|
-
}
|
|
122
|
-
if (article.lastUpdated) {
|
|
123
|
-
meta.push(`**Last Updated**: ${article.lastUpdated}`);
|
|
124
|
-
}
|
|
125
|
-
meta.push(`**Tokens**: ${tokenInfo.tokenCount.toLocaleString()}/${tokenInfo.maxTokens.toLocaleString()}`);
|
|
126
|
-
if (tokenInfo.truncated) {
|
|
127
|
-
meta.push('*(truncated)*');
|
|
128
|
-
}
|
|
129
|
-
if (meta.length > 0) {
|
|
130
|
-
markdown += `${meta.join(' | ')}\n\n`;
|
|
131
|
-
}
|
|
132
|
-
// Section filter note
|
|
133
|
-
if (params.section) {
|
|
134
|
-
markdown += `*Showing section: "${params.section}"*\n\n`;
|
|
135
|
-
}
|
|
136
|
-
markdown += '---\n\n';
|
|
137
|
-
// Content
|
|
138
|
-
markdown += article.content;
|
|
139
|
-
// Sections list (if not filtered to a specific section and there are sections)
|
|
140
|
-
if (!params.section && sections.length > 0 && tokenInfo.truncated) {
|
|
141
|
-
markdown += '\n\n---\n\n';
|
|
142
|
-
markdown += '## Available Sections\n\n';
|
|
143
|
-
for (const section of sections.slice(0, 15)) {
|
|
144
|
-
const indent = ' '.repeat(Math.max(0, section.level - 1));
|
|
145
|
-
markdown += `${indent}- **${section.title}** (~${section.tokenCount} tokens)\n`;
|
|
146
|
-
}
|
|
147
|
-
if (sections.length > 15) {
|
|
148
|
-
markdown += `\n*...and ${sections.length - 15} more sections*\n`;
|
|
149
|
-
}
|
|
150
|
-
markdown += '\n*Use `section` parameter to retrieve a specific section.*\n';
|
|
151
|
-
}
|
|
152
|
-
// Related articles
|
|
153
|
-
if (params.includeRelated && article.relatedArticles && article.relatedArticles.length > 0) {
|
|
154
|
-
markdown += '\n\n---\n\n';
|
|
155
|
-
markdown += '## Related Articles\n\n';
|
|
156
|
-
for (const related of article.relatedArticles) {
|
|
157
|
-
markdown += `- [${related.title}](${related.url})\n`;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
// Source link and token summary
|
|
161
|
-
markdown += '\n\n---\n\n';
|
|
162
|
-
markdown += `*Source: [${article.url}](${article.url})*\n`;
|
|
163
|
-
markdown += `*${tokenInfo.tokenCount.toLocaleString()} tokens`;
|
|
164
|
-
if (tokenInfo.truncated) {
|
|
165
|
-
markdown += ` (truncated from original, max: ${tokenInfo.maxTokens.toLocaleString()})`;
|
|
166
|
-
}
|
|
167
|
-
markdown += '*\n';
|
|
234
|
+
// Markdown format (full or compact)
|
|
235
|
+
const markdown = params.outputMode === OutputMode.COMPACT
|
|
236
|
+
? formatArticleAsCompact(article, tokenInfo)
|
|
237
|
+
: formatArticleAsMarkdown(article, tokenInfo, sections, {
|
|
238
|
+
section: params.section,
|
|
239
|
+
includeRelated: params.includeRelated
|
|
240
|
+
});
|
|
241
|
+
await reportProgress(extra, 100, 100);
|
|
168
242
|
return {
|
|
169
243
|
content: [{
|
|
170
244
|
type: 'text',
|
|
171
245
|
text: markdown
|
|
172
|
-
}]
|
|
246
|
+
}],
|
|
247
|
+
structuredContent
|
|
173
248
|
};
|
|
174
249
|
}
|
|
175
250
|
catch (error) {
|
|
176
|
-
const errorMessage = error
|
|
251
|
+
const errorMessage = getSafeErrorMessage(error);
|
|
177
252
|
// Provide helpful error messages
|
|
178
253
|
let helpText = '';
|
|
179
254
|
if (errorMessage.includes('404')) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-article.js","sourceRoot":"","sources":["../../src/tools/get-article.ts"],"names":[],"mappings":"AAAA;;;GAGG;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AK,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;YACtC,OAAO;gBACL,OAAO,EAAE,CAAC;wBACR,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,QAAQ;qBACf,CAAC;gBACF,iBAAiB;aAClB,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,YAAY,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;YAEhD,iCAAiC;YACjC,IAAI,QAAQ,GAAG,EAAE,CAAC;YAClB,IAAI,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBACjC,QAAQ,GAAG,gHAAgH,CAAC;YAC9H,CAAC;iBAAM,IAAI,YAAY,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;gBAC/C,QAAQ,GAAG,yCAAyC,CAAC;YACvD,CAAC;YAED,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,CAAC;wBACR,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,2BAA2B,YAAY,GAAG,QAAQ,EAAE;qBAC3D,CAAC;aACH,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/dist/tools/get-toc.d.ts
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* jamf_docs_get_toc tool
|
|
3
3
|
* Get the table of contents for a Jamf product's documentation.
|
|
4
4
|
*/
|
|
5
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
6
6
|
export declare function registerGetTocTool(server: McpServer): void;
|
|
7
7
|
//# sourceMappingURL=get-toc.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-toc.d.ts","sourceRoot":"","sources":["../../src/tools/get-toc.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"get-toc.d.ts","sourceRoot":"","sources":["../../src/tools/get-toc.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAmJzE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA2H1D"}
|
package/dist/tools/get-toc.js
CHANGED
|
@@ -3,8 +3,75 @@
|
|
|
3
3
|
* Get the table of contents for a Jamf product's documentation.
|
|
4
4
|
*/
|
|
5
5
|
import { GetTocInputSchema } from '../schemas/index.js';
|
|
6
|
-
import {
|
|
6
|
+
import { reportProgress } from '../utils/progress.js';
|
|
7
|
+
import { TocOutputSchema } from '../schemas/output.js';
|
|
8
|
+
import { ResponseFormat, OutputMode, JAMF_PRODUCTS, TOKEN_CONFIG } from '../constants.js';
|
|
7
9
|
import { fetchTableOfContents } from '../services/scraper.js';
|
|
10
|
+
import { getAvailableVersions } from '../services/metadata.js';
|
|
11
|
+
import { sanitizeMarkdownText, sanitizeMarkdownUrl, getSafeErrorMessage } from '../utils/sanitize.js';
|
|
12
|
+
/**
|
|
13
|
+
* Render a single TOC entry as markdown
|
|
14
|
+
*/
|
|
15
|
+
function renderTocEntry(entry, depth = 0, compact = false) {
|
|
16
|
+
const indent = ' '.repeat(depth);
|
|
17
|
+
let result = `${indent}- [${sanitizeMarkdownText(entry.title)}](${sanitizeMarkdownUrl(entry.url)})\n`;
|
|
18
|
+
if (!compact && entry.children !== undefined && entry.children.length > 0) {
|
|
19
|
+
for (const child of entry.children) {
|
|
20
|
+
result += renderTocEntry(child, depth + 1, compact);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Format TOC as compact markdown
|
|
27
|
+
*/
|
|
28
|
+
function formatTocCompact(productName, toc, pagination) {
|
|
29
|
+
let markdown = `## ${productName} TOC (${pagination.totalItems} entries)\n\n`;
|
|
30
|
+
for (const entry of toc) {
|
|
31
|
+
markdown += renderTocEntry(entry, 0, true);
|
|
32
|
+
}
|
|
33
|
+
markdown += `\n---\n*Page ${pagination.page}/${pagination.totalPages}`;
|
|
34
|
+
if (pagination.hasNext) {
|
|
35
|
+
markdown += ` | page=${pagination.page + 1} for more`;
|
|
36
|
+
}
|
|
37
|
+
markdown += '*\n';
|
|
38
|
+
return markdown;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Format TOC as full markdown
|
|
42
|
+
*/
|
|
43
|
+
function formatTocFull(productName, version, toc, pagination, tokenInfo) {
|
|
44
|
+
let markdown = `# ${productName} Documentation\n\n`;
|
|
45
|
+
markdown += `**Version**: ${version} | **Page ${pagination.page} of ${pagination.totalPages}** | ${tokenInfo.tokenCount.toLocaleString()} tokens\n\n`;
|
|
46
|
+
markdown += '---\n\n';
|
|
47
|
+
markdown += '## Table of Contents\n\n';
|
|
48
|
+
for (const entry of toc) {
|
|
49
|
+
markdown += renderTocEntry(entry);
|
|
50
|
+
}
|
|
51
|
+
markdown += '\n---\n\n';
|
|
52
|
+
markdown += `**Page ${pagination.page} of ${pagination.totalPages}** (${tokenInfo.tokenCount.toLocaleString()} tokens, ${pagination.totalItems} total entries)`;
|
|
53
|
+
if (pagination.hasNext) {
|
|
54
|
+
markdown += ` | Use \`page=${pagination.page + 1}\` for more`;
|
|
55
|
+
}
|
|
56
|
+
if (tokenInfo.truncated) {
|
|
57
|
+
markdown += '\n*TOC truncated due to token limit. Use `page` parameter or increase `maxTokens`.*';
|
|
58
|
+
}
|
|
59
|
+
markdown += '\n\n*Use `jamf_docs_get_article` with any URL above to read the full content.*\n';
|
|
60
|
+
return markdown;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Flatten nested TOC entries into a flat list
|
|
64
|
+
*/
|
|
65
|
+
function flattenTocEntries(entries) {
|
|
66
|
+
const flat = [];
|
|
67
|
+
for (const entry of entries) {
|
|
68
|
+
flat.push({ title: entry.title, url: entry.url });
|
|
69
|
+
if (entry.children !== undefined && entry.children.length > 0) {
|
|
70
|
+
flat.push(...flattenTocEntries(entry.children));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return flat;
|
|
74
|
+
}
|
|
8
75
|
const TOOL_NAME = 'jamf_docs_get_toc';
|
|
9
76
|
const TOOL_DESCRIPTION = `Get the table of contents for a Jamf product's documentation.
|
|
10
77
|
|
|
@@ -16,6 +83,7 @@ Args:
|
|
|
16
83
|
- version (string, optional): Specific version (defaults to latest)
|
|
17
84
|
- page (number, optional): Page number for pagination 1-100 (default: 1)
|
|
18
85
|
- maxTokens (number, optional): Maximum tokens in response 100-20000 (default: 5000)
|
|
86
|
+
- outputMode ('full' | 'compact'): Output detail level (default: 'full'). Use 'compact' for flat list without nested children
|
|
19
87
|
- responseFormat ('markdown' | 'json'): Output format (default: 'markdown')
|
|
20
88
|
|
|
21
89
|
Returns:
|
|
@@ -58,13 +126,14 @@ export function registerGetTocTool(server) {
|
|
|
58
126
|
title: 'Get Documentation Table of Contents',
|
|
59
127
|
description: TOOL_DESCRIPTION,
|
|
60
128
|
inputSchema: GetTocInputSchema,
|
|
129
|
+
outputSchema: TocOutputSchema,
|
|
61
130
|
annotations: {
|
|
62
131
|
readOnlyHint: true,
|
|
63
132
|
destructiveHint: false,
|
|
64
133
|
idempotentHint: true,
|
|
65
134
|
openWorldHint: true
|
|
66
135
|
}
|
|
67
|
-
}, async (args) => {
|
|
136
|
+
}, async (args, extra) => {
|
|
68
137
|
// Parse and validate input
|
|
69
138
|
const parseResult = GetTocInputSchema.safeParse(args);
|
|
70
139
|
if (!parseResult.success) {
|
|
@@ -87,22 +156,27 @@ export function registerGetTocTool(server) {
|
|
|
87
156
|
}
|
|
88
157
|
const productId = params.product;
|
|
89
158
|
const productInfo = JAMF_PRODUCTS[productId];
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
159
|
+
// Get available versions dynamically
|
|
160
|
+
const availableVersions = await getAvailableVersions(productId);
|
|
161
|
+
const version = params.version ?? 'current';
|
|
162
|
+
// Validate version if specified
|
|
163
|
+
if (params.version !== undefined && params.version !== '' && params.version !== 'current') {
|
|
164
|
+
if (availableVersions.length > 0 && !availableVersions.includes(params.version)) {
|
|
165
|
+
return {
|
|
166
|
+
isError: true,
|
|
167
|
+
content: [{
|
|
168
|
+
type: 'text',
|
|
169
|
+
text: `Version "${params.version}" not found for ${productInfo.name}.\n\nAvailable versions: ${availableVersions.length > 0 ? availableVersions.join(', ') : 'current'}`
|
|
170
|
+
}]
|
|
171
|
+
};
|
|
172
|
+
}
|
|
100
173
|
}
|
|
101
|
-
|
|
174
|
+
await reportProgress(extra, 0, 100);
|
|
102
175
|
const tocResult = await fetchTableOfContents(productId, version, {
|
|
103
176
|
...(params.page !== undefined && { page: params.page }),
|
|
104
177
|
maxTokens: params.maxTokens ?? TOKEN_CONFIG.DEFAULT_MAX_TOKENS
|
|
105
178
|
});
|
|
179
|
+
await reportProgress(extra, 50, 100);
|
|
106
180
|
const { toc, pagination, tokenInfo } = tocResult;
|
|
107
181
|
// Build response
|
|
108
182
|
const response = {
|
|
@@ -112,58 +186,44 @@ export function registerGetTocTool(server) {
|
|
|
112
186
|
tokenInfo,
|
|
113
187
|
pagination
|
|
114
188
|
};
|
|
115
|
-
|
|
189
|
+
const structuredContent = {
|
|
190
|
+
product: productInfo.name,
|
|
191
|
+
version,
|
|
192
|
+
totalEntries: pagination.totalItems,
|
|
193
|
+
page: pagination.page,
|
|
194
|
+
totalPages: pagination.totalPages,
|
|
195
|
+
hasMore: pagination.hasNext,
|
|
196
|
+
entries: flattenTocEntries(toc)
|
|
197
|
+
};
|
|
116
198
|
if (params.responseFormat === ResponseFormat.JSON) {
|
|
199
|
+
await reportProgress(extra, 100, 100);
|
|
117
200
|
return {
|
|
118
201
|
content: [{
|
|
119
202
|
type: 'text',
|
|
120
203
|
text: JSON.stringify(response, null, 2)
|
|
121
|
-
}]
|
|
204
|
+
}],
|
|
205
|
+
structuredContent
|
|
122
206
|
};
|
|
123
207
|
}
|
|
124
|
-
//
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
// Recursive function to render TOC
|
|
130
|
-
function renderTocEntry(entry, depth = 0) {
|
|
131
|
-
const indent = ' '.repeat(depth);
|
|
132
|
-
let result = `${indent}- [${entry.title}](${entry.url})\n`;
|
|
133
|
-
if (entry.children && entry.children.length > 0) {
|
|
134
|
-
for (const child of entry.children) {
|
|
135
|
-
result += renderTocEntry(child, depth + 1);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return result;
|
|
139
|
-
}
|
|
140
|
-
for (const entry of toc) {
|
|
141
|
-
markdown += renderTocEntry(entry);
|
|
142
|
-
}
|
|
143
|
-
// Pagination footer
|
|
144
|
-
markdown += '\n---\n\n';
|
|
145
|
-
markdown += `**Page ${pagination.page} of ${pagination.totalPages}** (${tokenInfo.tokenCount.toLocaleString()} tokens, ${pagination.totalItems} total entries)`;
|
|
146
|
-
if (pagination.hasNext) {
|
|
147
|
-
markdown += ` | Use \`page=${pagination.page + 1}\` for more`;
|
|
148
|
-
}
|
|
149
|
-
if (tokenInfo.truncated) {
|
|
150
|
-
markdown += '\n*TOC truncated due to token limit. Use `page` parameter or increase `maxTokens`.*';
|
|
151
|
-
}
|
|
152
|
-
markdown += '\n\n*Use `jamf_docs_get_article` with any URL above to read the full content.*\n';
|
|
208
|
+
// Format as markdown (compact or full)
|
|
209
|
+
const markdown = params.outputMode === OutputMode.COMPACT
|
|
210
|
+
? formatTocCompact(productInfo.name, toc, pagination)
|
|
211
|
+
: formatTocFull(productInfo.name, version, toc, pagination, tokenInfo);
|
|
212
|
+
await reportProgress(extra, 100, 100);
|
|
153
213
|
return {
|
|
154
214
|
content: [{
|
|
155
215
|
type: 'text',
|
|
156
216
|
text: markdown
|
|
157
|
-
}]
|
|
217
|
+
}],
|
|
218
|
+
structuredContent
|
|
158
219
|
};
|
|
159
220
|
}
|
|
160
221
|
catch (error) {
|
|
161
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
162
222
|
return {
|
|
163
223
|
isError: true,
|
|
164
224
|
content: [{
|
|
165
225
|
type: 'text',
|
|
166
|
-
text: `Error fetching table of contents: ${
|
|
226
|
+
text: `Error fetching table of contents: ${getSafeErrorMessage(error)}`
|
|
167
227
|
}]
|
|
168
228
|
};
|
|
169
229
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-toc.js","sourceRoot":"","sources":["../../src/tools/get-toc.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"get-toc.js","sourceRoot":"","sources":["../../src/tools/get-toc.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE1F,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEtG;;GAEG;AACH,SAAS,cAAc,CAAC,KAAe,EAAE,KAAK,GAAG,CAAC,EAAE,OAAO,GAAG,KAAK;IACjE,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAClC,IAAI,MAAM,GAAG,GA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,EAAE,CAAC;wBACR,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,QAAQ;qBACf,CAAC;gBACF,iBAAiB;aAClB,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,CAAC;wBACR,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,qCAAqC,mBAAmB,CAAC,KAAK,CAAC,EAAE;qBACxE,CAAC;aACH,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* jamf_docs_list_products tool
|
|
3
3
|
* Lists all available Jamf products and their documentation versions.
|
|
4
4
|
*/
|
|
5
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
6
6
|
export declare function registerListProductsTool(server: McpServer): void;
|
|
7
7
|
//# sourceMappingURL=list-products.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-products.d.ts","sourceRoot":"","sources":["../../src/tools/list-products.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"list-products.d.ts","sourceRoot":"","sources":["../../src/tools/list-products.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA2CzE,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAuIhE"}
|