@assistant-ui/mcp-docs-server 0.1.17 → 0.1.19
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 +518 -234
- package/.docs/organized/code-examples/{with-ai-sdk-v5.md → with-ai-sdk-v6.md} +476 -189
- package/.docs/organized/code-examples/with-assistant-transport.md +503 -301
- package/.docs/organized/code-examples/with-cloud.md +524 -226
- package/.docs/organized/code-examples/with-custom-thread-list.md +433 -146
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +2241 -0
- package/.docs/organized/code-examples/with-external-store.md +517 -231
- package/.docs/organized/code-examples/with-ffmpeg.md +500 -220
- package/.docs/organized/code-examples/with-langgraph.md +630 -319
- package/.docs/organized/code-examples/with-parent-id-grouping.md +517 -231
- package/.docs/organized/code-examples/with-react-hook-form.md +517 -233
- package/.docs/organized/code-examples/with-react-router.md +2167 -0
- package/.docs/organized/code-examples/{store-example.md → with-store.md} +18 -22
- package/.docs/organized/code-examples/with-tanstack.md +23 -41
- package/.docs/raw/blog/2025-01-31-changelog/index.mdx +0 -2
- package/.docs/raw/docs/{about-assistantui.mdx → (docs)/about-assistantui.mdx} +2 -1
- package/.docs/raw/docs/{architecture.mdx → (docs)/architecture.mdx} +3 -2
- package/.docs/raw/docs/{cli.mdx → (docs)/cli.mdx} +1 -19
- package/.docs/raw/docs/{copilots → (docs)/copilots}/make-assistant-readable.mdx +1 -0
- package/.docs/raw/docs/{copilots → (docs)/copilots}/make-assistant-tool-ui.mdx +2 -1
- package/.docs/raw/docs/{copilots → (docs)/copilots}/make-assistant-tool.mdx +2 -1
- package/.docs/raw/docs/{copilots → (docs)/copilots}/model-context.mdx +1 -0
- package/.docs/raw/docs/{copilots → (docs)/copilots}/motivation.mdx +1 -0
- package/.docs/raw/docs/{copilots → (docs)/copilots}/use-assistant-instructions.mdx +1 -0
- package/.docs/raw/docs/{devtools.mdx → (docs)/devtools.mdx} +4 -4
- package/.docs/raw/docs/{guides/Attachments.mdx → (docs)/guides/attachments.mdx} +4 -5
- package/.docs/raw/docs/{guides/Branching.mdx → (docs)/guides/branching.mdx} +2 -1
- package/.docs/raw/docs/{guides → (docs)/guides}/context-api.mdx +1 -0
- package/.docs/raw/docs/(docs)/guides/dictation.mdx +370 -0
- package/.docs/raw/docs/{guides/Editing.mdx → (docs)/guides/editing.mdx} +1 -0
- package/.docs/raw/docs/{guides/Latex.mdx → (docs)/guides/latex.mdx} +1 -2
- package/.docs/raw/docs/{guides/Speech.mdx → (docs)/guides/speech.mdx} +9 -10
- package/.docs/raw/docs/{guides/ToolUI.mdx → (docs)/guides/tool-ui.mdx} +15 -14
- package/.docs/raw/docs/{guides/Tools.mdx → (docs)/guides/tools.mdx} +10 -7
- package/.docs/raw/docs/{getting-started.mdx → (docs)/index.mdx} +17 -22
- package/.docs/raw/docs/{mcp-docs-server.mdx → (docs)/mcp-docs-server.mdx} +1 -2
- package/.docs/raw/docs/{api-reference/context-providers/AssistantRuntimeProvider.mdx → (reference)/api-reference/context-providers/assistant-runtime-provider.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/context-providers/TextMessagePartProvider.mdx → (reference)/api-reference/context-providers/text-message-part-provider.mdx} +2 -1
- package/.docs/raw/docs/{api-reference → (reference)/api-reference}/integrations/react-data-stream.mdx +2 -1
- package/.docs/raw/docs/{api-reference → (reference)/api-reference}/integrations/react-hook-form.mdx +2 -1
- package/.docs/raw/docs/{api-reference → (reference)/api-reference}/integrations/vercel-ai-sdk.mdx +2 -2
- package/.docs/raw/docs/{api-reference → (reference)/api-reference}/overview.mdx +1 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar-more.mdx +327 -0
- package/.docs/raw/docs/{api-reference/primitives/ActionBar.mdx → (reference)/api-reference/primitives/action-bar.mdx} +3 -1
- package/.docs/raw/docs/{api-reference/primitives/AssistantIf.mdx → (reference)/api-reference/primitives/assistant-if.mdx} +2 -2
- package/.docs/raw/docs/{api-reference/primitives/AssistantModal.mdx → (reference)/api-reference/primitives/assistant-modal.mdx} +3 -1
- package/.docs/raw/docs/{api-reference/primitives/Attachment.mdx → (reference)/api-reference/primitives/attachment.mdx} +3 -2
- package/.docs/raw/docs/{api-reference/primitives/BranchPicker.mdx → (reference)/api-reference/primitives/branch-picker.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/primitives/Composer.mdx → (reference)/api-reference/primitives/composer.mdx} +101 -2
- package/.docs/raw/docs/{api-reference → (reference)/api-reference}/primitives/composition.mdx +1 -0
- package/.docs/raw/docs/{api-reference/primitives/Error.mdx → (reference)/api-reference/primitives/error.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/primitives/MessagePart.mdx → (reference)/api-reference/primitives/message-part.mdx} +2 -2
- package/.docs/raw/docs/{api-reference/primitives/Message.mdx → (reference)/api-reference/primitives/message.mdx} +2 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item-more.mdx +221 -0
- package/.docs/raw/docs/{api-reference/primitives/ThreadListItem.mdx → (reference)/api-reference/primitives/thread-list-item.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/primitives/ThreadList.mdx → (reference)/api-reference/primitives/thread-list.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/primitives/Thread.mdx → (reference)/api-reference/primitives/thread.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/runtimes/AssistantRuntime.mdx → (reference)/api-reference/runtimes/assistant-runtime.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/runtimes/AttachmentRuntime.mdx → (reference)/api-reference/runtimes/attachment-runtime.mdx} +3 -2
- package/.docs/raw/docs/{api-reference/runtimes/ComposerRuntime.mdx → (reference)/api-reference/runtimes/composer-runtime.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/runtimes/MessagePartRuntime.mdx → (reference)/api-reference/runtimes/message-part-runtime.mdx} +3 -2
- package/.docs/raw/docs/{api-reference/runtimes/MessageRuntime.mdx → (reference)/api-reference/runtimes/message-runtime.mdx} +3 -2
- package/.docs/raw/docs/{api-reference/runtimes/ThreadListItemRuntime.mdx → (reference)/api-reference/runtimes/thread-list-item-runtime.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/runtimes/ThreadListRuntime.mdx → (reference)/api-reference/runtimes/thread-list-runtime.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/runtimes/ThreadRuntime.mdx → (reference)/api-reference/runtimes/thread-runtime.mdx} +3 -5
- package/.docs/raw/docs/{legacy/styled/AssistantModal.mdx → (reference)/legacy/styled/assistant-modal.mdx} +2 -3
- package/.docs/raw/docs/{legacy/styled/Decomposition.mdx → (reference)/legacy/styled/decomposition.mdx} +1 -0
- package/.docs/raw/docs/{legacy/styled/Markdown.mdx → (reference)/legacy/styled/markdown.mdx} +2 -4
- package/.docs/raw/docs/{legacy/styled/Scrollbar.mdx → (reference)/legacy/styled/scrollbar.mdx} +2 -1
- package/.docs/raw/docs/{legacy/styled/ThreadWidth.mdx → (reference)/legacy/styled/thread-width.mdx} +1 -0
- package/.docs/raw/docs/{legacy/styled/Thread.mdx → (reference)/legacy/styled/thread.mdx} +2 -3
- package/.docs/raw/docs/{migrations → (reference)/migrations}/deprecation-policy.mdx +1 -0
- package/.docs/raw/docs/{migrations → (reference)/migrations}/react-langgraph-v0-7.mdx +1 -2
- package/.docs/raw/docs/{migrations → (reference)/migrations}/v0-11.mdx +1 -0
- package/.docs/raw/docs/{migrations → (reference)/migrations}/v0-12.mdx +1 -0
- package/.docs/raw/docs/{react-compatibility.mdx → (reference)/react-compatibility.mdx} +2 -3
- package/.docs/raw/docs/cloud/authorization.mdx +1 -0
- package/.docs/raw/docs/cloud/overview.mdx +1 -0
- package/.docs/raw/docs/cloud/persistence/ai-sdk.mdx +2 -3
- package/.docs/raw/docs/cloud/persistence/langgraph.mdx +5 -7
- package/.docs/raw/docs/runtimes/ai-sdk/use-chat.mdx +9 -8
- package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +2 -3
- package/.docs/raw/docs/runtimes/assistant-transport.mdx +7 -6
- package/.docs/raw/docs/runtimes/custom/custom-thread-list.mdx +38 -3
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +6 -8
- package/.docs/raw/docs/runtimes/custom/local.mdx +43 -16
- package/.docs/raw/docs/runtimes/data-stream.mdx +32 -4
- package/.docs/raw/docs/runtimes/helicone.mdx +1 -0
- package/.docs/raw/docs/runtimes/langgraph/index.mdx +3 -3
- package/.docs/raw/docs/runtimes/langgraph/tutorial/index.mdx +1 -0
- package/.docs/raw/docs/runtimes/langgraph/tutorial/introduction.mdx +1 -0
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-1.mdx +1 -0
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +1 -0
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +2 -1
- package/.docs/raw/docs/runtimes/langserve.mdx +2 -2
- package/.docs/raw/docs/runtimes/mastra/full-stack-integration.mdx +4 -5
- package/.docs/raw/docs/runtimes/mastra/overview.mdx +1 -0
- package/.docs/raw/docs/runtimes/mastra/separate-server-integration.mdx +3 -4
- package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +2 -4
- package/.docs/raw/docs/ui/assistant-modal.mdx +163 -0
- package/.docs/raw/docs/ui/assistant-sidebar.mdx +90 -0
- package/.docs/raw/docs/ui/attachment.mdx +227 -0
- package/.docs/raw/docs/ui/{Markdown.mdx → markdown.mdx} +11 -6
- package/.docs/raw/docs/ui/{Mermaid.mdx → mermaid.mdx} +12 -5
- package/.docs/raw/docs/ui/{PartGrouping.mdx → part-grouping.mdx} +4 -6
- package/.docs/raw/docs/ui/reasoning.mdx +148 -0
- package/.docs/raw/docs/ui/{Scrollbar.mdx → scrollbar.mdx} +9 -7
- package/.docs/raw/docs/ui/sources.mdx +87 -0
- package/.docs/raw/docs/ui/{SyntaxHighlighting.mdx → syntax-highlighting.mdx} +9 -5
- package/.docs/raw/docs/ui/thread-list.mdx +275 -0
- package/.docs/raw/docs/ui/{Thread.mdx → thread.mdx} +5 -6
- package/.docs/raw/docs/ui/tool-fallback.mdx +112 -0
- package/.docs/raw/docs/ui/tool-group.mdx +214 -0
- 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 +124 -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/.docs/raw/docs/index.mdx +0 -7
- package/.docs/raw/docs/ui/AssistantModal.mdx +0 -45
- package/.docs/raw/docs/ui/AssistantSidebar.mdx +0 -41
- package/.docs/raw/docs/ui/Attachment.mdx +0 -84
- package/.docs/raw/docs/ui/Reasoning.mdx +0 -152
- package/.docs/raw/docs/ui/ThreadList.mdx +0 -90
- package/.docs/raw/docs/ui/ToolFallback.mdx +0 -63
- package/.docs/raw/docs/ui/ToolGroup.mdx +0 -96
- package/dist/chunk-M2RKUM66.js +0 -38
- package/dist/chunk-NVNFQ5ZO.js +0 -423
- /package/.docs/raw/docs/{copilots → (docs)/copilots}/assistant-frame.mdx +0 -0
package/package.json
CHANGED
|
@@ -1,46 +1,64 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@assistant-ui/mcp-docs-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"description": "MCP server for assistant-ui documentation and examples",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"mcp",
|
|
7
|
+
"model-context-protocol",
|
|
8
|
+
"assistant-ui",
|
|
9
|
+
"documentation",
|
|
10
|
+
"ai",
|
|
11
|
+
"claude"
|
|
12
|
+
],
|
|
13
|
+
"author": "AgentbaseAI Inc.",
|
|
14
|
+
"license": "MIT",
|
|
5
15
|
"type": "module",
|
|
6
|
-
"
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"aui-source": "./src/index.ts",
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"default": "./dist/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"main": "./dist/index.js",
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
7
25
|
"bin": {
|
|
8
26
|
"assistant-ui-mcp": "./dist/stdio.js"
|
|
9
27
|
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"src",
|
|
31
|
+
".docs",
|
|
32
|
+
"README.md"
|
|
33
|
+
],
|
|
34
|
+
"sideEffects": false,
|
|
10
35
|
"dependencies": {
|
|
11
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
12
|
-
"zod": "^4.1.13",
|
|
36
|
+
"@modelcontextprotocol/sdk": "^1.25.3",
|
|
13
37
|
"gray-matter": "^4.0.3",
|
|
14
|
-
"
|
|
38
|
+
"zod": "^4.3.5"
|
|
15
39
|
},
|
|
16
40
|
"devDependencies": {
|
|
17
|
-
"@types/node": "^25.0.
|
|
18
|
-
"tsup": "^8.5.1",
|
|
41
|
+
"@types/node": "^25.0.9",
|
|
19
42
|
"tsx": "^4.21.0",
|
|
20
|
-
"
|
|
21
|
-
"
|
|
43
|
+
"vitest": "^4.0.17",
|
|
44
|
+
"@assistant-ui/x-buildutils": "0.0.1"
|
|
22
45
|
},
|
|
23
|
-
"files": [
|
|
24
|
-
"dist",
|
|
25
|
-
".docs",
|
|
26
|
-
"README.md"
|
|
27
|
-
],
|
|
28
46
|
"publishConfig": {
|
|
29
47
|
"access": "public",
|
|
30
48
|
"provenance": true
|
|
31
49
|
},
|
|
50
|
+
"homepage": "https://www.assistant-ui.com/",
|
|
32
51
|
"repository": {
|
|
33
52
|
"type": "git",
|
|
34
|
-
"url": "https://github.com/assistant-ui/assistant-ui
|
|
53
|
+
"url": "git+https://github.com/assistant-ui/assistant-ui.git",
|
|
54
|
+
"directory": "packages/mcp-docs-server"
|
|
35
55
|
},
|
|
36
56
|
"bugs": {
|
|
37
57
|
"url": "https://github.com/assistant-ui/assistant-ui/issues"
|
|
38
58
|
},
|
|
39
59
|
"scripts": {
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"build:cli": "tsup src/stdio.ts src/prepare-docs/prepare.ts src/index.ts --format esm --treeshake=smallest --splitting",
|
|
43
|
-
"build": "pnpm clean && pnpm build:cli && pnpm prepare-docs",
|
|
60
|
+
"prepare-docs": "node ./dist/prepare-docs/prepare.js",
|
|
61
|
+
"build": "aui-build && pnpm prepare-docs",
|
|
44
62
|
"dev": "tsx src/stdio.ts",
|
|
45
63
|
"pretest": "pnpm build",
|
|
46
64
|
"test": "vitest run",
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
|
|
4
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
5
|
+
|
|
6
|
+
export const ROOT_DIR = join(__dirname, "../../../");
|
|
7
|
+
export const PACKAGE_DIR = join(__dirname, "../");
|
|
8
|
+
|
|
9
|
+
export const EXAMPLES_PATH = join(ROOT_DIR, "examples");
|
|
10
|
+
|
|
11
|
+
const DOCS_BASE = join(PACKAGE_DIR, ".docs");
|
|
12
|
+
export const DOCS_PATH = join(DOCS_BASE, "raw/docs");
|
|
13
|
+
export const CODE_EXAMPLES_PATH = join(DOCS_BASE, "organized/code-examples");
|
|
14
|
+
|
|
15
|
+
export const MDX_EXTENSION = ".mdx";
|
|
16
|
+
export const MD_EXTENSION = ".md";
|
|
17
|
+
|
|
18
|
+
export const MAX_FILE_SIZE = 10 * 1024 * 1024;
|
|
19
|
+
|
|
20
|
+
export const IS_PREPARE_MODE = process.argv[1]?.includes(
|
|
21
|
+
"prepare-docs/prepare",
|
|
22
|
+
);
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
|
|
8
|
+
import { readFileSync } from "node:fs";
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
|
|
11
|
+
const packageJson = JSON.parse(
|
|
12
|
+
readFileSync(join(PACKAGE_DIR, "package.json"), "utf-8"),
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export const server = new McpServer({
|
|
16
|
+
name: "assistant-ui-docs",
|
|
17
|
+
version: packageJson.version,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
server.tool(
|
|
21
|
+
docsTools.name,
|
|
22
|
+
docsTools.description,
|
|
23
|
+
docsTools.parameters,
|
|
24
|
+
docsTools.execute,
|
|
25
|
+
);
|
|
26
|
+
server.tool(
|
|
27
|
+
examplesTools.name,
|
|
28
|
+
examplesTools.description,
|
|
29
|
+
examplesTools.parameters,
|
|
30
|
+
examplesTools.execute,
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
export async function runServer() {
|
|
34
|
+
try {
|
|
35
|
+
logger.info(
|
|
36
|
+
`Starting assistant-ui MCP docs server v${packageJson.version}`,
|
|
37
|
+
);
|
|
38
|
+
const transport = new StdioServerTransport();
|
|
39
|
+
await server.connect(transport);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
logger.error("Failed to start MCP server", error);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
47
|
+
void runServer().catch((error) => {
|
|
48
|
+
console.error("Failed to start server:", error);
|
|
49
|
+
process.exit(1);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
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
|
+
|
|
6
|
+
const OUTPUT_DIR = join(
|
|
7
|
+
ROOT_DIR,
|
|
8
|
+
"packages/mcp-docs-server/.docs/organized/code-examples",
|
|
9
|
+
);
|
|
10
|
+
const MAX_LINES = 10000;
|
|
11
|
+
|
|
12
|
+
interface FileContent {
|
|
13
|
+
path: string;
|
|
14
|
+
content: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function scanDirectory(
|
|
18
|
+
dir: string,
|
|
19
|
+
baseDir: string,
|
|
20
|
+
): Promise<FileContent[]> {
|
|
21
|
+
const files: FileContent[] = [];
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
25
|
+
|
|
26
|
+
for (const entry of entries) {
|
|
27
|
+
const fullPath = join(dir, entry.name);
|
|
28
|
+
|
|
29
|
+
if (entry.isDirectory()) {
|
|
30
|
+
const skipDirs = [
|
|
31
|
+
"node_modules",
|
|
32
|
+
"dist",
|
|
33
|
+
"build",
|
|
34
|
+
".next",
|
|
35
|
+
".git",
|
|
36
|
+
".turbo",
|
|
37
|
+
];
|
|
38
|
+
if (!skipDirs.includes(entry.name)) {
|
|
39
|
+
const subFiles = await scanDirectory(fullPath, baseDir);
|
|
40
|
+
files.push(...subFiles);
|
|
41
|
+
}
|
|
42
|
+
} else if (entry.isFile()) {
|
|
43
|
+
const includeExts = [
|
|
44
|
+
".ts",
|
|
45
|
+
".tsx",
|
|
46
|
+
".js",
|
|
47
|
+
".jsx",
|
|
48
|
+
".json",
|
|
49
|
+
".css",
|
|
50
|
+
".md",
|
|
51
|
+
".mdx",
|
|
52
|
+
];
|
|
53
|
+
const ext = extname(entry.name).toLowerCase();
|
|
54
|
+
|
|
55
|
+
if (
|
|
56
|
+
includeExts.includes(ext) ||
|
|
57
|
+
entry.name === "package.json" ||
|
|
58
|
+
entry.name === "tsconfig.json"
|
|
59
|
+
) {
|
|
60
|
+
try {
|
|
61
|
+
const content = await readFile(fullPath, "utf-8");
|
|
62
|
+
const relativePath = relative(baseDir, fullPath);
|
|
63
|
+
files.push({ path: relativePath, content });
|
|
64
|
+
} catch (error) {
|
|
65
|
+
logger.warn(`Failed to read file: ${fullPath}`, error);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
} catch (error) {
|
|
71
|
+
logger.error(`Failed to scan directory: ${dir}`, error);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return files;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function getFileType(filename: string): string {
|
|
78
|
+
const ext = extname(filename).toLowerCase();
|
|
79
|
+
const extMap: Record<string, string> = {
|
|
80
|
+
".ts": "typescript",
|
|
81
|
+
".tsx": "tsx",
|
|
82
|
+
".js": "javascript",
|
|
83
|
+
".jsx": "jsx",
|
|
84
|
+
".json": "json",
|
|
85
|
+
".css": "css",
|
|
86
|
+
".md": "markdown",
|
|
87
|
+
".mdx": "mdx",
|
|
88
|
+
};
|
|
89
|
+
return extMap[ext] || "text";
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export async function prepareCodeExamples(): Promise<void> {
|
|
93
|
+
logger.info("Preparing code examples...");
|
|
94
|
+
|
|
95
|
+
try {
|
|
96
|
+
await rm(OUTPUT_DIR, { recursive: true, force: true });
|
|
97
|
+
await mkdir(OUTPUT_DIR, { recursive: true });
|
|
98
|
+
|
|
99
|
+
const exampleDirs = await readdir(EXAMPLES_PATH, { withFileTypes: true });
|
|
100
|
+
|
|
101
|
+
for (const dir of exampleDirs) {
|
|
102
|
+
if (dir.isDirectory() && !dir.name.startsWith(".")) {
|
|
103
|
+
const examplePath = join(EXAMPLES_PATH, dir.name);
|
|
104
|
+
logger.info(`Processing example: ${dir.name}`);
|
|
105
|
+
|
|
106
|
+
let description = "";
|
|
107
|
+
try {
|
|
108
|
+
const packageJsonPath = join(examplePath, "package.json");
|
|
109
|
+
const packageJson = JSON.parse(
|
|
110
|
+
await readFile(packageJsonPath, "utf-8"),
|
|
111
|
+
);
|
|
112
|
+
description = packageJson.description || "";
|
|
113
|
+
} catch (error: any) {
|
|
114
|
+
if (error?.code !== "ENOENT") {
|
|
115
|
+
logger.warn(`Failed to read package.json for ${dir.name}:`, error);
|
|
116
|
+
} else {
|
|
117
|
+
logger.debug(`No package.json found for example: ${dir.name}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const files = await scanDirectory(examplePath, examplePath);
|
|
122
|
+
|
|
123
|
+
files.sort((a, b) => a.path.localeCompare(b.path));
|
|
124
|
+
|
|
125
|
+
let markdown = `# Example: ${dir.name}\n\n`;
|
|
126
|
+
if (description) {
|
|
127
|
+
markdown += `${description}\n\n`;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
let totalLines = 0;
|
|
131
|
+
for (const file of files) {
|
|
132
|
+
const lines = file.content.split("\n").length;
|
|
133
|
+
if (totalLines + lines > MAX_LINES) {
|
|
134
|
+
markdown += `\n_Note: Additional files truncated due to size limits_\n`;
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Normalize Windows backslashes to forward slashes for consistent markdown output
|
|
139
|
+
markdown += `## ${file.path.replace(/\\/g, "/")}\n\n`;
|
|
140
|
+
markdown += `\`\`\`${getFileType(file.path)}\n`;
|
|
141
|
+
markdown += file.content;
|
|
142
|
+
markdown += `\n\`\`\`\n\n`;
|
|
143
|
+
|
|
144
|
+
totalLines += lines;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const outputPath = join(OUTPUT_DIR, `${dir.name}.md`);
|
|
148
|
+
await writeFile(outputPath, markdown, "utf-8");
|
|
149
|
+
logger.debug(`Created example: ${outputPath}`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
logger.info("Code examples preparation complete");
|
|
154
|
+
} catch (error) {
|
|
155
|
+
logger.error("Failed to prepare code examples", error);
|
|
156
|
+
throw error;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
|
|
6
|
+
const DOCS_SOURCE = join(ROOT_DIR, "apps/docs/content/docs");
|
|
7
|
+
const BLOG_SOURCE = join(ROOT_DIR, "apps/docs/content/blog");
|
|
8
|
+
const DOCS_DEST = join(ROOT_DIR, "packages/mcp-docs-server/.docs/raw");
|
|
9
|
+
|
|
10
|
+
async function copyDir(src: string, dest: string): Promise<void> {
|
|
11
|
+
try {
|
|
12
|
+
await mkdir(dest, { recursive: true });
|
|
13
|
+
const entries = await readdir(src, { withFileTypes: true });
|
|
14
|
+
|
|
15
|
+
for (const entry of entries) {
|
|
16
|
+
const srcPath = join(src, entry.name);
|
|
17
|
+
const destPath = join(dest, entry.name);
|
|
18
|
+
|
|
19
|
+
if (entry.isDirectory()) {
|
|
20
|
+
await copyDir(srcPath, destPath);
|
|
21
|
+
} else if (entry.isFile()) {
|
|
22
|
+
const ext = extname(entry.name).toLowerCase();
|
|
23
|
+
if (ext === ".mdx" || ext === ".md") {
|
|
24
|
+
await copyFile(srcPath, destPath);
|
|
25
|
+
logger.debug(`Copied: ${srcPath} -> ${destPath}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
} catch (error) {
|
|
30
|
+
logger.error(`Failed to copy directory: ${src}`, error);
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export async function copyRaw(): Promise<void> {
|
|
36
|
+
logger.info("Copying raw documentation files...");
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
await rm(DOCS_DEST, { recursive: true, force: true });
|
|
40
|
+
await mkdir(DOCS_DEST, { recursive: true });
|
|
41
|
+
|
|
42
|
+
const docsPath = join(DOCS_DEST, "docs");
|
|
43
|
+
await copyDir(DOCS_SOURCE, docsPath);
|
|
44
|
+
logger.info(`Copied documentation to ${docsPath}`);
|
|
45
|
+
|
|
46
|
+
const blogPath = join(DOCS_DEST, "blog");
|
|
47
|
+
await copyDir(BLOG_SOURCE, blogPath);
|
|
48
|
+
logger.info(`Copied blog posts to ${blogPath}`);
|
|
49
|
+
|
|
50
|
+
logger.info("Raw documentation copy complete");
|
|
51
|
+
} catch (error) {
|
|
52
|
+
logger.error("Failed to copy raw documentation", error);
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { logger } from "../utils/logger.js";
|
|
2
|
+
import { copyRaw } from "./copy-raw.js";
|
|
3
|
+
import { prepareCodeExamples } from "./code-examples.js";
|
|
4
|
+
|
|
5
|
+
async function prepare(): Promise<void> {
|
|
6
|
+
logger.info("Starting documentation preparation...");
|
|
7
|
+
|
|
8
|
+
try {
|
|
9
|
+
await copyRaw();
|
|
10
|
+
await prepareCodeExamples();
|
|
11
|
+
|
|
12
|
+
logger.info("Documentation preparation complete");
|
|
13
|
+
} catch (error) {
|
|
14
|
+
logger.error("Documentation preparation failed", error);
|
|
15
|
+
throw error;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
20
|
+
prepare().catch((error) => {
|
|
21
|
+
logger.error("Preparation failed", error);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
});
|
|
24
|
+
}
|
package/src/stdio.ts
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { z } from "zod/v3";
|
|
2
|
+
import { stat, lstat } from "node:fs/promises";
|
|
3
|
+
import { join, extname } from "node:path";
|
|
4
|
+
import { DOCS_PATH, MDX_EXTENSION, MAX_FILE_SIZE } from "../constants.js";
|
|
5
|
+
import { logger } from "../utils/logger.js";
|
|
6
|
+
import {
|
|
7
|
+
listDirContents,
|
|
8
|
+
getAvailablePaths,
|
|
9
|
+
findNearestPaths,
|
|
10
|
+
pathExists,
|
|
11
|
+
} from "../utils/paths.js";
|
|
12
|
+
import { readMDXFile, formatMDXContent } from "../utils/mdx.js";
|
|
13
|
+
import { formatMCPResponse } from "../utils/mcp-format.js";
|
|
14
|
+
import { sanitizePath } from "../utils/security.js";
|
|
15
|
+
|
|
16
|
+
const docsInputSchema = z.object({
|
|
17
|
+
paths: z
|
|
18
|
+
.array(z.string())
|
|
19
|
+
.min(1)
|
|
20
|
+
.describe(
|
|
21
|
+
'Documentation paths to retrieve (e.g., ["getting-started", "api-reference/primitives/thread"])',
|
|
22
|
+
),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
interface DocResult {
|
|
26
|
+
path: string;
|
|
27
|
+
found: boolean;
|
|
28
|
+
type?: "file" | "directory";
|
|
29
|
+
content?: string;
|
|
30
|
+
files?: string[];
|
|
31
|
+
directories?: string[];
|
|
32
|
+
suggestions?: string[];
|
|
33
|
+
error?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function readDocumentation(docPath: string): Promise<DocResult> {
|
|
37
|
+
logger.debug(`Reading documentation for path: ${docPath}`);
|
|
38
|
+
|
|
39
|
+
if (docPath === "/" || docPath === "") {
|
|
40
|
+
const { directories, files } = await listDirContents(DOCS_PATH);
|
|
41
|
+
return {
|
|
42
|
+
path: "/",
|
|
43
|
+
found: true,
|
|
44
|
+
type: "directory",
|
|
45
|
+
directories,
|
|
46
|
+
files: files.map((f) => f.replace(MDX_EXTENSION, "")),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
const sanitized = sanitizePath(docPath);
|
|
52
|
+
const fullPath = join(DOCS_PATH, sanitized);
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
const lstats = await lstat(fullPath);
|
|
56
|
+
if (lstats.isSymbolicLink()) {
|
|
57
|
+
logger.warn(`Symlink detected at path: ${fullPath}`);
|
|
58
|
+
return {
|
|
59
|
+
path: docPath,
|
|
60
|
+
found: false,
|
|
61
|
+
error: "Symlinks are not allowed for security reasons",
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
} catch {}
|
|
65
|
+
|
|
66
|
+
if (await pathExists(fullPath)) {
|
|
67
|
+
const stats = await stat(fullPath);
|
|
68
|
+
|
|
69
|
+
if (stats.isFile() && stats.size > MAX_FILE_SIZE) {
|
|
70
|
+
logger.warn(`File too large: ${fullPath} (${stats.size} bytes)`);
|
|
71
|
+
return {
|
|
72
|
+
path: docPath,
|
|
73
|
+
found: false,
|
|
74
|
+
error: `File size exceeds maximum allowed size of ${MAX_FILE_SIZE} bytes`,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (stats.isDirectory()) {
|
|
79
|
+
const { directories, files } = await listDirContents(fullPath);
|
|
80
|
+
|
|
81
|
+
const contents: Record<string, string> = {};
|
|
82
|
+
for (const file of files) {
|
|
83
|
+
const mdxContent = await readMDXFile(join(fullPath, file));
|
|
84
|
+
if (mdxContent) {
|
|
85
|
+
const fileName = file.replace(MDX_EXTENSION, "");
|
|
86
|
+
contents[fileName] = formatMDXContent(mdxContent);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const content =
|
|
91
|
+
Object.keys(contents).length > 0
|
|
92
|
+
? JSON.stringify(contents, null, 2)
|
|
93
|
+
: undefined;
|
|
94
|
+
return {
|
|
95
|
+
path: docPath,
|
|
96
|
+
found: true,
|
|
97
|
+
type: "directory",
|
|
98
|
+
directories,
|
|
99
|
+
files: files.map((f) => f.replace(MDX_EXTENSION, "")),
|
|
100
|
+
...(content !== undefined && { content }),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const mdxPath =
|
|
106
|
+
extname(fullPath) === MDX_EXTENSION
|
|
107
|
+
? fullPath
|
|
108
|
+
: `${fullPath}${MDX_EXTENSION}`;
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
const mdxLstats = await lstat(mdxPath);
|
|
112
|
+
if (mdxLstats.isSymbolicLink()) {
|
|
113
|
+
logger.warn(`Symlink detected at MDX path: ${mdxPath}`);
|
|
114
|
+
return {
|
|
115
|
+
path: docPath,
|
|
116
|
+
found: false,
|
|
117
|
+
error: "Symlinks are not allowed for security reasons",
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (mdxLstats.size > MAX_FILE_SIZE) {
|
|
122
|
+
logger.warn(`MDX file too large: ${mdxPath} (${mdxLstats.size} bytes)`);
|
|
123
|
+
return {
|
|
124
|
+
path: docPath,
|
|
125
|
+
found: false,
|
|
126
|
+
error: `File size exceeds maximum allowed size of ${MAX_FILE_SIZE} bytes`,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
} catch {}
|
|
130
|
+
|
|
131
|
+
if (await pathExists(mdxPath)) {
|
|
132
|
+
const mdxContent = await readMDXFile(mdxPath);
|
|
133
|
+
|
|
134
|
+
if (mdxContent) {
|
|
135
|
+
return {
|
|
136
|
+
path: docPath,
|
|
137
|
+
found: true,
|
|
138
|
+
type: "file",
|
|
139
|
+
content: formatMDXContent(mdxContent),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const availablePaths = await getAvailablePaths();
|
|
145
|
+
const suggestions = findNearestPaths(docPath, availablePaths);
|
|
146
|
+
|
|
147
|
+
return {
|
|
148
|
+
path: docPath,
|
|
149
|
+
found: false,
|
|
150
|
+
suggestions,
|
|
151
|
+
};
|
|
152
|
+
} catch (error) {
|
|
153
|
+
if (error instanceof Error && error.message.includes("Invalid path")) {
|
|
154
|
+
return {
|
|
155
|
+
path: docPath,
|
|
156
|
+
found: false,
|
|
157
|
+
error: error.message,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
throw error;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export const docsTools = {
|
|
165
|
+
name: "assistantUIDocs",
|
|
166
|
+
description:
|
|
167
|
+
'Retrieve assistant-ui documentation by path. Use "/" to list all sections. Supports multiple paths in a single request.',
|
|
168
|
+
parameters: docsInputSchema.shape,
|
|
169
|
+
execute: async ({ paths }: z.infer<typeof docsInputSchema>) => {
|
|
170
|
+
logger.info(`Retrieving documentation for paths: ${paths.join(", ")}`);
|
|
171
|
+
|
|
172
|
+
try {
|
|
173
|
+
const results = await Promise.all(
|
|
174
|
+
paths.map((path) => readDocumentation(path)),
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
if (results.length === 1) {
|
|
178
|
+
const result = results[0]!;
|
|
179
|
+
if (result.error) {
|
|
180
|
+
return formatMCPResponse({
|
|
181
|
+
error: result.error,
|
|
182
|
+
path: result.path,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
if (!result.found) {
|
|
186
|
+
return formatMCPResponse({
|
|
187
|
+
error: `Documentation not found for path: ${result.path}`,
|
|
188
|
+
suggestions: result.suggestions,
|
|
189
|
+
hint: 'Use "/" to list all available documentation sections',
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
return formatMCPResponse(result);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return formatMCPResponse({
|
|
196
|
+
results,
|
|
197
|
+
summary: `Retrieved ${results.filter((r) => r.found).length} of ${results.length} requested paths`,
|
|
198
|
+
});
|
|
199
|
+
} catch (error) {
|
|
200
|
+
logger.error("Failed to retrieve documentation", error);
|
|
201
|
+
return formatMCPResponse({
|
|
202
|
+
error: "Failed to retrieve documentation",
|
|
203
|
+
message: error instanceof Error ? error.message : String(error),
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
};
|