@assistant-ui/mcp-docs-server 0.1.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 (109) hide show
  1. package/.docs/organized/code-examples/local-ollama.md +1135 -0
  2. package/.docs/organized/code-examples/search-agent-for-e-commerce.md +1721 -0
  3. package/.docs/organized/code-examples/with-ai-sdk.md +1081 -0
  4. package/.docs/organized/code-examples/with-cloud.md +1164 -0
  5. package/.docs/organized/code-examples/with-external-store.md +1064 -0
  6. package/.docs/organized/code-examples/with-ffmpeg.md +1305 -0
  7. package/.docs/organized/code-examples/with-langgraph.md +1819 -0
  8. package/.docs/organized/code-examples/with-openai-assistants.md +1175 -0
  9. package/.docs/organized/code-examples/with-react-hook-form.md +1727 -0
  10. package/.docs/organized/code-examples/with-vercel-ai-rsc.md +1157 -0
  11. package/.docs/raw/blog/2024-07-29-hello/index.mdx +65 -0
  12. package/.docs/raw/blog/2024-09-11/index.mdx +10 -0
  13. package/.docs/raw/blog/2024-12-15/index.mdx +10 -0
  14. package/.docs/raw/blog/2025-01-31-changelog/index.mdx +129 -0
  15. package/.docs/raw/docs/about-assistantui.mdx +44 -0
  16. package/.docs/raw/docs/api-reference/context-providers/AssistantRuntimeProvider.mdx +30 -0
  17. package/.docs/raw/docs/api-reference/context-providers/TextContentPartProvider.mdx +26 -0
  18. package/.docs/raw/docs/api-reference/integrations/react-hook-form.mdx +103 -0
  19. package/.docs/raw/docs/api-reference/integrations/vercel-ai-sdk.mdx +145 -0
  20. package/.docs/raw/docs/api-reference/overview.mdx +583 -0
  21. package/.docs/raw/docs/api-reference/primitives/ActionBar.mdx +264 -0
  22. package/.docs/raw/docs/api-reference/primitives/AssistantModal.mdx +129 -0
  23. package/.docs/raw/docs/api-reference/primitives/Attachment.mdx +96 -0
  24. package/.docs/raw/docs/api-reference/primitives/BranchPicker.mdx +87 -0
  25. package/.docs/raw/docs/api-reference/primitives/Composer.mdx +204 -0
  26. package/.docs/raw/docs/api-reference/primitives/ContentPart.mdx +173 -0
  27. package/.docs/raw/docs/api-reference/primitives/Error.mdx +70 -0
  28. package/.docs/raw/docs/api-reference/primitives/Message.mdx +181 -0
  29. package/.docs/raw/docs/api-reference/primitives/Thread.mdx +197 -0
  30. package/.docs/raw/docs/api-reference/primitives/composition.mdx +21 -0
  31. package/.docs/raw/docs/api-reference/runtimes/AssistantRuntime.mdx +33 -0
  32. package/.docs/raw/docs/api-reference/runtimes/AttachmentRuntime.mdx +46 -0
  33. package/.docs/raw/docs/api-reference/runtimes/ComposerRuntime.mdx +69 -0
  34. package/.docs/raw/docs/api-reference/runtimes/ContentPartRuntime.mdx +22 -0
  35. package/.docs/raw/docs/api-reference/runtimes/MessageRuntime.mdx +49 -0
  36. package/.docs/raw/docs/api-reference/runtimes/ThreadListItemRuntime.mdx +32 -0
  37. package/.docs/raw/docs/api-reference/runtimes/ThreadListRuntime.mdx +31 -0
  38. package/.docs/raw/docs/api-reference/runtimes/ThreadRuntime.mdx +48 -0
  39. package/.docs/raw/docs/architecture.mdx +92 -0
  40. package/.docs/raw/docs/cloud/authorization.mdx +152 -0
  41. package/.docs/raw/docs/cloud/overview.mdx +55 -0
  42. package/.docs/raw/docs/cloud/persistence/ai-sdk.mdx +54 -0
  43. package/.docs/raw/docs/cloud/persistence/langgraph.mdx +123 -0
  44. package/.docs/raw/docs/concepts/architecture.mdx +19 -0
  45. package/.docs/raw/docs/concepts/runtime-layer.mdx +163 -0
  46. package/.docs/raw/docs/concepts/why.mdx +9 -0
  47. package/.docs/raw/docs/copilots/make-assistant-readable.mdx +71 -0
  48. package/.docs/raw/docs/copilots/make-assistant-tool-ui.mdx +76 -0
  49. package/.docs/raw/docs/copilots/make-assistant-tool.mdx +117 -0
  50. package/.docs/raw/docs/copilots/model-context.mdx +135 -0
  51. package/.docs/raw/docs/copilots/motivation.mdx +191 -0
  52. package/.docs/raw/docs/copilots/use-assistant-instructions.mdx +62 -0
  53. package/.docs/raw/docs/getting-started.mdx +1133 -0
  54. package/.docs/raw/docs/guides/Attachments.mdx +640 -0
  55. package/.docs/raw/docs/guides/Branching.mdx +59 -0
  56. package/.docs/raw/docs/guides/Editing.mdx +56 -0
  57. package/.docs/raw/docs/guides/Speech.mdx +43 -0
  58. package/.docs/raw/docs/guides/ToolUI.mdx +663 -0
  59. package/.docs/raw/docs/guides/Tools.mdx +496 -0
  60. package/.docs/raw/docs/index.mdx +7 -0
  61. package/.docs/raw/docs/legacy/styled/AssistantModal.mdx +85 -0
  62. package/.docs/raw/docs/legacy/styled/Decomposition.mdx +633 -0
  63. package/.docs/raw/docs/legacy/styled/Markdown.mdx +86 -0
  64. package/.docs/raw/docs/legacy/styled/Scrollbar.mdx +71 -0
  65. package/.docs/raw/docs/legacy/styled/Thread.mdx +84 -0
  66. package/.docs/raw/docs/legacy/styled/ThreadWidth.mdx +21 -0
  67. package/.docs/raw/docs/mcp-docs-server.mdx +324 -0
  68. package/.docs/raw/docs/migrations/deprecation-policy.mdx +41 -0
  69. package/.docs/raw/docs/migrations/v0-7.mdx +188 -0
  70. package/.docs/raw/docs/migrations/v0-8.mdx +160 -0
  71. package/.docs/raw/docs/migrations/v0-9.mdx +75 -0
  72. package/.docs/raw/docs/react-compatibility.mdx +208 -0
  73. package/.docs/raw/docs/runtimes/ai-sdk/rsc.mdx +226 -0
  74. package/.docs/raw/docs/runtimes/ai-sdk/use-assistant-hook.mdx +195 -0
  75. package/.docs/raw/docs/runtimes/ai-sdk/use-chat-hook.mdx +138 -0
  76. package/.docs/raw/docs/runtimes/ai-sdk/use-chat.mdx +136 -0
  77. package/.docs/raw/docs/runtimes/custom/external-store.mdx +1624 -0
  78. package/.docs/raw/docs/runtimes/custom/local.mdx +1185 -0
  79. package/.docs/raw/docs/runtimes/helicone.mdx +60 -0
  80. package/.docs/raw/docs/runtimes/langgraph/index.mdx +320 -0
  81. package/.docs/raw/docs/runtimes/langgraph/tutorial/index.mdx +11 -0
  82. package/.docs/raw/docs/runtimes/langgraph/tutorial/introduction.mdx +28 -0
  83. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-1.mdx +120 -0
  84. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +336 -0
  85. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +385 -0
  86. package/.docs/raw/docs/runtimes/langserve.mdx +126 -0
  87. package/.docs/raw/docs/runtimes/mastra/full-stack-integration.mdx +218 -0
  88. package/.docs/raw/docs/runtimes/mastra/overview.mdx +17 -0
  89. package/.docs/raw/docs/runtimes/mastra/separate-server-integration.mdx +196 -0
  90. package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +222 -0
  91. package/.docs/raw/docs/ui/AssistantModal.mdx +46 -0
  92. package/.docs/raw/docs/ui/AssistantSidebar.mdx +42 -0
  93. package/.docs/raw/docs/ui/Attachment.mdx +82 -0
  94. package/.docs/raw/docs/ui/Markdown.mdx +72 -0
  95. package/.docs/raw/docs/ui/Mermaid.mdx +79 -0
  96. package/.docs/raw/docs/ui/Scrollbar.mdx +59 -0
  97. package/.docs/raw/docs/ui/SyntaxHighlighting.mdx +253 -0
  98. package/.docs/raw/docs/ui/Thread.mdx +47 -0
  99. package/.docs/raw/docs/ui/ThreadList.mdx +49 -0
  100. package/.docs/raw/docs/ui/ToolFallback.mdx +64 -0
  101. package/.docs/raw/docs/ui/primitives/Thread.mdx +197 -0
  102. package/LICENSE +21 -0
  103. package/README.md +128 -0
  104. package/dist/chunk-C7O7EFKU.js +38 -0
  105. package/dist/chunk-CZCDQ3YH.js +420 -0
  106. package/dist/index.js +1 -0
  107. package/dist/prepare-docs/prepare.js +199 -0
  108. package/dist/stdio.js +8 -0
  109. package/package.json +43 -0
