@assistant-ui/mcp-docs-server 0.1.6 → 0.1.8

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 (47) hide show
  1. package/.docs/organized/code-examples/with-ai-sdk-v5.md +15 -13
  2. package/.docs/organized/code-examples/with-cloud.md +19 -25
  3. package/.docs/organized/code-examples/with-external-store.md +9 -7
  4. package/.docs/organized/code-examples/with-ffmpeg.md +21 -21
  5. package/.docs/organized/code-examples/with-langgraph.md +72 -46
  6. package/.docs/organized/code-examples/with-parent-id-grouping.md +9 -7
  7. package/.docs/organized/code-examples/with-react-hook-form.md +19 -21
  8. package/.docs/raw/docs/api-reference/integrations/react-data-stream.mdx +194 -0
  9. package/.docs/raw/docs/api-reference/overview.mdx +7 -4
  10. package/.docs/raw/docs/api-reference/primitives/Composer.mdx +31 -0
  11. package/.docs/raw/docs/api-reference/primitives/Message.mdx +108 -3
  12. package/.docs/raw/docs/api-reference/primitives/Thread.mdx +59 -0
  13. package/.docs/raw/docs/api-reference/primitives/ThreadList.mdx +128 -0
  14. package/.docs/raw/docs/api-reference/primitives/ThreadListItem.mdx +160 -0
  15. package/.docs/raw/docs/api-reference/runtimes/AssistantRuntime.mdx +0 -11
  16. package/.docs/raw/docs/api-reference/runtimes/ComposerRuntime.mdx +3 -3
  17. package/.docs/raw/docs/copilots/assistant-frame.mdx +397 -0
  18. package/.docs/raw/docs/getting-started.mdx +53 -52
  19. package/.docs/raw/docs/guides/Attachments.mdx +7 -115
  20. package/.docs/raw/docs/guides/ToolUI.mdx +3 -3
  21. package/.docs/raw/docs/guides/Tools.mdx +152 -92
  22. package/.docs/raw/docs/guides/context-api.mdx +574 -0
  23. package/.docs/raw/docs/migrations/v0-12.mdx +125 -0
  24. package/.docs/raw/docs/runtimes/ai-sdk/use-chat.mdx +134 -55
  25. package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +182 -0
  26. package/.docs/raw/docs/runtimes/custom/local.mdx +16 -3
  27. package/.docs/raw/docs/runtimes/data-stream.mdx +287 -0
  28. package/.docs/raw/docs/runtimes/langgraph/index.mdx +0 -1
  29. package/.docs/raw/docs/runtimes/langserve.mdx +9 -11
  30. package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +5 -0
  31. package/.docs/raw/docs/ui/ThreadList.mdx +54 -16
  32. package/dist/{chunk-L4K23SWI.js → chunk-NVNFQ5ZO.js} +4 -1
  33. package/dist/index.js +1 -1
  34. package/dist/prepare-docs/prepare.js +1 -1
  35. package/dist/stdio.js +1 -1
  36. package/package.json +7 -7
  37. package/.docs/organized/code-examples/local-ollama.md +0 -1135
  38. package/.docs/organized/code-examples/search-agent-for-e-commerce.md +0 -1721
  39. package/.docs/organized/code-examples/with-ai-sdk.md +0 -1082
  40. package/.docs/organized/code-examples/with-openai-assistants.md +0 -1175
  41. package/.docs/raw/docs/concepts/architecture.mdx +0 -19
  42. package/.docs/raw/docs/concepts/runtime-layer.mdx +0 -163
  43. package/.docs/raw/docs/concepts/why.mdx +0 -9
  44. package/.docs/raw/docs/runtimes/ai-sdk/rsc.mdx +0 -226
  45. package/.docs/raw/docs/runtimes/ai-sdk/use-assistant-hook.mdx +0 -195
  46. package/.docs/raw/docs/runtimes/ai-sdk/use-chat-hook.mdx +0 -138
  47. package/.docs/raw/docs/runtimes/ai-sdk/use-chat-v5.mdx +0 -212
