@assistant-ui/mcp-docs-server 0.1.39 → 0.2.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 (185) hide show
  1. package/.docs/organized/code-examples/waterfall.md +17 -18
  2. package/.docs/organized/code-examples/with-a2a.md +20 -15
  3. package/.docs/organized/code-examples/with-ag-ui.md +19 -17
  4. package/.docs/organized/code-examples/with-ai-sdk-v7.md +17 -16
  5. package/.docs/organized/code-examples/with-artifacts.md +471 -145
  6. package/.docs/organized/code-examples/with-assistant-transport.md +23 -31
  7. package/.docs/organized/code-examples/with-browser-extension.md +21 -14
  8. package/.docs/organized/code-examples/with-chain-of-thought.md +22 -20
  9. package/.docs/organized/code-examples/with-cloud-standalone.md +13 -14
  10. package/.docs/organized/code-examples/with-cloud.md +22 -17
  11. package/.docs/organized/code-examples/with-custom-thread-list.md +17 -16
  12. package/.docs/organized/code-examples/with-elevenlabs-conversational.md +17 -17
  13. package/.docs/organized/code-examples/with-elevenlabs-scribe.md +21 -19
  14. package/.docs/organized/code-examples/with-eve.md +70 -16
  15. package/.docs/organized/code-examples/with-expo.md +32 -51
  16. package/.docs/organized/code-examples/with-external-store.md +20 -15
  17. package/.docs/organized/code-examples/with-ffmpeg.md +24 -18
  18. package/.docs/organized/code-examples/with-generative-ui.md +20 -21
  19. package/.docs/organized/code-examples/with-google-adk.md +21 -16
  20. package/.docs/organized/code-examples/with-heat-graph.md +10 -11
  21. package/.docs/organized/code-examples/with-image-generation.md +13 -14
  22. package/.docs/organized/code-examples/with-interactables.md +17 -16
  23. package/.docs/organized/code-examples/with-langchain.md +13 -14
  24. package/.docs/organized/code-examples/with-langgraph.md +23 -17
  25. package/.docs/organized/code-examples/with-livekit.md +17 -17
  26. package/.docs/organized/code-examples/with-mcp.md +36 -32
  27. package/.docs/organized/code-examples/with-nuxt.md +2492 -0
  28. package/.docs/organized/code-examples/with-opencode.md +27 -21
  29. package/.docs/organized/code-examples/with-pi.md +69 -67
  30. package/.docs/organized/code-examples/with-react-hook-form.md +18 -17
  31. package/.docs/organized/code-examples/with-react-ink-web.md +10 -11
  32. package/.docs/organized/code-examples/with-react-ink.md +7 -7
  33. package/.docs/organized/code-examples/with-react-router.md +23 -17
  34. package/.docs/organized/code-examples/with-resumable-stream.md +15 -16
  35. package/.docs/organized/code-examples/with-store.md +31 -20
  36. package/.docs/organized/code-examples/with-tanstack.md +22 -16
  37. package/.docs/organized/code-examples/with-tap-runtime.md +19 -19
  38. package/.docs/organized/code-examples/with-virtualized-thread.md +12 -13
  39. package/.docs/organized/code-examples/with-vue.md +408 -0
  40. package/.docs/raw/docs/(docs)/cli.mdx +3 -1
  41. package/.docs/raw/docs/(docs)/devtools.mdx +7 -2
  42. package/.docs/raw/docs/(docs)/index.mdx +9 -76
  43. package/.docs/raw/docs/(docs)/installation.mdx +4 -18
  44. package/.docs/raw/docs/(reference)/api-reference/context-providers/assistant-runtime-provider.mdx +24 -4
  45. package/.docs/raw/docs/(reference)/api-reference/generative-ui/a2ui.mdx +40 -0
  46. package/.docs/raw/docs/(reference)/api-reference/generative-ui/index.mdx +3 -0
  47. package/.docs/raw/docs/(reference)/api-reference/hooks/primitives.mdx +19 -420
  48. package/.docs/raw/docs/(reference)/api-reference/hooks/state.mdx +4 -1
  49. package/.docs/raw/docs/(reference)/api-reference/integrations/eve.mdx +8 -0
  50. package/.docs/raw/docs/(reference)/api-reference/integrations/react-ai-sdk.mdx +21 -0
  51. package/.docs/raw/docs/(reference)/api-reference/model-context/context.mdx +1 -9
  52. package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-if.mdx +1 -18
  53. package/.docs/raw/docs/(reference)/api-reference/utilities/miscellaneous.mdx +24 -1
  54. package/.docs/raw/docs/cloud/ai-sdk-assistant-ui.mdx +1 -1
  55. package/.docs/raw/docs/cloud/ai-sdk.mdx +2 -2
  56. package/.docs/raw/docs/cloud/langgraph.mdx +1 -1
  57. package/.docs/raw/docs/copilots/model-context.mdx +5 -4
  58. package/.docs/raw/docs/copilots/motivation.mdx +5 -5
  59. package/.docs/raw/docs/guides/attachments.mdx +3 -3
  60. package/.docs/raw/docs/guides/branching.mdx +2 -2
  61. package/.docs/raw/docs/guides/chain-of-thought.mdx +1 -1
  62. package/.docs/raw/docs/guides/context-api.mdx +89 -111
  63. package/.docs/raw/docs/guides/editing.mdx +5 -5
  64. package/.docs/raw/docs/guides/electron.mdx +369 -0
  65. package/.docs/raw/docs/guides/index.mdx +10 -0
  66. package/.docs/raw/docs/guides/quoting.mdx +3 -3
  67. package/.docs/raw/docs/guides/resumable-stream-deployment.mdx +2 -2
  68. package/.docs/raw/docs/guides/resumable-streams.mdx +74 -3
  69. package/.docs/raw/docs/guides/suggestions.mdx +9 -9
  70. package/.docs/raw/docs/ink/hooks.mdx +12 -7
  71. package/.docs/raw/docs/ink/primitives.mdx +18 -10
  72. package/.docs/raw/docs/integrations/attachments/custom-adapter.mdx +16 -0
  73. package/.docs/raw/docs/integrations/auth/better-auth.mdx +3 -3
  74. package/.docs/raw/docs/integrations/auth/clerk.mdx +3 -3
  75. package/.docs/raw/docs/integrations/auth/next-auth.mdx +4 -4
  76. package/.docs/raw/docs/integrations/frameworks/cloudflare-agents/overview.mdx +1 -1
  77. package/.docs/raw/docs/integrations/frameworks/mastra/full-stack.mdx +2 -2
  78. package/.docs/raw/docs/integrations/frameworks/mastra/separate-server.mdx +1 -1
  79. package/.docs/raw/docs/integrations/gateways/index.mdx +2 -2
  80. package/.docs/raw/docs/integrations/observability/helicone.mdx +2 -2
  81. package/.docs/raw/docs/integrations/observability/langfuse.mdx +1 -1
  82. package/.docs/raw/docs/integrations/observability/langsmith.mdx +3 -3
  83. package/.docs/raw/docs/integrations/persistence/custom-adapter.mdx +36 -9
  84. package/.docs/raw/docs/migrations/toolkit-tools.mdx +15 -13
  85. package/.docs/raw/docs/migrations/v0-15.mdx +236 -0
  86. package/.docs/raw/docs/primitives/attachment.mdx +2 -2
  87. package/.docs/raw/docs/primitives/composer.mdx +3 -3
  88. package/.docs/raw/docs/primitives/message.mdx +33 -1
  89. package/.docs/raw/docs/primitives/suggestion.mdx +1 -1
  90. package/.docs/raw/docs/primitives/thread-list.mdx +2 -2
  91. package/.docs/raw/docs/react-native/hooks.mdx +17 -7
  92. package/.docs/raw/docs/react-native/index.mdx +3 -3
  93. package/.docs/raw/docs/react-native/primitives.mdx +41 -7
  94. package/.docs/raw/docs/runtimes/ai-sdk/overview.mdx +3 -3
  95. package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +5 -5
  96. package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +5 -5
  97. package/.docs/raw/docs/runtimes/ai-sdk/v6-legacy.mdx +13 -14
  98. package/.docs/raw/docs/runtimes/ai-sdk/v7.mdx +11 -12
  99. package/.docs/raw/docs/runtimes/concepts/threads.mdx +50 -11
  100. package/.docs/raw/docs/runtimes/custom/assistant-transport.mdx +20 -2
  101. package/.docs/raw/docs/runtimes/custom/external-store.mdx +31 -2
  102. package/.docs/raw/docs/runtimes/custom/local-runtime.mdx +39 -12
  103. package/.docs/raw/docs/runtimes/eve/overview.mdx +51 -0
  104. package/.docs/raw/docs/runtimes/eve/quickstart.mdx +51 -2
  105. package/.docs/raw/docs/runtimes/google-adk/hooks.mdx +9 -12
  106. package/.docs/raw/docs/runtimes/langchain.mdx +2 -2
  107. package/.docs/raw/docs/runtimes/langgraph/overview.mdx +1 -1
  108. package/.docs/raw/docs/runtimes/langgraph/streaming.mdx +1 -1
  109. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +7 -7
  110. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +4 -4
  111. package/.docs/raw/docs/runtimes/opencode/hooks.mdx +4 -1
  112. package/.docs/raw/docs/runtimes/opencode/overview.mdx +10 -0
  113. package/.docs/raw/docs/tools/a2ui.mdx +107 -0
  114. package/.docs/raw/docs/tools/backend.mdx +2 -2
  115. package/.docs/raw/docs/tools/defining-tools.mdx +9 -7
  116. package/.docs/raw/docs/tools/dynamic-tools.mdx +6 -4
  117. package/.docs/raw/docs/tools/interactables-legacy.mdx +28 -15
  118. package/.docs/raw/docs/tools/interactables.mdx +27 -16
  119. package/.docs/raw/docs/tools/mcp-apps.mdx +96 -8
  120. package/.docs/raw/docs/tools/mcp.mdx +9 -7
  121. package/.docs/raw/docs/tools/tool-ui.mdx +26 -22
  122. package/.docs/raw/docs/tools/user-managed-mcp.mdx +64 -14
  123. package/.docs/raw/docs/ui/file.mdx +6 -1
  124. package/.docs/raw/docs/ui/follow-up-suggestions.mdx +2 -0
  125. package/.docs/raw/docs/ui/mcp-config.mdx +8 -3
  126. package/.docs/raw/docs/ui/model-selector.mdx +9 -9
  127. package/.docs/raw/docs/ui/part-grouping.mdx +1 -5
  128. package/.docs/raw/docs/ui/reasoning.mdx +1 -1
  129. package/.docs/raw/docs/ui/thread.mdx +24 -5
  130. package/.docs/raw/docs/utilities/react-o11y.mdx +7 -9
  131. package/dist/constants.js +2 -2
  132. package/dist/constants.js.map +1 -1
  133. package/dist/index.d.ts +1 -1
  134. package/dist/index.js +2 -2
  135. package/dist/index.js.map +1 -1
  136. package/dist/prepare-docs/code-examples.js.map +1 -1
  137. package/dist/prepare-docs/prepare.d.ts +1 -1
  138. package/dist/prepare-docs/prepare.js.map +1 -1
  139. package/dist/stdio.d.ts +1 -1
  140. package/dist/tools/docs.d.ts +6 -10
  141. package/dist/tools/docs.d.ts.map +1 -1
  142. package/dist/tools/docs.js +6 -4
  143. package/dist/tools/docs.js.map +1 -1
  144. package/dist/tools/examples.d.ts +4 -8
  145. package/dist/tools/examples.d.ts.map +1 -1
  146. package/dist/tools/examples.js +4 -3
  147. package/dist/tools/examples.js.map +1 -1
  148. package/dist/tools/resources.d.ts +1 -1
  149. package/dist/tools/resources.d.ts.map +1 -1
  150. package/dist/tools/resources.js +3 -2
  151. package/dist/tools/resources.js.map +1 -1
  152. package/dist/tools/search.d.ts +4 -10
  153. package/dist/tools/search.d.ts.map +1 -1
  154. package/dist/tools/search.js +2 -2
  155. package/dist/tools/search.js.map +1 -1
  156. package/dist/tools/tests/mcp-test-client.d.ts +15 -0
  157. package/dist/tools/tests/mcp-test-client.d.ts.map +1 -0
  158. package/dist/tools/tests/mcp-test-client.js +68 -0
  159. package/dist/tools/tests/mcp-test-client.js.map +1 -0
  160. package/dist/tools/tests/test-setup.d.ts.map +1 -1
  161. package/dist/tools/tests/test-setup.js +2 -1
  162. package/dist/tools/tests/test-setup.js.map +1 -1
  163. package/dist/tools/xulux-templates.d.ts +9 -23
  164. package/dist/tools/xulux-templates.d.ts.map +1 -1
  165. package/dist/tools/xulux-templates.js +8 -6
  166. package/dist/tools/xulux-templates.js.map +1 -1
  167. package/dist/utils/logger.d.ts.map +1 -1
  168. package/dist/utils/mdx.js +2 -1
  169. package/dist/utils/mdx.js.map +1 -1
  170. package/dist/utils/security.js.map +1 -1
  171. package/dist/xulux/catalog-client.js +1 -1
  172. package/dist/xulux/catalog-client.js.map +1 -1
  173. package/package.json +6 -5
  174. package/src/index.ts +2 -2
  175. package/src/tools/docs.ts +2 -2
  176. package/src/tools/examples.ts +2 -2
  177. package/src/tools/resources.ts +1 -4
  178. package/src/tools/search.ts +2 -2
  179. package/src/tools/tests/completions.test.ts +40 -26
  180. package/src/tools/tests/docs.test.ts +2 -2
  181. package/src/tools/tests/integration.test.ts +3 -4
  182. package/src/tools/tests/mcp-protocol.test.ts +160 -175
  183. package/src/tools/tests/mcp-test-client.ts +111 -0
  184. package/src/tools/tests/resources.test.ts +97 -66
  185. package/src/tools/xulux-templates.ts +4 -4
