@transcend-io/mcp-server-docs 0.4.18 → 0.5.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 CHANGED
@@ -70,7 +70,7 @@ See [CONTRIBUTING.md](../../../CONTRIBUTING.md#mcp-servers) for workspace layout
70
70
 
71
71
  ## Tools
72
72
 
73
- - `docs_list` — Browse the Transcend docs sections (`llms.txt`), list one section's articles with `section`, or full-text search titles and article bodies with `query` (ranked snippets; then `docs_fetch`)
73
+ - `docs_list` — Browse the Transcend docs sections (`llms.txt`), list one section's articles with `section`, or full-text search titles and article bodies with `query` (ranked snippets; then `docs_fetch`), find docs for an Admin Dashboard page with `route` (a route pattern, path, or app URL; then more docs for its product), or list one product's docs with `product`. `route` and `product` can each be combined with `query`
74
74
  - `docs_fetch` — Fetch full markdown for a docs article URL (host restricted to `docs.transcend.io`)
75
75
 
76
76
  ## Related packages
package/dist/cli.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import { t as getDocsTools } from "./tools-BMbaq7_0.mjs";
2
+ import { t as getDocsTools } from "./tools-dFh4jyRG.mjs";
3
3
  import { createMCPServer } from "@transcend-io/mcp-server-base";
4
4
  //#endregion
5
5
  //#region src/cli.ts
6
6
  createMCPServer({
7
7
  name: "transcend-mcp-docs",
8
- version: "0.4.18",
8
+ version: "0.5.0",
9
9
  requireStartupAuth: false,
10
10
  oauthScopes: [],
11
11
  getTools: getDocsTools
package/dist/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ToolClients, ToolDefinition, z } from "@transcend-io/mcp-server-base";
2
+ import { DocsProduct } from "@transcend-io/privacy-types";
2
3
 
3
4
  //#region src/docsIndex.d.ts
4
5
  /** Public docs index URL (llms.txt). */
@@ -44,7 +45,9 @@ interface DocsSearchHit {
44
45
  }
45
46
  /** Full-text search over hydrated docs (title, URL path, section, body). */
46
47
  declare function searchDocs(query: string, options?: {
47
- /** Optional llms.txt section name (exact match). */section?: string;
48
+ /** Optional llms.txt section name (exact match). */section?: string; /** Optional predicate on the hit URL, applied before the result cap. */
49
+ urlFilter?: (url: string) => boolean; /** Maximum hits to return. Defaults to the standard search limit. */
50
+ limit?: number;
48
51
  }): Promise<{
49
52
  /** Ranked hits for this page. */hits: DocsSearchHit[]; /** Total matches before the fixed page size. */
50
53
  totalCount: number;
@@ -61,6 +64,19 @@ type DocsFetchInput = z.infer<typeof DocsFetchSchema>;
61
64
  //#endregion
62
65
  //#region src/tools/docs_list.d.ts
63
66
  declare const DocsListSchema: z.ZodObject<{
67
+ route: z.ZodOptional<z.ZodString>;
68
+ product: z.ZodOptional<z.ZodPreprocess<z.ZodEnum<{
69
+ Assessments: "Assessments";
70
+ Classification: "Classification";
71
+ "Consent Management": "Consent Management";
72
+ "Data Inventory": "Data Inventory";
73
+ "DSR Automation": "DSR Automation";
74
+ Platform: "Platform";
75
+ "Preference Management": "Preference Management";
76
+ "Privacy Center": "Privacy Center";
77
+ "System Discovery": "System Discovery";
78
+ "Web Auditor": "Web Auditor";
79
+ }>, unknown>>;
64
80
  section: z.ZodOptional<z.ZodString>;
65
81
  query: z.ZodOptional<z.ZodString>;
66
82
  }, z.core.$strip>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/docsIndex.ts","../src/docsSearch.ts","../src/tools/index.ts","../src/tools/docs_fetch.ts","../src/tools/docs_list.ts"],"mappings":";;;;cAKa,YAAA;;cAGA,SAAA;;UASI,QAAA;EAZQ;EAcvB,OAAA;EAXW;EAaX,KAAA;;EAEA,GAAA;AAAA;AANF;;;;AAAA,iBAagB,YAAA,CAAa,GAAA,WAAc,QAAA;;iBA2DrB,QAAA,CAAA,GAAY,OAAA,CAAQ,QAAA;;iBASpB,OAAA,CAAQ,GAAA,WAAc,OAAA;AApE5C;AAAA,iBA8EgB,cAAA,CAAe,GAAA;;iBAaf,uBAAA,CAAA;;;;UCvFC,aAAA;;EAEf,KAAA;ED/Bu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AAW,WAAA,GAAc,cAAA;;;cCEzC,eAAA,EAAe,CAAA,CAAA,SAAA;;;KAMhB,cAAA,GAAiB,CAAA,CAAE,KAAA,QAAa,eAAA;;;cC4B/B,cAAA,EAAc,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;KA+Bf,aAAA,GAAgB,CAAA,CAAE,KAAA,QAAa,cAAA"}
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as LLMS_TXT_URL, c as getIndex, d as searchDocs, i as DOCS_HOST, l as parseLlmsTxt, n as DocsListSchema, o as assertDocsHost, r as DocsFetchSchema, s as getBody, t as getDocsTools, u as resetDocsCachesForTests } from "./tools-BMbaq7_0.mjs";
1
+ import { a as LLMS_TXT_URL, c as getIndex, d as searchDocs, i as DOCS_HOST, l as parseLlmsTxt, n as DocsListSchema, o as assertDocsHost, r as DocsFetchSchema, s as getBody, t as getDocsTools, u as resetDocsCachesForTests } from "./tools-dFh4jyRG.mjs";
2
2
  export { DOCS_HOST, DocsFetchSchema, DocsListSchema, LLMS_TXT_URL, assertDocsHost, getBody, getDocsTools, getIndex, parseLlmsTxt, resetDocsCachesForTests, searchDocs };
@@ -0,0 +1,634 @@
1
+ import { ErrorCode, ToolError, createListResult, createToolResult, defineTool, groupBy, z } from "@transcend-io/mcp-server-base";
2
+ import { LRUCache } from "lru-cache";
3
+ import { create, insertMultiple, search } from "@orama/orama";
4
+ import { DocsProduct } from "@transcend-io/privacy-types";
5
+ //#region src/docsSearch.ts
6
+ const SEARCH_CACHE_KEY = "search";
7
+ const SEARCH_INDEX_TTL_MS = 1440 * 60 * 1e3;
8
+ /**
9
+ * Results per search. On a labeled benchmark the targets that missed the top
10
+ * ten sat at a median rank of 16 and 19, so one page deeper takes hit@k from
11
+ * 87% to 95% on title terms and 88% to 95% on natural questions for about 434
12
+ * extra tokens. Almost nothing recoverable lives past rank 30; those queries
13
+ * need different terms, not more pages, which is why there is no offset.
14
+ */
15
+ const SEARCH_LIMIT = 20;
16
+ const MAX_FILTERED_CANDIDATES = 1e3;
17
+ const HYDRATE_CONCURRENCY = 15;
18
+ const SNIPPET_CHARS = 200;
19
+ const SNIPPET_PREFIX = 40;
20
+ const DOC_SCHEMA = {
21
+ title: "string",
22
+ urlPath: "string",
23
+ section: "string",
24
+ body: "string",
25
+ url: "string"
26
+ };
27
+ function createDocsDb() {
28
+ return create({ schema: DOC_SCHEMA });
29
+ }
30
+ function urlToSearchText(url) {
31
+ try {
32
+ return new URL(url).pathname.replace(/\.md$/i, "").split(/[-_/]+/).filter(Boolean).join(" ");
33
+ } catch {
34
+ return "";
35
+ }
36
+ }
37
+ function extractSnippet(text, query) {
38
+ const collapsed = text.replace(/\s+/g, " ").trim();
39
+ if (!collapsed) return "";
40
+ const terms = query.toLowerCase().split(/\s+/).filter((term) => term.length > 1);
41
+ const lower = collapsed.toLowerCase();
42
+ let matchIndex = -1;
43
+ for (const term of terms) {
44
+ matchIndex = lower.indexOf(term);
45
+ if (matchIndex !== -1) break;
46
+ }
47
+ if (matchIndex === -1) return collapsed.length > SNIPPET_CHARS ? `${collapsed.slice(0, SNIPPET_CHARS).trim()}…` : collapsed;
48
+ const start = Math.max(0, matchIndex - SNIPPET_PREFIX);
49
+ const end = Math.min(collapsed.length, start + SNIPPET_CHARS);
50
+ const prefix = start > 0 ? "…" : "";
51
+ const suffix = end < collapsed.length ? "…" : "";
52
+ return `${prefix}${collapsed.slice(start, end).trim()}${suffix}`;
53
+ }
54
+ async function mapWithConcurrency(items, concurrency, mapper) {
55
+ if (items.length === 0) return [];
56
+ const results = new Array(items.length);
57
+ let next = 0;
58
+ async function worker() {
59
+ while (next < items.length) {
60
+ const index = next;
61
+ next += 1;
62
+ results[index] = await mapper(items[index]);
63
+ }
64
+ }
65
+ await Promise.all(Array.from({ length: Math.min(concurrency, items.length) }, () => worker()));
66
+ return results;
67
+ }
68
+ async function hydrateEntry(entry) {
69
+ let body = "";
70
+ try {
71
+ body = await getBody(entry.url);
72
+ } catch {}
73
+ return {
74
+ id: entry.url,
75
+ title: entry.title,
76
+ urlPath: urlToSearchText(entry.url),
77
+ section: entry.section,
78
+ body,
79
+ url: entry.url
80
+ };
81
+ }
82
+ async function buildSearchIndex() {
83
+ const documents = await mapWithConcurrency(await getIndex(), HYDRATE_CONCURRENCY, hydrateEntry);
84
+ const db = createDocsDb();
85
+ if (documents.length > 0) await Promise.resolve(insertMultiple(db, documents));
86
+ return db;
87
+ }
88
+ const searchIndexCache = new LRUCache({
89
+ max: 1,
90
+ ttl: SEARCH_INDEX_TTL_MS,
91
+ allowStale: true,
92
+ allowStaleOnFetchRejection: true,
93
+ fetchMethod: async () => buildSearchIndex()
94
+ });
95
+ /** Clears the Orama index (called from {@link resetDocsCachesForTests}). */
96
+ function clearSearchIndexCache() {
97
+ searchIndexCache.clear();
98
+ }
99
+ /** Full-text search over hydrated docs (title, URL path, section, body). */
100
+ async function searchDocs(query, options = {}) {
101
+ const term = query.trim();
102
+ if (!term) return {
103
+ hits: [],
104
+ totalCount: 0
105
+ };
106
+ const db = await searchIndexCache.fetch(SEARCH_CACHE_KEY);
107
+ if (!db) throw new Error("Failed to build documentation search index");
108
+ const results = await Promise.resolve(search(db, {
109
+ term,
110
+ limit: options.urlFilter ? MAX_FILTERED_CANDIDATES : options.limit ?? SEARCH_LIMIT,
111
+ tolerance: 0,
112
+ threshold: .3,
113
+ boost: {
114
+ title: 4,
115
+ urlPath: 2,
116
+ section: 1.5,
117
+ body: 1
118
+ },
119
+ ...options.section ? { where: { section: options.section } } : {}
120
+ }));
121
+ const { urlFilter } = options;
122
+ const matched = urlFilter ? results.hits.filter((hit) => urlFilter(hit.document.url)) : results.hits;
123
+ const cap = options.limit ?? SEARCH_LIMIT;
124
+ return {
125
+ hits: matched.slice(0, cap).map((hit) => {
126
+ const document = hit.document;
127
+ return {
128
+ title: document.title,
129
+ section: document.section,
130
+ url: document.url,
131
+ score: hit.score,
132
+ snippet: extractSnippet(`${document.title} ${document.body}`, term)
133
+ };
134
+ }),
135
+ totalCount: urlFilter ? matched.length : results.count
136
+ };
137
+ }
138
+ //#endregion
139
+ //#region src/docsIndex.ts
140
+ /** Public docs index URL (llms.txt). */
141
+ const LLMS_TXT_URL = "https://docs.transcend.io/llms.txt";
142
+ /** Admin Dashboard route to docs pages index. */
143
+ const DASHBOARD_ROUTES_URL = "https://docs.transcend.io/dashboard-routes.json";
144
+ /** Allowed hostname for fetched documentation articles. */
145
+ const DOCS_HOST = "docs.transcend.io";
146
+ const INDEX_CACHE_KEY = "index";
147
+ const ROUTES_CACHE_KEY = "routes";
148
+ const DEFAULT_INDEX_TTL_MS = 1440 * 60 * 1e3;
149
+ const DEFAULT_BODY_TTL_MS = 360 * 60 * 1e3;
150
+ const FETCH_TIMEOUT_MS = 8e3;
151
+ const MAX_BODY_CACHE_ENTRIES = 600;
152
+ /**
153
+ * Parses llms.txt markdown into structured entries.
154
+ * Expects `## Section` headers and `- [Title](url)` list items.
155
+ */
156
+ function parseLlmsTxt(raw) {
157
+ const entries = [];
158
+ let currentSection = "";
159
+ for (const line of raw.split("\n")) {
160
+ const sectionMatch = /^## (.+)$/.exec(line);
161
+ if (sectionMatch?.[1]) {
162
+ currentSection = sectionMatch[1].trim();
163
+ continue;
164
+ }
165
+ const linkMatch = /^- \[(.+)\]\((.+)\)\s*$/.exec(line);
166
+ if (linkMatch?.[1] && linkMatch[2] && currentSection) {
167
+ const title = linkMatch[1].trim();
168
+ if (!title) continue;
169
+ entries.push({
170
+ section: currentSection,
171
+ title,
172
+ url: linkMatch[2].trim()
173
+ });
174
+ }
175
+ }
176
+ return entries;
177
+ }
178
+ const RoutePageSchema = z.object({
179
+ title: z.string(),
180
+ url: z.string(),
181
+ guideType: z.string().nullish().transform((value) => value ?? null)
182
+ });
183
+ const RouteEntrySchema = z.object({
184
+ product: z.string().nullish().optional(),
185
+ primary: z.array(RoutePageSchema).default([]),
186
+ mentions: z.array(RoutePageSchema).default([])
187
+ });
188
+ /** Schema for dashboard-routes.json. */
189
+ const DashboardRoutesSchema = z.object({
190
+ routes: z.record(z.string(), RouteEntrySchema),
191
+ products: z.record(z.string(), z.array(RoutePageSchema)).optional(),
192
+ productPrefixes: z.array(z.object({
193
+ prefix: z.string(),
194
+ product: z.string().nullable()
195
+ })).optional()
196
+ });
197
+ /** Parses and validates dashboard-routes.json. Throws when the shape is invalid. */
198
+ function parseDashboardRoutes(raw) {
199
+ return DashboardRoutesSchema.parse(JSON.parse(raw));
200
+ }
201
+ /** Thrown when dashboard-routes.json cannot be fetched or is invalid. */
202
+ var RouteIndexUnavailableError = class extends Error {
203
+ constructor(cause) {
204
+ super(`The Admin Dashboard route index is not available: ${cause instanceof Error ? cause.message : String(cause)}`, { cause });
205
+ this.name = "RouteIndexUnavailableError";
206
+ }
207
+ };
208
+ async function fetchText(url, signal, accept = "text/markdown, text/plain") {
209
+ const response = await fetch(url, {
210
+ headers: { Accept: accept },
211
+ signal: signal ?? AbortSignal.timeout(FETCH_TIMEOUT_MS)
212
+ });
213
+ if (!response.ok) throw new Error(`Failed to fetch ${url}: HTTP ${response.status}`);
214
+ return response.text();
215
+ }
216
+ const indexCache = new LRUCache({
217
+ max: 1,
218
+ ttl: DEFAULT_INDEX_TTL_MS,
219
+ allowStale: true,
220
+ allowStaleOnFetchRejection: true,
221
+ fetchMethod: async (_key, _stale, { signal }) => {
222
+ return parseLlmsTxt(await fetchText(LLMS_TXT_URL, signal));
223
+ }
224
+ });
225
+ const routeIndexCache = new LRUCache({
226
+ max: 1,
227
+ ttl: DEFAULT_INDEX_TTL_MS,
228
+ allowStale: true,
229
+ allowStaleOnFetchRejection: true,
230
+ fetchMethod: async (_key, _stale, { signal }) => {
231
+ return parseDashboardRoutes(await fetchText(DASHBOARD_ROUTES_URL, signal, "application/json"));
232
+ }
233
+ });
234
+ const bodyCache = new LRUCache({
235
+ max: MAX_BODY_CACHE_ENTRIES,
236
+ ttl: DEFAULT_BODY_TTL_MS,
237
+ allowStale: true,
238
+ allowStaleOnFetchRejection: true,
239
+ fetchMethod: async (url, _stale, { signal }) => fetchText(url, signal)
240
+ });
241
+ /** Returns the parsed llms.txt index (cached with TTL). */
242
+ async function getIndex() {
243
+ const result = await indexCache.fetch(INDEX_CACHE_KEY);
244
+ if (!result) throw new Error("Failed to load documentation index");
245
+ return result;
246
+ }
247
+ /**
248
+ * Returns the parsed dashboard-routes.json index (cached with TTL).
249
+ * Throws {@link RouteIndexUnavailableError} when it is missing or invalid.
250
+ */
251
+ async function getRouteIndex() {
252
+ let result;
253
+ try {
254
+ result = await routeIndexCache.fetch(ROUTES_CACHE_KEY);
255
+ } catch (error) {
256
+ throw new RouteIndexUnavailableError(error);
257
+ }
258
+ if (!result) throw new RouteIndexUnavailableError("empty response");
259
+ return result;
260
+ }
261
+ /** Fetches and caches markdown body for a docs.transcend.io article URL. */
262
+ async function getBody(url) {
263
+ assertDocsHost(url);
264
+ const result = await bodyCache.fetch(url);
265
+ if (result === void 0) throw new Error(`Failed to fetch documentation: ${url}`);
266
+ return result;
267
+ }
268
+ /** Validates that a URL targets docs.transcend.io (SSRF guard for fetch). */
269
+ function assertDocsHost(url) {
270
+ let parsed;
271
+ try {
272
+ parsed = new URL(url);
273
+ } catch {
274
+ throw new Error(`Invalid documentation URL: ${url}`);
275
+ }
276
+ if (parsed.hostname !== "docs.transcend.io") throw new Error(`URL host must be ${DOCS_HOST}, got ${parsed.hostname}`);
277
+ }
278
+ /** Clears in-memory caches (for tests). */
279
+ function resetDocsCachesForTests() {
280
+ indexCache.clear();
281
+ routeIndexCache.clear();
282
+ bodyCache.clear();
283
+ clearSearchIndexCache();
284
+ }
285
+ //#endregion
286
+ //#region src/tools/docs_fetch.ts
287
+ /** Maximum markdown characters returned per article (long pages are truncated). */
288
+ const MAX_BODY_CHARS = 12e4;
289
+ const DocsFetchSchema = z.object({ url: z.string().url().describe("Absolute https URL of a docs.transcend.io article (.md) from docs_list.") });
290
+ function formatBody(body, url) {
291
+ return `${body.length > MAX_BODY_CHARS ? `${body.slice(0, MAX_BODY_CHARS)}\n\n...(truncated)` : body}\n\nSource: ${url}`;
292
+ }
293
+ function createDocsFetchTool(_clients) {
294
+ return defineTool({
295
+ name: "docs_fetch",
296
+ description: "Fetch full markdown content for a Transcend documentation article by URL. Use urls returned by docs_list.",
297
+ category: "Documentation",
298
+ readOnly: true,
299
+ requireAuth: false,
300
+ annotations: {
301
+ readOnlyHint: true,
302
+ destructiveHint: false,
303
+ idempotentHint: true
304
+ },
305
+ zodSchema: DocsFetchSchema,
306
+ handler: async ({ url }) => {
307
+ assertDocsHost(url);
308
+ return createToolResult(true, {
309
+ url,
310
+ markdown: formatBody(await getBody(url), url)
311
+ });
312
+ }
313
+ });
314
+ }
315
+ //#endregion
316
+ //#region src/docsRoutes.ts
317
+ const APP_HOST_PATTERN = /^app(\.[a-z0-9-]+)*\.transcend\.io$/i;
318
+ /**
319
+ * Normalizes a route pattern, concrete path, or full app URL to a path with a
320
+ * leading slash and no origin, query, hash, or trailing slash.
321
+ * Returns `/` for the root. Throws when a URL is not an `app.*transcend.io` URL.
322
+ */
323
+ function normalizeRoute(input) {
324
+ let value = input.trim();
325
+ if (/^[a-z][a-z0-9+.-]*:\/\//i.test(value)) {
326
+ let parsed;
327
+ try {
328
+ parsed = new URL(value);
329
+ } catch {
330
+ throw new Error(`Invalid URL: ${input}`);
331
+ }
332
+ if (!APP_HOST_PATTERN.test(parsed.hostname)) throw new Error(`URL host must be an app.transcend.io dashboard host, got ${parsed.hostname}`);
333
+ value = parsed.pathname;
334
+ } else value = value.split("#")[0].split("?")[0];
335
+ return `/${value.split("/").filter(Boolean).join("/")}`;
336
+ }
337
+ function splitSegments(path) {
338
+ return path.split("/").filter(Boolean);
339
+ }
340
+ function isParam(segment) {
341
+ return segment.startsWith(":") && segment.length > 1;
342
+ }
343
+ function isOptionalParam(segment) {
344
+ return isParam(segment) && segment.endsWith("?");
345
+ }
346
+ /**
347
+ * Whether a route pattern matches a concrete path.
348
+ * `:name` matches exactly one segment. `:name?` matches zero or one trailing segment.
349
+ */
350
+ function patternMatchesPath(pattern, path) {
351
+ const patternSegments = splitSegments(pattern);
352
+ const pathSegments = splitSegments(path);
353
+ const last = patternSegments.at(-1);
354
+ const hasOptionalTail = last !== void 0 && isOptionalParam(last);
355
+ const requiredLength = hasOptionalTail ? patternSegments.length - 1 : patternSegments.length;
356
+ if (pathSegments.length < requiredLength) return false;
357
+ if (pathSegments.length > patternSegments.length) return false;
358
+ if (!hasOptionalTail && pathSegments.length !== patternSegments.length) return false;
359
+ return pathSegments.every((segment, index) => {
360
+ const part = patternSegments[index];
361
+ return isParam(part) || part === segment;
362
+ });
363
+ }
364
+ function literalCount(pattern) {
365
+ return splitSegments(pattern).filter((segment) => !isParam(segment)).length;
366
+ }
367
+ /** Orders patterns: most literal segments first, then most segments, then no optional tail. */
368
+ function compareSpecificity(a, b) {
369
+ const literalDiff = literalCount(b) - literalCount(a);
370
+ if (literalDiff !== 0) return literalDiff;
371
+ const lengthDiff = splitSegments(b).length - splitSegments(a).length;
372
+ if (lengthDiff !== 0) return lengthDiff;
373
+ const optionalDiff = Number(isOptionalParam(splitSegments(a).at(-1) ?? "")) - Number(isOptionalParam(splitSegments(b).at(-1) ?? ""));
374
+ if (optionalDiff !== 0) return optionalDiff;
375
+ return a.localeCompare(b);
376
+ }
377
+ function toPages(pattern, entry) {
378
+ return [...entry.primary.map((page) => ({
379
+ ...page,
380
+ match: "primary",
381
+ route: pattern
382
+ })), ...entry.mentions.map((page) => ({
383
+ ...page,
384
+ match: "mention",
385
+ route: pattern
386
+ }))];
387
+ }
388
+ function hasPages(entry) {
389
+ return entry.primary.length > 0 || entry.mentions.length > 0;
390
+ }
391
+ function findBestPattern(index, path) {
392
+ if (Object.hasOwn(index, path) && hasPages(index[path])) return path;
393
+ return Object.keys(index).filter((pattern) => hasPages(index[pattern]) && patternMatchesPath(pattern, path)).sort(compareSpecificity)[0];
394
+ }
395
+ /**
396
+ * Resolves a route pattern, concrete path, or app URL to the docs pages for the
397
+ * best matching route pattern. Prefers the pattern with the most literal
398
+ * segments. When nothing matches, retries with each parent path, longest first.
399
+ * Returns undefined when no pattern with pages matches. Patterns with no pages
400
+ * are skipped.
401
+ */
402
+ function lookupRoute(index, input) {
403
+ const path = normalizeRoute(input);
404
+ const segments = splitSegments(path);
405
+ for (let length = segments.length; length >= Math.min(1, segments.length); length -= 1) {
406
+ const pattern = findBestPattern(index, length === 0 ? "/" : `/${segments.slice(0, length).join("/")}`);
407
+ if (pattern !== void 0) return {
408
+ path,
409
+ pattern,
410
+ isParentFallback: length < segments.length,
411
+ pages: toPages(pattern, index[pattern])
412
+ };
413
+ }
414
+ }
415
+ /** Finds the published product title for a user-supplied value, ignoring case. */
416
+ function findProductTitle(input) {
417
+ const wanted = input.trim().toLowerCase();
418
+ return Object.values(DocsProduct).find((title) => title.toLowerCase() === wanted);
419
+ }
420
+ /** Finds the key of `products` that equals `title`, ignoring case. */
421
+ function findProductKey(products, title) {
422
+ const wanted = title.toLowerCase();
423
+ return Object.keys(products).find((key) => key.toLowerCase() === wanted);
424
+ }
425
+ function pathHasPrefix(path, prefix) {
426
+ const normalized = normalizeRoute(prefix);
427
+ return normalized === "/" || path === normalized || path.startsWith(`${normalized}/`);
428
+ }
429
+ /**
430
+ * Resolves the product for a route. Uses the matched route entry's product when
431
+ * it has one, else the longest `productPrefixes` prefix that contains the path.
432
+ * Returns undefined for a platform route or when the index has no product fields.
433
+ */
434
+ function resolveRouteProduct(data, path, lookup) {
435
+ const entryProduct = lookup ? data.routes[lookup.pattern]?.product : void 0;
436
+ if (entryProduct) return entryProduct;
437
+ return [...data.productPrefixes ?? []].sort((a, b) => b.prefix.length - a.prefix.length).find((candidate) => pathHasPrefix(path, candidate.prefix))?.product ?? void 0;
438
+ }
439
+ /**
440
+ * Normalizes a docs URL for comparison: path only, lowercase, no `.md`, no
441
+ * trailing slash. The route index uses extensionless URLs, llms.txt uses `.md`.
442
+ */
443
+ function normalizeDocUrl(url) {
444
+ let pathname;
445
+ try {
446
+ pathname = new URL(url, "https://docs.transcend.io").pathname;
447
+ } catch {
448
+ pathname = url;
449
+ }
450
+ return pathname.replace(/\.md$/i, "").replace(/\/+$/, "").toLowerCase();
451
+ }
452
+ //#endregion
453
+ //#region src/tools/docs_list.ts
454
+ /**
455
+ * Cap on articles returned when listing a section. A listing entry is a title
456
+ * and a URL, roughly a fifth the size of a ranked hit with its snippet, so this
457
+ * sits above the search limit; the largest section would otherwise return 125
458
+ * articles and ~22KB.
459
+ */
460
+ const SECTION_LISTING_LIMIT = 50;
461
+ const docsProductTitles = Object.values(DocsProduct);
462
+ const docsProductEnumValues = docsProductTitles;
463
+ const DocsProductSchema = z.preprocess((value) => typeof value === "string" ? findProductTitle(value) : value, z.enum(docsProductEnumValues, { message: `Unknown product. Valid products: ${docsProductTitles.join(", ")}.` }));
464
+ const DocsListSchema = z.object({
465
+ route: z.string().optional().describe("Find docs for an Admin Dashboard page. Accepts a route pattern, a concrete path ('/privacy-center/general-settings/deployment'), or a full app URL. Returns pages about that page, then pages that link to it, then the page's product docs. Can combine with query. Not with section or product."),
466
+ product: DocsProductSchema.optional().describe(`List docs for one product, overview pages first. One of: ${docsProductTitles.join(", ")} (case-insensitive). Can combine with query. Not with section or route.`),
467
+ section: z.string().optional().describe("List the articles in this llms.txt section (exact match). Omit both arguments to see the available section names."),
468
+ query: z.string().optional().describe("Full-text search terms. Prefer the two or three most distinctive words for the topic over a whole sentence, since common words match most articles and blur the ranking. At most 20 results come back and there is no paging, so narrow the terms rather than expecting to page.")
469
+ });
470
+ /** Cap on product pages added after the route's own pages. */
471
+ const ROUTE_PRODUCT_LIMIT = 10;
472
+ /** Cap on pages returned when listing one product. */
473
+ const PRODUCT_LISTING_LIMIT = 50;
474
+ /** Cap on total rows when a route lookup is combined with a query. */
475
+ const COMBINED_LIMIT = 20;
476
+ function throwRouteIndexError(error) {
477
+ if (error instanceof RouteIndexUnavailableError) throw new ToolError(ErrorCode.API_ERROR, `${error.message}. Use query to search the docs instead.`);
478
+ throw error;
479
+ }
480
+ function toProductRows(pages, product) {
481
+ return pages.map((page) => ({
482
+ ...page,
483
+ match: "product",
484
+ product
485
+ }));
486
+ }
487
+ async function listDocsByProduct({ product, query }) {
488
+ const title = findProductTitle(product);
489
+ if (!title) throw new ToolError(ErrorCode.VALIDATION_ERROR, `Unknown product '${product}'. Valid products: ${docsProductTitles.join(", ")}.`);
490
+ let data;
491
+ try {
492
+ data = await getRouteIndex();
493
+ } catch (error) {
494
+ return throwRouteIndexError(error);
495
+ }
496
+ if (!data.products) throw new ToolError(ErrorCode.API_ERROR, "The docs index has no product data, so product is not available. Use query to search the docs instead.");
497
+ const key = findProductKey(data.products, title);
498
+ const pages = key ? data.products[key] ?? [] : [];
499
+ const terms = query?.trim();
500
+ if (terms) {
501
+ const inProduct = new Set(pages.map((page) => normalizeDocUrl(page.url)));
502
+ const { hits, totalCount } = await searchDocs(terms, { urlFilter: (url) => inProduct.has(normalizeDocUrl(url)) });
503
+ return createListResult(hits.map((hit) => ({
504
+ match: "search",
505
+ ...hit
506
+ })), {
507
+ totalCount,
508
+ paginationNote: `Search results limited to ${title} docs.` + (totalCount > hits.length ? ` Showing the ${hits.length} highest-ranked of ${totalCount} matches. Use more distinctive terms to narrow the search.` : "")
509
+ });
510
+ }
511
+ const page = pages.slice(0, PRODUCT_LISTING_LIMIT);
512
+ return createListResult(toProductRows(page, title), {
513
+ totalCount: pages.length,
514
+ paginationNote: pages.length === 0 ? `No ${title} pages are published yet. Use query to search the docs instead.` : pages.length > page.length ? `Showing ${page.length} of ${pages.length} ${title} pages, overview pages first. There is no paging: add query with product to search within them.` : `${title} pages, overview pages first.`
515
+ });
516
+ }
517
+ async function listDocsForRoute({ route, query }) {
518
+ let path;
519
+ try {
520
+ path = normalizeRoute(route);
521
+ } catch (error) {
522
+ throw new ToolError(ErrorCode.VALIDATION_ERROR, error instanceof Error ? error.message : String(error));
523
+ }
524
+ let data;
525
+ try {
526
+ data = await getRouteIndex();
527
+ } catch (error) {
528
+ return throwRouteIndexError(error);
529
+ }
530
+ const lookup = lookupRoute(data.routes, path);
531
+ const tier1 = lookup?.pages ?? [];
532
+ const productTitle = resolveRouteProduct(data, path, lookup);
533
+ const productKey = productTitle && data.products ? findProductKey(data.products, productTitle) : void 0;
534
+ const seen = new Set(tier1.map((page) => normalizeDocUrl(page.url)));
535
+ const tier2 = productKey && data.products ? toProductRows((data.products[productKey] ?? []).filter((page) => !seen.has(normalizeDocUrl(page.url))), productKey).slice(0, ROUTE_PRODUCT_LIMIT) : [];
536
+ const notes = [];
537
+ if (lookup?.isParentFallback) notes.push(`No docs are linked to '${path}'. Showing docs for its parent route '${lookup.pattern}'.`);
538
+ else if (lookup) notes.push(`Docs for route '${lookup.pattern}'. Pages with match 'primary' are about this page; 'mention' pages only link to it.`);
539
+ else if (tier2.length > 0) notes.push(`No docs are linked to '${path}' or its parent paths.`);
540
+ if (tier2.length > 0) notes.push(tier1.length > 0 ? `Pages with match 'product' are more ${productKey} docs.` : `Showing ${productKey} product docs instead.`);
541
+ const terms = query?.trim();
542
+ if (!terms) {
543
+ const rows = [...tier1, ...tier2];
544
+ if (rows.length === 0) return createListResult([], {
545
+ totalCount: 0,
546
+ paginationNote: `No docs are linked to '${path}' or its parent paths. Use query to search the docs instead.`
547
+ });
548
+ return createListResult(rows, {
549
+ totalCount: rows.length,
550
+ paginationNote: notes.join(" ")
551
+ });
552
+ }
553
+ const lead = [...tier1, ...tier2].slice(0, COMBINED_LIMIT);
554
+ const listed = new Set(lead.map((page) => normalizeDocUrl(page.url)));
555
+ const remaining = COMBINED_LIMIT - lead.length;
556
+ const { hits } = remaining > 0 ? await searchDocs(terms, {
557
+ limit: remaining,
558
+ urlFilter: (url) => !listed.has(normalizeDocUrl(url))
559
+ }) : { hits: [] };
560
+ const rows = [...lead, ...hits.map((hit) => ({
561
+ match: "search",
562
+ ...hit
563
+ }))];
564
+ notes.push(`Pages with match 'search' are full-text results for '${terms}'.`);
565
+ return createListResult(rows, {
566
+ totalCount: rows.length,
567
+ paginationNote: notes.join(" ")
568
+ });
569
+ }
570
+ function createDocsListTool(_clients) {
571
+ return defineTool({
572
+ name: "docs_list",
573
+ description: "List or full-text search Transcend documentation. Pick the narrowest argument you can: use route when you know the Admin Dashboard page the user is on (\"this page\"); it returns that page's docs, then more docs for its product. Otherwise use product when you know the product area. Otherwise use query, which ranks articles by title and body and returns snippets. route and product can each be combined with query. section alone lists one llms.txt section; with no arguments the tool returns the section names. Pick the best matching url, then call docs_fetch.",
574
+ category: "Documentation",
575
+ readOnly: true,
576
+ requireAuth: false,
577
+ annotations: {
578
+ readOnlyHint: true,
579
+ destructiveHint: false,
580
+ idempotentHint: true
581
+ },
582
+ zodSchema: DocsListSchema,
583
+ handler: async ({ section, query, route, product }) => {
584
+ if (section !== void 0 && (route !== void 0 || product !== void 0)) {
585
+ const other = route !== void 0 ? "route" : "product";
586
+ throw new ToolError(ErrorCode.VALIDATION_ERROR, `${other} cannot be combined with section. Pass ${other} alone or with query to find docs for a page or product, or drop it to browse a section.`);
587
+ }
588
+ if (route !== void 0 && product !== void 0) throw new ToolError(ErrorCode.VALIDATION_ERROR, "route cannot be combined with product. A route already resolves to its product: pass route, or pass product to list that product directly.");
589
+ if (query !== void 0 && query.trim() === "") throw new ToolError(ErrorCode.VALIDATION_ERROR, "query was empty. Pass the most distinctive terms for the topic, or omit query entirely to browse the sections.");
590
+ if (route !== void 0) return listDocsForRoute({
591
+ route,
592
+ query
593
+ });
594
+ if (product !== void 0) return listDocsByProduct({
595
+ product,
596
+ query
597
+ });
598
+ const entries = await getIndex();
599
+ const sectionCounts = groupBy(entries, "section");
600
+ if (section !== void 0 && !Object.hasOwn(sectionCounts, section)) throw new ToolError(ErrorCode.VALIDATION_ERROR, `Unknown section '${section}'. Valid sections: ${Object.keys(sectionCounts).join(", ")}.`);
601
+ const terms = query?.trim();
602
+ if (terms) {
603
+ const { hits, totalCount } = await searchDocs(terms, { section });
604
+ return createListResult(hits, {
605
+ totalCount,
606
+ ...totalCount > hits.length && { paginationNote: `Showing the ${hits.length} highest-ranked of ${totalCount} matches. There is no paging: use more distinctive terms to narrow the search.` }
607
+ });
608
+ }
609
+ if (section === void 0) return createListResult(Object.entries(sectionCounts).map(([name, articleCount]) => ({
610
+ section: name,
611
+ articleCount
612
+ })), { paginationNote: `Sections only. Call docs_list again with section to list its articles, or with query to search all ${entries.length} articles.` });
613
+ const filtered = entries.filter((entry) => entry.section === section);
614
+ const page = filtered.slice(0, SECTION_LISTING_LIMIT);
615
+ return createListResult(page.map(({ title, section: entrySection, url }) => ({
616
+ title,
617
+ section: entrySection,
618
+ url
619
+ })), {
620
+ totalCount: filtered.length,
621
+ ...filtered.length > page.length && { paginationNote: `Showing ${page.length} of ${filtered.length} articles in '${section}'. There is no paging: add query to search within this section.` }
622
+ });
623
+ }
624
+ });
625
+ }
626
+ //#endregion
627
+ //#region src/tools/index.ts
628
+ function getDocsTools(_clients) {
629
+ return [createDocsListTool(), createDocsFetchTool()];
630
+ }
631
+ //#endregion
632
+ export { LLMS_TXT_URL as a, getIndex as c, searchDocs as d, DOCS_HOST as i, parseLlmsTxt as l, DocsListSchema as n, assertDocsHost as o, DocsFetchSchema as r, getBody as s, getDocsTools as t, resetDocsCachesForTests as u };
633
+
634
+ //# sourceMappingURL=tools-dFh4jyRG.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools-dFh4jyRG.mjs","names":[],"sources":["../src/docsSearch.ts","../src/docsIndex.ts","../src/tools/docs_fetch.ts","../src/docsRoutes.ts","../src/tools/docs_list.ts","../src/tools/index.ts"],"mappings":";;;;;AAKA,MAAM,mBAAmB;AACzB,MAAM,sBAAsB,OAAU,KAAK;;;;;;;;AAQ3C,MAAM,eAAe;AACrB,MAAM,0BAA0B;AAChC,MAAM,sBAAsB;AAC5B,MAAM,gBAAgB;AACtB,MAAM,iBAAiB;AAEvB,MAAM,aAAa;CACjB,OAAO;CACP,SAAS;CACT,SAAS;CACT,MAAM;CACN,KAAK;CACN;AAED,SAAS,eA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json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transcend-io/mcp-server-docs",
3
- "version": "0.4.18",
3
+ "version": "0.5.0",
4
4
  "description": "Transcend MCP Server — Documentation lookup tools.",
5
5
  "homepage": "https://github.com/transcend-io/tools/tree/main/packages/mcp/mcp-server-docs",
6
6
  "license": "Apache-2.0",
@@ -32,7 +32,8 @@
32
32
  "dependencies": {
33
33
  "@orama/orama": "^3.1.18",
34
34
  "lru-cache": "^11.5.1",
35
- "@transcend-io/mcp-server-base": "^3.0.0"
35
+ "@transcend-io/mcp-server-base": "^3.1.0",
36
+ "@transcend-io/privacy-types": "^7.0.0"
36
37
  },
37
38
  "devDependencies": {
38
39
  "@arethetypeswrong/cli": "0.18.3",
@@ -1,317 +0,0 @@
1
- import { LRUCache } from "lru-cache";
2
- import { create, insertMultiple, search } from "@orama/orama";
3
- import { ErrorCode, ToolError, createListResult, createToolResult, defineTool, groupBy, z } from "@transcend-io/mcp-server-base";
4
- //#region src/docsSearch.ts
5
- const SEARCH_CACHE_KEY = "search";
6
- const SEARCH_INDEX_TTL_MS = 1440 * 60 * 1e3;
7
- /**
8
- * Results per search. On a labeled benchmark the targets that missed the top
9
- * ten sat at a median rank of 16 and 19, so one page deeper takes hit@k from
10
- * 87% to 95% on title terms and 88% to 95% on natural questions for about 434
11
- * extra tokens. Almost nothing recoverable lives past rank 30; those queries
12
- * need different terms, not more pages, which is why there is no offset.
13
- */
14
- const SEARCH_LIMIT = 20;
15
- const HYDRATE_CONCURRENCY = 15;
16
- const SNIPPET_CHARS = 200;
17
- const SNIPPET_PREFIX = 40;
18
- const DOC_SCHEMA = {
19
- title: "string",
20
- urlPath: "string",
21
- section: "string",
22
- body: "string",
23
- url: "string"
24
- };
25
- function createDocsDb() {
26
- return create({ schema: DOC_SCHEMA });
27
- }
28
- function urlToSearchText(url) {
29
- try {
30
- return new URL(url).pathname.replace(/\.md$/i, "").split(/[-_/]+/).filter(Boolean).join(" ");
31
- } catch {
32
- return "";
33
- }
34
- }
35
- function extractSnippet(text, query) {
36
- const collapsed = text.replace(/\s+/g, " ").trim();
37
- if (!collapsed) return "";
38
- const terms = query.toLowerCase().split(/\s+/).filter((term) => term.length > 1);
39
- const lower = collapsed.toLowerCase();
40
- let matchIndex = -1;
41
- for (const term of terms) {
42
- matchIndex = lower.indexOf(term);
43
- if (matchIndex !== -1) break;
44
- }
45
- if (matchIndex === -1) return collapsed.length > SNIPPET_CHARS ? `${collapsed.slice(0, SNIPPET_CHARS).trim()}…` : collapsed;
46
- const start = Math.max(0, matchIndex - SNIPPET_PREFIX);
47
- const end = Math.min(collapsed.length, start + SNIPPET_CHARS);
48
- const prefix = start > 0 ? "…" : "";
49
- const suffix = end < collapsed.length ? "…" : "";
50
- return `${prefix}${collapsed.slice(start, end).trim()}${suffix}`;
51
- }
52
- async function mapWithConcurrency(items, concurrency, mapper) {
53
- if (items.length === 0) return [];
54
- const results = new Array(items.length);
55
- let next = 0;
56
- async function worker() {
57
- while (next < items.length) {
58
- const index = next;
59
- next += 1;
60
- results[index] = await mapper(items[index]);
61
- }
62
- }
63
- await Promise.all(Array.from({ length: Math.min(concurrency, items.length) }, () => worker()));
64
- return results;
65
- }
66
- async function hydrateEntry(entry) {
67
- let body = "";
68
- try {
69
- body = await getBody(entry.url);
70
- } catch {}
71
- return {
72
- id: entry.url,
73
- title: entry.title,
74
- urlPath: urlToSearchText(entry.url),
75
- section: entry.section,
76
- body,
77
- url: entry.url
78
- };
79
- }
80
- async function buildSearchIndex() {
81
- const documents = await mapWithConcurrency(await getIndex(), HYDRATE_CONCURRENCY, hydrateEntry);
82
- const db = createDocsDb();
83
- if (documents.length > 0) await Promise.resolve(insertMultiple(db, documents));
84
- return db;
85
- }
86
- const searchIndexCache = new LRUCache({
87
- max: 1,
88
- ttl: SEARCH_INDEX_TTL_MS,
89
- allowStale: true,
90
- allowStaleOnFetchRejection: true,
91
- fetchMethod: async () => buildSearchIndex()
92
- });
93
- /** Clears the Orama index (called from {@link resetDocsCachesForTests}). */
94
- function clearSearchIndexCache() {
95
- searchIndexCache.clear();
96
- }
97
- /** Full-text search over hydrated docs (title, URL path, section, body). */
98
- async function searchDocs(query, options = {}) {
99
- const term = query.trim();
100
- if (!term) return {
101
- hits: [],
102
- totalCount: 0
103
- };
104
- const db = await searchIndexCache.fetch(SEARCH_CACHE_KEY);
105
- if (!db) throw new Error("Failed to build documentation search index");
106
- const results = await Promise.resolve(search(db, {
107
- term,
108
- limit: SEARCH_LIMIT,
109
- tolerance: 0,
110
- threshold: .3,
111
- boost: {
112
- title: 4,
113
- urlPath: 2,
114
- section: 1.5,
115
- body: 1
116
- },
117
- ...options.section ? { where: { section: options.section } } : {}
118
- }));
119
- return {
120
- hits: results.hits.map((hit) => {
121
- const document = hit.document;
122
- return {
123
- title: document.title,
124
- section: document.section,
125
- url: document.url,
126
- score: hit.score,
127
- snippet: extractSnippet(`${document.title} ${document.body}`, term)
128
- };
129
- }),
130
- totalCount: results.count
131
- };
132
- }
133
- //#endregion
134
- //#region src/docsIndex.ts
135
- /** Public docs index URL (llms.txt). */
136
- const LLMS_TXT_URL = "https://docs.transcend.io/llms.txt";
137
- /** Allowed hostname for fetched documentation articles. */
138
- const DOCS_HOST = "docs.transcend.io";
139
- const INDEX_CACHE_KEY = "index";
140
- const DEFAULT_INDEX_TTL_MS = 1440 * 60 * 1e3;
141
- const DEFAULT_BODY_TTL_MS = 360 * 60 * 1e3;
142
- const FETCH_TIMEOUT_MS = 8e3;
143
- const MAX_BODY_CACHE_ENTRIES = 600;
144
- /**
145
- * Parses llms.txt markdown into structured entries.
146
- * Expects `## Section` headers and `- [Title](url)` list items.
147
- */
148
- function parseLlmsTxt(raw) {
149
- const entries = [];
150
- let currentSection = "";
151
- for (const line of raw.split("\n")) {
152
- const sectionMatch = /^## (.+)$/.exec(line);
153
- if (sectionMatch?.[1]) {
154
- currentSection = sectionMatch[1].trim();
155
- continue;
156
- }
157
- const linkMatch = /^- \[(.+)\]\((.+)\)\s*$/.exec(line);
158
- if (linkMatch?.[1] && linkMatch[2] && currentSection) {
159
- const title = linkMatch[1].trim();
160
- if (!title) continue;
161
- entries.push({
162
- section: currentSection,
163
- title,
164
- url: linkMatch[2].trim()
165
- });
166
- }
167
- }
168
- return entries;
169
- }
170
- async function fetchText(url, signal) {
171
- const response = await fetch(url, {
172
- headers: { Accept: "text/markdown, text/plain" },
173
- signal: signal ?? AbortSignal.timeout(FETCH_TIMEOUT_MS)
174
- });
175
- if (!response.ok) throw new Error(`Failed to fetch ${url}: HTTP ${response.status}`);
176
- return response.text();
177
- }
178
- const indexCache = new LRUCache({
179
- max: 1,
180
- ttl: DEFAULT_INDEX_TTL_MS,
181
- allowStale: true,
182
- allowStaleOnFetchRejection: true,
183
- fetchMethod: async (_key, _stale, { signal }) => {
184
- return parseLlmsTxt(await fetchText(LLMS_TXT_URL, signal));
185
- }
186
- });
187
- const bodyCache = new LRUCache({
188
- max: MAX_BODY_CACHE_ENTRIES,
189
- ttl: DEFAULT_BODY_TTL_MS,
190
- allowStale: true,
191
- allowStaleOnFetchRejection: true,
192
- fetchMethod: async (url, _stale, { signal }) => fetchText(url, signal)
193
- });
194
- /** Returns the parsed llms.txt index (cached with TTL). */
195
- async function getIndex() {
196
- const result = await indexCache.fetch(INDEX_CACHE_KEY);
197
- if (!result) throw new Error("Failed to load documentation index");
198
- return result;
199
- }
200
- /** Fetches and caches markdown body for a docs.transcend.io article URL. */
201
- async function getBody(url) {
202
- assertDocsHost(url);
203
- const result = await bodyCache.fetch(url);
204
- if (result === void 0) throw new Error(`Failed to fetch documentation: ${url}`);
205
- return result;
206
- }
207
- /** Validates that a URL targets docs.transcend.io (SSRF guard for fetch). */
208
- function assertDocsHost(url) {
209
- let parsed;
210
- try {
211
- parsed = new URL(url);
212
- } catch {
213
- throw new Error(`Invalid documentation URL: ${url}`);
214
- }
215
- if (parsed.hostname !== "docs.transcend.io") throw new Error(`URL host must be ${DOCS_HOST}, got ${parsed.hostname}`);
216
- }
217
- /** Clears in-memory caches (for tests). */
218
- function resetDocsCachesForTests() {
219
- indexCache.clear();
220
- bodyCache.clear();
221
- clearSearchIndexCache();
222
- }
223
- //#endregion
224
- //#region src/tools/docs_fetch.ts
225
- /** Maximum markdown characters returned per article (long pages are truncated). */
226
- const MAX_BODY_CHARS = 12e4;
227
- const DocsFetchSchema = z.object({ url: z.string().url().describe("Absolute https URL of a docs.transcend.io article (.md) from docs_list.") });
228
- function formatBody(body, url) {
229
- return `${body.length > MAX_BODY_CHARS ? `${body.slice(0, MAX_BODY_CHARS)}\n\n...(truncated)` : body}\n\nSource: ${url}`;
230
- }
231
- function createDocsFetchTool(_clients) {
232
- return defineTool({
233
- name: "docs_fetch",
234
- description: "Fetch full markdown content for a Transcend documentation article by URL. Use urls returned by docs_list.",
235
- category: "Documentation",
236
- readOnly: true,
237
- requireAuth: false,
238
- annotations: {
239
- readOnlyHint: true,
240
- destructiveHint: false,
241
- idempotentHint: true
242
- },
243
- zodSchema: DocsFetchSchema,
244
- handler: async ({ url }) => {
245
- assertDocsHost(url);
246
- return createToolResult(true, {
247
- url,
248
- markdown: formatBody(await getBody(url), url)
249
- });
250
- }
251
- });
252
- }
253
- //#endregion
254
- //#region src/tools/docs_list.ts
255
- /**
256
- * Cap on articles returned when listing a section. A listing entry is a title
257
- * and a URL, roughly a fifth the size of a ranked hit with its snippet, so this
258
- * sits above the search limit; the largest section would otherwise return 125
259
- * articles and ~22KB.
260
- */
261
- const SECTION_LISTING_LIMIT = 50;
262
- const DocsListSchema = z.object({
263
- section: z.string().optional().describe("List the articles in this llms.txt section (exact match). Omit both arguments to see the available section names."),
264
- query: z.string().optional().describe("Full-text search terms. Prefer the two or three most distinctive words for the topic over a whole sentence, since common words match most articles and blur the ranking. At most 20 results come back and there is no paging, so narrow the terms rather than expecting to page.")
265
- });
266
- function createDocsListTool(_clients) {
267
- return defineTool({
268
- name: "docs_list",
269
- description: "List or full-text search Transcend documentation. With query, ranks articles by title and body and returns snippets; with section alone, lists that section; with neither, returns the section names. Pick the best matching url, then call docs_fetch.",
270
- category: "Documentation",
271
- readOnly: true,
272
- requireAuth: false,
273
- annotations: {
274
- readOnlyHint: true,
275
- destructiveHint: false,
276
- idempotentHint: true
277
- },
278
- zodSchema: DocsListSchema,
279
- handler: async ({ section, query }) => {
280
- if (query !== void 0 && query.trim() === "") throw new ToolError(ErrorCode.VALIDATION_ERROR, "query was empty. Pass the most distinctive terms for the topic, or omit query entirely to browse the sections.");
281
- const entries = await getIndex();
282
- const sectionCounts = groupBy(entries, "section");
283
- if (section !== void 0 && !Object.hasOwn(sectionCounts, section)) throw new ToolError(ErrorCode.VALIDATION_ERROR, `Unknown section '${section}'. Valid sections: ${Object.keys(sectionCounts).join(", ")}.`);
284
- const terms = query?.trim();
285
- if (terms) {
286
- const { hits, totalCount } = await searchDocs(terms, { section });
287
- return createListResult(hits, {
288
- totalCount,
289
- ...totalCount > hits.length && { paginationNote: `Showing the ${hits.length} highest-ranked of ${totalCount} matches. There is no paging: use more distinctive terms to narrow the search.` }
290
- });
291
- }
292
- if (section === void 0) return createListResult(Object.entries(sectionCounts).map(([name, articleCount]) => ({
293
- section: name,
294
- articleCount
295
- })), { paginationNote: `Sections only. Call docs_list again with section to list its articles, or with query to search all ${entries.length} articles.` });
296
- const filtered = entries.filter((entry) => entry.section === section);
297
- const page = filtered.slice(0, SECTION_LISTING_LIMIT);
298
- return createListResult(page.map(({ title, section: entrySection, url }) => ({
299
- title,
300
- section: entrySection,
301
- url
302
- })), {
303
- totalCount: filtered.length,
304
- ...filtered.length > page.length && { paginationNote: `Showing ${page.length} of ${filtered.length} articles in '${section}'. There is no paging: add query to search within this section.` }
305
- });
306
- }
307
- });
308
- }
309
- //#endregion
310
- //#region src/tools/index.ts
311
- function getDocsTools(_clients) {
312
- return [createDocsListTool(), createDocsFetchTool()];
313
- }
314
- //#endregion
315
- export { LLMS_TXT_URL as a, getIndex as c, searchDocs as d, DOCS_HOST as i, parseLlmsTxt as l, DocsListSchema as n, assertDocsHost as o, DocsFetchSchema as r, getBody as s, getDocsTools as t, resetDocsCachesForTests as u };
316
-
317
- //# sourceMappingURL=tools-BMbaq7_0.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tools-BMbaq7_0.mjs","names":[],"sources":["../src/docsSearch.ts","../src/docsIndex.ts","../src/tools/docs_fetch.ts","../src/tools/docs_list.ts","../src/tools/index.ts"],"mappings":";;;;AAKA,MAAM,mBAAmB;AACzB,MAAM,sBAAsB,OAAU,KAAK;;;;;;;;AAQ3C,MAAM,eAAe;AACrB,MAAM,sBAAsB;AAC5B,MAAM,gBAAgB;AACtB,MAAM,iBAAiB;AAEvB,MAAM,aAAa;CACjB,OAAO;CACP,SAAS;CACT,SAAS;CACT,MAAM;CACN,KAAK;CACN;AAED,SAAS,eAAe;AACtB,QAAO,OAAO,EAAE,QAAQ,YAAY,CAAC;;AAmBvC,SAAS,gBAAgB,KAAqB;AAC5C,KAAI;AACF,SAAO,IAAI,IAAI,IAAI,CAAC,SACjB,QAAQ,UAAU,GAAG,CACrB,MAAM,SAAS,CACf,OAAO,QAAQ,CACf,KAAK,IAAI;SACN;AACN,SAAO;;;AAIX,SAAS,eAAe,MAAc,OAAuB;CAC3D,MAAM,YAAY,KAAK,QAAQ,QAAQ,IAAI,CAAC,MAAM;AAClD,KAAI,CAAC,UACH,QAAO;CAET,MAAM,QAAQ,MACX,aAAa,CACb,MAAM,MAAM,CACZ,QAAQ,SAAS,KAAK,SAAS,EAAE;CACpC,MAAM,QAAQ,UAAU,aAAa;CACrC,IAAI,aAAa;AACjB,MAAK,MAAM,QAAQ,OAAO;AACxB,eAAa,MAAM,QAAQ,KAAK;AAChC,MAAI,eAAe,GACjB;;AAGJ,KAAI,eAAe,GACjB,QAAO,UAAU,SAAS,gBACtB,GAAG,UAAU,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,KAC5C;CAEN,MAAM,QAAQ,KAAK,IAAI,GAAG,aAAa,eAAe;CACtD,MAAM,MAAM,KAA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