@vercel/geistdocs 2.5.0 → 2.6.1

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.
Files changed (44) hide show
  1. package/dist/cli/index.js +1 -1
  2. package/dist/config.d.ts +9 -0
  3. package/dist/config.d.ts.map +1 -1
  4. package/dist/config.js +13 -0
  5. package/dist/internal/mdx-to-markdown.d.ts.map +1 -1
  6. package/dist/internal/mdx-to-markdown.js +465 -27
  7. package/dist/internal/provider-client.js +1 -1
  8. package/dist/internal/webmcp-client.d.ts +3 -4
  9. package/dist/internal/webmcp-client.d.ts.map +1 -1
  10. package/dist/internal/webmcp-client.js +9 -12
  11. package/dist/internal/webmcp.d.ts +2 -6
  12. package/dist/internal/webmcp.d.ts.map +1 -1
  13. package/dist/internal/webmcp.js +28 -79
  14. package/dist/proxy.d.ts.map +1 -1
  15. package/dist/proxy.js +10 -2
  16. package/dist/routes/agents.d.ts.map +1 -1
  17. package/dist/routes/agents.js +2 -0
  18. package/dist/routes/discovery.d.ts +3 -2
  19. package/dist/routes/discovery.d.ts.map +1 -1
  20. package/dist/routes/discovery.js +49 -1
  21. package/dist/routes/mcp.d.ts +7 -2
  22. package/dist/routes/mcp.d.ts.map +1 -1
  23. package/dist/routes/mcp.js +101 -1
  24. package/dist/routes/openapi.d.ts +64 -0
  25. package/dist/routes/openapi.d.ts.map +1 -0
  26. package/dist/routes/openapi.js +481 -0
  27. package/docs/agents.md +1 -1
  28. package/docs/llms.txt +60 -27
  29. package/docs/manifest.json +1 -1
  30. package/docs/pages/agent-readiness.md +30 -0
  31. package/docs/pages/configuration.md +1 -0
  32. package/docs/pages/migration.md +1 -0
  33. package/docs/pages/webmcp.md +27 -26
  34. package/package.json +9 -3
  35. package/template/AGENTS.md +1 -1
  36. package/template/app/[lang]/openapi.json/route.ts +6 -0
  37. package/template/app/api/mcp/route.ts +7 -0
  38. package/template/content/docs/agent-readiness.mdx +30 -0
  39. package/template/content/docs/configuration.mdx +1 -0
  40. package/template/content/docs/migration.mdx +1 -0
  41. package/template/content/docs/webmcp.mdx +27 -26
  42. package/template/geistdocs.tsx +3 -0
  43. package/template/lib/geistdocs/config.tsx +1 -0
  44. package/template/package.json +1 -1
@@ -4,8 +4,42 @@ import remarkMdx from "remark-mdx";
4
4
  import remarkParse from "remark-parse";
5
5
  import remarkStringify from "remark-stringify";
6
6
  import { unified } from "unified";