@@ -0,0 +1,287 @@
1
+ ---
2
+ title: Data Stream Protocol
3
+ ---
4
+
5
+ import { Step, Steps } from "fumadocs-ui/components/steps";
6
+ import { Callout } from "fumadocs-ui/components/callout";
7
+
8
+ The `@assistant-ui/react-data-stream` package provides integration with data stream protocol endpoints, enabling streaming AI responses with tool support and state management.
9
+
10
+ ## Overview
11
+
12
+ The data stream protocol is a standardized format for streaming AI responses that supports:
13
+
14
+ - **Streaming text responses** with real-time updates
15
+ - **Tool calling** with structured parameters and results
16
+ - **State management** for conversation context
17
+ - **Error handling** and cancellation support
18
+ - **Attachment support** for multimodal interactions
19
+
20
+ ## Installation
21
+
22
+ ```bash npm2yarn
23
+ npm install @assistant-ui/react-data-stream
24
+ ```
25
+
26
+ ## Basic Usage
27
+
28
+ <Steps>
29
+
30
+ <Step>
31
+
32
+ ### Set up the Runtime
33
+
34
+ Use `useDataStreamRuntime` to connect to your data stream endpoint:
35
+
36
+ ```tsx title="app/page.tsx"
37
+ "use client";
38
+ import { useDataStreamRuntime } from "@assistant-ui/react-data-stream";
39
+ import { AssistantRuntimeProvider } from "@assistant-ui/react";
40
+ import { Thread } from "@/components/assistant-ui/thread";
41
+
42
+ export default function ChatPage() {
43
+ const runtime = useDataStreamRuntime({
44
+ api: "/api/chat",
45
+ });
46
+
47
+ return (
48
+ <AssistantRuntimeProvider runtime={runtime}>
49
+ <Thread />
50
+ </AssistantRuntimeProvider>
51
+ );
52
+ }
53
+ ```
54
+
55
+ </Step>
56
+
57
+ <Step>
58
+
59
+ ### Create Backend Endpoint
60
+
61
+ Your backend endpoint should accept POST requests and return data stream responses:
62
+
63
+ ```typescript title="app/api/chat/route.ts"
64
+ import { DataStreamResponse } from "assistant-stream";
65
+
66
+ export async function POST(request: Request) {
67
+ const { messages, tools, system } = await request.json();
68
+
69
+ // Process the request with your AI provider
70
+ const stream = await processWithAI({
71
+ messages,
72
+ tools,
73
+ system,
74
+ });
75
+
76
+ return new DataStreamResponse(stream);
77
+ }
78
+ ```
79
+
80
+ </Step>
81
+
82
+ </Steps>
83
+
84
+ ## Advanced Configuration
85
+
86
+ ### Custom Headers and Authentication
87
+
88
+ ```tsx
89
+ const runtime = useDataStreamRuntime({
90
+ api: "/api/chat",
91
+ headers: {
92
+ "Authorization": "Bearer " + token,
93
+ "X-Custom-Header": "value",
94
+ },
95
+ credentials: "include",
96
+ });
97
+ ```
98
+
99
+ ### Dynamic Headers
100
+
101
+ ```tsx
102
+ const runtime = useDataStreamRuntime({
103
+ api: "/api/chat",
104
+ headers: async () => {
105
+ const token = await getAuthToken();
106
+ return {
107
+ "Authorization": "Bearer " + token,
108
+ };
109
+ },
110
+ });
111
+ ```
112
+
113
+ ### Event Callbacks
114
+
115
+ ```tsx
116
+ const runtime = useDataStreamRuntime({
117
+ api: "/api/chat",
118
+ onResponse: (response) => {
119
+ console.log("Response received:", response.status);
120
+ },
121
+ onFinish: (message) => {
122
+ console.log("Message completed:", message);
123
+ },
124
+ onError: (error) => {
125
+ console.error("Error occurred:", error);
126
+ },
127
+ onCancel: () => {
128
+ console.log("Request cancelled");
129
+ },
130
+ });
131
+ ```
132
+
133
+ ## Tool Integration
134
+
135
+ ### Frontend Tools
136
+
137
+ Use the `frontendTools` helper to serialize client-side tools:
138
+
139
+ ```tsx
140
+ import { frontendTools } from "@assistant-ui/react-data-stream";
141
+ import { makeAssistantTool } from "@assistant-ui/react";
142
+
143
+ const weatherTool = makeAssistantTool({
144
+ toolName: "get_weather",
145
+ description: "Get current weather",
146
+ parameters: z.object({
147
+ location: z.string(),
148
+ }),
149
+ execute: async ({ location }) => {
150
+ const weather = await fetchWeather(location);
151
+ return `Weather in ${location}: ${weather}`;
152
+ },
153
+ });
154
+
155
+ const runtime = useDataStreamRuntime({
156
+ api: "/api/chat",
157
+ body: {
158
+ tools: frontendTools({
159
+ get_weather: weatherTool,
160
+ }),
161
+ },
162
+ });
163
+ ```
164
+
165
+ ### Backend Tool Processing
166
+
167
+ Your backend should handle tool calls and return results:
168
+
169
+ ```typescript title="Backend tool handling"
170
+ // Tools are automatically forwarded to your endpoint
171
+ const { tools } = await request.json();
172
+
173
+ // Process tools with your AI provider
174
+ const response = await ai.generateText({
175
+ messages,
176
+ tools,
177
+ // Tool results are streamed back automatically
178
+ });
179
+ ```
180
+
181
+ ## Assistant Cloud Integration
182
+
183
+ For Assistant Cloud deployments, use `useCloudRuntime`:
184
+
185
+ ```tsx
186
+ import { useCloudRuntime } from "@assistant-ui/react-data-stream";
187
+
188
+ const runtime = useCloudRuntime({
189
+ cloud: assistantCloud,
190
+ assistantId: "my-assistant-id",
191
+ });
192
+ ```
193
+
194
+ <Callout type="info">
195
+ The `useCloudRuntime` hook is currently under active development and not yet ready for production use.
196
+ </Callout>
197
+
198
+ ## Message Conversion
199
+
200
+ The package includes utilities for converting between message formats:
201
+
202
+ ```tsx
203
+ import { toLanguageModelMessages } from "@assistant-ui/react-data-stream";
204
+
205
+ // Convert assistant-ui messages to language model format
206
+ const languageModelMessages = toLanguageModelMessages(messages, {
207
+ unstable_includeId: true, // Include message IDs
208
+ });
209
+ ```
210
+
211
+ ## Error Handling
212
+
213
+ The runtime automatically handles common error scenarios:
214
+
215
+ - **Network errors**: Automatically retried with exponential backoff
216
+ - **Stream interruptions**: Gracefully handled with partial content preservation
217
+ - **Tool execution errors**: Displayed in the UI with error states
218
+ - **Cancellation**: Clean abort signal handling
219
+
220
+ ## Best Practices
221
+
222
+ ### Performance Optimization
223
+
224
+ ```tsx
225
+ // Use React.memo for expensive components
226
+ const OptimizedThread = React.memo(Thread);
227
+
228
+ // Memoize runtime configuration
229
+ const runtimeConfig = useMemo(() => ({
230
+ api: "/api/chat",
231
+ headers: { "Authorization": `Bearer ${token}` },
232
+ }), [token]);
233
+
234
+ const runtime = useDataStreamRuntime(runtimeConfig);
235
+ ```
236
+
237
+ ### Error Boundaries
238
+
239
+ ```tsx
240
+ import { ErrorBoundary } from "react-error-boundary";
241
+
242
+ function ChatErrorFallback({ error, resetErrorBoundary }) {
243
+ return (
244
+ <div role="alert">
245
+ <h2>Something went wrong:</h2>
246
+ <pre>{error.message}</pre>
247
+ <button onClick={resetErrorBoundary}>Try again</button>
248
+ </div>
249
+ );
250
+ }
251
+
252
+ export default function App() {
253
+ return (
254
+ <ErrorBoundary FallbackComponent={ChatErrorFallback}>
255
+ <AssistantRuntimeProvider runtime={runtime}>
256
+ <Thread />
257
+ </AssistantRuntimeProvider>
258
+ </ErrorBoundary>
259
+ );
260
+ }
261
+ ```
262
+
263
+ ### State Persistence
264
+
265
+ ```tsx
266
+ const runtime = useDataStreamRuntime({
267
+ api: "/api/chat",
268
+ body: {
269
+ // Include conversation state
270
+ state: conversationState,
271
+ },
272
+ onFinish: (message) => {
273
+ // Save state after each message
274
+ saveConversationState(message.metadata.unstable_state);
275
+ },
276
+ });
277
+ ```
278
+
279
+ ## Examples
280
+
281
+ - **[Basic Data Stream Example](https://github.com/assistant-ui/assistant-ui/tree/main/examples/with-data-stream)** - Simple streaming chat
282
+ - **[Tool Integration Example](https://github.com/assistant-ui/assistant-ui/tree/main/examples/with-data-stream-tools)** - Frontend and backend tools
283
+ - **[Authentication Example](https://github.com/assistant-ui/assistant-ui/tree/main/examples/with-data-stream-auth)** - Secure endpoints
284
+
285
+ ## API Reference
286
+
287
+ For detailed API documentation, see the [`@assistant-ui/react-data-stream` API Reference](/docs/api-reference/integrations/react-data-stream).
@@ -61,7 +61,6 @@ npm install @assistant-ui/react @assistant-ui/react-ui @assistant-ui/react-langg
61
61
  ```tsx twoslash title="@/api/api/[...path]/route.ts"
62
62
  import { NextRequest, NextResponse } from "next/server";
63
63
 
64
- export const runtime = "edge";
65
64
 
66
65
  function getCorsHeaders() {
67
66
  return {
@@ -2,6 +2,10 @@
2
2
  title: LangChain LangServe
3
3
  ---
4
4
 
5
+ <Callout type="warning">
6
+ This integration has not been tested with AI SDK v5.
7
+ </Callout>
8
+
5
9
  ## Overview
6
10
 
7
11
  Integration with a LangServe server via Vercel AI SDK.
@@ -33,23 +37,17 @@ npm install @assistant-ui/react @assistant-ui/react-ai-sdk ai @ai-sdk/react @lan
33
37
 
34
38
  ### Setup a backend route under `/api/chat`
35
39
 
36
- ```tsx twoslash title="@/app/api/chat/route.ts"
37
- // @errors: 2558 2345
40
+ ```tsx title="@/app/api/chat/route.ts"
38
41
  import { RemoteRunnable } from "@langchain/core/runnables/remote";
39
- import type { RunnableConfig } from "@langchain/core/runnables";
40
- import { streamText, LangChainAdapter, type Message } from "ai";
42
+ import { toDataStreamResponse } from "@ai-sdk/langchain";
41
43
 
42
44
  export const maxDuration = 30;
43
45
 
44
46
  export async function POST(req: Request) {
45
- const { messages } = (await req.json()) as { messages: Message[] };
47
+ const { messages } = await req.json();
46
48
 
47
49
  // TODO replace with your own langserve URL
48
- const remoteChain = new RemoteRunnable<
49
- { messages: Message[] },
50
- string,
51
- RunnableConfig
52
- >({
50
+ const remoteChain = new RemoteRunnable({
53
51
  url: "<YOUR_LANGSERVE_URL>",
54
52
  });
55
53
 
@@ -57,7 +55,7 @@ export async function POST(req: Request) {
57
55
  messages,
58
56
  });
59
57
 
60
- return LangChainAdapter.toDataStreamResponse(stream);
58
+ return toDataStreamResponse(stream);
61
59
  }
62
60
  ```
63
61
 
@@ -48,6 +48,11 @@ For popular frameworks, we provide ready-to-use integrations built on top of our
48
48
  description="For useChat and useAssistant hooks - streaming with all major providers"
49
49
  href="/docs/runtimes/ai-sdk/use-chat"
50
50
  />
51
+ <Card
52
+ title="Data Stream Protocol"
53
+ description="For custom backends using the data stream protocol standard"
54
+ href="/docs/runtimes/data-stream"
55
+ />
51
56
  <Card
52
57
  title="LangGraph"
53
58
  description="For complex agent workflows with LangChain's graph framework"
@@ -3,6 +3,8 @@ title: ThreadList
3
3
  ---
4
4
 
5
5
  import { Steps, Step } from "fumadocs-ui/components/steps";
6
+ import { Callout } from "fumadocs-ui/components/callout";
7
+ import { Tabs, Tab } from "fumadocs-ui/components/tabs";
6
8
  import { ThreadListSample } from "../../../components/samples/threadlist-sample";
7
9
 
8
10
  ## Overview
@@ -11,37 +13,73 @@ The ThreadList component lets the user switch between threads.
11
13
 
12
14
  <ThreadListSample />
13
15
 
16
+ <Callout>
17
+ This demo uses **ThreadListSidebar**, which includes `thread-list` as a dependency and provides a complete sidebar layout. For custom implementations, you can use `thread-list` directly.
18
+ </Callout>
19
+
14
20
  ## Getting Started
15
21
 
16
22
  <Steps>
17
23
  <Step>
18
24
 
19
- ### Add `thread-list`
25
+ ### Add the component
20
26
 
21
27
  ```sh
28
+ # Complete thread-list sidebar layout
29
+ npx shadcn@latest add "https://r.assistant-ui.com/threadlist-sidebar"
30
+
31
+ # Just the thread-list for custom layouts
22
32
  npx shadcn@latest add "https://r.assistant-ui.com/thread-list"
23
33
  ```
24
34
 
25
- This adds a `/components/assistant-ui/thread-list.tsx` file to your project, which you can adjust as needed.
26
-
27
35
  </Step>
28
36
  <Step>
29
37
 
30
38
  ### Use in your application
31
39
 
32
- ```tsx title="/app/page.tsx" {1,5-6}
33
- import { Thread } from "@/components/assistant-ui/thread";
34
- import { ThreadList } from "@/components/assistant-ui/thread-list";
35
-
36
- export default function Home() {
37
- return (
38
- <div className="grid h-full grid-cols-[200px_1fr]">
39
- <ThreadList />
40
- <Thread />
41
- </div>
42
- );
43
- }
44
- ```
40
+ <Tabs items={["With Sidebar", "Without Sidebar"]}>
41
+ <Tab value="With Sidebar">
42
+ ```tsx title="/app/assistant.tsx"
43
+ import { Thread } from "@/components/assistant-ui/thread";
44
+ import { ThreadListSidebar } from "@/components/assistant-ui/threadlist-sidebar";
45
+ import {
46
+ SidebarProvider,
47
+ SidebarInset,
48
+ SidebarTrigger
49
+ } from "@/components/ui/sidebar";
50
+
51
+ export default function Assistant() {
52
+ return (
53
+ <SidebarProvider>
54
+ <div className="flex h-dvh w-full">
55
+ <ThreadListSidebar />
56
+ <SidebarInset>
57
+ {/* Add sidebar trigger, location can be customized */}
58
+ <SidebarTrigger className="absolute top-4 left-4" />
59
+ <Thread />
60
+ </SidebarInset>
61
+ </div>
62
+ </SidebarProvider>
63
+ );
64
+ }
65
+ ```
66
+ </Tab>
67
+ <Tab value="Without Sidebar">
68
+ ```tsx title="/app/assistant.tsx"
69
+ import { Thread } from "@/components/assistant-ui/thread";
70
+ import { ThreadList } from "@/components/assistant-ui/thread-list";
71
+
72
+ export default function Assistant() {
73
+ return (
74
+ <div className="grid h-full grid-cols-[200px_1fr]">
75
+ <ThreadList />
76
+ <Thread />
77
+ </div>
78
+ );
79
+ }
80
+ ```
81
+ </Tab>
82
+ </Tabs>
45
83
 
46
84
  </Step>
47
85
  </Steps>
@@ -109,6 +109,9 @@ function sanitizePath(userPath) {
109
109
  if (!userPath || typeof userPath !== "string") {
110
110
  throw new Error("Invalid path: Path must be a non-empty string");
111
111
  }
112
+ if (userPath.includes("../") || userPath.includes("..\\")) {
113
+ throw new Error("Invalid path: Directory traversal attempt detected");
114
+ }
112
115
  const normalized = normalize(userPath);
113
116
  if (path.isAbsolute(normalized)) {
114
117
  throw new Error("Invalid path: Absolute paths are not allowed");
@@ -138,7 +141,7 @@ function sanitizePath(userPath) {
138
141
  throw new Error("Invalid path: Hidden files are not allowed");
139
142
  }
140
143
  }
141
- return relativePath;
144
+ return relativePath.replace(/\\/g, "/");
142
145
  }
143
146
 
144
147
  // src/tools/docs.ts
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { runServer, server } from './chunk-L4K23SWI.js';
1
+ export { runServer, server } from './chunk-NVNFQ5ZO.js';
@@ -153,7 +153,7 @@ _Note: Additional files truncated due to size limits_
153
153
  `;
154
154
  break;
155
155
  }
156
- markdown += `## ${file.path}
156
+ markdown += `## ${file.path.replace(/\\/g, "/")}
157
157
 
158
158
  `;
159
159
  markdown += `\`\`\`${getFileType(file.path)}
package/dist/stdio.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { runServer } from './chunk-L4K23SWI.js';
2
+ import { runServer } from './chunk-NVNFQ5ZO.js';
3
3
 
4
4
  // src/stdio.ts
5
5
  void runServer().catch((error) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@assistant-ui/mcp-docs-server",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "MCP server for assistant-ui documentation and examples",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -8,18 +8,18 @@
8
8
  "assistant-ui-mcp": "./dist/stdio.js"
9
9
  },
10
10
  "dependencies": {
11
- "@modelcontextprotocol/sdk": "^1.17.1",
12
- "zod": "^4.0.14",
11
+ "@modelcontextprotocol/sdk": "^1.17.3",
12
+ "zod": "^4.0.17",
13
13
  "gray-matter": "^4.0.3",
14
14
  "cross-env": "^10.0.0"
15
15
  },
16
16
  "devDependencies": {
17
- "@types/node": "^24.1.0",
17
+ "@types/node": "^24.3.0",
18
18
  "tsup": "^8.5.0",
19
- "tsx": "^4.20.3",
19
+ "tsx": "^4.20.4",
20
20
  "typescript": "^5.9.2",
21
21
  "vitest": "^3.2.4",
22
- "eslint": "^9.32.0"
22
+ "eslint": "^9.33.0"
23
23
  },
24
24
  "files": [
25
25
  "dist",
@@ -30,7 +30,7 @@
30
30
  "access": "public"
31
31
  },
32
32
  "scripts": {
33
- "clean": "rm -rf dist .docs",
33
+ "clean": "tsx scripts/clean.mts",
34
34
  "prepare-docs": "cross-env PREPARE=true node ./dist/prepare-docs/prepare.js",
35
35
  "build:cli": "tsup src/stdio.ts src/prepare-docs/prepare.ts src/index.ts --format esm --treeshake=smallest --splitting",
36
36
  "build": "pnpm clean && pnpm build:cli && pnpm prepare-docs",