@assistant-ui/mcp-docs-server 0.1.39 → 0.2.0

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 (136) hide show
  1. package/.docs/organized/code-examples/waterfall.md +7 -7
  2. package/.docs/organized/code-examples/with-a2a.md +7 -7
  3. package/.docs/organized/code-examples/with-ag-ui.md +8 -8
  4. package/.docs/organized/code-examples/with-ai-sdk-v7.md +9 -9
  5. package/.docs/organized/code-examples/with-artifacts.md +463 -138
  6. package/.docs/organized/code-examples/with-assistant-transport.md +7 -7
  7. package/.docs/organized/code-examples/with-browser-extension.md +6 -6
  8. package/.docs/organized/code-examples/with-chain-of-thought.md +11 -11
  9. package/.docs/organized/code-examples/with-cloud-standalone.md +9 -9
  10. package/.docs/organized/code-examples/with-cloud.md +9 -9
  11. package/.docs/organized/code-examples/with-custom-thread-list.md +9 -9
  12. package/.docs/organized/code-examples/with-elevenlabs-conversational.md +11 -11
  13. package/.docs/organized/code-examples/with-elevenlabs-scribe.md +11 -11
  14. package/.docs/organized/code-examples/with-eve.md +8 -8
  15. package/.docs/organized/code-examples/with-expo.md +26 -46
  16. package/.docs/organized/code-examples/with-external-store.md +7 -7
  17. package/.docs/organized/code-examples/with-ffmpeg.md +9 -9
  18. package/.docs/organized/code-examples/with-generative-ui.md +10 -10
  19. package/.docs/organized/code-examples/with-google-adk.md +8 -8
  20. package/.docs/organized/code-examples/with-heat-graph.md +6 -6
  21. package/.docs/organized/code-examples/with-image-generation.md +9 -9
  22. package/.docs/organized/code-examples/with-interactables.md +9 -9
  23. package/.docs/organized/code-examples/with-langchain.md +9 -9
  24. package/.docs/organized/code-examples/with-langgraph.md +9 -9
  25. package/.docs/organized/code-examples/with-livekit.md +11 -11
  26. package/.docs/organized/code-examples/with-mcp.md +28 -23
  27. package/.docs/organized/code-examples/with-opencode.md +8 -11
  28. package/.docs/organized/code-examples/with-pi.md +14 -14
  29. package/.docs/organized/code-examples/with-react-hook-form.md +10 -10
  30. package/.docs/organized/code-examples/with-react-ink-web.md +5 -5
  31. package/.docs/organized/code-examples/with-react-ink.md +2 -2
  32. package/.docs/organized/code-examples/with-react-router.md +11 -11
  33. package/.docs/organized/code-examples/with-resumable-stream.md +10 -10
  34. package/.docs/organized/code-examples/with-store.md +6 -6
  35. package/.docs/organized/code-examples/with-tanstack.md +9 -9
  36. package/.docs/organized/code-examples/with-tap-runtime.md +7 -7
  37. package/.docs/organized/code-examples/with-virtualized-thread.md +8 -8
  38. package/.docs/raw/docs/(docs)/cli.mdx +2 -0
  39. package/.docs/raw/docs/(docs)/devtools.mdx +7 -2
  40. package/.docs/raw/docs/(reference)/api-reference/generative-ui/a2ui.mdx +40 -0
  41. package/.docs/raw/docs/(reference)/api-reference/generative-ui/index.mdx +3 -0
  42. package/.docs/raw/docs/(reference)/api-reference/hooks/primitives.mdx +19 -420
  43. package/.docs/raw/docs/(reference)/api-reference/hooks/state.mdx +4 -1
  44. package/.docs/raw/docs/(reference)/api-reference/integrations/react-ai-sdk.mdx +21 -0
  45. package/.docs/raw/docs/(reference)/api-reference/model-context/context.mdx +1 -9
  46. package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-if.mdx +1 -18
  47. package/.docs/raw/docs/cloud/langgraph.mdx +1 -1
  48. package/.docs/raw/docs/copilots/model-context.mdx +1 -1
  49. package/.docs/raw/docs/copilots/motivation.mdx +1 -1
  50. package/.docs/raw/docs/guides/attachments.mdx +3 -3
  51. package/.docs/raw/docs/guides/branching.mdx +2 -2
  52. package/.docs/raw/docs/guides/context-api.mdx +89 -111
  53. package/.docs/raw/docs/guides/editing.mdx +5 -5
  54. package/.docs/raw/docs/guides/electron.mdx +369 -0
  55. package/.docs/raw/docs/guides/index.mdx +10 -0
  56. package/.docs/raw/docs/guides/quoting.mdx +3 -3
  57. package/.docs/raw/docs/guides/resumable-stream-deployment.mdx +2 -2
  58. package/.docs/raw/docs/ink/hooks.mdx +3 -3
  59. package/.docs/raw/docs/ink/primitives.mdx +14 -7
  60. package/.docs/raw/docs/integrations/auth/better-auth.mdx +2 -2
  61. package/.docs/raw/docs/integrations/auth/clerk.mdx +2 -2
  62. package/.docs/raw/docs/integrations/auth/next-auth.mdx +3 -3
  63. package/.docs/raw/docs/integrations/observability/langsmith.mdx +1 -1
  64. package/.docs/raw/docs/integrations/persistence/custom-adapter.mdx +36 -9
  65. package/.docs/raw/docs/migrations/v0-15.mdx +156 -0
  66. package/.docs/raw/docs/primitives/composer.mdx +1 -1
  67. package/.docs/raw/docs/primitives/thread-list.mdx +2 -2
  68. package/.docs/raw/docs/react-native/hooks.mdx +3 -3
  69. package/.docs/raw/docs/react-native/index.mdx +2 -2
  70. package/.docs/raw/docs/react-native/primitives.mdx +39 -5
  71. package/.docs/raw/docs/runtimes/ai-sdk/overview.mdx +3 -3
  72. package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +4 -4
  73. package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +4 -4
  74. package/.docs/raw/docs/runtimes/ai-sdk/v6-legacy.mdx +4 -4
  75. package/.docs/raw/docs/runtimes/ai-sdk/v7.mdx +2 -2
  76. package/.docs/raw/docs/runtimes/concepts/threads.mdx +10 -10
  77. package/.docs/raw/docs/runtimes/custom/assistant-transport.mdx +2 -2
  78. package/.docs/raw/docs/runtimes/custom/external-store.mdx +1 -1
  79. package/.docs/raw/docs/runtimes/custom/local-runtime.mdx +3 -3
  80. package/.docs/raw/docs/runtimes/langchain.mdx +2 -2
  81. package/.docs/raw/docs/runtimes/langgraph/overview.mdx +1 -1
  82. package/.docs/raw/docs/runtimes/opencode/hooks.mdx +3 -1
  83. package/.docs/raw/docs/tools/a2ui.mdx +107 -0
  84. package/.docs/raw/docs/tools/interactables-legacy.mdx +4 -4
  85. package/.docs/raw/docs/tools/interactables.mdx +3 -3
  86. package/.docs/raw/docs/tools/mcp-apps.mdx +61 -2
  87. package/.docs/raw/docs/tools/user-managed-mcp.mdx +52 -7
  88. package/.docs/raw/docs/ui/follow-up-suggestions.mdx +2 -0
  89. package/.docs/raw/docs/ui/model-selector.mdx +1 -1
  90. package/.docs/raw/docs/ui/part-grouping.mdx +0 -4
  91. package/.docs/raw/docs/ui/reasoning.mdx +1 -1
  92. package/dist/index.d.ts +1 -1
  93. package/dist/index.js +2 -2
  94. package/dist/index.js.map +1 -1
  95. package/dist/prepare-docs/code-examples.js.map +1 -1
  96. package/dist/prepare-docs/prepare.d.ts +1 -1
  97. package/dist/stdio.d.ts +1 -1
  98. package/dist/tools/docs.d.ts +6 -10
  99. package/dist/tools/docs.d.ts.map +1 -1
  100. package/dist/tools/docs.js +2 -2
  101. package/dist/tools/docs.js.map +1 -1
  102. package/dist/tools/examples.d.ts +4 -8
  103. package/dist/tools/examples.d.ts.map +1 -1
  104. package/dist/tools/examples.js +2 -2
  105. package/dist/tools/examples.js.map +1 -1
  106. package/dist/tools/resources.d.ts +1 -1
  107. package/dist/tools/resources.d.ts.map +1 -1
  108. package/dist/tools/resources.js +1 -1
  109. package/dist/tools/resources.js.map +1 -1
  110. package/dist/tools/search.d.ts +4 -10
  111. package/dist/tools/search.d.ts.map +1 -1
  112. package/dist/tools/search.js +2 -2
  113. package/dist/tools/search.js.map +1 -1
  114. package/dist/tools/tests/mcp-test-client.d.ts +15 -0
  115. package/dist/tools/tests/mcp-test-client.d.ts.map +1 -0
  116. package/dist/tools/tests/mcp-test-client.js +68 -0
  117. package/dist/tools/tests/mcp-test-client.js.map +1 -0
  118. package/dist/tools/tests/test-setup.d.ts.map +1 -1
  119. package/dist/tools/xulux-templates.d.ts +9 -23
  120. package/dist/tools/xulux-templates.d.ts.map +1 -1
  121. package/dist/tools/xulux-templates.js +4 -4
  122. package/dist/tools/xulux-templates.js.map +1 -1
  123. package/dist/utils/logger.d.ts.map +1 -1
  124. package/dist/utils/security.js.map +1 -1
  125. package/package.json +4 -3
  126. package/src/index.ts +2 -2
  127. package/src/tools/docs.ts +2 -2
  128. package/src/tools/examples.ts +2 -2
  129. package/src/tools/resources.ts +1 -4
  130. package/src/tools/search.ts +2 -2
  131. package/src/tools/tests/completions.test.ts +40 -26
  132. package/src/tools/tests/integration.test.ts +3 -4
  133. package/src/tools/tests/mcp-protocol.test.ts +160 -175
  134. package/src/tools/tests/mcp-test-client.ts +111 -0
  135. package/src/tools/tests/resources.test.ts +97 -66
  136. package/src/tools/xulux-templates.ts +4 -4