@@ -25,7 +25,7 @@ platforms: ["react"]
25
25
  ```tsx title="app/providers.tsx"
26
26
  "use client";
27
27
 
28
- import { AuiProvider, useAui } from "@assistant-ui/react";
28
+ import { AuiConfig, AuiProvider, useAui } from "@assistant-ui/react";
29
29
  import { McpManagerResource, defineConnector } from "@assistant-ui/react-mcp";
30
30
 
31
31
  const connectors = [
@@ -38,8 +38,13 @@ const connectors = [
38
38
  ];
39
39
 
40
40
  export function Providers({ children }: { children: React.ReactNode }) {
41
- const aui = useAui({ mcp: McpManagerResource({ connectors }) });
42
- return <AuiProvider value={aui}>{children}</AuiProvider>;
41
+ const aui = useAui();
42
+ const config = AuiConfig({ mcp: McpManagerResource({ connectors }) });
43
+ return (
44
+ <AuiProvider extends={aui} config={config}>
45
+ {children}
46
+ </AuiProvider>
47
+ );
43
48
  }
44
49
  ```
45
50
 
@@ -38,11 +38,11 @@ const ComposerAction: FC = () => {
38
38
  <div className="flex items-center gap-1">
39
39
  <ModelSelector
40
40
  models={[
41
- { id: "gpt-5.4-nano", name: "GPT-5.4 Nano", description: "Fast and efficient" },
42
- { id: "gpt-5.4-mini", name: "GPT-5.4 Mini", description: "Balanced performance" },
43
- { id: "gpt-5.5", name: "GPT-5.5", description: "Most capable", efforts: true },
41
+ { id: "gpt-5.6-luna", name: "GPT-5.6 Luna", description: "Fast and efficient" },
42
+ { id: "gpt-5.6-terra", name: "GPT-5.6 Terra", description: "Balanced performance" },
43
+ { id: "gpt-5.6-sol", name: "GPT-5.6 Sol", description: "Most capable", efforts: true },
44
44
  ]}
45
- defaultValue="gpt-5.4-nano"
45
+ defaultValue="gpt-5.6-luna"
46
46
  defaultEffort="medium"
47
47
  size="sm"
48
48
  />
@@ -63,7 +63,7 @@ export async function POST(req: Request) {
63
63
  const { messages, config } = await req.json();
64
64
 
65
65
  const result = streamText({
66
- model: openai(config?.modelName ?? "gpt-5.4-nano"),
66
+ model: openai(config?.modelName ?? "gpt-5.6-luna"),
67
67
  providerOptions: {
68
68
  openai:
69
69
  config?.reasoningEffort !== undefined
@@ -88,8 +88,8 @@ A model that declares `efforts` shows a "Thinking" row at the bottom of the popo
88
88
 
89
89
  ```tsx
90
90
  {
91
- id: "gpt-5.5",
92
- name: "GPT-5.5",
91
+ id: "gpt-5.6-sol",
92
+ name: "GPT-5.6 Sol",
93
93
  efforts: [
94
94
  { id: "minimal", name: "Minimal" },
95
95
  { id: "high", name: "High" },
@@ -156,7 +156,7 @@ import { ClaudeLogo, GeminiLogo, OpenAILogo } from "@/components/assistant-ui/lo
156
156
 
157
157
  <ModelSelector
158
158
  models={[
159
- { id: "gpt-5.5", name: "GPT-5.5", icon: <OpenAILogo /> },
159
+ { id: "gpt-5.6-sol", name: "GPT-5.6 Sol", icon: <OpenAILogo /> },
160
160
  { id: "claude-opus-4.5", name: "Claude Opus 4.5", icon: <ClaudeLogo /> },
161
161
  { id: "gemini-3-pro", name: "Gemini 3 Pro", icon: <GeminiLogo /> },
162
162
  ]}
@@ -308,7 +308,7 @@ The picker implements the WAI-ARIA combobox pattern over Popover + Command.
308
308
 
309
309
  The default `ModelSelector` export registers the selection with assistant-ui's `ModelContext` system:
310
310
 
311
- 1. The component calls `aui.modelContext().register()` with `config.modelName`, plus `config.reasoningEffort` when the selected model supports the chosen level
311
+ 1. The component calls `aui.modelContext.register()` with `config.modelName`, plus `config.reasoningEffort` when the selected model supports the chosen level
312
312
  2. The `AssistantChatTransport` includes `config` in the request body of every chat request
313
313
  3. Your API route reads `config.modelName` and `config.reasoningEffort`
314
314
 
@@ -248,10 +248,6 @@ The synthetic `"standalone-tool-call"` key on `groupPartByType` matches all of t
248
248
  </MessagePrimitive.GroupedParts>;
249
249
  ```
250
250
 
251
- <Callout type="info">
252
- The `"mcp-app"` key is deprecated in favor of `"standalone-tool-call"`, which is a superset (it also matches MCP-app tool calls). Existing `"mcp-app"` usage keeps working.
253
- </Callout>
254
-
255
251
  ### Render Tool Calls as Flat Rows
256
252
 
257
253
  The previous section keeps `"tool-call"` folded into the chain-of-thought and only lifts standalone tool UIs out. To keep reasoning collapsed in a group while every tool call renders as its own row in the message flow, map both tool keys to `[]`:
@@ -579,7 +575,7 @@ Use `MessagePrimitive.Unstable_PartsGrouped` only when you need to collect non-a
579
575
  name: "Unstable_Audio",
580
576
  type: "Unstable_AudioMessagePartComponent",
581
577
  description:
582
- "Component for rendering audio content (experimental)",
578
+ "Component for rendering audio content (deprecated, render audio/* from File)",
583
579
  },
584
580
  {
585
581
  name: "tools",
@@ -28,7 +28,7 @@ Previously, reasoning parts were rendered via `components.Reasoning` and grouped
28
28
 
29
29
  Render reasoning parts through `MessagePrimitive.GroupedParts`. Group consecutive reasoning parts with `"group-reasoning"`, then compose `ReasoningRoot`, `ReasoningTrigger`, `ReasoningContent`, and `ReasoningText` around the grouped children.
30
30
 
31
- While reasoning is streaming, `part.status.type === "running"`. Pass that to `streaming` so the accordion auto-opens during streaming with a bottom-pinned live preview of the newest tokens, auto-collapses when the model moves on, and permanently defers to the first manual toggle. When `streaming` is provided it supersedes `defaultOpen`.
31
+ While reasoning is streaming, `part.status.type === "running"`. Pass that to `streaming` so the accordion auto-opens during streaming with a bottom-pinned live preview of the newest tokens, and permanently defers to the first manual toggle. `streaming` only holds the disclosure open; when it ends the accordion returns to `defaultOpen`, which is `false` by default and therefore collapses. Pass `defaultOpen` to keep reasoning expanded once the run finishes.
32
32
 
33
33
  ```tsx title="/app/components/assistant-ui/thread.tsx"
34
34
  import { MessagePrimitive, groupPartByType } from "@assistant-ui/react";
@@ -111,17 +111,36 @@ export default function Chat() {
111
111
  Display suggested prompts using the Suggestions API. See the [Suggestions guide](/docs/guides/suggestions) for detailed configuration.
112
112
 
113
113
  ```tsx
114
- import { SuggestionPrimitive, ThreadPrimitive } from "@assistant-ui/react";
114
+ import type { ReactNode } from "react";
115
+ import {
116
+ AssistantRuntimeProvider,
117
+ AuiConfig,
118
+ SuggestionPrimitive,
119
+ Suggestions,
120
+ ThreadPrimitive,
121
+ } from "@assistant-ui/react";
122
+ import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
115
123
 
116
124
  // Configure suggestions in your runtime provider
117
- const aui = useAui({
125
+ const config = AuiConfig({
118
126
  suggestions: Suggestions(["What's the weather?", "Tell me a joke"]),
119
127
  });
120
128
 
129
+ const App = ({ children }: { children: ReactNode }) => {
130
+ const runtime = useChatRuntime();
131
+ return (
132
+ <AssistantRuntimeProvider runtime={runtime} config={config}>
133
+ {children}
134
+ </AssistantRuntimeProvider>
135
+ );
136
+ };
137
+
121
138
  // Display suggestions in your thread component
122
- <ThreadPrimitive.Suggestions>
123
- {() => <SuggestionItem />}
124
- </ThreadPrimitive.Suggestions>
139
+ const ThreadSuggestions = () => (
140
+ <ThreadPrimitive.Suggestions>
141
+ {() => <SuggestionItem />}
142
+ </ThreadPrimitive.Suggestions>
143
+ );
125
144
 
126
145
  // Custom suggestion item
127
146
  const SuggestionItem = () => (
@@ -42,7 +42,7 @@ import {
42
42
  SpanResource,
43
43
  type SpanData,
44
44
  } from "@assistant-ui/react-o11y";
45
- import { useAui, AuiProvider } from "@assistant-ui/store";
45
+ import { AuiConfig, AuiProvider } from "@assistant-ui/store";
46
46
 
47
47
  function SpanRow() {
48
48
  return (
@@ -59,10 +59,9 @@ function SpanRow() {
59
59
  }
60
60
 
61
61
  export function TraceView({ spans }: { spans: SpanData[] }) {
62
- const aui = useAui({ span: SpanResource({ spans }) });
63
-
62
+ const config = AuiConfig({ span: SpanResource({ spans }) });
64
63
  return (
65
- <AuiProvider value={aui}>
64
+ <AuiProvider extends={null} config={config}>
66
65
  <SpanPrimitive.Children components={{ Span: SpanRow }} />
67
66
  </AuiProvider>
68
67
  );
@@ -106,10 +105,9 @@ import {
106
105
  SpanByIndexProvider,
107
106
  } from "@assistant-ui/react-o11y";
108
107
 
109
- // Top-level: mount SpanResource via useAui
110
- const aui = useAui({ span: SpanResource({ spans }) });
111
-
112
- <AuiProvider value={aui}>
108
+ // Top-level: mount SpanResource via AuiProvider
109
+ const config = AuiConfig({ span: SpanResource({ spans }) });
110
+ <AuiProvider extends={null} config={config}>
113
111
  {/* Render visible spans (flat-list output respecting collapsed state) */}
114
112
  <SpanPrimitive.Children components={{ Span: SpanRow }} />
115
113
  </AuiProvider>;
@@ -140,7 +138,7 @@ Resource that ingests raw span data and exposes a tree-aware reactive state to p
140
138
  SpanResource({ spans }: { spans: SpanData[] }): ClientOutput<"span">;
141
139
  ```
142
140
 
143
- Mount through `useAui({ span: SpanResource({ spans }) })`.
141
+ Mount through `config={config}`, where `const config = AuiConfig({ span: SpanResource({ spans }) })`.
144
142
 
145
143
  The resource computes:
146
144
 
package/dist/constants.js CHANGED
@@ -10,8 +10,8 @@ const DOCS_PATH = join(DOCS_BASE, "raw/docs");
10
10
  const CODE_EXAMPLES_PATH = join(DOCS_BASE, "organized/code-examples");
11
11
  const MDX_EXTENSION = ".mdx";
12
12
  const MD_EXTENSION = ".md";
13
- const MAX_FILE_SIZE = 10 * 1024 * 1024;
14
- const MAX_DIRECTORY_CONTENT_SIZE = 1024 * 1024;
13
+ const MAX_FILE_SIZE = 10485760;
14
+ const MAX_DIRECTORY_CONTENT_SIZE = 1048576;
15
15
  const IS_PREPARE_MODE = process.argv[1]?.includes("prepare-docs/prepare");
16
16
  //#endregion
17
17
  export { CODE_EXAMPLES_PATH, DOCS_PATH, EXAMPLES_PATH, IS_PREPARE_MODE, MAX_DIRECTORY_CONTENT_SIZE, MAX_FILE_SIZE, MDX_EXTENSION, MD_EXTENSION, PACKAGE_DIR, ROOT_DIR };
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import { fileURLToPath } from \"node:url\";\nimport { dirname, join } from \"node:path\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nexport const ROOT_DIR = join(__dirname, \"../../../\");\nexport const PACKAGE_DIR = join(__dirname, \"../\");\n\nexport const EXAMPLES_PATH = join(ROOT_DIR, \"examples\");\n\nconst DOCS_BASE = join(PACKAGE_DIR, \".docs\");\nexport const DOCS_PATH = join(DOCS_BASE, \"raw/docs\");\nexport const CODE_EXAMPLES_PATH = join(DOCS_BASE, \"organized/code-examples\");\n\nexport const MDX_EXTENSION = \".mdx\";\nexport const MD_EXTENSION = \".md\";\n\nexport const MAX_FILE_SIZE = 10 * 1024 * 1024;\n\nexport const MAX_DIRECTORY_CONTENT_SIZE = 1024 * 1024;\n\nexport const IS_PREPARE_MODE = process.argv[1]?.includes(\n \"prepare-docs/prepare\",\n);\n"],"mappings":";;;AAGA,MAAM,YAAY,QAAQ,cAAc,OAAO,KAAK,GAAG,CAAC;AAExD,MAAa,WAAW,KAAK,WAAW,WAAW;AACnD,MAAa,cAAc,KAAK,WAAW,KAAK;AAEhD,MAAa,gBAAgB,KAAK,UAAU,UAAU;AAEtD,MAAM,YAAY,KAAK,aAAa,OAAO;AAC3C,MAAa,YAAY,KAAK,WAAW,UAAU;AACnD,MAAa,qBAAqB,KAAK,WAAW,yBAAyB;AAE3E,MAAa,gBAAgB;AAC7B,MAAa,eAAe;AAE5B,MAAa,gBAAgB,KAAK,OAAO;AAEzC,MAAa,6BAA6B,OAAO;AAEjD,MAAa,kBAAkB,QAAQ,KAAK,EAAE,EAAE,SAC9C,sBACF"}
1
+ {"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import { fileURLToPath } from \"node:url\";\nimport { dirname, join } from \"node:path\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nexport const ROOT_DIR = join(__dirname, \"../../../\");\nexport const PACKAGE_DIR = join(__dirname, \"../\");\n\nexport const EXAMPLES_PATH = join(ROOT_DIR, \"examples\");\n\nconst DOCS_BASE = join(PACKAGE_DIR, \".docs\");\nexport const DOCS_PATH = join(DOCS_BASE, \"raw/docs\");\nexport const CODE_EXAMPLES_PATH = join(DOCS_BASE, \"organized/code-examples\");\n\nexport const MDX_EXTENSION = \".mdx\";\nexport const MD_EXTENSION = \".md\";\n\nexport const MAX_FILE_SIZE = 10 * 1024 * 1024;\n\nexport const MAX_DIRECTORY_CONTENT_SIZE = 1024 * 1024;\n\nexport const IS_PREPARE_MODE = process.argv[1]?.includes(\n \"prepare-docs/prepare\",\n);\n"],"mappings":";;;AAGA,MAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AAExD,MAAa,WAAW,KAAK,WAAW,WAAW;AACnD,MAAa,cAAc,KAAK,WAAW,KAAK;AAEhD,MAAa,gBAAgB,KAAK,UAAU,UAAU;AAEtD,MAAM,YAAY,KAAK,aAAa,OAAO;AAC3C,MAAa,YAAY,KAAK,WAAW,UAAU;AACnD,MAAa,qBAAqB,KAAK,WAAW,yBAAyB;AAE3E,MAAa,gBAAgB;AAC7B,MAAa,eAAe;AAE5B,MAAa,gBAAgB;AAE7B,MAAa,6BAA6B;AAE1C,MAAa,kBAAkB,QAAQ,KAAK,EAAE,EAAE,SAC9C,sBACF"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
1
+ import { McpServer } from "@modelcontextprotocol/server";
2
2
  //#region src/index.d.ts
3
3
  declare const server: McpServer;
4
4
  declare function runServer(): Promise<void>;
package/dist/index.js CHANGED
@@ -7,8 +7,8 @@ import { xuluxTemplateDetailsTool, xuluxTemplatePreviewTool, xuluxTemplatesListT
7
7
  import { xuluxPlaygroundPrompt } from "./prompts/xulux-playground.js";
8
8
  import { registerResources } from "./tools/resources.js";
9
9
  import { join } from "node:path";
10
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
11
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
10
+ import { McpServer } from "@modelcontextprotocol/server";
11
+ import { StdioServerTransport } from "@modelcontextprotocol/server/stdio";
12
12
  import { readFileSync } from "node:fs";
13
13
  //#region src/index.ts
14
14
  const packageJson = JSON.parse(readFileSync(join(PACKAGE_DIR, "package.json"), "utf-8"));
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport { docsTools } from \"./tools/docs.js\";\nimport { examplesTools } from \"./tools/examples.js\";\nimport { searchTools } from \"./tools/search.js\";\nimport {\n xuluxTemplatesListTool,\n xuluxTemplateDetailsTool,\n xuluxTemplatePreviewTool,\n} from \"./tools/xulux-templates.js\";\nimport { xuluxPlaygroundPrompt } from \"./prompts/xulux-playground.js\";\nimport { registerResources } from \"./tools/resources.js\";\nimport { logger } from \"./utils/logger.js\";\nimport { PACKAGE_DIR } from \"./constants.js\";\n\nimport { readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\nconst packageJson = JSON.parse(\n readFileSync(join(PACKAGE_DIR, \"package.json\"), \"utf-8\"),\n);\n\nexport const server = new McpServer({\n name: \"assistant-ui-docs\",\n version: packageJson.version,\n});\n\nserver.registerTool(\n docsTools.name,\n {\n title: \"assistant-ui Documentation\",\n description: docsTools.description,\n inputSchema: docsTools.parameters,\n annotations: { readOnlyHint: true, openWorldHint: false },\n },\n docsTools.execute,\n);\nserver.registerTool(\n examplesTools.name,\n {\n title: \"assistant-ui Examples\",\n description: examplesTools.description,\n inputSchema: examplesTools.parameters,\n annotations: { readOnlyHint: true, openWorldHint: false },\n },\n examplesTools.execute,\n);\nserver.registerTool(\n searchTools.name,\n {\n title: \"Search assistant-ui Documentation\",\n description: searchTools.description,\n inputSchema: searchTools.parameters,\n annotations: { readOnlyHint: true, openWorldHint: false },\n },\n searchTools.execute,\n);\n\nserver.registerTool(\n xuluxTemplatesListTool.name,\n {\n title: \"assistant-ui Templates\",\n description: xuluxTemplatesListTool.description,\n inputSchema: xuluxTemplatesListTool.parameters,\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n xuluxTemplatesListTool.execute,\n);\nserver.registerTool(\n xuluxTemplateDetailsTool.name,\n {\n title: \"assistant-ui Template Details\",\n description: xuluxTemplateDetailsTool.description,\n inputSchema: xuluxTemplateDetailsTool.parameters,\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n xuluxTemplateDetailsTool.execute,\n);\nserver.registerTool(\n xuluxTemplatePreviewTool.name,\n {\n title: \"assistant-ui Template Preview URLs\",\n description: xuluxTemplatePreviewTool.description,\n inputSchema: xuluxTemplatePreviewTool.parameters,\n annotations: { readOnlyHint: false, openWorldHint: true },\n },\n xuluxTemplatePreviewTool.execute,\n);\n\nserver.registerPrompt(\n xuluxPlaygroundPrompt.name,\n {\n title: \"assistant-ui Template Workflow\",\n description: xuluxPlaygroundPrompt.description,\n },\n () => ({\n messages: [\n {\n role: \"user\" as const,\n content: { type: \"text\" as const, text: xuluxPlaygroundPrompt.text },\n },\n ],\n }),\n);\n\nregisterResources(server);\n\nexport async function runServer() {\n try {\n logger.info(\n `Starting assistant-ui MCP docs server v${packageJson.version}`,\n );\n const transport = new StdioServerTransport();\n await server.connect(transport);\n } catch (error) {\n logger.error(\"Failed to start MCP server\", error);\n process.exit(1);\n }\n}\n\nif (import.meta.url === `file://${process.argv[1]}`) {\n void runServer().catch((error) => {\n console.error(\"Failed to start server:\", error);\n process.exit(1);\n });\n}\n"],"mappings":";;;;;;;;;;;;;AAkBA,MAAM,cAAc,KAAK,MACvB,aAAa,KAAK,aAAa,cAAc,GAAG,OAAO,CACzD;AAEA,MAAa,SAAS,IAAI,UAAU;CAClC,MAAM;CACN,SAAS,YAAY;AACvB,CAAC;AAED,OAAO,aACL,UAAU,MACV;CACE,OAAO;CACP,aAAa,UAAU;CACvB,aAAa,UAAU;CACvB,aAAa;EAAE,cAAc;EAAM,eAAe;CAAM;AAC1D,GACA,UAAU,OACZ;AACA,OAAO,aACL,cAAc,MACd;CACE,OAAO;CACP,aAAa,cAAc;CAC3B,aAAa,cAAc;CAC3B,aAAa;EAAE,cAAc;EAAM,eAAe;CAAM;AAC1D,GACA,cAAc,OAChB;AACA,OAAO,aACL,YAAY,MACZ;CACE,OAAO;CACP,aAAa,YAAY;CACzB,aAAa,YAAY;CACzB,aAAa;EAAE,cAAc;EAAM,eAAe;CAAM;AAC1D,GACA,YAAY,OACd;AAEA,OAAO,aACL,uBAAuB,MACvB;CACE,OAAO;CACP,aAAa,uBAAuB;CACpC,aAAa,uBAAuB;CACpC,aAAa;EAAE,cAAc;EAAM,eAAe;CAAK;AACzD,GACA,uBAAuB,OACzB;AACA,OAAO,aACL,yBAAyB,MACzB;CACE,OAAO;CACP,aAAa,yBAAyB;CACtC,aAAa,yBAAyB;CACtC,aAAa;EAAE,cAAc;EAAM,eAAe;CAAK;AACzD,GACA,yBAAyB,OAC3B;AACA,OAAO,aACL,yBAAyB,MACzB;CACE,OAAO;CACP,aAAa,yBAAyB;CACtC,aAAa,yBAAyB;CACtC,aAAa;EAAE,cAAc;EAAO,eAAe;CAAK;AAC1D,GACA,yBAAyB,OAC3B;AAEA,OAAO,eACL,sBAAsB,MACtB;CACE,OAAO;CACP,aAAa,sBAAsB;AACrC,UACO,EACL,UAAU,CACR;CACE,MAAM;CACN,SAAS;EAAE,MAAM;EAAiB,MAAM,sBAAsB;CAAK;AACrE,CACF,EACF,EACF;AAEA,kBAAkB,MAAM;AAExB,eAAsB,YAAY;CAChC,IAAI;EACF,OAAO,KACL,0CAA0C,YAAY,SACxD;EACA,MAAM,YAAY,IAAI,qBAAqB;EAC3C,MAAM,OAAO,QAAQ,SAAS;CAChC,SAAS,OAAO;EACd,OAAO,MAAM,8BAA8B,KAAK;EAChD,QAAQ,KAAK,CAAC;CAChB;AACF;AAEA,IAAI,OAAO,KAAK,QAAQ,UAAU,QAAQ,KAAK,MAC7C,UAAe,CAAC,CAAC,OAAO,UAAU;CAChC,QAAQ,MAAM,2BAA2B,KAAK;CAC9C,QAAQ,KAAK,CAAC;AAChB,CAAC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { McpServer } from \"@modelcontextprotocol/server\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/server/stdio\";\nimport { docsTools } from \"./tools/docs.js\";\nimport { examplesTools } from \"./tools/examples.js\";\nimport { searchTools } from \"./tools/search.js\";\nimport {\n xuluxTemplatesListTool,\n xuluxTemplateDetailsTool,\n xuluxTemplatePreviewTool,\n} from \"./tools/xulux-templates.js\";\nimport { xuluxPlaygroundPrompt } from \"./prompts/xulux-playground.js\";\nimport { registerResources } from \"./tools/resources.js\";\nimport { logger } from \"./utils/logger.js\";\nimport { PACKAGE_DIR } from \"./constants.js\";\n\nimport { readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\nconst packageJson = JSON.parse(\n readFileSync(join(PACKAGE_DIR, \"package.json\"), \"utf-8\"),\n);\n\nexport const server = new McpServer({\n name: \"assistant-ui-docs\",\n version: packageJson.version,\n});\n\nserver.registerTool(\n docsTools.name,\n {\n title: \"assistant-ui Documentation\",\n description: docsTools.description,\n inputSchema: docsTools.parameters,\n annotations: { readOnlyHint: true, openWorldHint: false },\n },\n docsTools.execute,\n);\nserver.registerTool(\n examplesTools.name,\n {\n title: \"assistant-ui Examples\",\n description: examplesTools.description,\n inputSchema: examplesTools.parameters,\n annotations: { readOnlyHint: true, openWorldHint: false },\n },\n examplesTools.execute,\n);\nserver.registerTool(\n searchTools.name,\n {\n title: \"Search assistant-ui Documentation\",\n description: searchTools.description,\n inputSchema: searchTools.parameters,\n annotations: { readOnlyHint: true, openWorldHint: false },\n },\n searchTools.execute,\n);\n\nserver.registerTool(\n xuluxTemplatesListTool.name,\n {\n title: \"assistant-ui Templates\",\n description: xuluxTemplatesListTool.description,\n inputSchema: xuluxTemplatesListTool.parameters,\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n xuluxTemplatesListTool.execute,\n);\nserver.registerTool(\n xuluxTemplateDetailsTool.name,\n {\n title: \"assistant-ui Template Details\",\n description: xuluxTemplateDetailsTool.description,\n inputSchema: xuluxTemplateDetailsTool.parameters,\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n xuluxTemplateDetailsTool.execute,\n);\nserver.registerTool(\n xuluxTemplatePreviewTool.name,\n {\n title: \"assistant-ui Template Preview URLs\",\n description: xuluxTemplatePreviewTool.description,\n inputSchema: xuluxTemplatePreviewTool.parameters,\n annotations: { readOnlyHint: false, openWorldHint: true },\n },\n xuluxTemplatePreviewTool.execute,\n);\n\nserver.registerPrompt(\n xuluxPlaygroundPrompt.name,\n {\n title: \"assistant-ui Template Workflow\",\n description: xuluxPlaygroundPrompt.description,\n },\n () => ({\n messages: [\n {\n role: \"user\" as const,\n content: { type: \"text\" as const, text: xuluxPlaygroundPrompt.text },\n },\n ],\n }),\n);\n\nregisterResources(server);\n\nexport async function runServer() {\n try {\n logger.info(\n `Starting assistant-ui MCP docs server v${packageJson.version}`,\n );\n const transport = new StdioServerTransport();\n await server.connect(transport);\n } catch (error) {\n logger.error(\"Failed to start MCP server\", error);\n process.exit(1);\n }\n}\n\nif (import.meta.url === `file://${process.argv[1]}`) {\n void runServer().catch((error) => {\n console.error(\"Failed to start server:\", error);\n process.exit(1);\n });\n}\n"],"mappings":";;;;;;;;;;;;;AAkBA,MAAM,cAAc,KAAK,MACvB,aAAa,KAAK,aAAa,cAAc,GAAG,OAAO,CACzD;AAEA,MAAa,SAAS,IAAI,UAAU;CAClC,MAAM;CACN,SAAS,YAAY;AACvB,CAAC;AAED,OAAO,aACL,UAAU,MACV;CACE,OAAO;CACP,aAAa,UAAU;CACvB,aAAa,UAAU;CACvB,aAAa;EAAE,cAAc;EAAM,eAAe;CAAM;AAC1D,GACA,UAAU,OACZ;AACA,OAAO,aACL,cAAc,MACd;CACE,OAAO;CACP,aAAa,cAAc;CAC3B,aAAa,cAAc;CAC3B,aAAa;EAAE,cAAc;EAAM,eAAe;CAAM;AAC1D,GACA,cAAc,OAChB;AACA,OAAO,aACL,YAAY,MACZ;CACE,OAAO;CACP,aAAa,YAAY;CACzB,aAAa,YAAY;CACzB,aAAa;EAAE,cAAc;EAAM,eAAe;CAAM;AAC1D,GACA,YAAY,OACd;AAEA,OAAO,aACL,uBAAuB,MACvB;CACE,OAAO;CACP,aAAa,uBAAuB;CACpC,aAAa,uBAAuB;CACpC,aAAa;EAAE,cAAc;EAAM,eAAe;CAAK;AACzD,GACA,uBAAuB,OACzB;AACA,OAAO,aACL,yBAAyB,MACzB;CACE,OAAO;CACP,aAAa,yBAAyB;CACtC,aAAa,yBAAyB;CACtC,aAAa;EAAE,cAAc;EAAM,eAAe;CAAK;AACzD,GACA,yBAAyB,OAC3B;AACA,OAAO,aACL,yBAAyB,MACzB;CACE,OAAO;CACP,aAAa,yBAAyB;CACtC,aAAa,yBAAyB;CACtC,aAAa;EAAE,cAAc;EAAO,eAAe;CAAK;AAC1D,GACA,yBAAyB,OAC3B;AAEA,OAAO,eACL,sBAAsB,MACtB;CACE,OAAO;CACP,aAAa,sBAAsB;AACrC,UACO,EACL,UAAU,CACR;CACE,MAAM;CACN,SAAS;EAAE,MAAM;EAAiB,MAAM,sBAAsB;CAAK;AACrE,CACF,EACF,EACF;AAEA,kBAAkB,MAAM;AAExB,eAAsB,YAAY;CAChC,IAAI;EACF,OAAO,KACL,0CAA0C,YAAY,SACxD;EACA,MAAM,YAAY,IAAI,qBAAqB;EAC3C,MAAM,OAAO,QAAQ,SAAS;CAChC,SAAS,OAAO;EACd,OAAO,MAAM,8BAA8B,KAAK;EAChD,QAAQ,KAAK,CAAC;CAChB;AACF;AAEA,IAAI,YAAY,QAAQ,UAAU,QAAQ,KAAK,MAC7C,UAAe,CAAC,CAAC,OAAO,UAAU;CAChC,QAAQ,MAAM,2BAA2B,KAAK;CAC9C,QAAQ,KAAK,CAAC;AAChB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"code-examples.js","names":[],"sources":["../../src/prepare-docs/code-examples.ts"],"sourcesContent":["import { rm, mkdir, readdir, readFile, writeFile } from \"node:fs/promises\";\nimport { join, relative, extname } from \"node:path\";\nimport { logger } from \"../utils/logger.js\";\nimport { ROOT_DIR, EXAMPLES_PATH } from \"../constants.js\";\n\nconst OUTPUT_DIR = join(\n ROOT_DIR,\n \"packages/mcp-docs-server/.docs/organized/code-examples\",\n);\nconst MAX_LINES = 10000;\n\ninterface FileContent {\n path: string;\n content: string;\n}\n\nasync function scanDirectory(\n dir: string,\n baseDir: string,\n): Promise<FileContent[]> {\n const files: FileContent[] = [];\n\n try {\n const entries = await readdir(dir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = join(dir, entry.name);\n\n if (entry.isDirectory()) {\n const skipDirs = [\n \"node_modules\",\n \"dist\",\n \"build\",\n \".next\",\n \".git\",\n \".turbo\",\n ];\n if (!skipDirs.includes(entry.name)) {\n const subFiles = await scanDirectory(fullPath, baseDir);\n files.push(...subFiles);\n }\n } else if (entry.isFile()) {\n const includeExts = [\n \".ts\",\n \".tsx\",\n \".js\",\n \".jsx\",\n \".json\",\n \".css\",\n \".md\",\n \".mdx\",\n ];\n const ext = extname(entry.name).toLowerCase();\n\n if (\n includeExts.includes(ext) ||\n entry.name === \"package.json\" ||\n entry.name === \"tsconfig.json\"\n ) {\n try {\n const content = await readFile(fullPath, \"utf-8\");\n const relativePath = relative(baseDir, fullPath);\n files.push({ path: relativePath, content });\n } catch (error) {\n logger.warn(`Failed to read file: ${fullPath}`, error);\n }\n }\n }\n }\n } catch (error) {\n logger.error(`Failed to scan directory: ${dir}`, error);\n }\n\n return files;\n}\n\nfunction getFileType(filename: string): string {\n const ext = extname(filename).toLowerCase();\n const extMap: Record<string, string> = {\n \".ts\": \"typescript\",\n \".tsx\": \"tsx\",\n \".js\": \"javascript\",\n \".jsx\": \"jsx\",\n \".json\": \"json\",\n \".css\": \"css\",\n \".md\": \"markdown\",\n \".mdx\": \"mdx\",\n };\n return extMap[ext] || \"text\";\n}\n\nexport async function prepareCodeExamples(): Promise<void> {\n logger.info(\"Preparing code examples...\");\n\n try {\n await rm(OUTPUT_DIR, { recursive: true, force: true });\n await mkdir(OUTPUT_DIR, { recursive: true });\n\n const exampleDirs = await readdir(EXAMPLES_PATH, { withFileTypes: true });\n\n for (const dir of exampleDirs) {\n if (dir.isDirectory() && !dir.name.startsWith(\".\")) {\n const examplePath = join(EXAMPLES_PATH, dir.name);\n logger.info(`Processing example: ${dir.name}`);\n\n let description = \"\";\n try {\n const packageJsonPath = join(examplePath, \"package.json\");\n const packageJson = JSON.parse(\n await readFile(packageJsonPath, \"utf-8\"),\n );\n description = packageJson.description || \"\";\n } catch (error: any) {\n if (error?.code !== \"ENOENT\") {\n logger.warn(`Failed to read package.json for ${dir.name}:`, error);\n } else {\n logger.debug(`No package.json found for example: ${dir.name}`);\n }\n }\n\n const files = await scanDirectory(examplePath, examplePath);\n\n files.sort((a, b) => a.path.localeCompare(b.path));\n\n let markdown = `# Example: ${dir.name}\\n\\n`;\n if (description) {\n markdown += `${description}\\n\\n`;\n }\n\n let totalLines = 0;\n for (const file of files) {\n const lines = file.content.split(\"\\n\").length;\n if (totalLines + lines > MAX_LINES) {\n markdown += `\\n_Note: Additional files truncated due to size limits_\\n`;\n break;\n }\n\n // Normalize Windows backslashes to forward slashes for consistent markdown output\n markdown += `## ${file.path.replace(/\\\\/g, \"/\")}\\n\\n`;\n markdown += `\\`\\`\\`${getFileType(file.path)}\\n`;\n markdown += file.content;\n markdown += `\\n\\`\\`\\`\\n\\n`;\n\n totalLines += lines;\n }\n\n const outputPath = join(OUTPUT_DIR, `${dir.name}.md`);\n await writeFile(outputPath, markdown, \"utf-8\");\n logger.debug(`Created example: ${outputPath}`);\n }\n }\n\n logger.info(\"Code examples preparation complete\");\n } catch (error) {\n logger.error(\"Failed to prepare code examples\", error);\n throw error;\n }\n}\n"],"mappings":";;;;;AAKA,MAAM,aAAa,KACjB,UACA,wDACF;AACA,MAAM,YAAY;AAOlB,eAAe,cACb,KACA,SACwB;CACxB,MAAM,QAAuB,CAAC;CAE9B,IAAI;EACF,MAAM,UAAU,MAAM,QAAQ,KAAK,EAAE,eAAe,KAAK,CAAC;EAE1D,KAAK,MAAM,SAAS,SAAS;GAC3B,MAAM,WAAW,KAAK,KAAK,MAAM,IAAI;GAErC,IAAI,MAAM,YAAY;QAShB,CAAC;KAPH;KACA;KACA;KACA;KACA;KACA;IAEU,CAAC,CAAC,SAAS,MAAM,IAAI,GAAG;KAClC,MAAM,WAAW,MAAM,cAAc,UAAU,OAAO;KACtD,MAAM,KAAK,GAAG,QAAQ;IACxB;UACK,IAAI,MA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,SAAS,OAAY;IACnB,IAAI,OAAO,SAAS,UAClB,OAAO,KAAK,mCAAmC,IAAI,KAAK,IAAI,KAAK;SAEjE,OAAO,MAAM,sCAAsC,IAAI,MAAM;GAEjE;GAEA,MAAM,QAAQ,MAAM,cAAc,aAAa,WAAW;GAE1D,MAAM,MAAM,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC;GAEjD,IAAI,WAAW,cAAc,IAAI,KAAK;GACtC,IAAI,aACF,YAAY,GAAG,YAAY;GAG7B,IAAI,aAAa;GACjB,KAAK,MAAM,QAAQ,OAAO;IACxB,MAAM,QAAQ,KAAK,QAAQ,MAAM,IAAI,CAAC,CAAC;IACvC,IAAI,aAAa,QAAQ,WAAW;KAClC,YAAY;KACZ;IACF;IAGA,YAAY,MAAM,KAAK,KAAK,QAAQ,OAAO,GAAG,EAAE;IAChD,YAAY,SAAS,YAAY,KAAK,IAAI,EAAE;IAC5C,YAAY,KAAK;IACjB,YAAY;IAEZ,cAAc;GAChB;GAEA,MAAM,aAAa,KAAK,YAAY,GAAG,IAAI,KAAK,IAAI;GACpD,MAAM,UAAU,YAAY,UAAU,OAAO;GAC7C,OAAO,MAAM,oBAAoB,YAAY;EAC/C;EAGF,OAAO,KAAK,oCAAoC;CAClD,SAAS,OAAO;EACd,OAAO,MAAM,mCAAmC,KAAK;EACrD,MAAM;CACR;AACF"}
1
+ {"version":3,"file":"code-examples.js","names":[],"sources":["../../src/prepare-docs/code-examples.ts"],"sourcesContent":["import { rm, mkdir, readdir, readFile, writeFile } from \"node:fs/promises\";\nimport { join, relative, extname } from \"node:path\";\nimport { logger } from \"../utils/logger.js\";\nimport { ROOT_DIR, EXAMPLES_PATH } from \"../constants.js\";\n\nconst OUTPUT_DIR = join(\n ROOT_DIR,\n \"packages/mcp-docs-server/.docs/organized/code-examples\",\n);\nconst MAX_LINES = 10000;\n\ninterface FileContent {\n path: string;\n content: string;\n}\n\nasync function scanDirectory(\n dir: string,\n baseDir: string,\n): Promise<FileContent[]> {\n const files: FileContent[] = [];\n\n try {\n const entries = await readdir(dir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = join(dir, entry.name);\n\n if (entry.isDirectory()) {\n const skipDirs = [\n \"node_modules\",\n \"dist\",\n \"build\",\n \".next\",\n \".git\",\n \".turbo\",\n ];\n if (!skipDirs.includes(entry.name)) {\n const subFiles = await scanDirectory(fullPath, baseDir);\n files.push(...subFiles);\n }\n } else if (entry.isFile()) {\n const includeExts = [\n \".ts\",\n \".tsx\",\n \".js\",\n \".jsx\",\n \".json\",\n \".css\",\n \".md\",\n \".mdx\",\n ];\n const ext = extname(entry.name).toLowerCase();\n\n if (\n includeExts.includes(ext) ||\n entry.name === \"package.json\" ||\n entry.name === \"tsconfig.json\"\n ) {\n try {\n const content = await readFile(fullPath, \"utf-8\");\n const relativePath = relative(baseDir, fullPath);\n files.push({ path: relativePath, content });\n } catch (error) {\n logger.warn(`Failed to read file: ${fullPath}`, error);\n }\n }\n }\n }\n } catch (error) {\n logger.error(`Failed to scan directory: ${dir}`, error);\n }\n\n return files;\n}\n\nfunction getFileType(filename: string): string {\n const ext = extname(filename).toLowerCase();\n const extMap: Record<string, string> = {\n \".ts\": \"typescript\",\n \".tsx\": \"tsx\",\n \".js\": \"javascript\",\n \".jsx\": \"jsx\",\n \".json\": \"json\",\n \".css\": \"css\",\n \".md\": \"markdown\",\n \".mdx\": \"mdx\",\n };\n return extMap[ext] || \"text\";\n}\n\nexport async function prepareCodeExamples(): Promise<void> {\n logger.info(\"Preparing code examples...\");\n\n try {\n await rm(OUTPUT_DIR, { recursive: true, force: true });\n await mkdir(OUTPUT_DIR, { recursive: true });\n\n const exampleDirs = await readdir(EXAMPLES_PATH, { withFileTypes: true });\n\n for (const dir of exampleDirs) {\n if (dir.isDirectory() && !dir.name.startsWith(\".\")) {\n const examplePath = join(EXAMPLES_PATH, dir.name);\n logger.info(`Processing example: ${dir.name}`);\n\n let description = \"\";\n try {\n const packageJsonPath = join(examplePath, \"package.json\");\n const packageJson = JSON.parse(\n await readFile(packageJsonPath, \"utf-8\"),\n );\n description = packageJson.description || \"\";\n } catch (error: any) {\n if (error?.code !== \"ENOENT\") {\n logger.warn(`Failed to read package.json for ${dir.name}:`, error);\n } else {\n logger.debug(`No package.json found for example: ${dir.name}`);\n }\n }\n\n const files = await scanDirectory(examplePath, examplePath);\n\n files.sort((a, b) => a.path.localeCompare(b.path));\n\n let markdown = `# Example: ${dir.name}\\n\\n`;\n if (description) {\n markdown += `${description}\\n\\n`;\n }\n\n let totalLines = 0;\n for (const file of files) {\n const lines = file.content.split(\"\\n\").length;\n if (totalLines + lines > MAX_LINES) {\n markdown += `\\n_Note: Additional files truncated due to size limits_\\n`;\n break;\n }\n\n // Normalize Windows backslashes to forward slashes for consistent markdown output\n markdown += `## ${file.path.replace(/\\\\/g, \"/\")}\\n\\n`;\n markdown += `\\`\\`\\`${getFileType(file.path)}\\n`;\n markdown += file.content;\n markdown += `\\n\\`\\`\\`\\n\\n`;\n\n totalLines += lines;\n }\n\n const outputPath = join(OUTPUT_DIR, `${dir.name}.md`);\n await writeFile(outputPath, markdown, \"utf-8\");\n logger.debug(`Created example: ${outputPath}`);\n }\n }\n\n logger.info(\"Code examples preparation complete\");\n } catch (error) {\n logger.error(\"Failed to prepare code examples\", error);\n throw error;\n }\n}\n"],"mappings":";;;;;AAKA,MAAM,aAAa,KACjB,UACA,wDACF;AACA,MAAM,YAAY;AAOlB,eAAe,cACb,KACA,SACwB;CACxB,MAAM,QAAuB,CAAC;CAE9B,IAAI;EACF,MAAM,UAAU,MAAM,QAAQ,KAAK,EAAE,eAAe,KAAK,CAAC;EAE1D,KAAK,MAAM,SAAS,SAAS;GAC3B,MAAM,WAAW,KAAK,KAAK,MAAM,IAAI;GAErC,IAAI,MAAM,YAAY,GAShB;QAAA,CAAC;KAPH;KACA;KACA;KACA;KACA;KACA;IAEU,CAAC,CAAC,SAAS,MAAM,IAAI,GAAG;KAClC,MAAM,WAAW,MAAM,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AAK,MACvB,MAAM,SAAS,iBAAiB,OAAO,CAEjB,CAAC,CAAC,eAAe;GAC3C,SAAS,OAAY;IACnB,IAAI,OAAO,SAAS,UAClB,OAAO,KAAK,mCAAmC,IAAI,KAAK,IAAI,KAAK;SAEjE,OAAO,MAAM,sCAAsC,IAAI,MAAM;GAEjE;GAEA,MAAM,QAAQ,MAAM,cAAc,aAAa,WAAW;GAE1D,MAAM,MAAM,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC;GAEjD,IAAI,WAAW,cAAc,IAAI,KAAK;GACtC,IAAI,aACF,YAAY,GAAG,YAAY;GAG7B,IAAI,aAAa;GACjB,KAAK,MAAM,QAAQ,OAAO;IACxB,MAAM,QAAQ,KAAK,QAAQ,MAAM,IAAI,CAAC,CAAC;IACvC,IAAI,aAAa,QAAQ,WAAW;KAClC,YAAY;KACZ;IACF;IAGA,YAAY,MAAM,KAAK,KAAK,QAAQ,OAAO,GAAG,EAAE;IAChD,YAAY,SAAS,YAAY,KAAK,IAAI,EAAE;IAC5C,YAAY,KAAK;IACjB,YAAY;IAEZ,cAAc;GAChB;GAEA,MAAM,aAAa,KAAK,YAAY,GAAG,IAAI,KAAK,IAAI;GACpD,MAAM,UAAU,YAAY,UAAU,OAAO;GAC7C,OAAO,MAAM,oBAAoB,YAAY;EAC/C;EAGF,OAAO,KAAK,oCAAoC;CAClD,SAAS,OAAO;EACd,OAAO,MAAM,mCAAmC,KAAK;EACrD,MAAM;CACR;AACF"}
@@ -1 +1 @@
1
- export { };
1
+ export {}
@@ -1 +1 @@
1
- {"version":3,"file":"prepare.js","names":[],"sources":["../../src/prepare-docs/prepare.ts"],"sourcesContent":["import { logger } from \"../utils/logger.js\";\nimport { copyRaw } from \"./copy-raw.js\";\nimport { prepareCodeExamples } from \"./code-examples.js\";\n\nasync function prepare(): Promise<void> {\n logger.info(\"Starting documentation preparation...\");\n\n try {\n await copyRaw();\n await prepareCodeExamples();\n\n logger.info(\"Documentation preparation complete\");\n } catch (error) {\n logger.error(\"Documentation preparation failed\", error);\n throw error;\n }\n}\n\nif (import.meta.url === `file://${process.argv[1]}`) {\n prepare().catch((error) => {\n logger.error(\"Preparation failed\", error);\n process.exit(1);\n });\n}\n"],"mappings":";;;;AAIA,eAAe,UAAyB;CACtC,OAAO,KAAK,uCAAuC;CAEnD,IAAI;EACF,MAAM,QAAQ;EACd,MAAM,oBAAoB;EAE1B,OAAO,KAAK,oCAAoC;CAClD,SAAS,OAAO;EACd,OAAO,MAAM,oCAAoC,KAAK;EACtD,MAAM;CACR;AACF;AAEA,IAAI,OAAO,KAAK,QAAQ,UAAU,QAAQ,KAAK,MAC7C,QAAQ,CAAC,CAAC,OAAO,UAAU;CACzB,OAAO,MAAM,sBAAsB,KAAK;CACxC,QAAQ,KAAK,CAAC;AAChB,CAAC"}
1
+ {"version":3,"file":"prepare.js","names":[],"sources":["../../src/prepare-docs/prepare.ts"],"sourcesContent":["import { logger } from \"../utils/logger.js\";\nimport { copyRaw } from \"./copy-raw.js\";\nimport { prepareCodeExamples } from \"./code-examples.js\";\n\nasync function prepare(): Promise<void> {\n logger.info(\"Starting documentation preparation...\");\n\n try {\n await copyRaw();\n await prepareCodeExamples();\n\n logger.info(\"Documentation preparation complete\");\n } catch (error) {\n logger.error(\"Documentation preparation failed\", error);\n throw error;\n }\n}\n\nif (import.meta.url === `file://${process.argv[1]}`) {\n prepare().catch((error) => {\n logger.error(\"Preparation failed\", error);\n process.exit(1);\n });\n}\n"],"mappings":";;;;AAIA,eAAe,UAAyB;CACtC,OAAO,KAAK,uCAAuC;CAEnD,IAAI;EACF,MAAM,QAAQ;EACd,MAAM,oBAAoB;EAE1B,OAAO,KAAK,oCAAoC;CAClD,SAAS,OAAO;EACd,OAAO,MAAM,oCAAoC,KAAK;EACtD,MAAM;CACR;AACF;AAEA,IAAI,YAAY,QAAQ,UAAU,QAAQ,KAAK,MAC7C,QAAQ,CAAC,CAAC,OAAO,UAAU;CACzB,OAAO,MAAM,sBAAsB,KAAK;CACxC,QAAQ,KAAK,CAAC;AAChB,CAAC"}
package/dist/stdio.d.ts CHANGED
@@ -1 +1 @@
1
- export { };
1
+ export {}
@@ -1,18 +1,14 @@
1
- import { z } from "zod/v3";
1
+ import { z } from "zod";
2
2
  //#region src/tools/docs.d.ts
3
3
  declare const docsInputSchema: z.ZodObject<{
4
- paths: z.ZodArray<z.ZodString, "many">;
5
- }, "strip", z.ZodTypeAny, {
6
- paths: string[];
7
- }, {
8
- paths: string[];
9
- }>;
4
+ paths: z.ZodArray<z.ZodString>;
5
+ }, z.core.$strip>;
10
6
  declare const docsTools: {
11
7
  name: string;
12
8
  description: string;
13
- parameters: {
14
- paths: z.ZodArray<z.ZodString, "many">;
15
- };
9
+ parameters: z.ZodObject<{
10
+ paths: z.ZodArray<z.ZodString>;
11
+ }, z.core.$strip>;
16
12
  execute: ({ paths }: z.infer<typeof docsInputSchema>) => Promise<{
17
13
  content: Array<{
18
14
  type: "text";
@@ -1 +1 @@
1
- {"version":3,"file":"docs.d.ts","names":[],"sources":["../../src/tools/docs.ts"],"mappings":";;cAoBM,iBAAe,EAAA;;;;;;;cA+LR;;;;;;uBAKgB,EAAE,aAAa,qBAAgB"}
1
+ {"version":3,"file":"docs.d.ts","names":[],"sources":["../../src/tools/docs.ts"],"mappings":";;cAoBM,iBAAe,EAAA;;GAOnB,EAAA,KAAA;cAwLW;;;;;;EAKgB,YAAA,SAAA,EAAE,aAAa,qBAAgB"}
@@ -5,7 +5,7 @@ import { formatMDXContent, readMDXFile } from "../utils/mdx.js";
5
5
  import { formatMCPResponse } from "../utils/mcp-format.js";
6
6
  import { sanitizePath } from "../utils/security.js";
7
7
  import { extname, join } from "node:path";
8
- import { z } from "zod/v3";
8
+ import { z } from "zod";
9
9
  import { lstat, stat } from "node:fs/promises";
10
10
  //#region src/tools/docs.ts
11
11
  const docsInputSchema = z.object({ paths: z.array(z.string()).min(1).describe("Documentation paths to retrieve (e.g., [\"getting-started\", \"api-reference/primitives/thread\"])") });
@@ -22,7 +22,8 @@ async function readDocumentation(docPath) {
22
22
  };
23
23
  }
24
24
  try {
25
- const fullPath = join(DOCS_PATH, sanitizePath(docPath));
25
+ const sanitized = sanitizePath(docPath);
26
+ const fullPath = join(DOCS_PATH, sanitized);
26
27
  try {
27
28
  if ((await lstat(fullPath)).isSymbolicLink()) {
28
29
  logger.warn(`Symlink detected at path: ${fullPath}`);
@@ -121,10 +122,11 @@ async function readDocumentation(docPath) {
121
122
  };
122
123
  }
123
124
  }
125
+ const availablePaths = await getAvailablePaths();
124
126
  return {
125
127
  path: docPath,
126
128
  found: false,
127
- suggestions: findNearestPaths(docPath, await getAvailablePaths())
129
+ suggestions: findNearestPaths(docPath, availablePaths)
128
130
  };
129
131
  } catch (error) {
130
132
  if (error instanceof Error && error.message.includes("Invalid path")) return {
@@ -138,7 +140,7 @@ async function readDocumentation(docPath) {
138
140
  const docsTools = {
139
141
  name: "assistantUIDocs",
140
142
  description: "Retrieve assistant-ui documentation by path. Use \"/\" to list all sections. Supports multiple paths in a single request.",
141
- parameters: docsInputSchema.shape,
143
+ parameters: docsInputSchema,
142
144
  execute: async ({ paths }) => {
143
145
  logger.info(`Retrieving documentation for paths: ${paths.join(", ")}`);
144
146
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"docs.js","names":[],"sources":["../../src/tools/docs.ts"],"sourcesContent":["import { z } from \"zod/v3\";\nimport { stat, lstat } from \"node:fs/promises\";\nimport { join, extname } from \"node:path\";\nimport {\n DOCS_PATH,\n MDX_EXTENSION,\n MAX_FILE_SIZE,\n MAX_DIRECTORY_CONTENT_SIZE,\n} from \"../constants.js\";\nimport { logger } from \"../utils/logger.js\";\nimport {\n listDirContents,\n getAvailablePaths,\n findNearestPaths,\n pathExists,\n} from \"../utils/paths.js\";\nimport { readMDXFile, formatMDXContent } from \"../utils/mdx.js\";\nimport { formatMCPResponse } from \"../utils/mcp-format.js\";\nimport { sanitizePath } from \"../utils/security.js\";\n\nconst docsInputSchema = z.object({\n paths: z\n .array(z.string())\n .min(1)\n .describe(\n 'Documentation paths to retrieve (e.g., [\"getting-started\", \"api-reference/primitives/thread\"])',\n ),\n});\n\ninterface DocResult {\n path: string;\n found: boolean;\n type?: \"file\" | \"directory\";\n content?: string;\n files?: string[];\n directories?: string[];\n summaries?: Array<{ name: string; title?: string; excerpt?: string }>;\n title?: string;\n excerpt?: string;\n suggestions?: string[];\n hint?: string;\n error?: string;\n}\n\nasync function readDocumentation(docPath: string): Promise<DocResult> {\n logger.debug(`Reading documentation for path: ${docPath}`);\n\n if (docPath === \"/\" || docPath === \"\") {\n const { directories, files } = await listDirContents(DOCS_PATH);\n return {\n path: \"/\",\n found: true,\n type: \"directory\",\n directories,\n files: files.map((f) => f.replace(MDX_EXTENSION, \"\")),\n };\n }\n\n try {\n const sanitized = sanitizePath(docPath);\n const fullPath = join(DOCS_PATH, sanitized);\n\n try {\n const lstats = await lstat(fullPath);\n if (lstats.isSymbolicLink()) {\n logger.warn(`Symlink detected at path: ${fullPath}`);\n return {\n path: docPath,\n found: false,\n error: \"Symlinks are not allowed for security reasons\",\n };\n }\n } catch {}\n\n if (await pathExists(fullPath)) {\n const stats = await stat(fullPath);\n\n if (stats.isFile() && stats.size > MAX_FILE_SIZE) {\n logger.warn(`File too large: ${fullPath} (${stats.size} bytes)`);\n return {\n path: docPath,\n found: false,\n error: `File size exceeds maximum allowed size of ${MAX_FILE_SIZE} bytes`,\n };\n }\n\n if (stats.isDirectory()) {\n const { directories, files } = await listDirContents(fullPath);\n\n const contents: Record<string, string> = {};\n const summaries: Array<{\n name: string;\n title?: string;\n excerpt?: string;\n }> = [];\n let aggregateSize = 0;\n let truncated = false;\n for (const file of files) {\n let fileSize: number;\n try {\n fileSize = (await stat(join(fullPath, file))).size;\n } catch (error) {\n logger.warn(\n `Failed to stat MDX file: ${join(fullPath, file)}`,\n error,\n );\n continue;\n }\n aggregateSize += fileSize;\n if (aggregateSize > MAX_DIRECTORY_CONTENT_SIZE) {\n truncated = true;\n break;\n }\n const mdxContent = await readMDXFile(join(fullPath, file));\n if (mdxContent) {\n const name = file.replace(MDX_EXTENSION, \"\");\n contents[name] = formatMDXContent(mdxContent);\n const title = mdxContent.frontmatter[\"title\"];\n summaries.push({\n name,\n ...(typeof title === \"string\" && { title }),\n ...(mdxContent.excerpt !== undefined && {\n excerpt: mdxContent.excerpt,\n }),\n });\n }\n }\n\n const content =\n !truncated && Object.keys(contents).length > 0\n ? JSON.stringify(contents, null, 2)\n : undefined;\n return {\n path: docPath,\n found: true,\n type: \"directory\",\n directories,\n files: files.map((f) => f.replace(MDX_EXTENSION, \"\")),\n ...(summaries.length > 0 && { summaries }),\n ...(content !== undefined && { content }),\n ...(truncated && {\n hint: `Directory content exceeds ${MAX_DIRECTORY_CONTENT_SIZE} bytes and was omitted; summaries cover only the files read before the limit. Request individual files by path to retrieve their content.`,\n }),\n };\n }\n }\n\n const mdxPath =\n extname(fullPath) === MDX_EXTENSION\n ? fullPath\n : `${fullPath}${MDX_EXTENSION}`;\n\n try {\n const mdxLstats = await lstat(mdxPath);\n if (mdxLstats.isSymbolicLink()) {\n logger.warn(`Symlink detected at MDX path: ${mdxPath}`);\n return {\n path: docPath,\n found: false,\n error: \"Symlinks are not allowed for security reasons\",\n };\n }\n\n if (mdxLstats.size > MAX_FILE_SIZE) {\n logger.warn(`MDX file too large: ${mdxPath} (${mdxLstats.size} bytes)`);\n return {\n path: docPath,\n found: false,\n error: `File size exceeds maximum allowed size of ${MAX_FILE_SIZE} bytes`,\n };\n }\n } catch {}\n\n if (await pathExists(mdxPath)) {\n const mdxContent = await readMDXFile(mdxPath);\n\n if (mdxContent) {\n const title = mdxContent.frontmatter[\"title\"];\n return {\n path: docPath,\n found: true,\n type: \"file\",\n content: formatMDXContent(mdxContent),\n ...(typeof title === \"string\" && { title }),\n ...(mdxContent.excerpt !== undefined && {\n excerpt: mdxContent.excerpt,\n }),\n };\n }\n }\n\n const availablePaths = await getAvailablePaths();\n const suggestions = findNearestPaths(docPath, availablePaths);\n\n return {\n path: docPath,\n found: false,\n suggestions,\n };\n } catch (error) {\n if (error instanceof Error && error.message.includes(\"Invalid path\")) {\n return {\n path: docPath,\n found: false,\n error: error.message,\n };\n }\n throw error;\n }\n}\n\nexport const docsTools = {\n name: \"assistantUIDocs\",\n description:\n 'Retrieve assistant-ui documentation by path. Use \"/\" to list all sections. Supports multiple paths in a single request.',\n parameters: docsInputSchema.shape,\n execute: async ({ paths }: z.infer<typeof docsInputSchema>) => {\n logger.info(`Retrieving documentation for paths: ${paths.join(\", \")}`);\n\n try {\n const results = await Promise.all(\n paths.map((path) => readDocumentation(path)),\n );\n\n if (results.length === 1) {\n const result = results[0]!;\n if (result.error) {\n return formatMCPResponse({\n error: result.error,\n path: result.path,\n });\n }\n if (!result.found) {\n return formatMCPResponse({\n error: `Documentation not found for path: ${result.path}`,\n suggestions: result.suggestions,\n hint: 'Use \"/\" to list all available documentation sections',\n });\n }\n return formatMCPResponse(result);\n }\n\n return formatMCPResponse({\n results,\n summary: `Retrieved ${results.filter((r) => r.found).length} of ${results.length} requested paths`,\n });\n } catch (error) {\n logger.error(\"Failed to retrieve documentation\", error);\n return formatMCPResponse({\n error: \"Failed to retrieve documentation\",\n message: error instanceof Error ? error.message : String(error),\n });\n }\n },\n};\n"],"mappings":";;;;;;;;;;AAoBA,MAAM,kBAAkB,EAAE,OAAO,EAC/B,OAAO,EACJ,MAAM,EAAE,OAAO,CAAC,CAAC,CACjB,IAAI,CAAC,CAAC,CACN,SACC,oGACF,EACJ,CAAC;AAiBD,eAAe,kBAAkB,SAAqC;CACpE,OAAO,MAAM,mCAAmC,SAAS;CAEzD,IAAI,YAAY,OAAO,YAAY,IAAI;EACrC,MAAM,EAAE,aAAa,UAAU,MAAM,gBAAgB,SAAS;EAC9D,OAAO;GACL,MAAM;GACN,OAAO;GACP,MAAM;GACN;GACA,OAAO,MAAM,KAAK,MAAM,EAAE,QAAQ,eAAe,EAAE,CAAC;EACtD;CACF;CAEA,IAAI;EA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O;GACL,MAAM;GACN,OAAO;GACP,OAAO,MAAM;EACf;EAEF,MAAM;CACR;AACF;AAEA,MAAa,YAAY;CACvB,MAAM;CACN,aACE;CACF,YAAY,gBAAgB;CAC5B,SAAS,OAAO,EAAE,YAA6C;EAC7D,OAAO,KAAK,uCAAuC,MAAM,KAAK,IAAI,GAAG;EAErE,IAAI;GACF,MAAM,UAAU,MAAM,QAAQ,IAC5B,MAAM,KAAK,SAAS,kBAAkB,IAAI,CAAC,CAC7C;GAEA,IAAI,QAAQ,WAAW,GAAG;IACxB,MAAM,SAAS,QAAQ;IACvB,IAAI,OAAO,OACT,OAAO,kBAAkB;KACvB,OAAO,OAAO;KACd,MAAM,OAAO;IACf,CAAC;IAEH,IAAI,CAAC,OAAO,OACV,OAAO,kBAAkB;KACvB,OAAO,qCAAqC,OAAO;KACnD,aAAa,OAAO;KACpB,MAAM;IACR,CAAC;IAEH,OAAO,kBAAkB,MAAM;GACjC;GAEA,OAAO,kBAAkB;IACvB;IACA,SAAS,aAAa,QAAQ,QAAQ,MAAM,EAAE,KAAK,CAAC,CAAC,OAAO,MAAM,QAAQ,OAAO;GACnF,CAAC;EACH,SAAS,OAAO;GACd,OAAO,MAAM,oCAAoC,KAAK;GACtD,OAAO,kBAAkB;IACvB,OAAO;IACP,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GAChE,CAAC;EACH;CACF;AACF"}
1
+ {"version":3,"file":"docs.js","names":[],"sources":["../../src/tools/docs.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { stat, lstat } from \"node:fs/promises\";\nimport { join, extname } from \"node:path\";\nimport {\n DOCS_PATH,\n MDX_EXTENSION,\n MAX_FILE_SIZE,\n MAX_DIRECTORY_CONTENT_SIZE,\n} from \"../constants.js\";\nimport { logger } from \"../utils/logger.js\";\nimport {\n listDirContents,\n getAvailablePaths,\n findNearestPaths,\n pathExists,\n} from \"../utils/paths.js\";\nimport { readMDXFile, formatMDXContent } from \"../utils/mdx.js\";\nimport { formatMCPResponse } from \"../utils/mcp-format.js\";\nimport { sanitizePath } from \"../utils/security.js\";\n\nconst docsInputSchema = z.object({\n paths: z\n .array(z.string())\n .min(1)\n .describe(\n 'Documentation paths to retrieve (e.g., [\"getting-started\", \"api-reference/primitives/thread\"])',\n ),\n});\n\ninterface DocResult {\n path: string;\n found: boolean;\n type?: \"file\" | \"directory\";\n content?: string;\n files?: string[];\n directories?: string[];\n summaries?: Array<{ name: string; title?: string; excerpt?: string }>;\n title?: string;\n excerpt?: string;\n suggestions?: string[];\n hint?: string;\n error?: string;\n}\n\nasync function readDocumentation(docPath: string): Promise<DocResult> {\n logger.debug(`Reading documentation for path: ${docPath}`);\n\n if (docPath === \"/\" || docPath === \"\") {\n const { directories, files } = await listDirContents(DOCS_PATH);\n return {\n path: \"/\",\n found: true,\n type: \"directory\",\n directories,\n files: files.map((f) => f.replace(MDX_EXTENSION, \"\")),\n };\n }\n\n try {\n const sanitized = sanitizePath(docPath);\n const fullPath = join(DOCS_PATH, sanitized);\n\n try {\n const lstats = await lstat(fullPath);\n if (lstats.isSymbolicLink()) {\n logger.warn(`Symlink detected at path: ${fullPath}`);\n return {\n path: docPath,\n found: false,\n error: \"Symlinks are not allowed for security reasons\",\n };\n }\n } catch {}\n\n if (await pathExists(fullPath)) {\n const stats = await stat(fullPath);\n\n if (stats.isFile() && stats.size > MAX_FILE_SIZE) {\n logger.warn(`File too large: ${fullPath} (${stats.size} bytes)`);\n return {\n path: docPath,\n found: false,\n error: `File size exceeds maximum allowed size of ${MAX_FILE_SIZE} bytes`,\n };\n }\n\n if (stats.isDirectory()) {\n const { directories, files } = await listDirContents(fullPath);\n\n const contents: Record<string, string> = {};\n const summaries: Array<{\n name: string;\n title?: string;\n excerpt?: string;\n }> = [];\n let aggregateSize = 0;\n let truncated = false;\n for (const file of files) {\n let fileSize: number;\n try {\n fileSize = (await stat(join(fullPath, file))).size;\n } catch (error) {\n logger.warn(\n `Failed to stat MDX file: ${join(fullPath, file)}`,\n error,\n );\n continue;\n }\n aggregateSize += fileSize;\n if (aggregateSize > MAX_DIRECTORY_CONTENT_SIZE) {\n truncated = true;\n break;\n }\n const mdxContent = await readMDXFile(join(fullPath, file));\n if (mdxContent) {\n const name = file.replace(MDX_EXTENSION, \"\");\n contents[name] = formatMDXContent(mdxContent);\n const title = mdxContent.frontmatter[\"title\"];\n summaries.push({\n name,\n ...(typeof title === \"string\" && { title }),\n ...(mdxContent.excerpt !== undefined && {\n excerpt: mdxContent.excerpt,\n }),\n });\n }\n }\n\n const content =\n !truncated && Object.keys(contents).length > 0\n ? JSON.stringify(contents, null, 2)\n : undefined;\n return {\n path: docPath,\n found: true,\n type: \"directory\",\n directories,\n files: files.map((f) => f.replace(MDX_EXTENSION, \"\")),\n ...(summaries.length > 0 && { summaries }),\n ...(content !== undefined && { content }),\n ...(truncated && {\n hint: `Directory content exceeds ${MAX_DIRECTORY_CONTENT_SIZE} bytes and was omitted; summaries cover only the files read before the limit. Request individual files by path to retrieve their content.`,\n }),\n };\n }\n }\n\n const mdxPath =\n extname(fullPath) === MDX_EXTENSION\n ? fullPath\n : `${fullPath}${MDX_EXTENSION}`;\n\n try {\n const mdxLstats = await lstat(mdxPath);\n if (mdxLstats.isSymbolicLink()) {\n logger.warn(`Symlink detected at MDX path: ${mdxPath}`);\n return {\n path: docPath,\n found: false,\n error: \"Symlinks are not allowed for security reasons\",\n };\n }\n\n if (mdxLstats.size > MAX_FILE_SIZE) {\n logger.warn(`MDX file too large: ${mdxPath} (${mdxLstats.size} bytes)`);\n return {\n path: docPath,\n found: false,\n error: `File size exceeds maximum allowed size of ${MAX_FILE_SIZE} bytes`,\n };\n }\n } catch {}\n\n if (await pathExists(mdxPath)) {\n const mdxContent = await readMDXFile(mdxPath);\n\n if (mdxContent) {\n const title = mdxContent.frontmatter[\"title\"];\n return {\n path: docPath,\n found: true,\n type: \"file\",\n content: formatMDXContent(mdxContent),\n ...(typeof title === \"string\" && { title }),\n ...(mdxContent.excerpt !== undefined && {\n excerpt: mdxContent.excerpt,\n }),\n };\n }\n }\n\n const availablePaths = await getAvailablePaths();\n const suggestions = findNearestPaths(docPath, availablePaths);\n\n return {\n path: docPath,\n found: false,\n suggestions,\n };\n } catch (error) {\n if (error instanceof Error && error.message.includes(\"Invalid path\")) {\n return {\n path: docPath,\n found: false,\n error: error.message,\n };\n }\n throw error;\n }\n}\n\nexport const docsTools = {\n name: \"assistantUIDocs\",\n description:\n 'Retrieve assistant-ui documentation by path. Use \"/\" to list all sections. Supports multiple paths in a single request.',\n parameters: docsInputSchema,\n execute: async ({ paths }: z.infer<typeof docsInputSchema>) => {\n logger.info(`Retrieving documentation for paths: ${paths.join(\", \")}`);\n\n try {\n const results = await Promise.all(\n paths.map((path) => readDocumentation(path)),\n );\n\n if (results.length === 1) {\n const result = results[0]!;\n if (result.error) {\n return formatMCPResponse({\n error: result.error,\n path: result.path,\n });\n }\n if (!result.found) {\n return formatMCPResponse({\n error: `Documentation not found for path: ${result.path}`,\n suggestions: result.suggestions,\n hint: 'Use \"/\" to list all available documentation sections',\n });\n }\n return formatMCPResponse(result);\n }\n\n return formatMCPResponse({\n results,\n summary: `Retrieved ${results.filter((r) => r.found).length} of ${results.length} requested paths`,\n });\n } catch (error) {\n logger.error(\"Failed to retrieve documentation\", error);\n return formatMCPResponse({\n error: \"Failed to retrieve documentation\",\n message: error instanceof Error ? error.message : String(error),\n });\n }\n },\n};\n"],"mappings":";;;;;;;;;;AAoBA,MAAM,kBAAkB,EAAE,OAAO,EAC/B,OAAO,EACJ,MAAM,EAAE,OAAO,CAAC,CAAC,CACjB,IAAI,CAAC,CAAC,CACN,SACC,oGACF,EACJ,CAAC;AAiBD,eAAe,kBAAkB,SAAqC;CACpE,OAAO,MAAM,mCAAmC,SAAS;CAEzD,IAAI,YAAY,OAAO,YAAY,IAAI;EACrC,MAAM,EAAE,aAAa,UAAU,MAAM,gBAAgB,SAAS;EAC9D,OAAO;GACL,MAAM;GACN,OAAO;GACP,MAAM;GACN;G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N,OAAO;GACP,aALkB,iBAAiB,SAAS,cAKlC;EACZ;CACF,SAAS,OAAO;EACd,IAAI,iBAAiB,SAAS,MAAM,QAAQ,SAAS,cAAc,GACjE,OAAO;GACL,MAAM;GACN,OAAO;GACP,OAAO,MAAM;EACf;EAEF,MAAM;CACR;AACF;AAEA,MAAa,YAAY;CACvB,MAAM;CACN,aACE;CACF,YAAY;CACZ,SAAS,OAAO,EAAE,YAA6C;EAC7D,OAAO,KAAK,uCAAuC,MAAM,KAAK,IAAI,GAAG;EAErE,IAAI;GACF,MAAM,UAAU,MAAM,QAAQ,IAC5B,MAAM,KAAK,SAAS,kBAAkB,IAAI,CAAC,CAC7C;GAEA,IAAI,QAAQ,WAAW,GAAG;IACxB,MAAM,SAAS,QAAQ;IACvB,IAAI,OAAO,OACT,OAAO,kBAAkB;KACvB,OAAO,OAAO;KACd,MAAM,OAAO;IACf,CAAC;IAEH,IAAI,CAAC,OAAO,OACV,OAAO,kBAAkB;KACvB,OAAO,qCAAqC,OAAO;KACnD,aAAa,OAAO;KACpB,MAAM;IACR,CAAC;IAEH,OAAO,kBAAkB,MAAM;GACjC;GAEA,OAAO,kBAAkB;IACvB;IACA,SAAS,aAAa,QAAQ,QAAQ,MAAM,EAAE,KAAK,CAAC,CAAC,OAAO,MAAM,QAAQ,OAAO;GACnF,CAAC;EACH,SAAS,OAAO;GACd,OAAO,MAAM,oCAAoC,KAAK;GACtD,OAAO,kBAAkB;IACvB,OAAO;IACP,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GAChE,CAAC;EACH;CACF;AACF"}
@@ -1,20 +1,16 @@
1
- import { z } from "zod/v3";
1
+ import { z } from "zod";
2
2
  //#region src/tools/examples.d.ts
3
3
  declare const examplesInputSchema: z.ZodObject<{
4
4
  example: z.ZodOptional<z.ZodString>;
5
- }, "strip", z.ZodTypeAny, {
6
- example?: string | undefined;
7
- }, {
8
- example?: string | undefined;
9
- }>;
5
+ }, z.core.$strip>;
10
6
  declare function listCodeExamples(): Promise<string[]>;
11
7
  declare function readCodeExample(exampleName: string): Promise<string | null>;
12
8
  declare const examplesTools: {
13
9
  name: string;
14
10
  description: string;
15
- parameters: {
11
+ parameters: z.ZodObject<{
16
12
  example: z.ZodOptional<z.ZodString>;
17
- };
13
+ }, z.core.$strip>;
18
14
  execute: ({ example }: z.infer<typeof examplesInputSchema>) => Promise<{
19
15
  content: Array<{
20
16
  type: "text";
@@ -1 +1 @@
1
- {"version":3,"file":"examples.d.ts","names":[],"sources":["../../src/tools/examples.ts"],"mappings":";;cASM,qBAAmB,EAAA;;;;;;;iBAWT,oBAAoB;iBAed,gBACpB,sBACC;cAwBU;;;;;;yBAKkB,EAAE,aAAa,yBAAoB"}
1
+ {"version":3,"file":"examples.d.ts","names":[],"sources":["../../src/tools/examples.ts"],"mappings":";;cASM,qBAAmB,EAAA;;GAOvB,EAAA,KAAA;iBAIc,oBAAoB;iBAed,gBACpB,sBACC;cAwBU;;;;;;EAKkB,YAAA,WAAA,EAAE,aAAa,yBAAoB"}
@@ -4,7 +4,7 @@ import { cacheListing } from "../utils/cache.js";
4
4
  import { formatMCPResponse } from "../utils/mcp-format.js";
5
5
  import { sanitizePath } from "../utils/security.js";
6
6
  import { extname, join } from "node:path";
7
- import { z } from "zod/v3";
7
+ import { z } from "zod";
8
8
  import { lstat, readFile, readdir } from "node:fs/promises";
9
9
  //#region src/tools/examples.ts
10
10
  const examplesInputSchema = z.object({ example: z.string().optional().describe("Example name (e.g., \"with-ai-sdk-v7\"). Leave empty to list all examples.") });
@@ -20,7 +20,8 @@ async function scanCodeExamples() {
20
20
  }
21
21
  async function readCodeExample(exampleName) {
22
22
  try {
23
- const filePath = join(CODE_EXAMPLES_PATH, `${sanitizePath(exampleName)}.md`);
23
+ const sanitized = sanitizePath(exampleName);
24
+ const filePath = join(CODE_EXAMPLES_PATH, `${sanitized}.md`);
24
25
  const stats = await lstat(filePath);
25
26
  if (stats.isSymbolicLink()) {
26
27
  logger.warn(`Attempted to read symlink: ${filePath}`);
@@ -39,7 +40,7 @@ async function readCodeExample(exampleName) {
39
40
  const examplesTools = {
40
41
  name: "assistantUIExamples",
41
42
  description: "List available examples or retrieve complete code for a specific example",
42
- parameters: examplesInputSchema.shape,
43
+ parameters: examplesInputSchema,
43
44
  execute: async ({ example }) => {
44
45
  try {
45
46
  if (!example) {
@@ -1 +1 @@
1
- {"version":3,"file":"examples.js","names":[],"sources":["../../src/tools/examples.ts"],"sourcesContent":["import { z } from \"zod/v3\";\nimport { readFile, readdir, lstat } from \"node:fs/promises\";\nimport { join, extname } from \"node:path\";\nimport { CODE_EXAMPLES_PATH, MAX_FILE_SIZE } from \"../constants.js\";\nimport { cacheListing } from \"../utils/cache.js\";\nimport { logger } from \"../utils/logger.js\";\nimport { formatMCPResponse } from \"../utils/mcp-format.js\";\nimport { sanitizePath } from \"../utils/security.js\";\n\nconst examplesInputSchema = z.object({\n example: z\n .string()\n .optional()\n .describe(\n 'Example name (e.g., \"with-ai-sdk-v7\"). Leave empty to list all examples.',\n ),\n});\n\nconst loadCodeExamples = cacheListing(scanCodeExamples);\n\nexport function listCodeExamples(): Promise<string[]> {\n return loadCodeExamples().catch((error) => {\n logger.error(\"Failed to list code examples\", error);\n return [];\n });\n}\n\nasync function scanCodeExamples(): Promise<string[]> {\n const files = await readdir(CODE_EXAMPLES_PATH);\n return files\n .filter((file) => extname(file) === \".md\")\n .map((file) => file.replace(\".md\", \"\"))\n .sort();\n}\n\nexport async function readCodeExample(\n exampleName: string,\n): Promise<string | null> {\n try {\n const sanitized = sanitizePath(exampleName);\n const filePath = join(CODE_EXAMPLES_PATH, `${sanitized}.md`);\n\n const stats = await lstat(filePath);\n if (stats.isSymbolicLink()) {\n logger.warn(`Attempted to read symlink: ${filePath}`);\n return null;\n }\n\n if (stats.size > MAX_FILE_SIZE) {\n logger.warn(`File size exceeds limit: ${filePath} (${stats.size} bytes)`);\n return null;\n }\n\n const content = await readFile(filePath, \"utf-8\");\n return content;\n } catch (error) {\n logger.error(`Failed to read example: ${exampleName}`, error);\n return null;\n }\n}\n\nexport const examplesTools = {\n name: \"assistantUIExamples\",\n description:\n \"List available examples or retrieve complete code for a specific example\",\n parameters: examplesInputSchema.shape,\n execute: async ({ example }: z.infer<typeof examplesInputSchema>) => {\n try {\n if (!example) {\n logger.info(\"Listing all available examples\");\n const examples = await listCodeExamples();\n\n if (examples.length === 0) {\n return formatMCPResponse({\n error:\n \"No examples found. Please run documentation preparation first.\",\n hint: \"Run: pnpm prepare-docs\",\n });\n }\n\n return formatMCPResponse({\n type: \"list\",\n examples,\n total: examples.length,\n hint: \"Use example parameter to get complete code for any example\",\n });\n }\n\n logger.info(`Retrieving example: ${example}`);\n const content = await readCodeExample(example);\n\n if (!content) {\n const availableExamples = await listCodeExamples();\n return formatMCPResponse({\n error: `Example not found: ${example}`,\n availableExamples,\n hint: \"Use without example parameter to list all available examples\",\n });\n }\n\n return formatMCPResponse({\n type: \"example\",\n name: example,\n content,\n });\n } catch (error) {\n logger.error(\"Failed to retrieve examples\", error);\n return formatMCPResponse({\n error: \"Failed to retrieve examples\",\n message: error instanceof Error ? error.message : String(error),\n });\n }\n },\n};\n"],"mappings":";;;;;;;;;AASA,MAAM,sBAAsB,EAAE,OAAO,EACnC,SAAS,EACN,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SACC,4EACF,EACJ,CAAC;AAED,MAAM,mBAAmB,aAAa,gBAAgB;AAEtD,SAAgB,mBAAsC;CACpD,OAAO,iBAAiB,CAAC,CAAC,OAAO,UAAU;EACzC,OAAO,MAAM,gCAAgC,KAAK;EAClD,OAAO,CAAC;CACV,CAAC;AACH;AAEA,eAAe,mBAAsC;CAEnD,QAAO,MADa,QAAQ,kBAAkB,EAAA,CAE3C,QAAQ,SAAS,QAAQ,IAAI,MAAM,KAAK,CAAC,CACzC,KAAK,SAAS,KAAK,QAAQ,OAAO,EAAE,CAAC,CAAC,CACtC,KAAK;AACV;AAEA,eAAsB,gBACpB,aACwB;CACxB,IA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sourcesContent":["import { z } from \"zod\";\nimport { readFile, readdir, lstat } from \"node:fs/promises\";\nimport { join, extname } from \"node:path\";\nimport { CODE_EXAMPLES_PATH, MAX_FILE_SIZE } from \"../constants.js\";\nimport { cacheListing } from \"../utils/cache.js\";\nimport { logger } from \"../utils/logger.js\";\nimport { formatMCPResponse } from \"../utils/mcp-format.js\";\nimport { sanitizePath } from \"../utils/security.js\";\n\nconst examplesInputSchema = z.object({\n example: z\n .string()\n .optional()\n .describe(\n 'Example name (e.g., \"with-ai-sdk-v7\"). Leave empty to list all examples.',\n ),\n});\n\nconst loadCodeExamples = cacheListing(scanCodeExamples);\n\nexport function listCodeExamples(): Promise<string[]> {\n return loadCodeExamples().catch((error) => {\n logger.error(\"Failed to list code examples\", error);\n return [];\n });\n}\n\nasync function scanCodeExamples(): Promise<string[]> {\n const files = await readdir(CODE_EXAMPLES_PATH);\n return files\n .filter((file) => extname(file) === \".md\")\n .map((file) => file.replace(\".md\", \"\"))\n .sort();\n}\n\nexport async function readCodeExample(\n exampleName: string,\n): Promise<string | null> {\n try {\n const sanitized = sanitizePath(exampleName);\n const filePath = join(CODE_EXAMPLES_PATH, `${sanitized}.md`);\n\n const stats = await lstat(filePath);\n if (stats.isSymbolicLink()) {\n logger.warn(`Attempted to read symlink: ${filePath}`);\n return null;\n }\n\n if (stats.size > MAX_FILE_SIZE) {\n logger.warn(`File size exceeds limit: ${filePath} (${stats.size} bytes)`);\n return null;\n }\n\n const content = await readFile(filePath, \"utf-8\");\n return content;\n } catch (error) {\n logger.error(`Failed to read example: ${exampleName}`, error);\n return null;\n }\n}\n\nexport const examplesTools = {\n name: \"assistantUIExamples\",\n description:\n \"List available examples or retrieve complete code for a specific example\",\n parameters: examplesInputSchema,\n execute: async ({ example }: z.infer<typeof examplesInputSchema>) => {\n try {\n if (!example) {\n logger.info(\"Listing all available examples\");\n const examples = await listCodeExamples();\n\n if (examples.length === 0) {\n return formatMCPResponse({\n error:\n \"No examples found. Please run documentation preparation first.\",\n hint: \"Run: pnpm prepare-docs\",\n });\n }\n\n return formatMCPResponse({\n type: \"list\",\n examples,\n total: examples.length,\n hint: \"Use example parameter to get complete code for any example\",\n });\n }\n\n logger.info(`Retrieving example: ${example}`);\n const content = await readCodeExample(example);\n\n if (!content) {\n const availableExamples = await listCodeExamples();\n return formatMCPResponse({\n error: `Example not found: ${example}`,\n availableExamples,\n hint: \"Use without example parameter to list all available examples\",\n });\n }\n\n return formatMCPResponse({\n type: \"example\",\n name: example,\n content,\n });\n } catch (error) {\n logger.error(\"Failed to retrieve examples\", error);\n return formatMCPResponse({\n error: \"Failed to retrieve examples\",\n message: error instanceof Error ? error.message : String(error),\n });\n }\n },\n};\n"],"mappings":";;;;;;;;;AASA,MAAM,sBAAsB,EAAE,OAAO,EACnC,SAAS,EACN,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SACC,4EACF,EACJ,CAAC;AAED,MAAM,mBAAmB,aAAa,gBAAgB;AAEtD,SAAgB,mBAAsC;CACpD,OAAO,iBAAiB,CAAC,CAAC,OAAO,UAAU;EACzC,OAAO,MAAM,gCAAgC,KAAK;EAClD,OAAO,CAAC;CACV,CAAC;AACH;AAEA,eAAe,mBAAsC;CAEnD,QAAO,MADa,QAAQ,kBAAkB,EAAA,CAE3C,QAAQ,SAAS,QAAQ,IAAI,MAAM,KAAK,CAAC,CACzC,KAAK,SAAS,KAAK,QAAQ,OAAO,EAAE,CAAC,CAAC,CACtC,KAAK;AACV;AAEA,eAAsB,gBACpB,aACwB;CACxB,IAAI;EACF,MAAM,YAAY,aAAa,WAAW;EAC1C,MAAM,WAAW,KAAK,oBAAoB,GAAG,UAAU,IAAI;EAE3D,MAAM,QAAQ,MAAM,MAAM,QAAQ;EAClC,IAAI,MAAM,eAAe,GAAG;GAC1B,OAAO,KAAK,8BAA8B,UAAU;GACpD,OAAO;EACT;EAEA,IAAI,MAAM,OAAA,UAAsB;GAC9B,OAAO,KAAK,4BAA4B,SAAS,IAAI,MAAM,KAAK,QAAQ;GACxE,OAAO;EACT;EAGA,OAAO,MADe,SAAS,UAAU,OAAO;CAElD,SAAS,OAAO;EACd,OAAO,MAAM,2BAA2B,eAAe,KAAK;EAC5D,OAAO;CACT;AACF;AAEA,MAAa,gBAAgB;CAC3B,MAAM;CACN,aACE;CACF,YAAY;CACZ,SAAS,OAAO,EAAE,cAAmD;EACnE,IAAI;GACF,IAAI,CAAC,SAAS;IACZ,OAAO,KAAK,gCAAgC;IAC5C,MAAM,WAAW,MAAM,iBAAiB;IAExC,IAAI,SAAS,WAAW,GACtB,OAAO,kBAAkB;KACvB,OACE;KACF,MAAM;IACR,CAAC;IAGH,OAAO,kBAAkB;KACvB,MAAM;KACN;KACA,OAAO,SAAS;KAChB,MAAM;IACR,CAAC;GACH;GAEA,OAAO,KAAK,uBAAuB,SAAS;GAC5C,MAAM,UAAU,MAAM,gBAAgB,OAAO;GAE7C,IAAI,CAAC,SAAS;IACZ,MAAM,oBAAoB,MAAM,iBAAiB;IACjD,OAAO,kBAAkB;KACvB,OAAO,sBAAsB;KAC7B;KACA,MAAM;IACR,CAAC;GACH;GAEA,OAAO,kBAAkB;IACvB,MAAM;IACN,MAAM;IACN;GACF,CAAC;EACH,SAAS,OAAO;GACd,OAAO,MAAM,+BAA+B,KAAK;GACjD,OAAO,kBAAkB;IACvB,OAAO;IACP,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GAChE,CAAC;EACH;CACF;AACF"}
@@ -1,4 +1,4 @@
1
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
1
+ import { McpServer } from "@modelcontextprotocol/server";
2
2
  //#region src/tools/resources.d.ts
3
3
  declare function registerResources(server: McpServer): void;
4
4
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"resources.d.ts","names":[],"sources":["../../src/tools/resources.ts"],"mappings":";;iBAuFgB,kBAAkB,QAAQ"}
1
+ {"version":3,"file":"resources.d.ts","names":[],"sources":["../../src/tools/resources.ts"],"mappings":";;iBAoFgB,kBAAkB,QAAQ"}
@@ -5,7 +5,7 @@ import { formatMDXContent, readMDXFileSafe } from "../utils/mdx.js";
5
5
  import { sanitizePath } from "../utils/security.js";
6
6
  import { listCodeExamples, readCodeExample } from "./examples.js";
7
7
  import { join } from "node:path";
8
- import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
8
+ import { ResourceTemplate } from "@modelcontextprotocol/server";
9
9
  //#region src/tools/resources.ts
10
10
  const MARKDOWN_MIME_TYPE = "text/markdown";
11
11
  const DOCS_SCHEME = "aui-docs";
@@ -42,7 +42,8 @@ function registerMarkdownResource(server, config) {
42
42
  });
43
43
  }
44
44
  async function readDocResource(path) {
45
- const mdx = await readMDXFileSafe(join(DOCS_PATH, `${sanitizePath(path)}${MDX_EXTENSION}`));
45
+ const sanitized = sanitizePath(path);
46
+ const mdx = await readMDXFileSafe(join(DOCS_PATH, `${sanitized}${MDX_EXTENSION}`));
46
47
  return mdx ? formatMDXContent(mdx) : null;
47
48
  }
48
49
  function registerResources(server) {
@@ -1 +1 @@
1
- {"version":3,"file":"resources.js","names":[],"sources":["../../src/tools/resources.ts"],"sourcesContent":["import {\n McpServer,\n ResourceTemplate,\n} from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { join } from \"node:path\";\nimport { DOCS_PATH, MDX_EXTENSION } from \"../constants.js\";\nimport { getAvailableDocFiles } from \"../utils/paths.js\";\nimport { readMDXFileSafe, formatMDXContent } from \"../utils/mdx.js\";\nimport { sanitizePath } from \"../utils/security.js\";\nimport { listCodeExamples, readCodeExample } from \"./examples.js\";\nimport { logger } from \"../utils/logger.js\";\n\nconst MARKDOWN_MIME_TYPE = \"text/markdown\";\nconst DOCS_SCHEME = \"aui-docs\";\nconst EXAMPLE_SCHEME = \"aui-example\";\n\nfunction templateVarToPath(value: string | string[] | undefined): string {\n if (Array.isArray(value)) return value.join(\"/\");\n return value ?? \"\";\n}\n\ninterface MarkdownResourceConfig {\n name: string;\n scheme: string;\n variable: string;\n title: string;\n description: string;\n notFoundLabel: string;\n list: () => Promise<string[]>;\n read: (key: string) => Promise<string | null>;\n}\n\nfunction registerMarkdownResource(\n server: McpServer,\n config: MarkdownResourceConfig,\n): void {\n const {\n name,\n scheme,\n variable,\n title,\n description,\n notFoundLabel,\n list,\n read,\n } = config;\n server.registerResource(\n name,\n new ResourceTemplate(`${scheme}:///{+${variable}}`, {\n list: async () => ({\n resources: (await list()).map((key) => ({\n uri: `${scheme}:///${key}`,\n name: key,\n mimeType: MARKDOWN_MIME_TYPE,\n })),\n }),\n complete: {\n [variable]: async (value) => {\n const needle = value.toLowerCase();\n return (await list()).filter((key) =>\n key.toLowerCase().includes(needle),\n );\n },\n },\n }),\n { title, description, mimeType: MARKDOWN_MIME_TYPE },\n async (uri, variables) => {\n const key = templateVarToPath(variables[variable]);\n const text = await read(key);\n if (text === null) {\n throw new Error(`${notFoundLabel} not found: ${key}`);\n }\n return {\n contents: [{ uri: uri.href, mimeType: MARKDOWN_MIME_TYPE, text }],\n };\n },\n );\n}\n\nasync function readDocResource(path: string): Promise<string | null> {\n const sanitized = sanitizePath(path);\n const mdx = await readMDXFileSafe(\n join(DOCS_PATH, `${sanitized}${MDX_EXTENSION}`),\n );\n return mdx ? formatMDXContent(mdx) : null;\n}\n\nexport function registerResources(server: McpServer): void {\n registerMarkdownResource(server, {\n name: \"assistant-ui-docs\",\n scheme: DOCS_SCHEME,\n variable: \"path\",\n title: \"assistant-ui Documentation\",\n description:\n \"Individual assistant-ui documentation pages, readable as markdown by path.\",\n notFoundLabel: \"Documentation\",\n list: getAvailableDocFiles,\n read: readDocResource,\n });\n\n registerMarkdownResource(server, {\n name: \"assistant-ui-examples\",\n scheme: EXAMPLE_SCHEME,\n variable: \"name\",\n title: \"assistant-ui Examples\",\n description:\n \"Complete assistant-ui example projects, readable as markdown.\",\n notFoundLabel: \"Example\",\n list: listCodeExamples,\n read: readCodeExample,\n });\n\n logger.debug(\"Registered docs and examples resources\");\n}\n"],"mappings":";;;;;;;;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AAM;CACR,CAAC;CAED,yBAAyB,QAAQ;EAC/B,MAAM;EACN,QAAQ;EACR,UAAU;EACV,OAAO;EACP,aACE;EACF,eAAe;EACf,MAAM;EACN,MAAM;CACR,CAAC;CAED,OAAO,MAAM,wCAAwC;AACvD"}
1
+ {"version":3,"file":"resources.js","names":[],"sources":["../../src/tools/resources.ts"],"sourcesContent":["import { type McpServer, ResourceTemplate } from \"@modelcontextprotocol/server\";\nimport { join } from \"node:path\";\nimport { DOCS_PATH, MDX_EXTENSION } from \"../constants.js\";\nimport { getAvailableDocFiles } from \"../utils/paths.js\";\nimport { readMDXFileSafe, formatMDXContent } from \"../utils/mdx.js\";\nimport { sanitizePath } from \"../utils/security.js\";\nimport { listCodeExamples, readCodeExample } from \"./examples.js\";\nimport { logger } from \"../utils/logger.js\";\n\nconst MARKDOWN_MIME_TYPE = \"text/markdown\";\nconst DOCS_SCHEME = \"aui-docs\";\nconst EXAMPLE_SCHEME = \"aui-example\";\n\nfunction templateVarToPath(value: string | string[] | undefined): string {\n if (Array.isArray(value)) return value.join(\"/\");\n return value ?? \"\";\n}\n\ninterface MarkdownResourceConfig {\n name: string;\n scheme: string;\n variable: string;\n title: string;\n description: string;\n notFoundLabel: string;\n list: () => Promise<string[]>;\n read: (key: string) => Promise<string | null>;\n}\n\nfunction registerMarkdownResource(\n server: McpServer,\n config: MarkdownResourceConfig,\n): void {\n const {\n name,\n scheme,\n variable,\n title,\n description,\n notFoundLabel,\n list,\n read,\n } = config;\n server.registerResource(\n name,\n new ResourceTemplate(`${scheme}:///{+${variable}}`, {\n list: async () => ({\n resources: (await list()).map((key) => ({\n uri: `${scheme}:///${key}`,\n name: key,\n mimeType: MARKDOWN_MIME_TYPE,\n })),\n }),\n complete: {\n [variable]: async (value) => {\n const needle = value.toLowerCase();\n return (await list()).filter((key) =>\n key.toLowerCase().includes(needle),\n );\n },\n },\n }),\n { title, description, mimeType: MARKDOWN_MIME_TYPE },\n async (uri, variables) => {\n const key = templateVarToPath(variables[variable]);\n const text = await read(key);\n if (text === null) {\n throw new Error(`${notFoundLabel} not found: ${key}`);\n }\n return {\n contents: [{ uri: uri.href, mimeType: MARKDOWN_MIME_TYPE, text }],\n };\n },\n );\n}\n\nasync function readDocResource(path: string): Promise<string | null> {\n const sanitized = sanitizePath(path);\n const mdx = await readMDXFileSafe(\n join(DOCS_PATH, `${sanitized}${MDX_EXTENSION}`),\n );\n return mdx ? formatMDXContent(mdx) : null;\n}\n\nexport function registerResources(server: McpServer): void {\n registerMarkdownResource(server, {\n name: \"assistant-ui-docs\",\n scheme: DOCS_SCHEME,\n variable: \"path\",\n title: \"assistant-ui Documentation\",\n description:\n \"Individual assistant-ui documentation pages, readable as markdown by path.\",\n notFoundLabel: \"Documentation\",\n list: getAvailableDocFiles,\n read: readDocResource,\n });\n\n registerMarkdownResource(server, {\n name: \"assistant-ui-examples\",\n scheme: EXAMPLE_SCHEME,\n variable: \"name\",\n title: \"assistant-ui Examples\",\n description:\n \"Complete assistant-ui example projects, readable as markdown.\",\n notFoundLabel: \"Example\",\n list: listCodeExamples,\n read: readCodeExample,\n });\n\n logger.debug(\"Registered docs and examples resources\");\n}\n"],"mappings":";;;;;;;;;AASA,MAAM,qBAAqB;AAC3B,MAAM,cAAc;AACpB,MAAM,iBAAiB;AAEvB,SAAS,kBAAkB,OAA8C;CACvE,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,KAAK,GAAG;CAC/C,OAAO,SAAS;AAClB;AAaA,SAAS,yBACP,QACA,QACM;CACN,MAAM,EACJ,MACA,QACA,UACA,OACA,aACA,eACA,MACA,SACE;CACJ,OAAO,iBACL,MACA,IAAI,iBAAiB,GAAG,OAAO,QAAQ,SAAS,IAAI;EAClD,MAAM,aAAa,EACjB,YAAY,MAAM,KAAK,EAAA,CAAG,KAAK,SAAS;GACtC,KAAK,GAAG,OAAO,MAAM;GACrB,MAAM;GACN,UAAU;EACZ,EAAE,EACJ;EACA,UAAU,GACP,WAAW,OAAO,UAAU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