@assistant-ui/mcp-docs-server 0.1.9 → 0.1.10

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.
@@ -4,26 +4,64 @@ title: Thread
4
4
 
5
5
  import { Steps, Step } from "fumadocs-ui/components/steps";
6
6
  import { Callout } from "fumadocs-ui/components/callout";
7
+ import { Tab, Tabs } from "fumadocs-ui/components/tabs";
8
+ import { ParametersTable } from "@/components/docs";
7
9
  import { ThreadSample } from "../../../components/samples/thread-sample";
8
10
 
11
+ A complete chat interface that combines message rendering, auto-scrolling, composer input,
12
+ attachments, and conditional UI states. Fully customizable and composable.
9
13
 
10
- ## Overview
11
-
12
- The raw message list and message composer UI.
13
14
 
14
15
  <ThreadSample />
15
16
 
17
+ ## Anatomy
18
+
19
+ The Thread component is built with the following primitives:
20
+
21
+ ```tsx
22
+ import { ThreadPrimitive } from "@assistant-ui/react";
23
+
24
+ <ThreadPrimitive.Root>
25
+ <ThreadPrimitive.Viewport>
26
+ <ThreadPrimitive.Empty />
27
+ <ThreadPrimitive.Messages
28
+ components={{
29
+ EditComposer,
30
+ UserMessage,
31
+ AssistantMessage,
32
+ }}
33
+ />
34
+ <ThreadPrimitive.ScrollToBottom />
35
+ </ThreadPrimitive.Viewport>
36
+ <ThreadPrimitive.Suggestion />
37
+ <ThreadPrimitive.If />
38
+ </ThreadPrimitive.Root>
39
+ ```
40
+
16
41
  ## Getting Started
17
42
 
18
43
  <Steps>
19
44
  <Step>
20
45
 
21
- ### Add `thread`
46
+ ### Add the component
47
+
48
+ <Tabs items={["assistant-ui", "shadcn"]}>
49
+ <Tab>
50
+
51
+ ```sh
52
+ npx assistant-ui@latest add thread
53
+ ```
54
+
55
+ </Tab>
56
+ <Tab>
22
57
 
23
58
  ```sh
24
59
  npx shadcn@latest add "https://r.assistant-ui.com/thread"
25
60
  ```
26
61
 
62
+ </Tab>
63
+ </Tabs>
64
+
27
65
  This adds a `/components/assistant-ui/thread.tsx` file to your project, which you can adjust as needed.
28
66
 
29
67
  </Step>