7
+ const LEADING_WHITESPACE = /^\s+/;
8
+ const TRAILING_WHITESPACE = /\s+$/;
9
+ const WHITESPACE = /\s+/;
10
+ // JSX applies props left to right, so a repeated attribute or a later spread
11
+ // wins at runtime. Read the last literal and distrust it when a spread follows.
12
+ const findAttribute = (node, name) => {
13
+ const attributes = node.attributes ?? [];
14
+ let index = -1;
15
+ for (let position = attributes.length - 1; position >= 0; position -= 1) {
16
+ const entry = attributes[position];
17
+ if (entry.type === "mdxJsxAttribute" && entry.name === name) {
18
+ index = position;
19
+ break;
20
+ }
21
+ }
22
+ if (index < 0 ||
23
+ attributes
24
+ .slice(index + 1)
25
+ .some((entry) => entry.type === "mdxJsxExpressionAttribute")) {
26
+ return undefined;
27
+ }
28
+ return attributes[index];
29
+ };
30
+ function expressionString(node) {
31
+ if (node?.type === "Literal" && typeof node.value === "string") {
32
+ return node.value;
33
+ }
34
+ if (node?.type === "TemplateLiteral" &&
35
+ node.expressions?.length === 0 &&
36
+ node.quasis?.length === 1) {
37
+ return node.quasis[0].value?.cooked ?? node.quasis[0].value?.raw;
38
+ }
39
+ return undefined;
40
+ }
7
41
  const getAttribute = (node, name) => {
8
- const attribute = node.attributes?.find((entry) => entry.type === "mdxJsxAttribute" && entry.name === name);
42
+ const attribute = findAttribute(node, name);
9
43
  if (!attribute) {
10
44
  return undefined;
11
45
  }
@@ -16,14 +50,127 @@ const getAttribute = (node, name) => {
16
50
  const expression = statement?.type === "ExpressionStatement"
17
51
  ? statement.expression
18
52
  : undefined;
19
- return expression?.type === "Literal" && typeof expression.value === "string"
20
- ? expression.value
53
+ return expressionString(expression);
54
+ };
55
+ const getAttributeExpression = (node, name) => {
56
+ const value = findAttribute(node, name)?.value;
57
+ if (!value || typeof value === "string") {
58
+ return undefined;
59
+ }
60
+ const statement = value.data?.estree?.body[0];
61
+ return statement?.type === "ExpressionStatement"
62
+ ? statement.expression
21
63
  : undefined;
22
64
  };
65
+ const propertyName = (node) => {
66
+ if (node.key?.type === "Identifier") {
67
+ return node.key.name;
68
+ }
69
+ return expressionString(node.key);
70
+ };
71
+ const objectProperty = (node, name) => {
72
+ if (node?.type !== "ObjectExpression") {
73
+ return undefined;
74
+ }
75
+ const properties = node.properties ?? [];
76
+ let index = -1;
77
+ for (let position = properties.length - 1; position >= 0; position -= 1) {
78
+ const property = properties[position];
79
+ if (property.type === "Property" &&
80
+ !property.computed &&
81
+ propertyName(property) === name) {
82
+ index = position;
83
+ break;
84
+ }
85
+ }
86
+ if (index < 0 ||
87
+ properties
88
+ .slice(index + 1)
89
+ .some((property) => property.type === "SpreadElement")) {
90
+ return undefined;
91
+ }
92
+ return properties[index].value;
93
+ };
23
94
  const paragraph = (value) => ({
24
95
  children: [{ type: "text", value }],
25
96
  type: "paragraph",
26
97
  });
98
+ const inlineCode = (value) => ({
99
+ type: "inlineCode",
100
+ value,
101
+ });
102
+ const heading = (children, depth = 4) => ({
103
+ children,
104
+ depth,
105
+ type: "heading",
106
+ });
107
+ const BLOCK_NODE_TYPES = new Set([
108
+ "blockquote",
109
+ "code",
110
+ "heading",
111
+ "html",
112
+ "list",
113
+ "paragraph",
114
+ "table",
115
+ "thematicBreak",
116
+ ]);
117
+ const phrasingChildren = (node) => {
118
+ const children = [];
119
+ for (const child of node.children ?? []) {
120
+ if (child.type === "paragraph") {
121
+ const paragraphChildren = child.children ?? [];
122
+ if (children.length > 0 && paragraphChildren.length > 0) {
123
+ children.push({ type: "text", value: " " });
124
+ }
125
+ children.push(...paragraphChildren);
126
+ }
127
+ else if (BLOCK_NODE_TYPES.has(child.type)) {
128
+ return undefined;
129
+ }
130
+ else {
131
+ children.push(child);
132
+ }
133
+ }
134
+ return children;
135
+ };
136
+ const blockChildren = (node, force = false) => {
137
+ const children = node.children ?? [];
138
+ if (!force && node.type !== "mdxJsxFlowElement") {
139
+ return children;
140
+ }
141
+ const blocks = [];
142
+ let phrasing = [];
143
+ const flush = () => {
144
+ const children = phrasing.map((child, index) => {
145
+ if (child.type !== "text" || !child.value) {
146
+ return child;
147
+ }
148
+ let value = child.value;
149
+ if (index === 0) {
150
+ value = value.replace(LEADING_WHITESPACE, "");
151
+ }
152
+ if (index === phrasing.length - 1) {
153
+ value = value.replace(TRAILING_WHITESPACE, "");
154
+ }
155
+ return { ...child, value };
156
+ });
157
+ if (children.some((child) => child.type !== "text" || child.value)) {
158
+ blocks.push({ children, type: "paragraph" });
159
+ }
160
+ phrasing = [];
161
+ };
162
+ for (const child of children) {
163
+ if (BLOCK_NODE_TYPES.has(child.type)) {
164
+ flush();
165
+ blocks.push(child);
166
+ }
167
+ else {
168
+ phrasing.push(child);
169
+ }
170
+ }
171
+ flush();
172
+ return blocks;
173
+ };
27
174
  const OMITTED_NODE_TYPES = new Set([
28
175
  "mdxFlowExpression",
29
176
  "mdxTextExpression",
@@ -44,12 +191,283 @@ const imageNodes = (node) => {
44
191
  type: "paragraph",
45
192
  });
46
193
  }
194
+ else if (alt) {
195
+ nodes.push({
196
+ children: [
197
+ {
198
+ children: [{ type: "text", value: "Image:" }],
199
+ type: "strong",
200
+ },
201
+ { type: "text", value: ` ${alt}` },
202
+ ],
203
+ type: "paragraph",
204
+ });
205
+ }
47
206
  const caption = getAttribute(node, "caption");
48
207
  if (caption) {
49
208
  nodes.push(paragraph(caption));
50
209
  }
51
210
  return nodes;
52
211
  };
