@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,160 @@
1
+ ---
2
+ title: ThreadListItemPrimitive
3
+ ---
4
+
5
+ A single thread item within a thread list.
6
+
7
+ import { ParametersTable } from "@/components/docs";
8
+
9
+ ## Anatomy
10
+
11
+ ```tsx
12
+ import { ThreadListItemPrimitive } from "@assistant-ui/react";
13
+
14
+ const ThreadListItem = () => (
15
+ <ThreadListItemPrimitive.Root>
16
+ <ThreadListItemPrimitive.Trigger>
17
+ <ThreadListItemPrimitive.Title />
18
+ </ThreadListItemPrimitive.Trigger>
19
+ <ThreadListItemPrimitive.Archive />
20
+ <ThreadListItemPrimitive.Unarchive />
21
+ <ThreadListItemPrimitive.Delete />
22
+ </ThreadListItemPrimitive.Root>
23
+ );
24
+ ```
25
+
26
+ ## API Reference
27
+
28
+ ### Root
29
+
30
+ Contains all parts of the thread list item.
31
+
32
+ This primitive renders a `<div>` element unless `asChild` is set. It automatically adds `data-active="true"` and `aria-current="true"` attributes when the thread is the currently active thread.
33
+
34
+ <ParametersTable
35
+ type="ThreadListItemPrimitiveRootProps"
36
+ parameters={[
37
+ {
38
+ name: "asChild",
39
+ },
40
+ ]}
41
+ />
42
+
43
+ ### Trigger
44
+
45
+ A button that switches to the thread when clicked.
46
+
47
+ This primitive renders a `<button>` element unless `asChild` is set.
48
+
49
+ <ParametersTable
50
+ type="ThreadListItemPrimitiveTriggerProps"
51
+ parameters={[
52
+ {
53
+ name: "asChild",
54
+ },
55
+ ]}
56
+ />
57
+
58
+ ### Title
59
+
60
+ Displays the title of the thread.
61
+
62
+ This primitive renders a `<span>` element unless `asChild` is set. The title is automatically derived from the first user message in the thread.
63
+
64
+ <ParametersTable
65
+ type="ThreadListItemPrimitiveTitleProps"
66
+ parameters={[
67
+ {
68
+ name: "asChild",
69
+ },
70
+ ]}
71
+ />
72
+
73
+ ### Archive
74
+
75
+ A button to archive the thread. Only shown for non-archived threads.
76
+
77
+ This primitive renders a `<button>` element unless `asChild` is set.
78
+
79
+ <ParametersTable
80
+ type="ThreadListItemPrimitiveArchiveProps"
81
+ parameters={[
82
+ {
83
+ name: "asChild",
84
+ },
85
+ ]}
86
+ />
87
+
88
+ ### Unarchive
89
+
90
+ A button to unarchive the thread. Only shown for archived threads.
91
+
92
+ This primitive renders a `<button>` element unless `asChild` is set.
93
+
94
+ <ParametersTable
95
+ type="ThreadListItemPrimitiveUnarchiveProps"
96
+ parameters={[
97
+ {
98
+ name: "asChild",
99
+ },
100
+ ]}
101
+ />
102
+
103
+ ### Delete
104
+
105
+ A button to permanently delete the thread.
106
+
107
+ This primitive renders a `<button>` element unless `asChild` is set.
108
+
109
+ <ParametersTable
110
+ type="ThreadListItemPrimitiveDeleteProps"
111
+ parameters={[
112
+ {
113
+ name: "asChild",
114
+ },
115
+ ]}
116
+ />
117
+
118
+ ## Examples
119
+
120
+ ### Basic Thread List Item
121
+
122
+ ```tsx
123
+ const MyThreadListItem = () => {
124
+ return (
125
+ <ThreadListItemPrimitive.Root className="thread-item">
126
+ <ThreadListItemPrimitive.Trigger className="thread-trigger">
127
+ <ThreadListItemPrimitive.Title />
128
+ </ThreadListItemPrimitive.Trigger>
129
+ <div className="thread-actions">
130
+ <ThreadListItemPrimitive.Archive>
131
+ Archive
132
+ </ThreadListItemPrimitive.Archive>
133
+ <ThreadListItemPrimitive.Delete>
134
+ Delete
135
+ </ThreadListItemPrimitive.Delete>
136
+ </div>
137
+ </ThreadListItemPrimitive.Root>
138
+ );
139
+ };
140
+ ```
141
+
142
+ ### Archived Thread List Item
143
+
144
+ ```tsx
145
+ const ArchivedThreadListItem = () => {
146
+ return (
147
+ <ThreadListItemPrimitive.Root className="archived-thread-item">
148
+ <ThreadListItemPrimitive.Trigger>
149
+ <ThreadListItemPrimitive.Title />
150
+ </ThreadListItemPrimitive.Trigger>
151
+ <ThreadListItemPrimitive.Unarchive>
152
+ Restore
153
+ </ThreadListItemPrimitive.Unarchive>
154
+ <ThreadListItemPrimitive.Delete>
155
+ Delete Permanently
156
+ </ThreadListItemPrimitive.Delete>
157
+ </ThreadListItemPrimitive.Root>
158
+ );
159
+ };
160
+ ```
@@ -20,14 +20,3 @@ const runtime = useAssistantRuntime();
20
20
  ### Tool UI Registry
