@assistant-ui/mcp-docs-server 0.1.8 → 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.
Files changed (28) hide show
  1. package/.docs/organized/code-examples/with-ai-sdk-v5.md +24 -17
  2. package/.docs/organized/code-examples/with-assistant-transport.md +1599 -0
  3. package/.docs/organized/code-examples/with-cloud.md +11 -11
  4. package/.docs/organized/code-examples/with-external-store.md +9 -9
  5. package/.docs/organized/code-examples/with-ffmpeg.md +17 -16
  6. package/.docs/organized/code-examples/with-langgraph.md +33 -110
  7. package/.docs/organized/code-examples/with-parent-id-grouping.md +9 -9
  8. package/.docs/organized/code-examples/with-react-hook-form.md +17 -16
  9. package/.docs/raw/docs/api-reference/primitives/Thread.mdx +40 -8
  10. package/.docs/raw/docs/cloud/persistence/langgraph.mdx +42 -66
  11. package/.docs/raw/docs/copilots/assistant-frame.mdx +18 -16
  12. package/.docs/raw/docs/devtools.mdx +51 -0
  13. package/.docs/raw/docs/getting-started.mdx +2 -4
  14. package/.docs/raw/docs/guides/ToolUI.mdx +112 -37
  15. package/.docs/raw/docs/guides/Tools.mdx +170 -6
  16. package/.docs/raw/docs/migrations/react-langgraph-v0-7.mdx +324 -0
  17. package/.docs/raw/docs/runtimes/ai-sdk/use-chat.mdx +2 -2
  18. package/.docs/raw/docs/runtimes/custom/local.mdx +1 -1
  19. package/.docs/raw/docs/runtimes/langgraph/index.mdx +55 -20
  20. package/.docs/raw/docs/runtimes/mastra/full-stack-integration.mdx +6 -5
  21. package/.docs/raw/docs/runtimes/mastra/overview.mdx +3 -3
  22. package/.docs/raw/docs/runtimes/mastra/separate-server-integration.mdx +13 -13
  23. package/.docs/raw/docs/ui/Thread.mdx +368 -5
  24. package/package.json +8 -8
  25. package/.docs/raw/docs/migrations/v0-7.mdx +0 -188
  26. package/.docs/raw/docs/migrations/v0-8.mdx +0 -160
  27. package/.docs/raw/docs/migrations/v0-9.mdx +0 -75
  28. package/.docs/raw/docs/ui/primitives/Thread.mdx +0 -197