212
+ const cardNodes = (node) => {
213
+ const title = getAttribute(node, "title");
214
+ const href = getAttribute(node, "href");
215
+ const description = getAttribute(node, "description");
216
+ const nodes = [];
217
+ if (title) {
218
+ const titleNode = { type: "text", value: title };
219
+ nodes.push(heading([
220
+ href ? { children: [titleNode], type: "link", url: href } : titleNode,
221
+ ]));
222
+ }
223
+ if (description) {
224
+ nodes.push(paragraph(description));
225
+ }
226
+ nodes.push(...blockChildren(node, true));
227
+ return nodes;
228
+ };
229
+ const linkNodes = (node) => {
230
+ const href = getAttribute(node, "href");
231
+ if (!href) {
232
+ return node.children ?? [];
233
+ }
234
+ const children = phrasingChildren(node);
235
+ if (!children) {
236
+ return blockChildren(node, true);
237
+ }
238
+ if (children.length === 0) {
239
+ const label = getAttribute(node, "title") ?? getAttribute(node, "label") ?? href;
240
+ children.push({ type: "text", value: label });
241
+ }
242
+ const link = { children, type: "link", url: href };
243
+ return node.type === "mdxJsxFlowElement"
244
+ ? [{ children: [link], type: "paragraph" }]
245
+ : [link];
246
+ };
247
+ const labelledContentNodes = (node, attributes) => {
248
+ const label = attributes
249
+ .map((attribute) => getAttribute(node, attribute))
250
+ .find(Boolean);
251
+ return [
252
+ ...(label ? [heading([{ type: "text", value: label }])] : []),
253
+ ...blockChildren(node, true),
254
+ ];
255
+ };
256
+ const summaryNodes = (node) => {
257
+ const children = phrasingChildren(node);
258
+ if (!children) {
259
+ return blockChildren(node, true);
260
+ }
261
+ return children.length === 0
262
+ ? []
263
+ : [
264
+ {
265
+ children: [{ children, type: "strong" }],
266
+ type: "paragraph",
267
+ },
268
+ ];
269
+ };
270
+ const typeTableNodes = (node) => {
271
+ const definition = getAttributeExpression(node, "type");
272
+ if (definition?.type !== "ObjectExpression") {
273
+ return [];
274
+ }
275
+ const properties = definition.properties ?? [];
276
+ const rows = properties.flatMap((property, index) => {
277
+ if (property.type !== "Property" ||
278
+ property.computed ||
279
+ properties
280
+ .slice(index + 1)
281
+ .some((entry) => entry.type === "SpreadElement")) {
282
+ return [];
283
+ }
284
+ const name = propertyName(property);
285
+ const value = property.value;
286
+ const type = expressionString(objectProperty(value, "type"));
287
+ const description = expressionString(objectProperty(value, "description"));
288
+ return name && (type || description)
289
+ ? [
290
+ {
291
+ children: [
292
+ {
293
+ children: [inlineCode(name)],
294
+ type: "tableCell",
295
+ },
296
+ {
297
+ children: type ? [inlineCode(type)] : [],
298
+ type: "tableCell",
299
+ },
300
+ {
301
+ children: description
302
+ ? [{ type: "text", value: description }]
303
+ : [],
304
+ type: "tableCell",
305
+ },
306
+ ],
307
+ type: "tableRow",
308
+ },
309
+ ]
310
+ : [];
311
+ });
312
+ if (rows.length === 0) {
313
+ return [];
314
+ }
315
+ return [
316
+ {
317
+ children: [
318
+ {
319
+ children: ["Property", "Type", "Description"].map((value) => ({
320
+ children: [{ type: "text", value }],
321
+ type: "tableCell",
322
+ })),
323
+ type: "tableRow",
324
+ },
325
+ ...rows,
326
+ ],
327
+ type: "table",
328
+ },
329
+ ];
330
+ };
331
+ const mermaidNodes = (node) => {
332
+ const chart = getAttribute(node, "chart");
333
+ return chart ? [{ lang: "mermaid", type: "code", value: chart }] : [];
334
+ };
335
+ const fileTreeItems = (node) => {
336
+ if (node.name !== "File" && node.name !== "Folder") {
337
+ return [];
338
+ }
339
+ const descendants = (node.children ?? []).flatMap(fileTreeItems);
340
+ const name = getAttribute(node, "name");
341
+ if (!name) {
342
+ return descendants;
343
+ }
344
+ return [
345
+ {
346
+ children: [
347
+ {
348
+ children: [inlineCode(`${name}${node.name === "Folder" ? "/" : ""}`)],
349
+ type: "paragraph",
350
+ },
351
+ ...(descendants.length > 0
352
+ ? [
353
+ {
354
+ children: descendants,
355
+ ordered: false,
356
+ spread: false,
357
+ type: "list",
358
+ },
359
+ ]
360
+ : []),
361
+ ],
362
+ spread: false,
363
+ type: "listItem",
364
+ },
365
+ ];
366
+ };
367
+ const filesNodes = (node) => {
368
+ const items = (node.children ?? []).flatMap(fileTreeItems);
369
+ return items.length > 0
370
+ ? [{ children: items, ordered: false, spread: false, type: "list" }]
371
+ : [];
372
+ };
373
+ const packageNodes = (node) => {
374
+ const packageValue = getAttribute(node, "package") ?? getAttribute(node, "packages");
375
+ const packageExpression = getAttributeExpression(node, "packages");
376
+ const packages = packageValue
377
+ ? packageValue.split(WHITESPACE).filter(Boolean)
378
+ : (packageExpression?.elements ?? [])
379
+ .map((entry) => expressionString(entry ?? undefined))
380
+ .filter((entry) => Boolean(entry));
381
+ if (packages.length === 0) {
382
+ return [];
383
+ }
384
+ return [
385
+ {
386
+ children: [
387
+ {
388
+ children: [{ type: "text", value: "Packages:" }],
389
+ type: "strong",
390
+ },
391
+ { type: "text", value: " " },
392
+ ...packages.flatMap((entry, index) => [
393
+ ...(index > 0 ? [{ type: "text", value: ", " }] : []),
394
+ inlineCode(entry),
395
+ ]),
396
+ ],
397
+ type: "paragraph",
398
+ },
399
+ ];
400
+ };
401
+ const videoNodes = (node) => {
402
+ const url = getAttribute(node, "src") ?? getAttribute(node, "url");
403
+ if (!url) {
404
+ return [];
405
+ }
406
+ const label = getAttribute(node, "title") ?? "Video";
407
+ return [
408
+ {
409
+ children: [
410
+ {
411
+ children: [{ type: "text", value: label }],
412
+ type: "link",
413
+ url,
414
+ },
415
+ ],
416
+ type: "paragraph",
417
+ },
418
+ ];
419
+ };
420
+ const apiOperationNodes = (node) => {
421
+ const operations = getAttributeExpression(node, "operations");
422
+ if (operations?.type !== "ArrayExpression") {
423
+ return [];
424
+ }
425
+ return (operations.elements ?? []).flatMap((operation) => {
426
+ const method = expressionString(objectProperty(operation ?? undefined, "method"));
427
+ const path = expressionString(objectProperty(operation ?? undefined, "path"));
428
+ return method && path
429
+ ? [heading([inlineCode(`${method.toUpperCase()} ${path}`)])]
430
+ : [];
431
+ });
432
+ };
433
+ const endpointNodes = (node) => {
434
+ const method = getAttribute(node, "method");
435
+ const path = getAttribute(node, "path");
436
+ return method && path
437
+ ? [heading([inlineCode(`${method.toUpperCase()} ${path}`)])]
438
+ : [];
439
+ };
440
+ const themeAwareImageNodes = (node) => {
441
+ const light = getAttributeExpression(node, "light");
442
+ const dark = getAttributeExpression(node, "dark");
443
+ const source = expressionString(objectProperty(light, "src")) ??
444
+ expressionString(objectProperty(dark, "src"));
445
+ const alt = expressionString(objectProperty(light, "alt")) ??
446
+ expressionString(objectProperty(dark, "alt")) ??
447
+ "";
448
+ if (source) {
449
+ return [
450
+ {
451
+ children: [{ alt, type: "image", url: source }],
452
+ type: "paragraph",
453
+ },
454
+ ];
455
+ }
456
+ return alt
457
+ ? [
458
+ {
459
+ children: [
460
+ {
461
+ children: [{ type: "text", value: "Image:" }],
462
+ type: "strong",
463
+ },
464
+ { type: "text", value: ` ${alt}` },
465
+ ],
466
+ type: "paragraph",
467
+ },
468
+ ]
469
+ : [];
470
+ };
53
471
  const calloutNode = (node) => {
54
472
  const title = getAttribute(node, "title");
55
473
  const heading = title
@@ -66,7 +484,7 @@ const calloutNode = (node) => {
66
484
  ]
67
485
  : [];
68
486
  return {
69
- children: [...heading, ...(node.children ?? [])],
487
+ children: [...heading, ...blockChildren(node, true)],
70
488
  type: "blockquote",
71
489
  };
72
490
  };