21
21
 
22
22
  The tool UI registry is part of the assistant runtime. It allows you to display custom UI for tool calls, enabling generative UI.
23
-
24
- #### `useToolUIs`
25
-
26
- ```tsx
27
- import { useToolUIs } from "@assistant-ui/react";
28
-
29
- const toolUIs = useToolUIs();
30
- const webSearchToolUI = useToolUIs((m) => m.getToolUI("web_search"));
31
- ```
32
-
33
- <ParametersTable {...AssistantToolUIsState} />
@@ -7,15 +7,15 @@ The composer runtime allows you to view or edit anything related to how new info
7
7
  import { ParametersTable } from "@/components/docs";
8
8
  import { ComposerRuntime, ThreadComposerRuntime, ThreadComposerState, EditComposerState } from "@/generated/typeDocs";
9
9
 
10
- ### `useComposer`
10
+ ### `useComposerRuntime`
11
11
 
12
12
  Grabs the nearest composer (whether it’s the edit composer or the thread’s composer):
13
13
 
14
14
  ```tsx
15
15
  // Example
16
- import { useComposer } from "@assistant-ui/react";
16
+ import { useComposerRuntime } from "@assistant-ui/react";
17
17
 
18
- const composerRuntime = useComposer();
18
+ const composerRuntime = useComposerRuntime();
19
19
 
20
20
  // set the text
21
21
  composerRuntime.setText("Hello from the composer runtime");
@@ -0,0 +1,397 @@
1
+ ---
2
+ title: Assistant Frame API
3
+ description: Share model context across iframe boundaries
4
+ ---
5
+
6
+ The Assistant Frame API enables iframes to provide model context (tools and instructions) to a parent window's assistant. This is particularly useful for embedded applications, plugins, or sandboxed components that need to contribute capabilities to the main assistant.
7
+
8
+ ## Overview
9
+
10
+ The Assistant Frame system consists of two main components:
11
+
12
+ - **AssistantFrameProvider**: Runs inside the iframe and provides model context
13
+ - **AssistantFrameHost**: Runs in the parent window and consumes context from iframes
14
+
15
+ ## Basic Usage
16
+
17
+ ### In the iframe (Provider)
18
+
19
+ The iframe acts as a provider of model context using `AssistantFrameProvider`:
20
+
21
+ ```tsx
22
+ // iframe.tsx
23
+ import { AssistantFrameProvider } from "@assistant-ui/react";
24
+ import { ModelContextRegistry } from "@assistant-ui/react";
25
+ import { z } from "zod";
26
+
27
+ // Create a registry to manage your model context
28
+ const registry = new ModelContextRegistry();
29
+
30
+ // Expose the registry to the parent window
31
+ AssistantFrameProvider.addModelContextProvider(registry);
32
+
33
+ // Add tools that will be available to the parent assistant
34
+ registry.addTool({
35
+ toolName: "searchProducts",
36
+ description: "Search for products in the catalog",
37
+ parameters: z.object({
38
+ query: z.string(),
39
+ category: z.string().optional(),
40
+ }),
41
+ execute: async ({ query, category }) => {
42
+ // Tool implementation runs in the iframe
43
+ const results = await searchAPI(query, category);
44
+ return { products: results };
45
+ },
46
+ });
47
+
48
+ // Add system instructions
49
+ const instructionHandle = registry.addInstruction(
50
+ "You are a helpful assistant.",
51
+ );
52
+
53
+ // update the instruction
54
+ instructionHandle.update("You have access to a product catalog search tool.");
55
+ ```
56
+
57
+ ### In the parent window (Host)
58
+
59
+ The parent window consumes the iframe's context using `AssistantFrameHost`:
60
+
61
+ ```tsx
62
+ // parent.tsx
63
+ import { useAssistantFrameHost } from "@assistant-ui/react";
64
+ import { useRef } from "react";
65
+
66
+ function ParentComponent() {
67
+ const iframeRef = useRef<HTMLIFrameElement>(null);
68
+
69
+ // Connect to the iframe's model context
70
+ useAssistantFrameHost({
71
+ iframeRef,
72
+ targetOrigin: "https://trusted-iframe-domain.com", // optional for increased security
73
+ });
74
+
75
+ return (
76
+ <div>
77
+ <Thread /> {/* Your assistant UI */}
78
+ <iframe
79
+ ref={iframeRef}
80
+ src="https://trusted-iframe-domain.com/embed"
81
+ title="Embedded App"
82
+ />
83
+ </div>
84
+ );
85
+ }
86
+ ```
87
+
88
+ ## Advanced Usage
89
+
90
+ ### ModelContextRegistry
91
+
92
+ The `ModelContextRegistry` provides a flexible way to manage model context dynamically:
93
+
94
+ ```tsx
95
+ const registry = new ModelContextRegistry();
96
+
97
+ // Add a tool with handle for updates
98
+ const toolHandle = registry.addTool({
99
+ toolName: "convertCurrency",
100
+ description: "Convert between currencies",
101
+ parameters: z.object({
102
+ amount: z.number(),
103
+ from: z.string(),
104
+ to: z.string()
105
+ }),
106
+ execute: async ({ amount, from, to }) => {
107
+ const rate = await fetchExchangeRate(from, to);
108
+ return { result: amount * rate, currency: to };
109
+ },
110
+ });
111
+
112
+ // Update the tool later
113
+ toolHandle.update({
114
+ toolName: "convertCurrency",
115
+ description: "Convert between currencies with live rates", // Updated description
116
+ parameters: z.object({
117
+ amount: z.number(),
118
+ from: z.string(),
119
+ to: z.string(),
120
+ includesFees: z.boolean().optional()
121
+ }),
122
+ execute: async ({ amount, from, to, includesFees }) => {
123
+ const rate = await fetchExchangeRate(from, to);
124
+ const fee = includesFees ? 0.02 : 0; // 2% fee
125
+ return {
126
+ result: amount * rate * (1 - fee),
127
+ currency: to,
128
+ fee: includesFees ? amount * rate * fee : 0
129
+ };
130
+ },
131
+ });
132
+
133
+ // Remove the tool when no longer needed
134
+ toolHandle.remove();
135
+
136
+ // Add multiple instructions
137
+ const instruction1 = registry.addInstruction("Be helpful and concise.");
138
+ const instruction2 = registry.addInstruction("Use metric units.");
139
+
140
+ // Remove instructions
141
+ instruction1.remove();
142
+ ```
143
+
144
+ ### Multiple Providers
145
+
146
+ You can register multiple model context providers in the same iframe:
147
+
148
+ ```tsx
149
+ const catalogRegistry = new ModelContextRegistry();
150
+ const analyticsRegistry = new ModelContextRegistry();
151
+
152
+ // Add different tools to each registry
153
+ catalogRegistry.addTool({
154
+ /* ... */
155
+ });
156
+ analyticsRegistry.addTool({
157
+ /* ... */
158
+ });
159
+
160
+ // Register both providers
161
+ const unsubscribe1 =
162
+ AssistantFrameProvider.addModelContextProvider(catalogRegistry);
163
+ const unsubscribe2 =
164
+ AssistantFrameProvider.addModelContextProvider(analyticsRegistry);
165
+
166
+ // Later, unsubscribe if needed
167
+ unsubscribe1();
168
+ unsubscribe2();
169
+ ```
170
+
171
+ ### Security Considerations
172
+
173
+ #### Origin Validation
174
+
175
+ Both the provider and host can specify allowed origins for security:
176
+
177
+ ```tsx
178
+ // In iframe - only accept messages from specific parent
179
+ AssistantFrameProvider.addModelContextProvider(
180
+ registry,
181
+ "https://parent-app.com",
182
+ );
183
+
184
+ // In parent - only accept messages from specific iframe
185
+ useAssistantFrameHost({
186
+ iframeRef,
187
+ targetOrigin: "https://iframe-app.com",
188
+ });
189
+ ```
190
+
191
+ #### Tool Execution
192
+
193
+ Tools are executed in the iframe's context, keeping sensitive operations sandboxed:
194
+
195
+ ```tsx
196
+ registry.addTool({
197
+ toolName: "accessDatabase",
198
+ description: "Query the database",
199
+ parameters: z.object({ query: z.string() }),
200
+ execute: async ({ query }) => {
201
+ // This runs in the iframe with iframe's permissions
202
+ // Parent cannot directly access the database
203
+ const results = await db.query(query);
204
+ return results;
205
+ },
206
+ });
207
+ ```
208
+
209
+ ## API Reference
210
+
211
+ ### AssistantFrameProvider
212
+
213
+ Static class that manages model context providers in an iframe.
214
+
215
+ #### Methods
216
+
217
+ ##### `addModelContextProvider(provider, targetOrigin?)`
218
+
219
+ Registers a model context provider to share with parent windows.
220
+
221
+ ```tsx
222
+ const unsubscribe = AssistantFrameProvider.addModelContextProvider(
223
+ registry,
224
+ "https://parent-domain.com", // Optional origin restriction
225
+ );
226
+ ```
227
+
228
+ ##### `dispose()`
229
+
230
+ Cleans up all resources and removes all providers.
231
+
232
+ ```tsx
233
+ AssistantFrameProvider.dispose();
234
+ ```
235
+
236
+ ### AssistantFrameHost
237
+
238
+ Class that connects to an iframe's model context providers.
239
+
240
+ #### Constructor
241
+
242
+ ```tsx
243
+ const host = new AssistantFrameHost(
244
+ iframeWindow,
245
+ targetOrigin? // Optional origin restriction
246
+ );
247
+ ```
248
+
249
+ #### Methods
250
+
251
+ ##### `getModelContext()`
252
+
253
+ Returns the current merged model context from the iframe.
254
+
255
+ ```tsx
256
+ const context = host.getModelContext();
257
+ // { system: "...", tools: { ... } }
258
+ ```
259
+
260
+ ##### `subscribe(callback)`
261
+
262
+ Subscribes to model context changes.
263
+
264
+ ```tsx
265
+ const unsubscribe = host.subscribe(() => {
266
+ console.log("Context updated:", host.getModelContext());
267
+ });
268
+ ```
269
+
270
+ ##### `dispose()`
271
+
272
+ Cleans up the connection to the iframe.
273
+
274
+ ```tsx
275
+ host.dispose();
276
+ ```
277
+
278
+ ### useAssistantFrameHost
279
+
280
+ React hook that manages the lifecycle of an AssistantFrameHost.
281
+
282
+ ```tsx
283
+ useAssistantFrameHost({
284
+ iframeRef: RefObject<HTMLIFrameElement>,
285
+ targetOrigin?: string,
286
+ });
287
+ ```
288
+
289
+ ### ModelContextRegistry
290
+
291
+ A flexible registry for managing model context with dynamic updates.
292
+
293
+ #### Methods
294
+
295
+ ##### `addTool(tool)`
296
+
297
+ Adds a tool and returns a handle for updates/removal.
298
+
299
+ ```tsx
300
+ const handle = registry.addTool({
301
+ toolName: string,
302
+ description?: string,
303
+ parameters: ZodSchema | JSONSchema,
304
+ execute: (args, context) => Promise<any>,
305
+ });
306
+
307
+ handle.update(newTool); // Update the tool
308
+ handle.remove(); // Remove the tool
309
+ ```
310
+
311
+ ##### `addInstruction(instruction)`
312
+
313
+ Adds a system instruction and returns a handle.
314
+
315
+ ```tsx
316
+ const handle = registry.addInstruction("Be concise.");
317
+ handle.update("Be detailed."); // Update instruction
318
+ handle.remove(); // Remove instruction
319
+ ```
320
+
321
+ ##### `addProvider(provider)`
322
+
323
+ Adds another model context provider.
324
+
325
+ ```tsx
326
+ const handle = registry.addProvider(anotherProvider);
327
+ handle.remove(); // Remove provider
328
+ ```
329
+
330
+ ## Use Cases
331
+
332
+ ### Embedded Analytics Dashboard
333
+
334
+ An analytics iframe can provide data query tools to the parent assistant:
335
+
336
+ ```tsx
337
+ // In analytics iframe
338
+ registry.addTool({
339
+ toolName: "queryMetrics",
340
+ description: "Query analytics data",
341
+ parameters: z.object({
342
+ metric: z.string(),
343
+ timeRange: z.string(),
344
+ }),
345
+ execute: async ({ metric, timeRange }) => {
346
+ const data = await analyticsAPI.query(metric, timeRange);
347
+ return { data, visualization: createChart(data) };
348
+ },
349
+ });
350
+ ```
351
+
352
+ ### Plugin System
353
+
354
+ Third-party plugins can extend the assistant's capabilities:
355
+
356
+ ```tsx
357
+ // In plugin iframe
358
+ registry.addTool({
359
+ toolName: "translateText",
360
+ description: "Translate text to another language",
361
+ parameters: z.object({
362
+ text: z.string(),
363
+ targetLanguage: z.string(),
364
+ }),
365
+ execute: async ({ text, targetLanguage }) => {
366
+ return await pluginAPI.translate(text, targetLanguage);
367
+ },
368
+ });
369
+ ```
370
+
371
+ ### Data Visualization
372
+
373
+ Provide data visualization tools in an iframe:
374
+
375
+ ```tsx
376
+ // In visualization iframe
377
+ registry.addTool({
378
+ toolName: "createChart",
379
+ description: "Generate a chart from data",
380
+ parameters: z.object({
381
+ data: z.array(z.object({
382
+ label: z.string(),
383
+ value: z.number()
384
+ })),
385
+ chartType: z.enum(["bar", "line", "pie"]),
386
+ title: z.string().optional()
387
+ }),
388
+ execute: async ({ data, chartType, title }) => {
389
+ // Generate chart using a library like Chart.js or D3
390
+ const chartUrl = await generateChart(data, chartType, title);
391
+ return {
392
+ chartUrl,
393
+ summary: `Created ${chartType} chart with ${data.length} data points`
394
+ };
395
+ },
396
+ });
397
+ ```