@get-technology-inc/jamf-docs-mcp-server 0.0.1 → 1.0.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/LICENSE +21 -0
- package/README.md +189 -29
- package/dist/constants.d.ts +260 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +303 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas/index.d.ts +98 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +110 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/services/cache.d.ts +56 -0
- package/dist/services/cache.d.ts.map +1 -0
- package/dist/services/cache.js +189 -0
- package/dist/services/cache.js.map +1 -0
- package/dist/services/scraper.d.ts +62 -0
- package/dist/services/scraper.d.ts.map +1 -0
- package/dist/services/scraper.js +568 -0
- package/dist/services/scraper.js.map +1 -0
- package/dist/services/tokenizer.d.ts +77 -0
- package/dist/services/tokenizer.d.ts.map +1 -0
- package/dist/services/tokenizer.js +274 -0
- package/dist/services/tokenizer.js.map +1 -0
- package/dist/tools/get-article.d.ts +7 -0
- package/dist/tools/get-article.d.ts.map +1 -0
- package/dist/tools/get-article.js +195 -0
- package/dist/tools/get-article.js.map +1 -0
- package/dist/tools/get-toc.d.ts +7 -0
- package/dist/tools/get-toc.d.ts.map +1 -0
- package/dist/tools/get-toc.js +172 -0
- package/dist/tools/get-toc.js.map +1 -0
- package/dist/tools/list-products.d.ts +7 -0
- package/dist/tools/list-products.d.ts.map +1 -0
- package/dist/tools/list-products.js +132 -0
- package/dist/tools/list-products.js.map +1 -0
- package/dist/tools/search.d.ts +7 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/search.js +212 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/types.d.ts +197 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +28 -0
- package/dist/types.js.map +1 -0
- package/package.json +68 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokenizer.d.ts","sourceRoot":"","sources":["../../src/services/tokenizer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,SAAS,CAAC;IACrB,iBAAiB,CAAC,EAAE,cAAc,EAAE,CAAC;CACtC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/B,SAAS,EAAE,SAAS,CAAC;CACtB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAgBnD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,SAAS,GAAE,OAAe,GACzB,SAAS,CAMX;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,EAAE,CAiDjE;AAYD;;GAEG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,iBAAiB,EAAE,MAAM,EACzB,SAAS,GAAE,MAAwC,GAClD,oBAAoB,CAyDtB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,SAAS,GAAE,MAAwC,GAClD,cAAc,CAiFhB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GACf;IACD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAcA;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,EACzC,KAAK,EAAE,CAAC,EAAE,EACV,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,EACjC,IAAI,GAAE,MAAU,EAChB,QAAQ,GAAE,MAAW,GACpB;IACD,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE;QACV,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,OAAO,CAAC;QACjB,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;CACH,CAsCA"}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tokenizer service for Context7-style token management
|
|
3
|
+
*
|
|
4
|
+
* Provides token estimation, smart truncation, and section extraction
|
|
5
|
+
* for controlling response size in LLM contexts.
|
|
6
|
+
*/
|
|
7
|
+
import { TOKEN_CONFIG } from '../constants.js';
|
|
8
|
+
/**
|
|
9
|
+
* Estimate token count for a text string
|
|
10
|
+
* Uses different ratios for code blocks vs normal text
|
|
11
|
+
*/
|
|
12
|
+
export function estimateTokens(text) {
|
|
13
|
+
if (!text) {
|
|
14
|
+
return 0;
|
|
15
|
+
}
|
|
16
|
+
// Split content into code blocks and regular text
|
|
17
|
+
const codeBlockRegex = /```[\s\S]*?```/g;
|
|
18
|
+
const codeBlocks = text.match(codeBlockRegex) || [];
|
|
19
|
+
const regularText = text.replace(codeBlockRegex, '');
|
|
20
|
+
// Calculate tokens for each type
|
|
21
|
+
const codeTokens = codeBlocks.reduce((sum, block) => {
|
|
22
|
+
return sum + Math.ceil(block.length / TOKEN_CONFIG.CODE_CHARS_PER_TOKEN);
|
|
23
|
+
}, 0);
|
|
24
|
+
const textTokens = Math.ceil(regularText.length / TOKEN_CONFIG.CHARS_PER_TOKEN);
|
|
25
|
+
return codeTokens + textTokens;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Create a TokenInfo object
|
|
29
|
+
*/
|
|
30
|
+
export function createTokenInfo(content, maxTokens, truncated = false) {
|
|
31
|
+
return {
|
|
32
|
+
tokenCount: estimateTokens(content),
|
|
33
|
+
truncated,
|
|
34
|
+
maxTokens
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Extract sections (headings) from Markdown content
|
|
39
|
+
*/
|
|
40
|
+
export function extractSections(content) {
|
|
41
|
+
const sections = [];
|
|
42
|
+
const lines = content.split('\n');
|
|
43
|
+
let currentSection = null;
|
|
44
|
+
let sectionContent = '';
|
|
45
|
+
for (let i = 0; i < lines.length; i++) {
|
|
46
|
+
const line = lines[i] ?? '';
|
|
47
|
+
const headingMatch = line.match(/^(#{1,6})\s+(.+)$/);
|
|
48
|
+
if (headingMatch) {
|
|
49
|
+
// Save previous section
|
|
50
|
+
if (currentSection) {
|
|
51
|
+
const id = generateSectionId(currentSection.title);
|
|
52
|
+
sections.push({
|
|
53
|
+
id,
|
|
54
|
+
title: currentSection.title,
|
|
55
|
+
level: currentSection.level,
|
|
56
|
+
tokenCount: estimateTokens(sectionContent)
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
// Start new section
|
|
60
|
+
const title = headingMatch[2]?.trim() ?? '';
|
|
61
|
+
const level = headingMatch[1]?.length ?? 1;
|
|
62
|
+
currentSection = {
|
|
63
|
+
title,
|
|
64
|
+
level,
|
|
65
|
+
startLine: i
|
|
66
|
+
};
|
|
67
|
+
sectionContent = line + '\n';
|
|
68
|
+
}
|
|
69
|
+
else if (currentSection) {
|
|
70
|
+
sectionContent += line + '\n';
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Don't forget the last section
|
|
74
|
+
if (currentSection) {
|
|
75
|
+
const id = generateSectionId(currentSection.title);
|
|
76
|
+
sections.push({
|
|
77
|
+
id,
|
|
78
|
+
title: currentSection.title,
|
|
79
|
+
level: currentSection.level,
|
|
80
|
+
tokenCount: estimateTokens(sectionContent)
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return sections;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Generate a section ID from title
|
|
87
|
+
*/
|
|
88
|
+
function generateSectionId(title) {
|
|
89
|
+
return title
|
|
90
|
+
.toLowerCase()
|
|
91
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
92
|
+
.replace(/^-|-$/g, '');
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Extract a specific section from Markdown content
|
|
96
|
+
*/
|
|
97
|
+
export function extractSection(content, sectionIdentifier, maxTokens = TOKEN_CONFIG.DEFAULT_MAX_TOKENS) {
|
|
98
|
+
const lines = content.split('\n');
|
|
99
|
+
const normalizedId = generateSectionId(sectionIdentifier);
|
|
100
|
+
let inTargetSection = false;
|
|
101
|
+
let targetLevel = 0;
|
|
102
|
+
const sectionLines = [];
|
|
103
|
+
let foundSection = null;
|
|
104
|
+
for (let i = 0; i < lines.length; i++) {
|
|
105
|
+
const line = lines[i] ?? '';
|
|
106
|
+
const headingMatch = line.match(/^(#{1,6})\s+(.+)$/);
|
|
107
|
+
if (headingMatch) {
|
|
108
|
+
const level = headingMatch[1]?.length ?? 1;
|
|
109
|
+
const title = headingMatch[2]?.trim() ?? '';
|
|
110
|
+
const id = generateSectionId(title);
|
|
111
|
+
if (inTargetSection) {
|
|
112
|
+
// Check if we've reached a heading at the same or higher level
|
|
113
|
+
if (level <= targetLevel) {
|
|
114
|
+
break; // End of target section
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// Check if this is the target section
|
|
118
|
+
if (id === normalizedId || title.toLowerCase().includes(sectionIdentifier.toLowerCase())) {
|
|
119
|
+
inTargetSection = true;
|
|
120
|
+
targetLevel = level;
|
|
121
|
+
foundSection = {
|
|
122
|
+
id,
|
|
123
|
+
title,
|
|
124
|
+
level,
|
|
125
|
+
tokenCount: 0 // Will be calculated later
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (inTargetSection) {
|
|
130
|
+
sectionLines.push(line);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const sectionContent = sectionLines.join('\n');
|
|
134
|
+
// Apply token limit with smart truncation
|
|
135
|
+
const truncateResult = truncateToTokenLimit(sectionContent, maxTokens);
|
|
136
|
+
if (foundSection) {
|
|
137
|
+
foundSection.tokenCount = truncateResult.tokenInfo.tokenCount;
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
content: truncateResult.content,
|
|
141
|
+
section: foundSection,
|
|
142
|
+
tokenInfo: truncateResult.tokenInfo
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Smart truncation that preserves document structure
|
|
147
|
+
* - Preserves paragraph boundaries
|
|
148
|
+
* - Correctly closes code blocks
|
|
149
|
+
* - Lists remaining sections when truncated
|
|
150
|
+
*/
|
|
151
|
+
export function truncateToTokenLimit(content, maxTokens = TOKEN_CONFIG.DEFAULT_MAX_TOKENS) {
|
|
152
|
+
const currentTokens = estimateTokens(content);
|
|
153
|
+
// If within limit, return as-is
|
|
154
|
+
if (currentTokens <= maxTokens) {
|
|
155
|
+
return {
|
|
156
|
+
content,
|
|
157
|
+
tokenInfo: {
|
|
158
|
+
tokenCount: currentTokens,
|
|
159
|
+
truncated: false,
|
|
160
|
+
maxTokens
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
// Extract all sections before truncation
|
|
165
|
+
const allSections = extractSections(content);
|
|
166
|
+
// Smart truncation
|
|
167
|
+
const lines = content.split('\n');
|
|
168
|
+
const truncatedLines = [];
|
|
169
|
+
let runningTokens = 0;
|
|
170
|
+
let inCodeBlock = false;
|
|
171
|
+
// Reserve tokens for truncation notice and remaining sections list
|
|
172
|
+
const reservedTokens = Math.min(500, Math.floor(maxTokens * 0.1));
|
|
173
|
+
const effectiveMax = maxTokens - reservedTokens;
|
|
174
|
+
for (const line of lines) {
|
|
175
|
+
// Track code blocks
|
|
176
|
+
if (line.startsWith('```')) {
|
|
177
|
+
inCodeBlock = !inCodeBlock;
|
|
178
|
+
}
|
|
179
|
+
const lineTokens = estimateTokens(line + '\n');
|
|
180
|
+
if (runningTokens + lineTokens > effectiveMax) {
|
|
181
|
+
// Close any open code block
|
|
182
|
+
if (inCodeBlock) {
|
|
183
|
+
truncatedLines.push('```');
|
|
184
|
+
}
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
truncatedLines.push(line);
|
|
188
|
+
runningTokens += lineTokens;
|
|
189
|
+
}
|
|
190
|
+
// Find remaining sections (sections not fully included)
|
|
191
|
+
const truncatedContent = truncatedLines.join('\n');
|
|
192
|
+
const includedSections = extractSections(truncatedContent);
|
|
193
|
+
const includedIds = new Set(includedSections.map(s => s.id));
|
|
194
|
+
const remainingSections = allSections.filter(s => !includedIds.has(s.id));
|
|
195
|
+
// Build truncation notice
|
|
196
|
+
let notice = '\n\n---\n\n*[Content truncated due to token limit]*\n';
|
|
197
|
+
if (remainingSections.length > 0) {
|
|
198
|
+
notice += '\n**Remaining sections:**\n';
|
|
199
|
+
for (const section of remainingSections.slice(0, 10)) {
|
|
200
|
+
const indent = ' '.repeat(Math.max(0, section.level - 1));
|
|
201
|
+
notice += `${indent}- ${section.title} (~${section.tokenCount} tokens)\n`;
|
|
202
|
+
}
|
|
203
|
+
if (remainingSections.length > 10) {
|
|
204
|
+
notice += `\n*...and ${remainingSections.length - 10} more sections*\n`;
|
|
205
|
+
}
|
|
206
|
+
notice += '\n*Use the `section` parameter to retrieve specific sections.*';
|
|
207
|
+
}
|
|
208
|
+
const finalContent = truncatedContent + notice;
|
|
209
|
+
return {
|
|
210
|
+
content: finalContent,
|
|
211
|
+
tokenInfo: {
|
|
212
|
+
tokenCount: estimateTokens(finalContent),
|
|
213
|
+
truncated: true,
|
|
214
|
+
maxTokens
|
|
215
|
+
},
|
|
216
|
+
remainingSections
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Calculate pagination info
|
|
221
|
+
*/
|
|
222
|
+
export function calculatePagination(totalItems, page, pageSize) {
|
|
223
|
+
const totalPages = Math.ceil(totalItems / pageSize);
|
|
224
|
+
const normalizedPage = Math.min(Math.max(1, page), totalPages || 1);
|
|
225
|
+
return {
|
|
226
|
+
page: normalizedPage,
|
|
227
|
+
pageSize,
|
|
228
|
+
totalPages,
|
|
229
|
+
totalItems,
|
|
230
|
+
hasNext: normalizedPage < totalPages,
|
|
231
|
+
hasPrev: normalizedPage > 1,
|
|
232
|
+
startIndex: (normalizedPage - 1) * pageSize,
|
|
233
|
+
endIndex: Math.min(normalizedPage * pageSize, totalItems)
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Truncate an array of items to fit within token limit
|
|
238
|
+
* Returns items that fit and pagination info
|
|
239
|
+
*/
|
|
240
|
+
export function truncateItemsToTokenLimit(items, maxTokens, itemToString, page = 1, pageSize = 10) {
|
|
241
|
+
const pagination = calculatePagination(items.length, page, pageSize);
|
|
242
|
+
const pageItems = items.slice(pagination.startIndex, pagination.endIndex);
|
|
243
|
+
// Check if page items fit in token limit
|
|
244
|
+
const includedItems = [];
|
|
245
|
+
let runningTokens = 0;
|
|
246
|
+
let truncated = false;
|
|
247
|
+
for (const item of pageItems) {
|
|
248
|
+
const itemString = itemToString(item);
|
|
249
|
+
const itemTokens = estimateTokens(itemString);
|
|
250
|
+
if (runningTokens + itemTokens > maxTokens) {
|
|
251
|
+
truncated = true;
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
includedItems.push(item);
|
|
255
|
+
runningTokens += itemTokens;
|
|
256
|
+
}
|
|
257
|
+
return {
|
|
258
|
+
items: includedItems,
|
|
259
|
+
tokenInfo: {
|
|
260
|
+
tokenCount: runningTokens,
|
|
261
|
+
truncated,
|
|
262
|
+
maxTokens
|
|
263
|
+
},
|
|
264
|
+
pagination: {
|
|
265
|
+
page: pagination.page,
|
|
266
|
+
pageSize: pagination.pageSize,
|
|
267
|
+
totalPages: pagination.totalPages,
|
|
268
|
+
totalItems: pagination.totalItems,
|
|
269
|
+
hasNext: pagination.hasNext || truncated,
|
|
270
|
+
hasPrev: pagination.hasPrev
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
//# sourceMappingURL=tokenizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokenizer.js","sourceRoot":"","sources":["../../src/services/tokenizer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAqB/C;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,IAAI,CAAC,IAAI,EAAE,CAAC;QAAA,OAAO,CAAC,CAAC;IAAA,CAAC;IAEtB,kDAAkD;IAClD,MAAM,cAAc,GAAG,iBAAiB,CAAC;IACzC,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;IACpD,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;IAErD,iCAAiC;IACjC,MAAM,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QAClD,OAAO,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,YAAY,CAAC,oBAAoB,CAAC,CAAC;IAC3E,CAAC,EAAE,CA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;IAE1E,yCAAyC;IACzC,MAAM,aAAa,GAAQ,EAAE,CAAC;IAC9B,IAAI,aAAa,GAAG,CAAC,CAAC;IACtB,IAAI,SAAS,GAAG,KAAK,CAAC;IAEtB,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;QAC7B,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;QACtC,MAAM,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;QAE9C,IAAI,aAAa,GAAG,UAAU,GAAG,SAAS,EAAE,CAAC;YAC3C,SAAS,GAAG,IAAI,CAAC;YACjB,MAAM;QACR,CAAC;QAED,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzB,aAAa,IAAI,UAAU,CAAC;IAC9B,CAAC;IAED,OAAO;QACL,KAAK,EAAE,aAAa;QACpB,SAAS,EAAE;YACT,UAAU,EAAE,aAAa;YACzB,SAAS;YACT,SAAS;SACV;QACD,UAAU,EAAE;YACV,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,QAAQ,EAAE,UAAU,CAAC,QAAQ;YAC7B,UAAU,EAAE,UAAU,CAAC,UAAU;YACjC,UAAU,EAAE,UAAU,CAAC,UAAU;YACjC,OAAO,EAAE,UAAU,CAAC,OAAO,IAAI,SAAS;YACxC,OAAO,EAAE,UAAU,CAAC,OAAO;SAC5B;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* jamf_docs_get_article tool
|
|
3
|
+
* Retrieve the full content of a specific Jamf documentation article.
|
|
4
|
+
*/
|
|
5
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
6
|
+
export declare function registerGetArticleTool(server: McpServer): void;
|
|
7
|
+
//# sourceMappingURL=get-article.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-article.d.ts","sourceRoot":"","sources":["../../src/tools/get-article.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA6DpE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAiJ9D"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* jamf_docs_get_article tool
|
|
3
|
+
* Retrieve the full content of a specific Jamf documentation article.
|
|
4
|
+
*/
|
|
5
|
+
import { GetArticleInputSchema } from '../schemas/index.js';
|
|
6
|
+
import { ResponseFormat, TOKEN_CONFIG } from '../constants.js';
|
|
7
|
+
import { fetchArticle } from '../services/scraper.js';
|
|
8
|
+
const TOOL_NAME = 'jamf_docs_get_article';
|
|
9
|
+
const TOOL_DESCRIPTION = `Retrieve the full content of a specific Jamf documentation article.
|
|
10
|
+
|
|
11
|
+
This tool fetches and parses a Jamf documentation article, converting it to
|
|
12
|
+
a clean, readable format. Works with any article from docs.jamf.com or learn.jamf.com.
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
- url (string, required): Full URL of the article (must be from docs.jamf.com or learn.jamf.com)
|
|
16
|
+
- section (string, optional): Extract only a specific section by title or ID (e.g., "Prerequisites", "Configuration")
|
|
17
|
+
- includeRelated (boolean, optional): Include links to related articles (default: false)
|
|
18
|
+
- maxTokens (number, optional): Maximum tokens in response 100-20000 (default: 5000)
|
|
19
|
+
- responseFormat ('markdown' | 'json'): Output format (default: 'markdown')
|
|
20
|
+
|
|
21
|
+
Returns:
|
|
22
|
+
For JSON format:
|
|
23
|
+
{
|
|
24
|
+
"title": string,
|
|
25
|
+
"content": string,
|
|
26
|
+
"url": string,
|
|
27
|
+
"product": string,
|
|
28
|
+
"version": string,
|
|
29
|
+
"breadcrumb": string[],
|
|
30
|
+
"relatedArticles": [...],
|
|
31
|
+
"tokenInfo": {
|
|
32
|
+
"tokenCount": number,
|
|
33
|
+
"truncated": boolean,
|
|
34
|
+
"maxTokens": number
|
|
35
|
+
},
|
|
36
|
+
"sections": [
|
|
37
|
+
{
|
|
38
|
+
"id": string,
|
|
39
|
+
"title": string,
|
|
40
|
+
"level": number,
|
|
41
|
+
"tokenCount": number
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
For Markdown format:
|
|
47
|
+
The article content with token info and available sections.
|
|
48
|
+
|
|
49
|
+
Examples:
|
|
50
|
+
- Get full article: url="https://learn.jamf.com/en-US/bundle/jamf-pro-documentation/page/Configuration_Profiles.html"
|
|
51
|
+
- Get specific section: url="...", section="Prerequisites"
|
|
52
|
+
- Limit response size: url="...", maxTokens=2000
|
|
53
|
+
|
|
54
|
+
Errors:
|
|
55
|
+
- "Article not found (404)" if the URL returns a 404 error
|
|
56
|
+
- "Invalid URL" if the URL is not from docs.jamf.com or learn.jamf.com
|
|
57
|
+
- "Section not found" if the specified section doesn't exist (will list available sections)
|
|
58
|
+
|
|
59
|
+
Note: Large articles are intelligently truncated with remaining sections listed.
|
|
60
|
+
Use the \`section\` parameter to retrieve specific sections for long articles.`;
|
|
61
|
+
export function registerGetArticleTool(server) {
|
|
62
|
+
server.registerTool(TOOL_NAME, {
|
|
63
|
+
title: 'Get Jamf Documentation Article',
|
|
64
|
+
description: TOOL_DESCRIPTION,
|
|
65
|
+
inputSchema: GetArticleInputSchema,
|
|
66
|
+
annotations: {
|
|
67
|
+
readOnlyHint: true,
|
|
68
|
+
destructiveHint: false,
|
|
69
|
+
idempotentHint: true,
|
|
70
|
+
openWorldHint: true
|
|
71
|
+
}
|
|
72
|
+
}, async (args) => {
|
|
73
|
+
// Parse and validate input
|
|
74
|
+
const parseResult = GetArticleInputSchema.safeParse(args);
|
|
75
|
+
if (!parseResult.success) {
|
|
76
|
+
return {
|
|
77
|
+
isError: true,
|
|
78
|
+
content: [{ type: 'text', text: `Invalid input: ${parseResult.error.message}` }]
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const params = parseResult.data;
|
|
82
|
+
try {
|
|
83
|
+
// Fetch and parse the article with new options
|
|
84
|
+
const article = await fetchArticle(params.url, {
|
|
85
|
+
includeRelated: params.includeRelated,
|
|
86
|
+
...(params.section && { section: params.section }),
|
|
87
|
+
maxTokens: params.maxTokens ?? TOKEN_CONFIG.DEFAULT_MAX_TOKENS
|
|
88
|
+
});
|
|
89
|
+
const { tokenInfo, sections } = article;
|
|
90
|
+
// Build response
|
|
91
|
+
const response = {
|
|
92
|
+
...article,
|
|
93
|
+
format: params.responseFormat,
|
|
94
|
+
tokenInfo,
|
|
95
|
+
sections
|
|
96
|
+
};
|
|
97
|
+
// Format output
|
|
98
|
+
if (params.responseFormat === ResponseFormat.JSON) {
|
|
99
|
+
return {
|
|
100
|
+
content: [{
|
|
101
|
+
type: 'text',
|
|
102
|
+
text: JSON.stringify(response, null, 2)
|
|
103
|
+
}]
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
// Markdown format with Context7 style
|
|
107
|
+
let markdown = '';
|
|
108
|
+
// Breadcrumb
|
|
109
|
+
if (article.breadcrumb && article.breadcrumb.length > 0) {
|
|
110
|
+
markdown += `*${article.breadcrumb.join(' > ')}*\n\n`;
|
|
111
|
+
}
|
|
112
|
+
// Title with token info
|
|
113
|
+
markdown += `# ${article.title}\n\n`;
|
|
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';
|
|
168
|
+
return {
|
|
169
|
+
content: [{
|
|
170
|
+
type: 'text',
|
|
171
|
+
text: markdown
|
|
172
|
+
}]
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
177
|
+
// Provide helpful error messages
|
|
178
|
+
let helpText = '';
|
|
179
|
+
if (errorMessage.includes('404')) {
|
|
180
|
+
helpText = '\n\nThe article may have been moved or deleted. Try searching with `jamf_docs_search` to find the current URL.';
|
|
181
|
+
}
|
|
182
|
+
else if (errorMessage.includes('rate limit')) {
|
|
183
|
+
helpText = '\n\nPlease wait a moment and try again.';
|
|
184
|
+
}
|
|
185
|
+
return {
|
|
186
|
+
isError: true,
|
|
187
|
+
content: [{
|
|
188
|
+
type: 'text',
|
|
189
|
+
text: `Error fetching article: ${errorMessage}${helpText}`
|
|
190
|
+
}]
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=get-article.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-article.js","sourceRoot":"","sources":["../../src/tools/get-article.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,MAAM,SAAS,GAAG,uBAAuB,CAAC;AAE1C,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+EAmDsD,CAAC;AAEhF,MAAM,UAAU,sBAAsB,CAAC,MAAiB;IACtD,MAAM,CAAC,YAAY,CACjB,SAAS,EACT;QACE,KAAK,EAAE,gCAAgC;QACvC,WAAW,EAAE,gBAAgB;QAC7B,WAAW,EAAE,qBAAqB;QAClC,WAAW,EAAE;Y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
4
|
+
*/
|
|
5
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
6
|
+
export declare function registerGetTocTool(server: McpServer): void;
|
|
7
|
+
//# sourceMappingURL=get-toc.d.ts.map
|
|
@@ -0,0 +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;AAyDpE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAqI1D"}
|