@@ -93,21 +511,40 @@ const buttonNodes = (node) => {
93
511
  ? [{ children: [link], type: "paragraph" }]
94
512
  : [link];
95
513
  };
514
+ const COMPONENT_REPLACERS = {
515
+ Accordion: (node) => labelledContentNodes(node, ["title"]),
516
+ APIPage: apiOperationNodes,
517
+ APISignature: endpointNodes,
518
+ Button: buttonNodes,
519
+ Callout: (node) => [calloutNode(node)],
520
+ Card: cardNodes,
521
+ Details: (node) => blockChildren(node, true),
522
+ EndpointDisplay: endpointNodes,
523
+ Image: imageNodes,
524
+ InstallPackages: packageNodes,
525
+ LearnMore: linkNodes,
526
+ Link: linkNodes,
527
+ MDXImage: imageNodes,
528
+ Mermaid: mermaidNodes,
529
+ PackageInstall: packageNodes,
530
+ PropertiesTable: typeTableNodes,
531
+ Summary: summaryNodes,
532
+ Tab: (node) => labelledContentNodes(node, ["title", "label", "value"]),
533
+ ThemeAwareImage: themeAwareImageNodes,
534
+ TypeTable: typeTableNodes,
535
+ Video: videoNodes,
536
+ };
96
537
  const replaceComponent = (node) => {
97
- if (OMITTED_COMPONENTS.has(node.name ?? "")) {
538
+ const name = node.name ?? "";
539
+ if (OMITTED_COMPONENTS.has(name)) {
98
540
  return [];
99
541
  }
100
- if (node.name === "Check" || node.name === "Cross") {
101
- return [{ type: "text", value: node.name === "Check" ? "✓" : "✗" }];
102
- }
103
- if (node.name === "Image") {
104
- return imageNodes(node);
542
+ if (name === "Check" || name === "Cross") {
543
+ return [{ type: "text", value: name === "Check" ? "✓" : "✗" }];
105
544
  }
106
- if (node.name === "Callout") {
107
- return [calloutNode(node)];
108
- }
109
- if (node.name === "Button") {
110
- return buttonNodes(node);
545
+ const replacer = COMPONENT_REPLACERS[name];
546
+ if (replacer) {
547
+ return replacer(node);
111
548
  }
112
549
  const text = getAttribute(node, "text");
113
550
  if ((node.name === "CopyPrompt" || node.name === "Prompt") && text) {
@@ -119,22 +556,13 @@ const replaceComponent = (node) => {
119
556
  return node.children ?? [];
120
557
  };
121
558
  const isJsxElement = (node) => node.type === "mdxJsxFlowElement" || node.type === "mdxJsxTextElement";
122
- const getAttributeExpression = (node, name) => {
123
- const value = node.attributes?.find((entry) => entry.type === "mdxJsxAttribute" && entry.name === name)?.value;
124
- if (!value || typeof value === "string") {
125
- return undefined;
126
- }
127
- const statement = value.data?.estree?.body[0];
128
- return statement?.type === "ExpressionStatement"
129
- ? statement.expression
130
- : undefined;
131
- };
132
559
  const tabsNodes = (node) => {
133
560
  const expression = getAttributeExpression(node, "tabs");
561
+ const elements = expression?.elements ?? [];
134
562
  // Read literals without evaluating MDX. A spread makes label positions unknown.
135
563
  const labels = expression?.type === "ArrayExpression" &&
136
- !expression.elements.some((element) => element?.type === "SpreadElement")
137
- ? expression.elements.map((element) => element?.type === "Literal" && typeof element.value === "string"
564
+ !elements.some((element) => element?.type === "SpreadElement")
565
+ ? elements.map((element) => element?.type === "Literal" && typeof element.value === "string"
138
566
  ? element.value
139
567
  : undefined)
140
568
  : [];
@@ -198,12 +626,22 @@ const cleanNode = (node) => {
198
626
  if (isStepsNode(node)) {
199
627
  return stepsNodes(node);
200
628
  }
629
+ if (isJsxElement(node) && node.name === "Files") {
630
+ return filesNodes(node);
631
+ }
201
632
  if (isJsxElement(node) && node.name === "TabsWithChildren") {
202
633
  return tabsNodes(node);
203
634
  }
204
635
  if (node.children) {
205
636
  node.children = node.children.flatMap(cleanNode);
206
637
  }
638
+ // Inline JSX can expand into block Markdown (for example an Accordion title
639
+ // becomes a heading). Lift those blocks out of the containing paragraph so
640
+ // remark-stringify does not concatenate structurally invalid children.
641
+ if (node.type === "paragraph" &&
642
+ node.children?.some((child) => BLOCK_NODE_TYPES.has(child.type))) {
643
+ return blockChildren(node, true);
644
+ }
207
645
  if (!isJsxElement(node)) {
208
646
  return [node];
209
647
  }
@@ -46,6 +46,6 @@ const GeistdocsProviderInner = ({ config, search, theme: _theme, lang, ...props
46
46
  return (_jsxs("div", { className: cn("@container transition-[padding-right] duration-150 ease-[cubic-bezier(0.175,0.885,0.32,1.1)] motion-reduce:transition-none", enabled && isOpen && !isMobile ? "pr-[400px]!" : null), "data-geistdocs-container": true, children: [_jsx(RootProvider, { i18n: i18nProvider(lang ?? i18n.defaultLanguage), search: {
47
47
  SearchDialog: SearchDialogComponent,
48
48
  ...search,
49
- }, theme: { enabled: false }, ...props }), _jsx(GeistdocsWebMCP, { config: config, lang: lang }), _jsx(Toasts, {}), hasBeenOpened ? (_jsx(Suspense, { fallback: isOpen ? (_jsx(ChatLoadingSkeleton, { isMobile: isMobile, title: config.title })) : null, children: _jsx(GeistdocsChatShell, {}) })) : null] }));
49
+ }, theme: { enabled: false }, ...props }), _jsx(GeistdocsWebMCP, { config: config }), _jsx(Toasts, {}), hasBeenOpened ? (_jsx(Suspense, { fallback: isOpen ? (_jsx(ChatLoadingSkeleton, { isMobile: isMobile, title: config.title })) : null, children: _jsx(GeistdocsChatShell, {}) })) : null] }));
50
50
  };
51
51
  export const GeistdocsProvider = (props) => (_jsx(GeistProvider, { storageKey: "geistdocs-theme", withScript: false, children: _jsx(GeistdocsConfigProvider, { config: props.config, children: _jsx(GeistdocsChatProvider, { config: props.config, children: _jsx(GeistdocsProviderInner, { ...props }) }) }) }));
@@ -1,6 +1,5 @@
1
- import type { GeistdocsConfig } from "../config";
2
- export declare const GeistdocsWebMCP: ({ config, lang, }: {
1
+ import { type GeistdocsConfig } from "../config";
2
+ export declare const GeistdocsWebMCP: ({ config }: {
3
3
  config: GeistdocsConfig;
4
- lang?: string;
5
- }) => null;
4
+ }) => import("react/jsx-runtime").JSX.Element | null;
6
5
  //# sourceMappingURL=webmcp-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"webmcp-client.d.ts","sourceRoot":"","sources":["../../src/internal/webmcp-client.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAOjD,eAAO,MAAM,eAAe,GAAI,mBAG7B;IACD,MAAM,EAAE,eAAe,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,SAiBA,CAAC"}
1
+ {"version":3,"file":"webmcp-client.d.ts","sourceRoot":"","sources":["../../src/internal/webmcp-client.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,WAAW,CAAC;AAOhE,eAAO,MAAM,eAAe,GAAI,YAAY;IAAE,MAAM,EAAE,eAAe,CAAA;CAAE,mDAqBtE,CAAC"}
@@ -1,21 +1,18 @@
1
1
  "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import Script from "next/script";
2
4
  import { useEffect } from "react";
5
+ import { getPublicPath } from "../config";
3
6
  import { createWebMCPTools, registerWebMCPTools, } from "./webmcp";
4
- export const GeistdocsWebMCP = ({ config, lang, }) => {
7
+ export const GeistdocsWebMCP = ({ config }) => {
8
+ const enabled = config.webmcp?.enabled;
5
9
  useEffect(() => {
6
10
  const context = document
7
11
  .modelContext;
8
- if (!(config.webmcp?.enabled && context?.registerTool)) {
12
+ if (!(enabled && context?.registerTool)) {
9
13
  return;
10
14
  }
11
- const tools = createWebMCPTools({
12
- config,
13
- lang,
14
- location: window.location,
15
- });
16
- return registerWebMCPTools(context, tools, (error) => {
17
- console.warn("Geistdocs WebMCP registration failed:", error);
18
- });
19
- }, [config, lang]);
20
- return null;
15
+ return registerWebMCPTools(context, createWebMCPTools({ location: window.location }), (error) => console.warn("Geistdocs WebMCP registration failed:", error));
16
+ }, [enabled]);
17
+ return enabled ? (_jsx(Script, { id: "geistdocs-webmcp", src: `${getPublicPath("/api/mcp", config.basePath)}?webmcp-script` })) : null;
21
18
  };
@@ -1,4 +1,3 @@
1
- import { type GeistdocsConfig } from "../config.js";
2
1
  interface ToolExecutionContext {
3
2
  signal?: AbortSignal;
4
3
  }
@@ -17,14 +16,11 @@ export interface WebMCPContext {
17
16
  signal: AbortSignal;
18
17
  }) => Promise<void>;
19
18
  }
20
- interface WebMCPOptions {
21
- config: GeistdocsConfig;
19
+ export declare const createWebMCPTools: ({ fetcher, location, requestTimeoutMs, }: {
22
20
  fetcher?: typeof fetch;
23
- lang?: string;
24
21
  location: Pick<Location, "href">;
25
22
  requestTimeoutMs?: number;
26
- }
27
- export declare const createWebMCPTools: ({ config, fetcher, lang, location, requestTimeoutMs, }: WebMCPOptions) => WebMCPTool[];
23
+ }) => WebMCPTool[];
28
24
  export declare const registerWebMCPTools: (context: WebMCPContext, tools: WebMCPTool[], onError: (error: unknown) => void) => () => void;
29
25
  export {};
30
26
  //# sourceMappingURL=webmcp.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"webmcp.d.ts","sourceRoot":"","sources":["../../src/internal/webmcp.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EAGrB,MAAM,cAAc,CAAC;AAEtB,UAAU,oBAAoB;IAC5B,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,UAAU,UAAU;IAClB,WAAW,EAAE;QAAE,YAAY,EAAE,OAAO,CAAC;QAAC,oBAAoB,EAAE,OAAO,CAAA;KAAE,CAAC;IACtE,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,CACP,KA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