@@ -34,7 +72,7 @@ This adds a `/components/assistant-ui/thread.tsx` file to your project, which yo
34
72
  ```tsx title="/app/page.tsx" {1,6}
35
73
  import { Thread } from "@/components/assistant-ui/thread";
36
74
 
37
- export default function Home() {
75
+ export default function Chat() {
38
76
  return (
39
77
  <div className="h-full">
40
78
  <Thread />
@@ -45,3 +83,328 @@ export default function Home() {
45
83
 
46
84
  </Step>
47
85
  </Steps>
86
+
87
+ ## Examples
88
+
89
+ ### Welcome Screen
90
+
91
+ ```tsx
92
+ <ThreadPrimitive.If empty>
93
+ <ThreadWelcome />
94
+ </ThreadPrimitive.If>
95
+ ```
96
+
97
+ ### Viewport Spacer
98
+
99
+ ```tsx
100
+ <ThreadPrimitive.If empty={false}>
101
+ <div className="min-h-8 grow" />
102
+ </ThreadPrimitive.If>
103
+ ```
104
+
105
+ ### Conditional Send/Cancel Button
106
+
107
+ ```tsx
108
+ <ThreadPrimitive.If running={false}>
109
+ <ComposerPrimitive.Send>
110
+ Send
111
+ </ComposerPrimitive.Send>
112
+ </ThreadPrimitive.If>
113
+
114
+ <ThreadPrimitive.If running>
115
+ <ComposerPrimitive.Cancel>
116
+ Cancel
117
+ </ComposerPrimitive.Cancel>
118
+ </ThreadPrimitive.If>
119
+ ```
120
+
121
+ ### Suggestions
122
+
123
+ ```tsx
124
+ <ThreadPrimitive.Suggestion
125
+ prompt="What's the weather in San Francisco?"
126
+ send
127
+ />
128
+ ```
129
+
130
+ ## API Reference
131
+
132
+ The following primitives are used within the Thread component and can be customized in your `/components/assistant-ui/thread.tsx` file.
133
+
134
+ ### Root
135
+
136
+ Contains all parts of the thread.
137
+
138
+ <ParametersTable
139
+ type="ThreadPrimitiveRootProps"
140
+ parameters={[
141
+ {
142
+ name: "asChild",
143
+ type: "boolean",
144
+ default: "false",
145
+ description: "Merge props with child element instead of rendering a wrapper div.",
146
+ },
147
+ {
148
+ name: "className",
149
+ type: "string",
150
+ description: "CSS class name.",
151
+ },
152
+ ]}
153
+ />
154
+
155
+ This primitive renders a `<div>` element unless `asChild` is set.
156
+
157
+ ### Viewport
158
+
159
+ The scrollable area containing all messages. Automatically scrolls to the bottom as new messages are added.
160
+
161
+ <ParametersTable
162
+ type="ThreadPrimitiveViewportProps"
163
+ parameters={[
164
+ {
165
+ name: "asChild",
166
+ type: "boolean",
167
+ default: "false",
168
+ description: "Merge props with child element instead of rendering a wrapper div.",
169
+ },
170
+ {
171
+ name: "autoScroll",
172
+ type: "boolean",
173
+ default: "true",
174
+ description:
175
+ "Whether to automatically scroll to the bottom when new messages are added while the viewport was previously scrolled to the bottom.",
176
+ },
177
+ {
178
+ name: "className",
179
+ type: "string",
180
+ description: "CSS class name.",
181
+ },
182
+ ]}
183
+ />
184
+
185
+ This primitive renders a `<div>` element unless `asChild` is set.
186
+
187
+ ### Messages
188
+
189
+ Renders all messages in the thread. This primitive renders a separate component for each message.
190
+
191
+ ```tsx
192
+ <ThreadPrimitive.Messages
193
+ components={{
194
+ UserMessage: UserMessage,
195
+ EditComposer: EditComposer,
196
+ AssistantMessage: AssistantMessage,
197
+ }}
198
+ />
199
+ ```
200
+
201
+ <ParametersTable
202
+ type="ThreadPrimitiveMessagesProps"
203
+ parameters={[
204
+ {
205
+ name: "components",
206
+ type: "MessageComponents",
207
+ required: true,
208
+ description: "Components to render for different message types.",
209
+ children: [
210
+ {
211
+ type: "MessageComponents",
212
+ parameters: [
213
+ {
214
+ name: "Message",
215
+ type: "ComponentType",
216
+ description: "Default component for all messages.",
217
+ },
218
+ {
219
+ name: "UserMessage",
220
+ type: "ComponentType",
221
+ description: "Component for user messages.",
222
+ },
223
+ {
224
+ name: "EditComposer",
225
+ type: "ComponentType",
226
+ description:
227
+ "Component for user messages being edited.",
228
+ },
229
+ {
230
+ name: "AssistantMessage",
231
+ type: "ComponentType",
232
+ description: "Component for assistant messages.",
233
+ },
234
+ {
235
+ name: "SystemMessage",
236
+ type: "ComponentType",
237
+ description: "Component for system messages.",
238
+ },
239
+ ],
240
+ },
241
+ ],
242
+ },
243
+ ]}
244
+ />
245
+
246
+
247
+ ### MessageByIndex
248
+
249
+ Renders a single message at the specified index.
250
+
251
+ ```tsx
252
+ <ThreadPrimitive.MessageByIndex
253
+ index={0}
254
+ components={{
255
+ UserMessage: UserMessage,
256
+ AssistantMessage: AssistantMessage
257
+ }}
258
+ />
259
+ ```
260
+
261
+ <ParametersTable
262
+ type="ThreadPrimitiveMessageByIndexProps"
263
+ parameters={[
264
+ {
265
+ name: "index",
266
+ type: "number",
267
+ required: true,
268
+ description: "The index of the message to render.",
269
+ },
270
+ {
271
+ name: "components",
272
+ type: "MessageComponents",
273
+ description: "Components to render for different message types.",
274
+ },
275
+ ]}
276
+ />
277
+
278
+ ### Empty
279
+
280
+ Renders children only when there are no messages in the thread.
281
+
282
+ <ParametersTable
283
+ type="ThreadPrimitiveEmptyProps"
284
+ parameters={[
285
+ {
286
+ name: "children",
287
+ type: "ReactNode",
288
+ description: "Content to display when the thread is empty.",
289
+ },
290
+ ]}
291
+ />
292
+
293
+ ### ScrollToBottom
294
+
295
+ A button to scroll the viewport to the bottom. Disabled when the viewport is already at the bottom.
296
+
297
+ <ParametersTable
298
+ type="ThreadPrimitiveScrollToBottomProps"
299
+ parameters={[
300
+ {
301
+ name: "asChild",
302
+ type: "boolean",
303
+ default: "false",
304
+ description: "Merge props with child element instead of rendering a wrapper button.",
305
+ },
306
+ {
307
+ name: "className",
308
+ type: "string",
309
+ description: "CSS class name.",
310
+ },
311
+ ]}
312
+ />
313
+
314
+ This primitive renders a `<button>` element unless `asChild` is set.
315
+
316
+ ### Suggestion
317
+
318
+ Shows a suggestion to the user. When clicked, replaces the composer's value with the suggestion and optionally sends it.
319
+
320
+ ```tsx
321
+ <ThreadPrimitive.Suggestion
322
+ prompt="Tell me about React hooks"
323
+ send
324
+ />
325
+ ```
326
+
327
+ <ParametersTable
328
+ type="ThreadPrimitiveSuggestionProps"
329
+ parameters={[
330
+ {
331
+ name: "prompt",
332
+ type: "string",
333
+ required: true,
334
+ description: "The suggestion text to use when clicked.",
335
+ },
336
+ {
337
+ name: "send",
338
+ type: "boolean",
339
+ description:
340
+ "When true, automatically sends the message. When false, replaces or appends the composer text with the suggestion - depending on the value of `clearComposer`",
341
+ },
342
+ {
343
+ name: "clearComposer",
344
+ type: "boolean",
345
+ default: "true",
346
+ description:
347
+ "Whether to clear the composer after sending. When send is set to false, determines if composer text is replaced with suggestion (true, default), or if the suggestion's prompt is appended to the composer text (false).",
348
+ },
349
+ {
350
+ name: "autoSend",
351
+ type: "boolean",
352
+ deprecated: true,
353
+ description: "Deprecated. Use 'send' instead.",
354
+ },
355
+ {
356
+ name: "method",
357
+ type: "'replace'",
358
+ deprecated: true,
359
+ description: "Deprecated. This parameter is no longer used.",
360
+ },
361
+ {
362
+ name: "asChild",
363
+ type: "boolean",
364
+ default: "false",
365
+ description: "Merge props with child element instead of rendering a wrapper button.",
366
+ },
367
+ {
368
+ name: "className",
369
+ type: "string",
370
+ description: "CSS class name.",
371
+ },
372
+ ]}
373
+ />
374
+
375
+ This primitive renders a `<button>` element unless `asChild` is set.
376
+
377
+ ### If
378
+
379
+ Conditionally renders children based on thread state.
380
+
381
+ <ParametersTable
382
+ type="ThreadPrimitiveIfProps"
383
+ parameters={[
384
+ {
385
+ name: "empty",
386
+ type: "boolean | undefined",
387
+ description: "Render children if the thread is empty (no messages).",
388
+ },
389
+ {
390
+ name: "running",
391
+ type: "boolean | undefined",
392
+ description: "Render children if the thread is running (assistant is responding).",
393
+ },
394
+ {
395
+ name: "disabled",
396
+ type: "boolean | undefined",
397
+ description: "Render children if the thread is disabled.",
398
+ },
399
+ ]}
400
+ />
401
+
402
+ <Callout type="info">
403
+ Multiple conditions can be combined on `ThreadPrimitive.If` - all specified conditions must match for children to render.
404
+ </Callout>
405
+
406
+
407
+ ## Related Components
408
+
409
+ - [ThreadList](/docs/ui/ThreadList) - List of threads
410
+ - [ThreadListSidebar](/docs/ui/ThreadListSidebar) - Sidebar with thread list
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@assistant-ui/mcp-docs-server",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "MCP server for assistant-ui documentation and examples",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -8,16 +8,16 @@
8
8
  "assistant-ui-mcp": "./dist/stdio.js"
9
9
  },
10
10
  "dependencies": {
11
- "@modelcontextprotocol/sdk": "^1.18.2",
11
+ "@modelcontextprotocol/sdk": "^1.19.1",
12
12
  "zod": "^4.1.11",
13
13
  "gray-matter": "^4.0.3",
14
- "cross-env": "^10.0.0"
14
+ "cross-env": "^10.1.0"
15
15
  },
16
16
  "devDependencies": {
17
- "@types/node": "^24.5.2",
17
+ "@types/node": "^24.6.2",
18
18
  "tsup": "^8.5.0",
19
19
  "tsx": "^4.20.6",
20
- "typescript": "^5.9.2",
20
+ "typescript": "^5.9.3",
21
21
  "vitest": "^3.2.4",
22
22
  "eslint": "^9.36.0"
23
23
  },
@@ -1,188 +0,0 @@
1
- ---
2
- title: Migration to v0.7
3
- ---
4
-
5
- import { Callout } from "fumadocs-ui/components/callout";
6
-
7
- This guide serves as a reference for users facing breaking changes during upgrade to v0.7. You do not need to read this guide to upgrade to v0.7.
8
-
9
- All breaking changes in v0.7 are renames or removals of existing APIs. Therefore, all breaking changes should cause a Typescript error, so you can simply check for errors after upgrading.
10
-
11
- ### Component Property Types moved to `Component.Props`
12
-
13
- Component property types are now neatly organized under the component itself.
14
-
15
- ```diff
16
- -import { ThreadPrimitiveMessagesProps } from "@assistant-ui/react";
17
- +import { ThreadPrimitive } from "@assistant-ui/react";
18
-
19
- -type Props = ThreadPrimitiveMessagesProps;
20
- +type Props = ThreadPrimitive.Messages.Props;
21
- ```
22
-
23
- ## Context API simplifications
24
-
25
- ### `useThreadContext`, `useMessageContext`, ... replaced with direct imports of stores
26
-
27
- `useAssistantContext`, `useThreadContext`, `useMessageContext` and `useMessagePartContext` have been removed in favor of direct exports from `@assistant-ui/react`;
28
-
29
- ```diff
30
- -const { useThread } = useThreadContext();
31
-
32
- +import { useThread } from "@assistant-ui/react";
33
- ```
34
-
35
- # Assistant Context API simplifications
36
-
37
- ### `useAssistantActions` replaced with `useAssistantRuntime`
38
-
39
- `useAssistantActions` has been removed in favor of `useAssistantRuntime`.
40
-
41
- ```diff
42
- -const switchToNewThread = useAssistantActions(a => a.switchToNewThread);
43
- +const runtime = useAssistantRuntime();
44
- +runtime.switchToNewThread();
45
- ```
46
-
47
- ### `switchToThread(null)` replaced with `switchToNewThread()`
48
-
49
- ```diff
50
- -useThreadRuntime().switchToThread(null);
51
- +useThreadRuntime().switchToNewThread();
52
- ```
53
-
54
- ### useSwtichToNewThread() moved to useAssistantRuntime().switchToNewThread()
55
-
56
- ```diff
57
- -useSwitchToNewThread();
58
- +const runtime = useAssistantRuntime()
59
- +runtime.switchToNewThread();
60
- ```
61
-
62
- ### `runtime.subscribe` removed, `subscribeToMainThread` removed
63
-
64
- Previously, you needed to subscribe to the runtime to receive updates whenever the main thread changed and resubscribe to the main thread whenever you switched to a new thread. The `runtime.thread` value now always refers to the current main thread, there is no need to subscribe to the runtime anymore.
65
-
66
- ## ThreadRuntime API simplifications
67
-
68
- ### `useAppendMessage` moved to `useThreadRuntime().append()`
69
-
70
- ```diff
71
- -const append = useAppendMessage();
72
- +const threadRuntime = useThreadRuntime();
73
- -append("hello world");
74
- +threadRuntime.append("hello world");
75
- ```
76
-
77
- ### `useThreadActions` replaced with `useThreadRuntime`
78
-
79
- `useThreadActions` has been removed in favor of `useThreadRuntime`.
80
-
81
- ```diff
82
- -const reload = useThreadActions(a => a.reload);
83
- +const threadRuntime = useThreadRuntime();
84
- +threadRuntime.reload();
85
- ```
86
-
87
- ### State values moved to `threadRuntime.getState()`
88
-
89
- In order to make it clear that accessing the state only provides a snapshot of the current state and will not cause a re-render on changes, the state values of `useThreadRuntime` have been moved to `threadRuntime.getState()`.
90
-
91
- ```diff
92
- -const isRunning = useThreadRuntime().isRunning; // anti-pattern, your code will not update on change
93
- +const isRunning = useThread(t => t.isRunning);
94
- ```
95
-
96
- ### `useThreadStore` replaced with `useThreadRuntime().getState()`
97
-
98
- `useThreadStore` has been removed in favor of `useThreadRuntime().getState()`.
99
-
100
- ### `threadRuntime.getBranches()` replaced with `useThreadRuntime().getMessageByIndex(idx).getState().branchNumber/Count`
101
-
102
- The branch IDs are an internal implementation detail. The new Message Runtime API provides `branchNumber` and `branchCount` state fields that can be used instead.
103
-
104
- ### New Message Runtime API replaces several methods from `useThreadRuntime`
105
-
106
- A few methods from `useThreadRuntime` have been moved to `useMessageRuntime()`.
107
-
108
- - `threadRuntime.switchToBranch()` has been removed in favor of `useThreadRuntime().getMessageByIndex(idx).switchToBranch()`.
109
- - `threadRuntime.addToolResult()` has been removed in favor of `useThreadRuntime().getMessageByIndex(idx).getMessagePartByToolCallId(toolCallId).addToolResult()`.
110
- - `threadRuntime.speak()` has been removed in favor of `useThreadRuntime().getMessageByIndex(idx).speak()`.
111
- - `threadRuntime.submitFeedback()` has been removed in favor of `useThreadRuntime().getMessageByIndex(idx).submitFeedback()`.
112
- - `threadRuntime.getEditComposer()` has been removed in favor of `useThreadRuntime().getMessageById(id).getMessageByIndex(idx).composer`.
113
- - `threadRuntime.beginEdit()` has been removed in favor of `useThreadRuntime().getMessageById(id).getMessageByIndex(idx).composer.beginEdit()`.
114
-
115
- ## Composer Runtime API simplifications
116
-
117
- ### Methods inside `useComposer` moved to `useComposerRuntime`
118
-
119
- `useComposer()` used to provide several methods such as `setText`, `addAttachment`, `send`, `edit`, `cancel`, ...
120
- These methods have been moved to `useComposerRuntime()`.
121
-
122
- ### `useComposerStore` replaced with `useComposerRuntime().getState()`
123
-
124
- `useComposerStore` has been removed in favor of `useComposerRuntime().getState()`.
125
-
126
- ### `value` `setValue` replaced with `text` `setText`
127
-
128
- ```diff
129
- -useComposer(c => c.value);
130
- +useComposer(c => c.text);
131
- ```
132
-
133
- ### `focus`, `onFocus` methods removed
134
-
135
- These methods have been removed.
136
-
137
- ## Message Context API simplifications
138
-
139
- ### Flattened context values `useMessage().message` -> `useMessage()`
140
-
141
- `MessageState` is now itself a message, so you no longer need to access the nested `useMessage().message` field.
142
-
143
- ```diff
144
- -useMessage(m => m.message.content);
145
- +useMessage(m => m.content);
146
- ```
147
-
148
- ### `useMessageStore` replaced with `useMessageRuntime().getState()`
149
-
150
- `useMessageStore` has been removed in favor of `useMessageRuntime().getState()`.
151
-
152
- ## Message part Context API simplifications
153
-
154
- ### Flattened context values `useMessagePart().part` -> `useMessagePart()`
155
-
156
- `MessagePartState` is now itself a message part, so you no longer need to access the nested `useMessagePart().part` field.
157
-
158
- ```diff
159
- -useMessagePart(c => c.part.type);
160
- +useMessagePart(c => c.type);
161
- ```
162
-
163
- This also applies to tool UI render functions:
164
-
165
- ```diff
166
- makeAssistantToolUI({
167
- ...
168
- - render: ({ part: { args } }) => <>{args}</>,
169
- + render: ({ args }) => <>{args}</>,
170
- });
171
- ```
172
-
173
- ## Attachment Context API simplifications
174
-
175
- ### Flattened context values `useAttachment().attachment` -> `useAttachment()`
176
-
177
- `AttachmentState` is now itself an attachment, so you no longer need to access the nested `useAttachment().attachment` field.
178
-
179
- ```diff
180
- -useAttachment(a => a.attachment.type);
181
- +useAttachment(a => a.type);
182
- ```
183
-
184
- ## Roundtrips renamed to steps
185
-
186
- `AssistantMessage.roundtrips` was renamed to `AssistantMessage.metadata.steps`.
187
-
188
- Edge runtime's `maxToolRoundtrips` was replaced with `maxSteps` (which is `maxToolRoundtrips` + 1; if you had `maxToolRoundtrips` at 2, set `maxSteps` to 3).