@@ -0,0 +1,336 @@
1
+ ---
2
+ title: "Part 2: Generative UI"
3
+ ---
4
+
5
+ In the previous step, we set up the frontend to connect to a LangGraph Cloud endpoint.
6
+
7
+ In this step, we will set up a component to display stock ticker information.
8
+
9
+ import Image from "next/image";
10
+ import price from "./images/acme-price.png";
11
+
12
+ <Image
13
+ src={price}
14
+ alt="Price snapshot"
15
+ width={600}
16
+ className="mx-auto rounded-lg border shadow"
17
+ />
18
+
19
+ For reference, this the corresponding code in the backend:
20
+
21
+ https://github.com/assistant-ui/assistant-ui-stockbroker/blob/main/backend/src/tools.ts#L193C1-L216C3
22
+
23
+ ```ts title="assistant-ui-stockbroker/backend/tools/PriceSnapshotTool.ts"
24
+ export const priceSnapshotTool = tool(
25
+ async (input) => {
26
+ const data = await callFinancialDatasetAPI<SnapshotResponse>({
27
+ endpoint: "/prices/snapshot",
28
+ params: {
29
+ ticker: input.ticker,
30
+ },
31
+ });
32
+ return JSON.stringify(data, null);
33
+ },
34
+ {
35
+ name: "price_snapshot",
36
+ description:
37
+ "Retrieves the current stock price and related market data for a given company.",
38
+ schema: z.object({
39
+ ticker: z.string().describe("The ticker of the company. Example: 'AAPL'"),
40
+ }),
41
+ },
42
+ );
43
+ ```
44
+
45
+ ## PriceSnapshotTool
46
+
47
+ We create a new file under `/components/tools/price-snapshot/PriceSnapshotTool.tsx` to define the tool.
48
+
49
+ First, we define the tool arguments and result types:
50
+
51
+ ```ts title="@/components/tools/price-snapshot/PriceSnapshotTool.tsx"
52
+ type PriceSnapshotToolArgs = {
53
+ ticker: string;
54
+ };
55
+
56
+ type PriceSnapshotToolResult = {
57
+ snapshot: {
58
+ price: number;
59
+ day_change: number;
60
+ day_change_percent: number;
61
+ time: string;
62
+ };
63
+ };
64
+ ```
65
+
66
+ Then, we use `makeAssistantToolUI` to define the tool UI:
67
+
68
+ ```tsx title="@/components/tools/price-snapshot/PriceSnapshotTool.tsx"
69
+ "use client";
70
+
71
+ import { makeAssistantToolUI } from "@assistant-ui/react";
72
+
73
+ export const PriceSnapshotTool = makeAssistantToolUI<
74
+ PriceSnapshotToolArgs,
75
+ string
76
+ >({
77
+ toolName: "price_snapshot",
78
+ render: function PriceSnapshotUI({ args, result }) {
79
+ return (
80
+ <div className="mb-4 flex flex-col items-center">
81
+ <pre className="whitespace-pre-wrap break-all text-center">
82
+ price_snapshot({JSON.stringify(args)})
83
+ </pre>
84
+ </div>
85
+ );
86
+ },
87
+ });
88
+ ```
89
+
90
+ This simply displays the tool name and arguments passed to it, but not the result.
91
+
92
+ ### Bind tool UI
93
+
94
+ ```tsx title="@/app/page.tsx" {1,8}
95
+ import { PriceSnapshotTool } from "@/components/tools/price-snapshot/PriceSnapshotTool";
96
+
97
+ export default function Home() {
98
+ return (
99
+ <div className="flex h-full flex-col">
100
+ <Thread
101
+ ...
102
+ tools={[PriceSnapshotTool]}
103
+ />
104
+ </div>
105
+ );
106
+ }
107
+ ```
108
+
109
+ ### Try it out!
110
+
111
+ Ask the assistant for the current stock price of Tesla. You should see the following text appear:
112
+
113
+ ```
114
+ price_snapshot({ticker: "TSLA"})
115
+ ```
116
+
117
+ Next, we will visualize the function's result.
118
+
119
+ ## Visualizing tool results
120
+
121
+ ### Install dependencies
122
+
123
+ The tool result component relies on shadcn/ui's `Card` component. We will install it as a dependency.
124
+
125
+ ```sh
126
+ npx shadcn@latest add card
127
+ ```
128
+
129
+ You will be prompted to setup a `components.json` file, after this step, a `card` UI component will be installed in your project.
130
+
131
+ ### Add `PriceSnapshot`
132
+
133
+ We create a new file under `/components/tools/price-snapshot/price-snapshot.tsx` to define the new tool result UI.
134
+
135
+ ```tsx title="@/components/tools/price-snapshot/price-snapshot.tsx"
136
+ "use client";
137
+
138
+ import { ArrowDownIcon, ArrowUpIcon } from "lucide-react";
139
+
140
+ import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
141
+
142
+ type PriceSnapshotToolArgs = {
143
+ ticker: string;
144
+ };
145
+
146
+ type PriceSnapshotToolResult = {
147
+ price: number;
148
+ day_change: number;
149
+ day_change_percent: number;
150
+ time: string;
151
+ };
152
+
153
+ export function PriceSnapshot({
154
+ ticker,
155
+ price,
156
+ day_change,
157
+ day_change_percent,
158
+ time,
159
+ }: PriceSnapshotToolArgs & PriceSnapshotToolResult) {
160
+ const isPositiveChange = day_change >= 0;
161
+ const changeColor = isPositiveChange ? "text-green-600" : "text-red-600";
162
+ const ArrowIcon = isPositiveChange ? ArrowUpIcon : ArrowDownIcon;
163
+
164
+ return (
165
+ <Card className="mx-auto w-full max-w-md">
166
+ <CardHeader>
167
+ <CardTitle className="text-2xl font-bold">{ticker}</CardTitle>
168
+ </CardHeader>
169
+ <CardContent>
170
+ <div className="grid grid-cols-2 gap-4">
171
+ <div className="col-span-2">
172
+ <p className="text-3xl font-semibold">${price?.toFixed(2)}</p>
173
+ </div>
174
+ <div>
175
+ <p className="text-muted-foreground text-sm">Day Change</p>
176
+ <p
177
+ className={`flex items-center text-lg font-medium ${changeColor}`}
178
+ >
179
+ <ArrowIcon className="mr-1 h-4 w-4" />$
180
+ {Math.abs(day_change)?.toFixed(2)} (
181
+ {Math.abs(day_change_percent)?.toFixed(2)}%)
182
+ </p>
183
+ </div>
184
+ <div>
185
+ <p className="text-muted-foreground text-sm">Last Updated</p>
186
+ <p className="text-lg font-medium">
187
+ {new Date(time).toLocaleTimeString()}
188
+ </p>
189
+ </div>
190
+ </div>
191
+ </CardContent>
192
+ </Card>
193
+ );
194
+ }
195
+ ```
196
+
197
+ ### Update `PriceSnapshotTool`
198
+
199
+ We will import the new `<PriceSnapshot />` component and use it in the `render` function whenever a tool result is available.
200
+
201
+ ```tsx title="@/components/tools/price-snapshot/PriceSnapshotTool.tsx" {3,25-30,37-42}
202
+ "use client";
203
+
204
+ import { PriceSnapshot } from "./price-snapshot";
205
+ import { makeAssistantToolUI } from "@assistant-ui/react";
206
+
207
+ type PriceSnapshotToolArgs = {
208
+ ticker: string;
209
+ };
210
+
211
+ type PriceSnapshotToolResult = {
212
+ snapshot: {
213
+ price: number;
214
+ day_change: number;
215
+ day_change_percent: number;
216
+ time: string;
217
+ };
218
+ };
219
+
220
+ export const PriceSnapshotTool = makeAssistantToolUI<
221
+ PriceSnapshotToolArgs,
222
+ string
223
+ >({
224
+ toolName: "price_snapshot",
225
+ render: function PriceSnapshotUI({ args, result }) {
226
+ let resultObj: PriceSnapshotToolResult | { error: string };
227
+ try {
228
+ resultObj = result ? JSON.parse(result) : {};
229
+ } catch (e) {
230
+ resultObj = { error: result! };
231
+ }
232
+
233
+ return (
234
+ <div className="mb-4 flex flex-col items-center gap-2">
235
+ <pre className="whitespace-pre-wrap break-all text-center">
236
+ price_snapshot({JSON.stringify(args)})
237
+ </pre>
238
+ {"snapshot" in resultObj && (
239
+ <PriceSnapshot ticker={args.ticker} {...resultObj.snapshot} />
240
+ )}
241
+ {"error" in resultObj && (
242
+ <p className="text-red-500">{resultObj.error}</p>
243
+ )}
244
+ </div>
245
+ );
246
+ },
247
+ });
248
+ ```
249
+
250
+ ### Try it out!
251
+
252
+ Ask the assistant for the current stock price of Tesla. You should see the tool result appear:
253
+
254
+ import price2 from "./images/tsla-price.png";
255
+
256
+ <Image
257
+ src={price2}
258
+ alt="Price snapshot result"
259
+ width={600}
260
+ className="mx-auto rounded-lg border shadow"
261
+ />
262
+
263
+ ## Fallback tool UI
264
+
265
+ Instead of defining a custom tool UI for every tool, we can also define a fallback UI for all tools that are not explicitly defined.
266
+
267
+ This requires shadcn/ui's `Button` component. We will install it as a dependency.
268
+
269
+ ```sh
270
+ npx shadcn@latest add button
271
+ ```
272
+
273
+ Then create a new file under `/components/tools/ToolFallback.tsx` to define the fallback UI.
274
+
275
+ ```tsx title="@/components/tools/ToolFallback.tsx"
276
+ import { ToolCallContentPartComponent } from "@assistant-ui/react";
277
+ import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react";
278
+ import { useState } from "react";
279
+ import { Button } from "../ui/button";
280
+
281
+ export const ToolFallback: ToolCallContentPartComponent = ({
282
+ toolName,
283
+ argsText,
284
+ result,
285
+ }) => {
286
+ const [isCollapsed, setIsCollapsed] = useState(true);
287
+ return (
288
+ <div className="mb-4 flex w-full flex-col gap-3 rounded-lg border py-3">
289
+ <div className="flex items-center gap-2 px-4">
290
+ <CheckIcon className="size-4" />
291
+ <p className="">
292
+ Used tool: <b>{toolName}</b>
293
+ </p>
294
+ <div className="flex-grow" />
295
+ <Button onClick={() => setIsCollapsed(!isCollapsed)}>
296
+ {isCollapsed ? <ChevronUpIcon /> : <ChevronDownIcon />}
297
+ </Button>
298
+ </div>
299
+ {!isCollapsed && (
300
+ <div className="flex flex-col gap-2 border-t pt-2">
301
+ <div className="px-4">
302
+ <pre className="whitespace-pre-wrap">{argsText}</pre>
303
+ </div>
304
+ {result !== undefined && (
305
+ <div className="border-t border-dashed px-4 pt-2">
306
+ <p className="font-semibold">Result:</p>
307
+ <pre className="whitespace-pre-wrap">
308
+ {typeof result === "string"
309
+ ? result
310
+ : JSON.stringify(result, null, 2)}
311
+ </pre>
312
+ </div>
313
+ )}
314
+ </div>
315
+ )}
316
+ </div>
317
+ );
318
+ };
319
+ ```
320
+
321
+ ### Bind fallback UI
322
+
323
+ ```tsx title="@/app/page.tsx" {1,8}
324
+ import { ToolFallback } from "@/components/tools/ToolFallback";
325
+
326
+ export default function Home() {
327
+ return (
328
+ <div className="flex h-full flex-col">
329
+ <Thread
330
+ ...
331
+ assistantMessage={{ components: { Text: MarkdownText, ToolFallback } }}
332
+ />
333
+ </div>
334
+ );
335
+ }
336
+ ```