@@ -1,102 +1,133 @@
1
- import { describe, it, expect } from "vitest";
1
+ import { afterEach, beforeEach, describe, expect, it } from "vitest";
2
2
  import { server } from "../../index.js";
3
+ import { createMcpTestClient, type McpTestClient } from "./mcp-test-client.js";
3
4
 
4
- function handler(method: string) {
5
- const handlers = (server as any).server._requestHandlers;
6
- const h = handlers.get(method);
7
- if (!h) throw new Error(`No handler for ${method}`);
8
- return h;
5
+ type Resource = {
6
+ uri: string;
7
+ };
8
+
9
+ type ResourceListResult = {
10
+ resources: Resource[];
11
+ };
12
+
13
+ type ResourceReadResult = {
14
+ contents: Array<{
15
+ mimeType?: string;
16
+ text?: string;
17
+ }>;
18
+ };
19
+
20
+ function requireResource(resources: Resource[], prefix: string): Resource {
21
+ const resource = resources.find((candidate) =>
22
+ candidate.uri.startsWith(prefix),
23
+ );
24
+ expect(resource).toBeDefined();
25
+ if (!resource) throw new Error(`Missing resource with URI prefix: ${prefix}`);
26
+ return resource;
9
27
  }
10
28
 
11
29
  describe("MCP resources", () => {
30
+ let client: McpTestClient;
31
+
32
+ beforeEach(async () => {
33
+ client = await createMcpTestClient(server);
34
+ await client.initialize();
35
+ });
36
+
37
+ afterEach(async () => {
38
+ await client?.close();
39
+ });
40
+
12
41
  it("lists docs and example resources", async () => {
13
- const result = await handler("resources/list")(
14
- { method: "resources/list", params: {} },
15
- {},
16
- );
42
+ const result = await client.request<ResourceListResult>({
43
+ method: "resources/list",
44
+ params: {},
45
+ });
46
+
17
47
  expect(result.resources.length).toBeGreaterThan(0);
18
48
  expect(
19
- result.resources.some((r: any) => r.uri.startsWith("aui-docs:///")),
49
+ result.resources.some((resource) =>
50
+ resource.uri.startsWith("aui-docs:///"),
51
+ ),
20
52
  ).toBe(true);
21
53
  expect(
22
- result.resources.some((r: any) => r.uri.startsWith("aui-example:///")),
54
+ result.resources.some((resource) =>
55
+ resource.uri.startsWith("aui-example:///"),
56
+ ),
23
57
  ).toBe(true);
24
58
  });
25
59
 
26
60
  it("reads a documentation resource as markdown", async () => {
27
- const list = await handler("resources/list")(
28
- { method: "resources/list", params: {} },
29
- {},
30
- );
31
- const doc = list.resources.find((r: any) =>
32
- r.uri.startsWith("aui-docs:///"),
33
- );
34
- const read = await handler("resources/read")(
35
- { method: "resources/read", params: { uri: doc.uri } },
36
- {},
37
- );
38
- expect(read.contents[0].mimeType).toBe("text/markdown");
39
- expect(typeof read.contents[0].text).toBe("string");
40
- expect(read.contents[0].text.length).toBeGreaterThan(0);
61
+ const list = await client.request<ResourceListResult>({
62
+ method: "resources/list",
63
+ params: {},
64
+ });
65
+ const doc = requireResource(list.resources, "aui-docs:///");
66
+ const read = await client.request<ResourceReadResult>({
67
+ method: "resources/read",
68
+ params: { uri: doc.uri },
69
+ });
70
+
71
+ expect(read.contents[0]?.mimeType).toBe("text/markdown");
72
+ expect(typeof read.contents[0]?.text).toBe("string");
73
+ expect(read.contents[0]?.text.length).toBeGreaterThan(0);
41
74
  });
42
75
 
43
76
  it("reads a slash-containing documentation resource", async () => {
44
- const list = await handler("resources/list")(
45
- { method: "resources/list", params: {} },
46
- {},
47
- );
77
+ const list = await client.request<ResourceListResult>({
78
+ method: "resources/list",
79
+ params: {},
80
+ });
48
81
  const prefix = "aui-docs:///";
49
82
  const nested = list.resources.find(
50
- (r: any) =>
51
- r.uri.startsWith(prefix) && r.uri.slice(prefix.length).includes("/"),
83
+ (resource) =>
84
+ resource.uri.startsWith(prefix) &&
85
+ resource.uri.slice(prefix.length).includes("/"),
52
86
  );
87
+
53
88
  expect(nested).toBeDefined();
54
- const read = await handler("resources/read")(
55
- { method: "resources/read", params: { uri: nested.uri } },
56
- {},
57
- );
58
- expect(read.contents[0].mimeType).toBe("text/markdown");
59
- expect(read.contents[0].text.length).toBeGreaterThan(0);
89
+ if (!nested) throw new Error("Missing nested documentation resource");
90
+
91
+ const read = await client.request<ResourceReadResult>({
92
+ method: "resources/read",
93
+ params: { uri: nested.uri },
94
+ });
95
+
96
+ expect(read.contents[0]?.mimeType).toBe("text/markdown");
97
+ expect(read.contents[0]?.text.length).toBeGreaterThan(0);
60
98
  });
61
99
 
62
100
  it("errors on an unknown documentation resource", async () => {
63
101
  await expect(
64
- handler("resources/read")(
65
- {
66
- method: "resources/read",
67
- params: { uri: "aui-docs:///definitely-not-a-real-doc" },
68
- },
69
- {},
70
- ),
102
+ client.request({
103
+ method: "resources/read",
104
+ params: { uri: "aui-docs:///definitely-not-a-real-doc" },
105
+ }),
71
106
  ).rejects.toThrow();
72
107
  });
73
108
 
74
109
  it("reads an example resource as markdown", async () => {
75
- const list = await handler("resources/list")(
76
- { method: "resources/list", params: {} },
77
- {},
78
- );
79
- const example = list.resources.find((r: any) =>
80
- r.uri.startsWith("aui-example:///"),
81
- );
82
- const read = await handler("resources/read")(
83
- { method: "resources/read", params: { uri: example.uri } },
84
- {},
85
- );
86
- expect(read.contents[0].mimeType).toBe("text/markdown");
87
- expect(typeof read.contents[0].text).toBe("string");
88
- expect(read.contents[0].text.length).toBeGreaterThan(0);
110
+ const list = await client.request<ResourceListResult>({
111
+ method: "resources/list",
112
+ params: {},
113
+ });
114
+ const example = requireResource(list.resources, "aui-example:///");
115
+ const read = await client.request<ResourceReadResult>({
116
+ method: "resources/read",
117
+ params: { uri: example.uri },
118
+ });
119
+
120
+ expect(read.contents[0]?.mimeType).toBe("text/markdown");
121
+ expect(typeof read.contents[0]?.text).toBe("string");
122
+ expect(read.contents[0]?.text.length).toBeGreaterThan(0);
89
123
  });
90
124
 
91
125
  it("errors on an unknown example resource", async () => {
92
126
  await expect(
93
- handler("resources/read")(
94
- {
95
- method: "resources/read",
96
- params: { uri: "aui-example:///definitely-not-a-real-example" },
97
- },
98
- {},
99
- ),
127
+ client.request({
128
+ method: "resources/read",
129
+ params: { uri: "aui-example:///definitely-not-a-real-example" },
130
+ }),
100
131
  ).rejects.toThrow();
101
132
  });
102
133
  });
@@ -1,4 +1,4 @@
1
- import { z } from "zod/v3";
1
+ import { z } from "zod";
2
2
  import { logger } from "../utils/logger.js";
3
3
  import { formatMCPResponse } from "../utils/mcp-format.js";
4
4
  import { getXuluxCatalog } from "../xulux/catalog-client.js";
@@ -56,7 +56,7 @@ export const xuluxTemplatesListTool = {
56
56
  "Call this first for any assistant-ui app-building request. Use the features and customizable fields to decide which template fits. " +
57
57
  "If customizable is empty, the entry is a fixed demo that should be used as-is rather than configured. " +
58
58
  "Call assistantUITemplateDetails on the chosen template before requesting a preview.",
59
- parameters: emptyInputSchema.shape,
59
+ parameters: emptyInputSchema,
60
60
  execute: async (_args: z.infer<typeof emptyInputSchema>) => {
61
61
  logger.info("Listing assistant-ui templates");
62
62
  try {
@@ -82,7 +82,7 @@ export const xuluxTemplateDetailsTool = {
82
82
  "Fixed demos return no configRoots; use those as-is without config. " +
83
83
  "Use this before calling assistantUITemplatePreview to understand exactly what config to write. " +
84
84
  "If assistantUITemplatePreview returns validationWarnings, call this again and cross-reference configRoots to correct the config.",
85
- parameters: detailsInputSchema.shape,
85
+ parameters: detailsInputSchema,
86
86
  execute: async (args: z.infer<typeof detailsInputSchema>) => {
87
87
  logger.info(
88
88
  `Getting assistant-ui template details for: ${args.templateId}`,
@@ -115,7 +115,7 @@ export const xuluxTemplatePreviewTool = {
115
115
  "If you pass config, a preview session is created on the hosted template sandbox and the returned URLs reflect that configuration. " +
116
116
  "Do not pass config for fixed demos that have no configRoots in assistantUITemplateDetails. " +
117
117
  "This tool only returns URLs.",
118
- parameters: previewInputSchema.shape,
118
+ parameters: previewInputSchema,
119
119
  execute: async (args: z.infer<typeof previewInputSchema>) => {
120
120
  logger.info(
121
121
  `Creating assistant-ui template preview for: ${args.templateId}`,