@assistant-ui/mcp-docs-server 0.1.17 → 0.1.18
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.
- package/.docs/organized/code-examples/with-ag-ui.md +146 -152
- package/.docs/organized/code-examples/with-ai-sdk-v5.md +96 -101
- package/.docs/organized/code-examples/with-assistant-transport.md +132 -220
- package/.docs/organized/code-examples/with-cloud.md +124 -131
- package/.docs/organized/code-examples/with-custom-thread-list.md +26 -46
- package/.docs/organized/code-examples/with-external-store.md +146 -151
- package/.docs/organized/code-examples/with-ffmpeg.md +129 -139
- package/.docs/organized/code-examples/with-langgraph.md +231 -225
- package/.docs/organized/code-examples/with-parent-id-grouping.md +146 -151
- package/.docs/organized/code-examples/with-react-hook-form.md +146 -152
- package/.docs/organized/code-examples/{store-example.md → with-store.md} +16 -20
- package/.docs/organized/code-examples/with-tanstack.md +23 -41
- package/.docs/raw/docs/runtimes/custom/custom-thread-list.mdx +36 -0
- package/.docs/raw/docs/runtimes/custom/local.mdx +31 -8
- package/.docs/raw/docs/ui/Scrollbar.mdx +0 -6
- package/dist/constants.d.ts +10 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +14 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -1
- package/dist/index.js.map +1 -0
- package/dist/prepare-docs/code-examples.d.ts +2 -0
- package/dist/prepare-docs/code-examples.d.ts.map +1 -0
- package/dist/prepare-docs/code-examples.js +129 -0
- package/dist/prepare-docs/code-examples.js.map +1 -0
- package/dist/prepare-docs/copy-raw.d.ts +2 -0
- package/dist/prepare-docs/copy-raw.d.ts.map +1 -0
- package/dist/prepare-docs/copy-raw.js +50 -0
- package/dist/prepare-docs/copy-raw.js.map +1 -0
- package/dist/prepare-docs/prepare.d.ts +2 -0
- package/dist/prepare-docs/prepare.d.ts.map +1 -0
- package/dist/prepare-docs/prepare.js +18 -195
- package/dist/prepare-docs/prepare.js.map +1 -0
- package/dist/stdio.d.ts +3 -0
- package/dist/stdio.d.ts.map +1 -0
- package/dist/stdio.js +4 -5
- package/dist/stdio.js.map +1 -0
- package/dist/tools/docs.d.ts +23 -0
- package/dist/tools/docs.d.ts.map +1 -0
- package/dist/tools/docs.js +168 -0
- package/dist/tools/docs.js.map +1 -0
- package/dist/tools/examples.d.ts +23 -0
- package/dist/tools/examples.d.ts.map +1 -0
- package/dist/tools/examples.js +95 -0
- package/dist/tools/examples.js.map +1 -0
- package/dist/tools/tests/test-setup.d.ts +4 -0
- package/dist/tools/tests/test-setup.d.ts.map +1 -0
- package/dist/tools/tests/test-setup.js +36 -0
- package/dist/tools/tests/test-setup.js.map +1 -0
- package/dist/utils/logger.d.ts +7 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +20 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/mcp-format.d.ts +7 -0
- package/dist/utils/mcp-format.d.ts.map +1 -0
- package/dist/utils/mcp-format.js +11 -0
- package/dist/utils/mcp-format.js.map +1 -0
- package/dist/utils/mdx.d.ts +9 -0
- package/dist/utils/mdx.d.ts.map +1 -0
- package/dist/utils/mdx.js +27 -0
- package/dist/utils/mdx.js.map +1 -0
- package/dist/utils/paths.d.ts +8 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +84 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/security.d.ts +2 -0
- package/dist/utils/security.d.ts.map +1 -0
- package/dist/utils/security.js +43 -0
- package/dist/utils/security.js.map +1 -0
- package/package.json +37 -19
- package/src/constants.ts +22 -0
- package/src/index.ts +51 -0
- package/src/prepare-docs/code-examples.ts +158 -0
- package/src/prepare-docs/copy-raw.ts +55 -0
- package/src/prepare-docs/prepare.ts +24 -0
- package/src/stdio.ts +7 -0
- package/src/tools/docs.ts +207 -0
- package/src/tools/examples.ts +107 -0
- package/src/tools/tests/docs.test.ts +122 -0
- package/src/tools/tests/examples.test.ts +94 -0
- package/src/tools/tests/integration.test.ts +46 -0
- package/src/tools/tests/json-parsing.test.ts +23 -0
- package/src/tools/tests/mcp-protocol.test.ts +133 -0
- package/src/tools/tests/path-traversal.test.ts +81 -0
- package/src/tools/tests/test-setup.ts +40 -0
- package/src/utils/logger.ts +20 -0
- package/src/utils/mcp-format.ts +12 -0
- package/src/utils/mdx.ts +39 -0
- package/src/utils/paths.ts +114 -0
- package/src/utils/security.ts +52 -0
- package/src/utils/tests/security.test.ts +119 -0
- package/dist/chunk-M2RKUM66.js +0 -38
- package/dist/chunk-NVNFQ5ZO.js +0 -423
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
|
|
23
23
|
```json
|
|
24
24
|
{
|
|
25
|
-
"name": "
|
|
25
|
+
"name": "with-tanstack",
|
|
26
|
+
"version": "0.0.0",
|
|
26
27
|
"private": true,
|
|
27
28
|
"type": "module",
|
|
28
29
|
"scripts": {
|
|
@@ -36,28 +37,28 @@
|
|
|
36
37
|
"@radix-ui/react-slot": "^1.2.4",
|
|
37
38
|
"@radix-ui/react-tooltip": "^1.2.8",
|
|
38
39
|
"@tailwindcss/vite": "^4.1.18",
|
|
39
|
-
"@tanstack/react-router": "^1.141.
|
|
40
|
-
"@tanstack/react-start": "^1.
|
|
41
|
-
"@tanstack/router-plugin": "^1.141.1",
|
|
40
|
+
"@tanstack/react-router": "^1.141.8",
|
|
41
|
+
"@tanstack/react-start": "^1.142.1",
|
|
42
42
|
"class-variance-authority": "^0.7.1",
|
|
43
43
|
"clsx": "^2.1.1",
|
|
44
|
-
"lucide-react": "^0.
|
|
45
|
-
"nitro": "
|
|
46
|
-
"openai": "^6.
|
|
47
|
-
"react": "
|
|
48
|
-
"react-dom": "
|
|
44
|
+
"lucide-react": "^0.562.0",
|
|
45
|
+
"nitro": "^3.0.1-alpha.1",
|
|
46
|
+
"openai": "^6.15.0",
|
|
47
|
+
"react": "19.2.3",
|
|
48
|
+
"react-dom": "19.2.3",
|
|
49
49
|
"remark-gfm": "^4.0.1",
|
|
50
50
|
"tailwind-merge": "^3.4.0",
|
|
51
51
|
"tailwindcss": "^4.1.18",
|
|
52
|
-
"vite-tsconfig-paths": "^
|
|
52
|
+
"vite-tsconfig-paths": "^6.0.3"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@
|
|
55
|
+
"@assistant-ui/x-buildutils": "workspace:*",
|
|
56
|
+
"@types/node": "^25.0.3",
|
|
56
57
|
"@types/react": "^19.2.7",
|
|
57
58
|
"@types/react-dom": "^19.2.3",
|
|
58
59
|
"@vitejs/plugin-react": "^5.1.2",
|
|
59
60
|
"typescript": "^5.9.3",
|
|
60
|
-
"vite": "^7.
|
|
61
|
+
"vite": "^7.3.0"
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
|
|
@@ -368,7 +369,7 @@ const ThreadScrollToBottom: FC = () => {
|
|
|
368
369
|
<TooltipIconButton
|
|
369
370
|
tooltip="Scroll to bottom"
|
|
370
371
|
variant="outline"
|
|
371
|
-
className="aui-thread-scroll-to-bottom -top-12
|
|
372
|
+
className="aui-thread-scroll-to-bottom absolute -top-12 z-10 self-center rounded-full p-4 disabled:invisible dark:bg-background dark:hover:bg-accent"
|
|
372
373
|
>
|
|
373
374
|
<ArrowDownIcon />
|
|
374
375
|
</TooltipIconButton>
|
|
@@ -541,7 +542,7 @@ const AssistantActionBar: FC = () => {
|
|
|
541
542
|
hideWhenRunning
|
|
542
543
|
autohide="not-last"
|
|
543
544
|
autohideFloat="single-branch"
|
|
544
|
-
className="aui-assistant-action-bar-root
|
|
545
|
+
className="aui-assistant-action-bar-root col-start-3 row-start-2 -ml-1 flex gap-1 text-muted-foreground data-floating:absolute data-floating:rounded-md data-floating:border data-floating:bg-background data-floating:p-1 data-floating:shadow-sm"
|
|
545
546
|
>
|
|
546
547
|
<ActionBarPrimitive.Copy asChild>
|
|
547
548
|
<TooltipIconButton tooltip="Copy">
|
|
@@ -572,12 +573,12 @@ const UserMessage: FC = () => {
|
|
|
572
573
|
<div className="aui-user-message-content wrap-break-word rounded-3xl bg-muted px-5 py-2.5 text-foreground">
|
|
573
574
|
<MessagePrimitive.Parts />
|
|
574
575
|
</div>
|
|
575
|
-
<div className="aui-user-action-bar-wrapper -translate-x-full -translate-y-1/2
|
|
576
|
+
<div className="aui-user-action-bar-wrapper absolute top-1/2 left-0 -translate-x-full -translate-y-1/2 pr-2">
|
|
576
577
|
<UserActionBar />
|
|
577
578
|
</div>
|
|
578
579
|
</div>
|
|
579
580
|
|
|
580
|
-
<BranchPicker className="aui-user-branch-picker
|
|
581
|
+
<BranchPicker className="aui-user-branch-picker col-span-full col-start-1 row-start-3 -mr-1 justify-end" />
|
|
581
582
|
</MessagePrimitive.Root>
|
|
582
583
|
);
|
|
583
584
|
};
|
|
@@ -632,7 +633,7 @@ const BranchPicker: FC<BranchPickerPrimitive.Root.Props> = ({
|
|
|
632
633
|
<BranchPickerPrimitive.Root
|
|
633
634
|
hideWhenSingleBranch
|
|
634
635
|
className={cn(
|
|
635
|
-
"aui-branch-picker-root -
|
|
636
|
+
"aui-branch-picker-root mr-2 -ml-2 inline-flex items-center text-muted-foreground text-xs",
|
|
636
637
|
className,
|
|
637
638
|
)}
|
|
638
639
|
{...rest}
|
|
@@ -1516,32 +1517,13 @@ export const chatStream = createServerFn({ method: "POST" })
|
|
|
1516
1517
|
|
|
1517
1518
|
```json
|
|
1518
1519
|
{
|
|
1519
|
-
"
|
|
1520
|
+
"extends": "@assistant-ui/x-buildutils/ts/base",
|
|
1520
1521
|
"compilerOptions": {
|
|
1521
|
-
"target": "ES2022",
|
|
1522
|
-
"jsx": "react-jsx",
|
|
1523
|
-
"module": "ESNext",
|
|
1524
|
-
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
1525
1522
|
"types": ["vite/client"],
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
"verbatimModuleSyntax": false,
|
|
1531
|
-
"noEmit": true,
|
|
1532
|
-
|
|
1533
|
-
/* Linting */
|
|
1534
|
-
"skipLibCheck": true,
|
|
1535
|
-
"strict": true,
|
|
1536
|
-
"noUnusedLocals": true,
|
|
1537
|
-
"noUnusedParameters": true,
|
|
1538
|
-
"noFallthroughCasesInSwitch": true,
|
|
1539
|
-
"noUncheckedSideEffectImports": true,
|
|
1540
|
-
"baseUrl": ".",
|
|
1541
|
-
"paths": {
|
|
1542
|
-
"@/*": ["./src/*"]
|
|
1543
|
-
}
|
|
1544
|
-
}
|
|
1523
|
+
"paths": { "@/*": ["./src/*"] }
|
|
1524
|
+
},
|
|
1525
|
+
"include": ["**/*.ts", "**/*.tsx"],
|
|
1526
|
+
"exclude": ["node_modules"]
|
|
1545
1527
|
}
|
|
1546
1528
|
|
|
1547
1529
|
```
|
|
@@ -217,6 +217,42 @@ When the hook mounts it calls `list()` on your adapter, hydrates existing thread
|
|
|
217
217
|
- `generateTitle()` powers the automatic title button and expects an `AssistantStream`.
|
|
218
218
|
- Provide a `runtimeHook` that always returns a fresh runtime instance per active thread.
|
|
219
219
|
|
|
220
|
+
## Avoiding Race Conditions in History Adapters
|
|
221
|
+
|
|
222
|
+
<Callout type="warn">
|
|
223
|
+
When implementing a custom history adapter, you must await thread initialization before saving messages. Failing to do so can cause the first message to be lost due to a race condition.
|
|
224
|
+
</Callout>
|
|
225
|
+
|
|
226
|
+
If you're building a history adapter that persists messages to your own database, use `api.threadListItem().initialize()` to ensure the thread is fully initialized before saving:
|
|
227
|
+
|
|
228
|
+
```tsx
|
|
229
|
+
import { useAssistantApi } from "@assistant-ui/react";
|
|
230
|
+
|
|
231
|
+
// Inside your unstable_Provider component
|
|
232
|
+
const api = useAssistantApi();
|
|
233
|
+
|
|
234
|
+
const history = useMemo<ThreadHistoryAdapter>(
|
|
235
|
+
() => ({
|
|
236
|
+
async append(message) {
|
|
237
|
+
// Wait for initialization to complete and get the remoteId
|
|
238
|
+
const { remoteId } = await api.threadListItem().initialize();
|
|
239
|
+
|
|
240
|
+
// Now safe to save the message using the remoteId
|
|
241
|
+
await saveMessageToDatabase(remoteId, message);
|
|
242
|
+
},
|
|
243
|
+
// ...
|
|
244
|
+
}),
|
|
245
|
+
[api],
|
|
246
|
+
);
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
The `initialize()` method:
|
|
250
|
+
- Can be called multiple times safely
|
|
251
|
+
- Always waits for the initial `initialize()` call to complete
|
|
252
|
+
- Returns the same `remoteId` on subsequent calls
|
|
253
|
+
|
|
254
|
+
See `AssistantCloudThreadHistoryAdapter` in the source code for a production-ready reference implementation.
|
|
255
|
+
|
|
220
256
|
## Optional Adapters
|
|
221
257
|
|
|
222
258
|
If you need history or attachment support, expose them via `unstable_Provider`. The cloud implementation wraps each thread runtime with `RuntimeAdapterProvider` to inject:
|
|
@@ -415,7 +415,7 @@ For custom thread storage, use `useRemoteThreadListRuntime` with your own adapte
|
|
|
415
415
|
```tsx
|
|
416
416
|
import {
|
|
417
417
|
unstable_useRemoteThreadListRuntime as useRemoteThreadListRuntime,
|
|
418
|
-
|
|
418
|
+
useAssistantApi,
|
|
419
419
|
RuntimeAdapterProvider,
|
|
420
420
|
AssistantRuntimeProvider,
|
|
421
421
|
type unstable_RemoteThreadListAdapter as RemoteThreadListAdapter,
|
|
@@ -487,13 +487,13 @@ export function MyRuntimeProvider({ children }) {
|
|
|
487
487
|
// The Provider component adds thread-specific adapters
|
|
488
488
|
unstable_Provider: ({ children }) => {
|
|
489
489
|
// This runs in the context of each thread
|
|
490
|
-
const
|
|
491
|
-
const remoteId = threadListItem.remoteId;
|
|
490
|
+
const api = useAssistantApi();
|
|
492
491
|
|
|
493
492
|
// Create thread-specific history adapter
|
|
494
493
|
const history = useMemo<ThreadHistoryAdapter>(
|
|
495
494
|
() => ({
|
|
496
495
|
async load() {
|
|
496
|
+
const { remoteId } = api.threadListItem().getState();
|
|
497
497
|
if (!remoteId) return { messages: [] };
|
|
498
498
|
|
|
499
499
|
const messages = await db.messages.findByThreadId(remoteId);
|
|
@@ -508,10 +508,8 @@ export function MyRuntimeProvider({ children }) {
|
|
|
508
508
|
},
|
|
509
509
|
|
|
510
510
|
async append(message) {
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
return;
|
|
514
|
-
}
|
|
511
|
+
// Wait for initialization to get remoteId (safe to call multiple times)
|
|
512
|
+
const { remoteId } = await api.threadListItem().initialize();
|
|
515
513
|
|
|
516
514
|
await db.messages.create({
|
|
517
515
|
threadId: remoteId,
|
|
@@ -522,7 +520,7 @@ export function MyRuntimeProvider({ children }) {
|
|
|
522
520
|
});
|
|
523
521
|
},
|
|
524
522
|
}),
|
|
525
|
-
[
|
|
523
|
+
[api],
|
|
526
524
|
);
|
|
527
525
|
|
|
528
526
|
const adapters = useMemo(() => ({ history }), [history]);
|
|
@@ -570,6 +568,31 @@ The complete multi-thread implementation requires:
|
|
|
570
568
|
|
|
571
569
|
Without the history adapter, threads would have no message persistence, making them effectively useless. The Provider pattern allows you to add thread-specific functionality while keeping the runtime creation simple.
|
|
572
570
|
|
|
571
|
+
<Callout type="warn" title="Avoiding Race Conditions">
|
|
572
|
+
When implementing a history adapter, `append()` may be called before the thread is fully initialized, causing the first message to be lost. Instead of checking `if (!remoteId)`, await initialization to ensure the `remoteId` is available:
|
|
573
|
+
|
|
574
|
+
```tsx
|
|
575
|
+
import { useAssistantApi } from "@assistant-ui/react";
|
|
576
|
+
|
|
577
|
+
// Inside your unstable_Provider component
|
|
578
|
+
const api = useAssistantApi();
|
|
579
|
+
|
|
580
|
+
const history = useMemo<ThreadHistoryAdapter>(
|
|
581
|
+
() => ({
|
|
582
|
+
async append(message) {
|
|
583
|
+
// Wait for initialization - safe to call multiple times
|
|
584
|
+
const { remoteId } = await api.threadListItem().initialize();
|
|
585
|
+
await db.messages.create({ threadId: remoteId, ...message });
|
|
586
|
+
},
|
|
587
|
+
// ...
|
|
588
|
+
}),
|
|
589
|
+
[api],
|
|
590
|
+
);
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
See `AssistantCloudThreadHistoryAdapter` in the source for a production reference.
|
|
594
|
+
</Callout>
|
|
595
|
+
|
|
573
596
|
#### Database Schema Example
|
|
574
597
|
|
|
575
598
|
```typescript
|
|
@@ -11,12 +11,6 @@ An example implementation of this is [shadcn/ui's Scroll Area](https://ui.shadcn
|
|
|
11
11
|
|
|
12
12
|
<InstallCommand shadcn={["scroll-area"]} />
|
|
13
13
|
|
|
14
|
-
### @radix-ui/react-scroll-area v1.2.0 release candidate required
|
|
15
|
-
|
|
16
|
-
The v1.2.0-rc.x release candidate can be installed via
|
|
17
|
-
|
|
18
|
-
<InstallCommand npm={["@radix-ui/react-scroll-area@next"]} />
|
|
19
|
-
|
|
20
14
|
## Additional Styles
|
|
21
15
|
|
|
22
16
|
The Radix UI Viewport component adds an intermediate `<div data-radix-scroll-area-content>` element.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const ROOT_DIR: string;
|
|
2
|
+
export declare const PACKAGE_DIR: string;
|
|
3
|
+
export declare const EXAMPLES_PATH: string;
|
|
4
|
+
export declare const DOCS_PATH: string;
|
|
5
|
+
export declare const CODE_EXAMPLES_PATH: string;
|
|
6
|
+
export declare const MDX_EXTENSION = ".mdx";
|
|
7
|
+
export declare const MD_EXTENSION = ".md";
|
|
8
|
+
export declare const MAX_FILE_SIZE: number;
|
|
9
|
+
export declare const IS_PREPARE_MODE: boolean | undefined;
|
|
10
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,QAAQ,QAA+B,CAAC;AACrD,eAAO,MAAM,WAAW,QAAyB,CAAC;AAElD,eAAO,MAAM,aAAa,QAA6B,CAAC;AAGxD,eAAO,MAAM,SAAS,QAA8B,CAAC;AACrD,eAAO,MAAM,kBAAkB,QAA6C,CAAC;AAE7E,eAAO,MAAM,aAAa,SAAS,CAAC;AACpC,eAAO,MAAM,YAAY,QAAQ,CAAC;AAElC,eAAO,MAAM,aAAa,QAAmB,CAAC;AAE9C,eAAO,MAAM,eAAe,qBAE3B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
4
|
+
export const ROOT_DIR = join(__dirname, "../../../");
|
|
5
|
+
export const PACKAGE_DIR = join(__dirname, "../");
|
|
6
|
+
export const EXAMPLES_PATH = join(ROOT_DIR, "examples");
|
|
7
|
+
const DOCS_BASE = join(PACKAGE_DIR, ".docs");
|
|
8
|
+
export const DOCS_PATH = join(DOCS_BASE, "raw/docs");
|
|
9
|
+
export const CODE_EXAMPLES_PATH = join(DOCS_BASE, "organized/code-examples");
|
|
10
|
+
export const MDX_EXTENSION = ".mdx";
|
|
11
|
+
export const MD_EXTENSION = ".md";
|
|
12
|
+
export const MAX_FILE_SIZE = 10 * 1024 * 1024;
|
|
13
|
+
export const IS_PREPARE_MODE = process.argv[1]?.includes("prepare-docs/prepare");
|
|
14
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE1D,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AACrD,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AAElD,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AAExD,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AAC7C,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AACrD,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC,SAAS,EAAE,yBAAyB,CAAC,CAAC;AAE7E,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC;AACpC,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,CAAC;AAElC,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAE9C,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,CACtD,sBAAsB,CACvB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAcpE,eAAO,MAAM,MAAM,WAGjB,CAAC;AAeH,wBAAsB,SAAS,kBAW9B"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import { docsTools } from "./tools/docs.js";
|
|
4
|
+
import { examplesTools } from "./tools/examples.js";
|
|
5
|
+
import { logger } from "./utils/logger.js";
|
|
6
|
+
import { PACKAGE_DIR } from "./constants.js";
|
|
7
|
+
import { readFileSync } from "node:fs";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
const packageJson = JSON.parse(readFileSync(join(PACKAGE_DIR, "package.json"), "utf-8"));
|
|
10
|
+
export const server = new McpServer({
|
|
11
|
+
name: "assistant-ui-docs",
|
|
12
|
+
version: packageJson.version,
|
|
13
|
+
});
|
|
14
|
+
server.tool(docsTools.name, docsTools.description, docsTools.parameters, docsTools.execute);
|
|
15
|
+
server.tool(examplesTools.name, examplesTools.description, examplesTools.parameters, examplesTools.execute);
|
|
16
|
+
export async function runServer() {
|
|
17
|
+
try {
|
|
18
|
+
logger.info(`Starting assistant-ui MCP docs server v${packageJson.version}`);
|
|
19
|
+
const transport = new StdioServerTransport();
|
|
20
|
+
await server.connect(transport);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
logger.error("Failed to start MCP server", error);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
28
|
+
void runServer().catch((error) => {
|
|
29
|
+
console.error("Failed to start server:", error);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAC5B,YAAY,CAAC,IAAI,CAAC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ples.d.ts","sourceRoot":"","sources":["../../src/prepare-docs/code-examples.ts"],"names":[],"mappings":"AA2FA,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAkEzD"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { rm, mkdir, readdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { join, relative, extname } from "node:path";
|
|
3
|
+
import { logger } from "../utils/logger.js";
|
|
4
|
+
import { ROOT_DIR, EXAMPLES_PATH } from "../constants.js";
|
|
5
|
+
const OUTPUT_DIR = join(ROOT_DIR, "packages/mcp-docs-server/.docs/organized/code-examples");
|
|
6
|
+
const MAX_LINES = 10000;
|
|
7
|
+
async function scanDirectory(dir, baseDir) {
|
|
8
|
+
const files = [];
|
|
9
|
+
try {
|
|
10
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
11
|
+
for (const entry of entries) {
|
|
12
|
+
const fullPath = join(dir, entry.name);
|
|
13
|
+
if (entry.isDirectory()) {
|
|
14
|
+
const skipDirs = [
|
|
15
|
+
"node_modules",
|
|
16
|
+
"dist",
|
|
17
|
+
"build",
|
|
18
|
+
".next",
|
|
19
|
+
".git",
|
|
20
|
+
".turbo",
|
|
21
|
+
];
|
|
22
|
+
if (!skipDirs.includes(entry.name)) {
|
|
23
|
+
const subFiles = await scanDirectory(fullPath, baseDir);
|
|
24
|
+
files.push(...subFiles);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
else if (entry.isFile()) {
|
|
28
|
+
const includeExts = [
|
|
29
|
+
".ts",
|
|
30
|
+
".tsx",
|
|
31
|
+
".js",
|
|
32
|
+
".jsx",
|
|
33
|
+
".json",
|
|
34
|
+
".css",
|
|
35
|
+
".md",
|
|
36
|
+
".mdx",
|
|
37
|
+
];
|
|
38
|
+
const ext = extname(entry.name).toLowerCase();
|
|
39
|
+
if (includeExts.includes(ext) ||
|
|
40
|
+
entry.name === "package.json" ||
|
|
41
|
+
entry.name === "tsconfig.json") {
|
|
42
|
+
try {
|
|
43
|
+
const content = await readFile(fullPath, "utf-8");
|
|
44
|
+
const relativePath = relative(baseDir, fullPath);
|
|
45
|
+
files.push({ path: relativePath, content });
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
logger.warn(`Failed to read file: ${fullPath}`, error);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
logger.error(`Failed to scan directory: ${dir}`, error);
|
|
56
|
+
}
|
|
57
|
+
return files;
|
|
58
|
+
}
|
|
59
|
+
function getFileType(filename) {
|
|
60
|
+
const ext = extname(filename).toLowerCase();
|
|
61
|
+
const extMap = {
|
|
62
|
+
".ts": "typescript",
|
|
63
|
+
".tsx": "tsx",
|
|
64
|
+
".js": "javascript",
|
|
65
|
+
".jsx": "jsx",
|
|
66
|
+
".json": "json",
|
|
67
|
+
".css": "css",
|
|
68
|
+
".md": "markdown",
|
|
69
|
+
".mdx": "mdx",
|
|
70
|
+
};
|
|
71
|
+
return extMap[ext] || "text";
|
|
72
|
+
}
|
|
73
|
+
export async function prepareCodeExamples() {
|
|
74
|
+
logger.info("Preparing code examples...");
|
|
75
|
+
try {
|
|
76
|
+
await rm(OUTPUT_DIR, { recursive: true, force: true });
|
|
77
|
+
await mkdir(OUTPUT_DIR, { recursive: true });
|
|
78
|
+
const exampleDirs = await readdir(EXAMPLES_PATH, { withFileTypes: true });
|
|
79
|
+
for (const dir of exampleDirs) {
|
|
80
|
+
if (dir.isDirectory() && !dir.name.startsWith(".")) {
|
|
81
|
+
const examplePath = join(EXAMPLES_PATH, dir.name);
|
|
82
|
+
logger.info(`Processing example: ${dir.name}`);
|
|
83
|
+
let description = "";
|
|
84
|
+
try {
|
|
85
|
+
const packageJsonPath = join(examplePath, "package.json");
|
|
86
|
+
const packageJson = JSON.parse(await readFile(packageJsonPath, "utf-8"));
|
|
87
|
+
description = packageJson.description || "";
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
if (error?.code !== "ENOENT") {
|
|
91
|
+
logger.warn(`Failed to read package.json for ${dir.name}:`, error);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
logger.debug(`No package.json found for example: ${dir.name}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const files = await scanDirectory(examplePath, examplePath);
|
|
98
|
+
files.sort((a, b) => a.path.localeCompare(b.path));
|
|
99
|
+
let markdown = `# Example: ${dir.name}\n\n`;
|
|
100
|
+
if (description) {
|
|
101
|
+
markdown += `${description}\n\n`;
|
|
102
|
+
}
|
|
103
|
+
let totalLines = 0;
|
|
104
|
+
for (const file of files) {
|
|
105
|
+
const lines = file.content.split("\n").length;
|
|
106
|
+
if (totalLines + lines > MAX_LINES) {
|
|
107
|
+
markdown += `\n_Note: Additional files truncated due to size limits_\n`;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
// Normalize Windows backslashes to forward slashes for consistent markdown output
|
|
111
|
+
markdown += `## ${file.path.replace(/\\/g, "/")}\n\n`;
|
|
112
|
+
markdown += `\`\`\`${getFileType(file.path)}\n`;
|
|
113
|
+
markdown += file.content;
|
|
114
|
+
markdown += `\n\`\`\`\n\n`;
|
|
115
|
+
totalLines += lines;
|
|
116
|
+
}
|
|
117
|
+
const outputPath = join(OUTPUT_DIR, `${dir.name}.md`);
|
|
118
|
+
await writeFile(outputPath, markdown, "utf-8");
|
|
119
|
+
logger.debug(`Created example: ${outputPath}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
logger.info("Code examples preparation complete");
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
logger.error("Failed to prepare code examples", error);
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=code-examples.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-examples.js","sourceRoot":"","sources":["../../src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AAC,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;gBAC/C,MAAM,CAAC,KAAK,CAAC,oBAAoB,UAAU,EAAE,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;IACpD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;QACvD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy-raw.d.ts","sourceRoot":"","sources":["../../src/prepare-docs/copy-raw.ts"],"names":[],"mappings":"AAkCA,wBAAsB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAoB7C"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { rm, mkdir, readdir, copyFile } from "node:fs/promises";
|
|
2
|
+
import { join, extname } from "node:path";
|
|
3
|
+
import { logger } from "../utils/logger.js";
|
|
4
|
+
import { ROOT_DIR } from "../constants.js";
|
|
5
|
+
const DOCS_SOURCE = join(ROOT_DIR, "apps/docs/content/docs");
|
|
6
|
+
const BLOG_SOURCE = join(ROOT_DIR, "apps/docs/content/blog");
|
|
7
|
+
const DOCS_DEST = join(ROOT_DIR, "packages/mcp-docs-server/.docs/raw");
|
|
8
|
+
async function copyDir(src, dest) {
|
|
9
|
+
try {
|
|
10
|
+
await mkdir(dest, { recursive: true });
|
|
11
|
+
const entries = await readdir(src, { withFileTypes: true });
|
|
12
|
+
for (const entry of entries) {
|
|
13
|
+
const srcPath = join(src, entry.name);
|
|
14
|
+
const destPath = join(dest, entry.name);
|
|
15
|
+
if (entry.isDirectory()) {
|
|
16
|
+
await copyDir(srcPath, destPath);
|
|
17
|
+
}
|
|
18
|
+
else if (entry.isFile()) {
|
|
19
|
+
const ext = extname(entry.name).toLowerCase();
|
|
20
|
+
if (ext === ".mdx" || ext === ".md") {
|
|
21
|
+
await copyFile(srcPath, destPath);
|
|
22
|
+
logger.debug(`Copied: ${srcPath} -> ${destPath}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
logger.error(`Failed to copy directory: ${src}`, error);
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export async function copyRaw() {
|
|
33
|
+
logger.info("Copying raw documentation files...");
|
|
34
|
+
try {
|
|
35
|
+
await rm(DOCS_DEST, { recursive: true, force: true });
|
|
36
|
+
await mkdir(DOCS_DEST, { recursive: true });
|
|
37
|
+
const docsPath = join(DOCS_DEST, "docs");
|
|
38
|
+
await copyDir(DOCS_SOURCE, docsPath);
|
|
39
|
+
logger.info(`Copied documentation to ${docsPath}`);
|
|
40
|
+
const blogPath = join(DOCS_DEST, "blog");
|
|
41
|
+
await copyDir(BLOG_SOURCE, blogPath);
|
|
42
|
+
logger.info(`Copied blog posts to ${blogPath}`);
|
|
43
|
+
logger.info("Raw documentation copy complete");
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
logger.error("Failed to copy raw documentation", error);
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=copy-raw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy-raw.js","sourceRoot":"","sources":["../../src/prepare-docs/copy-raw.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,MAAM,WAAW,GAAG,IAAI,CAAC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