@@ -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).
@@ -1,160 +0,0 @@
1
- ---
2
- title: Migration to v0.8
3
- ---
4
-
5
- ## Styled Components moved to @assistant-ui/react-ui
6
-
7
- All styled components (Thread, ThreadList, AssistantModal, makeMarkdownText, etc.) have been moved to a new package, `@assistant-ui/react-ui`.
8
-
9
- To migrate, use the migration codemod:
10
-
11
- ```sh
12
- # IMPORTANT: make sure to commit all changes to git / creating a backup before running the codemod
13
- npx assistant-ui upgrade
14
- ```
15
-
16
- ## Vercel AI SDK RSC requires additional setup
17
-
18
- Built-in RSC support in assistant-ui has been removed, so an additional setup step is required.
19
- The RSC runtime now requires additional setup to display React Server Components.
20
-
21
- ```ts
22
- import { RSCDisplay } from "@assistant-ui/react-ai-sdk";
23
-
24
- // if you are using the default Thread component
25
- // add RSCDisplay to assistantMessage.components.Text
26
- <Thread assistantMessage={{ components: { Text: RSCDisplay } }} />
27
-
28
-
29
- // if you are using unstyled primitives, update MyThread.tsx
30
- <MessagePrimitive.Parts components={{ Text: RSCDisplay }} />
31
- ```
32
-
33
- ## Migrate away from UIMessagePart
34
-
35
- For instructions on migrating for Vercel AI SDK RSC, see section above.
36
- This migration guide is for users of `useExternalStoreRuntime`.
37
-
38
- ### Recommended Approach: Use ToolUI
39
-
40
- First, reconsider your approach.
41
-
42
- Creating UI components in the `convertMessage` callback is considered an anti-pattern.
43
- The recommended alternative approach is to pass tool-call message parts, and use `makeAssistantToolUI` to map these tool calls to UI components.
44
-
45
- This ensures that the data layer is separate and decoupled from the UI layer.
46
-
47
- #### Example
48
-
49
- Consider the following example, where you are using a UIMessagePart to show a loading indicator.
50
-
51
- ```ts title="bad.ts"
52
- // THIS IS BAD
53
- const convertMessage = (message: MyMessage): ThreadMessageLike => {
54
- if (message.isLoading) {
55
- return { content: [{ type: "ui", display:< MyLoader /> }] };
56
- }
57
- // ...
58
- };
59
- ```
60
-
61
- ```ts title="good.ts"
62
- const convertMessage = (message: MyMessage): ThreadMessageLike => {
63
- if (message.isLoading) {
64
- return { content: [] };
65
- }
66
- // ...
67
- };
68
-
69
- // use the empty message part to show the loading indicator
70
- <Thread assistantMessage={{ components: { Empty: MyLoader } }} />;
71
- ```
72
-
73
- (if you are using unstyled primitives, update MyThread.tsx, and pass the component to MessagePrimitive.Parts)
74
-
75
- #### Example 2
76
-
77
- Consider the following example, where you are displaying a custom chart based on data received from an external source.
78
-
79
- ```ts title="bad.ts"
80
- // THIS IS BAD
81
- const convertMessage = (message: MyMessage): ThreadMessageLike => {
82
- return { content: [{ type: "ui", display: <MyChart data={message.chartData} /> }] };
83
- };
84
- ```
85
-
86
- ```ts title="good.ts"
87
- const convertMessage = (message: MyMessage): ThreadMessageLike => {
88
- return {
89
- content: [
90
- {
91
- type: "tool-call",
92
- toolName: "chart",
93
- args: message.chartData,
94
- },
95
- ],
96
- };
97
- };
98
-
99
- const ChartToolUI = makeAssistantToolUI({
100
- toolName: "chart",
101
- render: ({ args }) => <MyChart data={args} />,
102
- });
103
-
104
- // use tool UI to display the chart
105
- <Thread tools={[ChartToolUI]} />;
106
- ```
107
-
108
- (if you are using unstyled primitives, render the `<ChartToolUI />` component anywhere inside your AssistantRuntimeProvider)
109
-
110
- ### Fallback Approach: Override MessagePartText
111
-
112
- However, sometimes you receive UI components from an external source.
113
-
114
- The example below assumes that your custom `MyMessage` type has a `display` field.
115
-
116
- First, we define a dummy `UI_PLACEHOLDER` message part, which we will replace with the UI component later:
117
-
118
- ```ts
119
- const UI_PLACEHOLDER = Object.freeze({
120
- type: "text",
121
- text: "UI content placeholder",
122
- });
123
- const convertMessage = (message: MyMessage): ThreadMessageLike => ({
124
- content: [
125
- // other message parts,
126
- UI_PLACEHOLDER,
127
- ],
128
- });
129
- ```
130
-
131
- Then, we define a custom `TextMessagePartComponent`:
132
-
133
- ```tsx
134
- const MyText: TextMessagePartComponent = () => {
135
- const isUIPlaceholder = useMessagePart((p) => p === UI_PLACEHOLDER);
136
-
137
- // this assumes that you have a `display` field on your original message objects before conversion.
138
- const ui = useMessage((m) =>
139
- isUIPlaceholder ? getExternalStoreMessage(m).display : undefined,
140
- );
141
- if (ui) {
142
- return ui;
143
- }
144
-
145
- return <MarkdownText />; // your default text component
146
- };
147
- ```
148
-
149
- We pass this component to our Thread:
150
-
151
- ```tsx
152
- <Thread
153
- assistantMessage={{ components: { Text: MyText } }}
154
- userMessage={{ components: { Text: MyText } }}
155
- />
156
- ```
157
-
158
- (if you are using unstyled primitives, update MyThread.tsx, and pass the component to MessagePrimitive.Parts)
159
-
160
- Now, the `UI_PLACEHOLDER` message part is replaced with the UI component we defined earlier.
@@ -1,75 +0,0 @@
1
- ---
2
- title: Migration to v0.9
3
- ---
4
-
5
- ## Edge Runtime moved to @assistant-ui/react-edge
6
-
7
- The edge runtime, as well as the `CoreMessage` type, moved to `@assistant-ui/react-edge`.
8
-
9
- The following components and types have been moved to `@assistant-ui/react-edge`:
10
-
11
- - Edge Runtime
12
-
13
- - `useEdgeRuntime`
14
- - `EdgeRuntimeOptions`
15
- - `EdgeModelAdapter`
16
- - `EdgeChatAdapter`
17
- - `EdgeRuntimeRequestOptions`
18
- - `createEdgeRuntimeAPI`
19
- - `getEdgeRuntimeResponse`
20
-
21
- - Core Types
22
- - `CoreMessage`
23
- - `CoreUserMessage`
24
- - `CoreAssistantMessage`
25
- - `CoreSystemMessage`
26
- - `CoreUserMessagePart`
27
- - `CoreAssistantMessagePart`
28
- - `CoreToolCallMessagePart`
29
- - Core message converters
30
- - `fromCoreMessages`
31
- - `fromCoreMessage`
32
- - `toCoreMessages`
33
- - `toCoreMessage`
34
-
35
- To migrate, use the migration codemod:
36
-
37
- ```sh
38
- # IMPORTANT: make sure to commit all changes to git / creating a backup before running the codemod
39
- npx assistant-ui upgrade
40
- ```
41
-
42
- ## Language Model converters and useDangerousInBrowserRuntime moved to @assistant-ui/react-ai-sdk
43
-
44
- The following methods have been moved to `@assistant-ui/react-ai-sdk`:
45
-
46
- - Language Model converters
47
- - `toLanguageModelMessages`
48
- - `toLanguageModelTools`
49
- - `fromLanguageModelMessages`
50
- - `fromLanguageModelTools`
51
- - Dangerous in Browser Runtime
52
- - `useDangerousInBrowserRuntime`
53
-
54
- To migrate, use the migration codemod:
55
-
56
- ```sh
57
- # IMPORTANT: make sure to commit all changes to git / creating a backup before running the codemod
58
- npx assistant-ui upgrade
59
- ```
60
-
61
- ## LangGraph `unstable_allowImageAttachments` removed
62
-
63
- The `unstable_allowImageAttachments` option has been removed. Use the `adapters` option instead.
64
-
65
- ```ts
66
- useLangGraphRuntime({
67
- adapters: {
68
- attachments: new SimpleImageAttachmentAdapter(),
69
- },
70
- });
71
- ```
72
-
73
- ## Markdown `components.by_language` removed
74
-
75
- The `components.by_language` option has been removed. Use the `componentsByLanguage` option instead.
@@ -1,197 +0,0 @@
1
- ---
2
- title: Thread
3
- ---
4
-
5
- A conversation between a user and an assistant.
6
-
7
- import { ParametersTable } from "@/components/docs";
8
-
9
- ## Anatomy
10
-
11
- ```tsx
12
- import { ThreadPrimitive } from "@assistant-ui/react";
13
-
14
- const Thread = () => (
15
- <ThreadPrimitive.Root>
16
- <ThreadPrimitive.Viewport>
17
- <ThreadPrimitive.Empty>...</ThreadPrimitive.Empty>
18
- <ThreadPrimitive.Messages components={...} />
19
- </ThreadPrimitive.Viewport>
20
- <Composer />
21
- </ThreadPrimitive.Root>
22
- );
23
- ```
24
-
25
- ## API Reference
26
-
27
- ### Root
28
-
29
- Contains all parts of the thread.
30
-
31
- This primitive renders a `<div>` element unless `asChild` is set.
32
-
33
- <ParametersTable
34
- type="ThreadPrimitiveRootProps"
35
- parameters={[
36
- {
37
- name: "asChild",
38
- },
39
- ]}
40
- />
41
-
42
- ### Viewport
43
-
44
- The scrollable area containing all messages. Anchors scroll to the bottom as new messages are added.
45
-
46
- This primitive renders a `<div>` element unless `asChild` is set.
47
-
48
- <ParametersTable
49
- type="ThreadPrimitiveViewportProps"
50
- parameters={[
51
- {
52
- name: "asChild",
53
- },
54
- {
55
- name: "autoScroll",
56
- type: "boolean",
57
- default: "true",
58
- description:
59
- "Whether to automatically scroll to the bottom of the viewport when new messages are added while the viewport is was previously scrolled to the bottom.",
60
- },
61
- ]}
62
- />
63
-
64
- ### Messages
65
-
66
- Renders all messages. This primitive renders a separate component for each message.
67
-
68
- <ParametersTable
69
- type="ThreadPrimitiveMessagesProps"
70
- parameters={[
71
- {
72
- name: "components",
73
- type: "MessageComponents",
74
- description: "The component to render for each message.",
75
- children: [
76
- {
77
- type: "MessageComponents",
78
- parameters: [
79
- {
80
- name: "Message",
81
- type: "ComponentType",
82
- description: "The component to render for each message.",
83
- },
84
- {
85
- name: "UserMessage",
86
- type: "ComponentType",
87
- description: "The component to render for user messages.",
88
- },
89
- {
90
- name: "EditComposer",
91
- type: "ComponentType",
92
- description:
93
- "The component to render for user messages that are being edited.",
94
- },
95
- {
96
- name: "AssistantMessage",
97
- type: "ComponentType",
98
- description: "The component to render for assistant messages.",
99
- },
100
- ],
101
- },
102
- ],
103
- },
104
- ]}
105
- />
106
-
107
- ### Empty
108
-
109
- Renders children only when there are no messages.
110
-
111
- ### ScrollToBottom
112
-
113
- A button to scroll the viewport to the bottom. Disabled when the viewport is already at bottom.
114
-
115
- This primitive renders a `<button>` element unless `asChild` is set.
116
-
117
- <ParametersTable
118
- type="ThreadPrimitiveScrollToBottomProps"
119
- parameters={[
120
- {
121
- name: "asChild",
122
- },
123
- ]}
124
- />
125
-
126
- ### `ThreadPrimitive.Suggestion`
127
-
128
- Shows a suggestion to the user. When the user clicks on the suggestion, the composer's value is set to the suggestion's prompt.
129
-
130
- This primitive renders a `<button>` element unless `asChild` is set.
131
-
132
- ```tsx
133
- import { ThreadPrimitive } from "@assistant-ui/react";
134
-
135
- const Suggestion = () => {
136
- return (
137
- <ThreadPrimitive.Suggestion
138
- prompt="I need help with product search"
139
- method="replace"
140
- autoSend
141
- />
142
- );
143
- };
144
- ```
145
-
146
- <ParametersTable
147
- type="ThreadPrimitiveSuggestionProps"
148
- parameters={[
149
- {
150
- name: "prompt",
151
- type: "string",
152
- description: "The suggestion's prompt.",
153
- },
154
- {
155
- name: "method",
156
- type: "'replace'",
157
- description:
158
- "How does the suggestion interact with the composer's existing value.",
159
- },
160
- {
161
- name: "autoSend",
162
- type: "boolean",
163
- description:
164
- "Whether to automatically send the suggestion when the user clicks on it.",
165
- default: "false",
166
- },
167
- ]}
168
- />
169
-
170
- ### If
171
-
172
- Renders children if a condition is met.
173
-
174
- <ParametersTable
175
- type="ThreadPrimitiveIfProps"
176
- parameters={[
177
- {
178
- name: "empty",
179
- type: "boolean | undefined",
180
- description: "Render children if the thread is empty.",
181
- },
182
- {
183
- name: "running",
184
- type: "boolean | undefined",
185
- description: "Render children if the thread is running.",
186
- },
187
- ]}
188
- />
189
-
190
- ```tsx
191
- <Thread.If empty>
192
- {/* equivalent to <Thread.Empty> */}
193
- </Thread.If>
194
- <Thread.If empty={false}>
195
- {/* rendered if thread is not empty */}
196
- </Thread.If>
197
- ```