@assistant-ui/mcp-docs-server 0.1.39 → 0.2.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.
- package/.docs/organized/code-examples/waterfall.md +17 -18
- package/.docs/organized/code-examples/with-a2a.md +20 -15
- package/.docs/organized/code-examples/with-ag-ui.md +19 -17
- package/.docs/organized/code-examples/with-ai-sdk-v7.md +17 -16
- package/.docs/organized/code-examples/with-artifacts.md +471 -145
- package/.docs/organized/code-examples/with-assistant-transport.md +23 -31
- package/.docs/organized/code-examples/with-browser-extension.md +21 -14
- package/.docs/organized/code-examples/with-chain-of-thought.md +22 -20
- package/.docs/organized/code-examples/with-cloud-standalone.md +13 -14
- package/.docs/organized/code-examples/with-cloud.md +22 -17
- package/.docs/organized/code-examples/with-custom-thread-list.md +17 -16
- package/.docs/organized/code-examples/with-elevenlabs-conversational.md +17 -17
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +21 -19
- package/.docs/organized/code-examples/with-eve.md +70 -16
- package/.docs/organized/code-examples/with-expo.md +32 -51
- package/.docs/organized/code-examples/with-external-store.md +20 -15
- package/.docs/organized/code-examples/with-ffmpeg.md +24 -18
- package/.docs/organized/code-examples/with-generative-ui.md +20 -21
- package/.docs/organized/code-examples/with-google-adk.md +21 -16
- package/.docs/organized/code-examples/with-heat-graph.md +10 -11
- package/.docs/organized/code-examples/with-image-generation.md +13 -14
- package/.docs/organized/code-examples/with-interactables.md +17 -16
- package/.docs/organized/code-examples/with-langchain.md +13 -14
- package/.docs/organized/code-examples/with-langgraph.md +23 -17
- package/.docs/organized/code-examples/with-livekit.md +17 -17
- package/.docs/organized/code-examples/with-mcp.md +36 -32
- package/.docs/organized/code-examples/with-nuxt.md +2492 -0
- package/.docs/organized/code-examples/with-opencode.md +27 -21
- package/.docs/organized/code-examples/with-pi.md +69 -67
- package/.docs/organized/code-examples/with-react-hook-form.md +18 -17
- package/.docs/organized/code-examples/with-react-ink-web.md +10 -11
- package/.docs/organized/code-examples/with-react-ink.md +7 -7
- package/.docs/organized/code-examples/with-react-router.md +23 -17
- package/.docs/organized/code-examples/with-resumable-stream.md +15 -16
- package/.docs/organized/code-examples/with-store.md +31 -20
- package/.docs/organized/code-examples/with-tanstack.md +22 -16
- package/.docs/organized/code-examples/with-tap-runtime.md +19 -19
- package/.docs/organized/code-examples/with-virtualized-thread.md +12 -13
- package/.docs/organized/code-examples/with-vue.md +408 -0
- package/.docs/raw/docs/(docs)/cli.mdx +3 -1
- package/.docs/raw/docs/(docs)/devtools.mdx +7 -2
- package/.docs/raw/docs/(docs)/index.mdx +9 -76
- package/.docs/raw/docs/(docs)/installation.mdx +4 -18
- package/.docs/raw/docs/(reference)/api-reference/context-providers/assistant-runtime-provider.mdx +24 -4
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/a2ui.mdx +40 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/index.mdx +3 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/primitives.mdx +19 -420
- package/.docs/raw/docs/(reference)/api-reference/hooks/state.mdx +4 -1
- package/.docs/raw/docs/(reference)/api-reference/integrations/eve.mdx +8 -0
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-ai-sdk.mdx +21 -0
- package/.docs/raw/docs/(reference)/api-reference/model-context/context.mdx +1 -9
- package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-if.mdx +1 -18
- package/.docs/raw/docs/(reference)/api-reference/utilities/miscellaneous.mdx +24 -1
- package/.docs/raw/docs/cloud/ai-sdk-assistant-ui.mdx +1 -1
- package/.docs/raw/docs/cloud/ai-sdk.mdx +2 -2
- package/.docs/raw/docs/cloud/langgraph.mdx +1 -1
- package/.docs/raw/docs/copilots/model-context.mdx +5 -4
- package/.docs/raw/docs/copilots/motivation.mdx +5 -5
- package/.docs/raw/docs/guides/attachments.mdx +3 -3
- package/.docs/raw/docs/guides/branching.mdx +2 -2
- package/.docs/raw/docs/guides/chain-of-thought.mdx +1 -1
- package/.docs/raw/docs/guides/context-api.mdx +89 -111
- package/.docs/raw/docs/guides/editing.mdx +5 -5
- package/.docs/raw/docs/guides/electron.mdx +369 -0
- package/.docs/raw/docs/guides/index.mdx +10 -0
- package/.docs/raw/docs/guides/quoting.mdx +3 -3
- package/.docs/raw/docs/guides/resumable-stream-deployment.mdx +2 -2
- package/.docs/raw/docs/guides/resumable-streams.mdx +74 -3
- package/.docs/raw/docs/guides/suggestions.mdx +9 -9
- package/.docs/raw/docs/ink/hooks.mdx +12 -7
- package/.docs/raw/docs/ink/primitives.mdx +18 -10
- package/.docs/raw/docs/integrations/attachments/custom-adapter.mdx +16 -0
- package/.docs/raw/docs/integrations/auth/better-auth.mdx +3 -3
- package/.docs/raw/docs/integrations/auth/clerk.mdx +3 -3
- package/.docs/raw/docs/integrations/auth/next-auth.mdx +4 -4
- package/.docs/raw/docs/integrations/frameworks/cloudflare-agents/overview.mdx +1 -1
- package/.docs/raw/docs/integrations/frameworks/mastra/full-stack.mdx +2 -2
- package/.docs/raw/docs/integrations/frameworks/mastra/separate-server.mdx +1 -1
- package/.docs/raw/docs/integrations/gateways/index.mdx +2 -2
- package/.docs/raw/docs/integrations/observability/helicone.mdx +2 -2
- package/.docs/raw/docs/integrations/observability/langfuse.mdx +1 -1
- package/.docs/raw/docs/integrations/observability/langsmith.mdx +3 -3
- package/.docs/raw/docs/integrations/persistence/custom-adapter.mdx +36 -9
- package/.docs/raw/docs/migrations/toolkit-tools.mdx +15 -13
- package/.docs/raw/docs/migrations/v0-15.mdx +236 -0
- package/.docs/raw/docs/primitives/attachment.mdx +2 -2
- package/.docs/raw/docs/primitives/composer.mdx +3 -3
- package/.docs/raw/docs/primitives/message.mdx +33 -1
- package/.docs/raw/docs/primitives/suggestion.mdx +1 -1
- package/.docs/raw/docs/primitives/thread-list.mdx +2 -2
- package/.docs/raw/docs/react-native/hooks.mdx +17 -7
- package/.docs/raw/docs/react-native/index.mdx +3 -3
- package/.docs/raw/docs/react-native/primitives.mdx +41 -7
- package/.docs/raw/docs/runtimes/ai-sdk/overview.mdx +3 -3
- package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +5 -5
- package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +5 -5
- package/.docs/raw/docs/runtimes/ai-sdk/v6-legacy.mdx +13 -14
- package/.docs/raw/docs/runtimes/ai-sdk/v7.mdx +11 -12
- package/.docs/raw/docs/runtimes/concepts/threads.mdx +50 -11
- package/.docs/raw/docs/runtimes/custom/assistant-transport.mdx +20 -2
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +31 -2
- package/.docs/raw/docs/runtimes/custom/local-runtime.mdx +39 -12
- package/.docs/raw/docs/runtimes/eve/overview.mdx +51 -0
- package/.docs/raw/docs/runtimes/eve/quickstart.mdx +51 -2
- package/.docs/raw/docs/runtimes/google-adk/hooks.mdx +9 -12
- package/.docs/raw/docs/runtimes/langchain.mdx +2 -2
- package/.docs/raw/docs/runtimes/langgraph/overview.mdx +1 -1
- package/.docs/raw/docs/runtimes/langgraph/streaming.mdx +1 -1
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +7 -7
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +4 -4
- package/.docs/raw/docs/runtimes/opencode/hooks.mdx +4 -1
- package/.docs/raw/docs/runtimes/opencode/overview.mdx +10 -0
- package/.docs/raw/docs/tools/a2ui.mdx +107 -0
- package/.docs/raw/docs/tools/backend.mdx +2 -2
- package/.docs/raw/docs/tools/defining-tools.mdx +9 -7
- package/.docs/raw/docs/tools/dynamic-tools.mdx +6 -4
- package/.docs/raw/docs/tools/interactables-legacy.mdx +28 -15
- package/.docs/raw/docs/tools/interactables.mdx +27 -16
- package/.docs/raw/docs/tools/mcp-apps.mdx +96 -8
- package/.docs/raw/docs/tools/mcp.mdx +9 -7
- package/.docs/raw/docs/tools/tool-ui.mdx +26 -22
- package/.docs/raw/docs/tools/user-managed-mcp.mdx +64 -14
- package/.docs/raw/docs/ui/file.mdx +6 -1
- package/.docs/raw/docs/ui/follow-up-suggestions.mdx +2 -0
- package/.docs/raw/docs/ui/mcp-config.mdx +8 -3
- package/.docs/raw/docs/ui/model-selector.mdx +9 -9
- package/.docs/raw/docs/ui/part-grouping.mdx +1 -5
- package/.docs/raw/docs/ui/reasoning.mdx +1 -1
- package/.docs/raw/docs/ui/thread.mdx +24 -5
- package/.docs/raw/docs/utilities/react-o11y.mdx +7 -9
- package/dist/constants.js +2 -2
- package/dist/constants.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/prepare-docs/code-examples.js.map +1 -1
- package/dist/prepare-docs/prepare.d.ts +1 -1
- package/dist/prepare-docs/prepare.js.map +1 -1
- package/dist/stdio.d.ts +1 -1
- package/dist/tools/docs.d.ts +6 -10
- package/dist/tools/docs.d.ts.map +1 -1
- package/dist/tools/docs.js +6 -4
- package/dist/tools/docs.js.map +1 -1
- package/dist/tools/examples.d.ts +4 -8
- package/dist/tools/examples.d.ts.map +1 -1
- package/dist/tools/examples.js +4 -3
- package/dist/tools/examples.js.map +1 -1
- package/dist/tools/resources.d.ts +1 -1
- package/dist/tools/resources.d.ts.map +1 -1
- package/dist/tools/resources.js +3 -2
- package/dist/tools/resources.js.map +1 -1
- package/dist/tools/search.d.ts +4 -10
- package/dist/tools/search.d.ts.map +1 -1
- package/dist/tools/search.js +2 -2
- package/dist/tools/search.js.map +1 -1
- package/dist/tools/tests/mcp-test-client.d.ts +15 -0
- package/dist/tools/tests/mcp-test-client.d.ts.map +1 -0
- package/dist/tools/tests/mcp-test-client.js +68 -0
- package/dist/tools/tests/mcp-test-client.js.map +1 -0
- package/dist/tools/tests/test-setup.d.ts.map +1 -1
- package/dist/tools/tests/test-setup.js +2 -1
- package/dist/tools/tests/test-setup.js.map +1 -1
- package/dist/tools/xulux-templates.d.ts +9 -23
- package/dist/tools/xulux-templates.d.ts.map +1 -1
- package/dist/tools/xulux-templates.js +8 -6
- package/dist/tools/xulux-templates.js.map +1 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/mdx.js +2 -1
- package/dist/utils/mdx.js.map +1 -1
- package/dist/utils/security.js.map +1 -1
- package/dist/xulux/catalog-client.js +1 -1
- package/dist/xulux/catalog-client.js.map +1 -1
- package/package.json +6 -5
- package/src/index.ts +2 -2
- package/src/tools/docs.ts +2 -2
- package/src/tools/examples.ts +2 -2
- package/src/tools/resources.ts +1 -4
- package/src/tools/search.ts +2 -2
- package/src/tools/tests/completions.test.ts +40 -26
- package/src/tools/tests/docs.test.ts +2 -2
- package/src/tools/tests/integration.test.ts +3 -4
- package/src/tools/tests/mcp-protocol.test.ts +160 -175
- package/src/tools/tests/mcp-test-client.ts +111 -0
- package/src/tools/tests/resources.test.ts +97 -66
- package/src/tools/xulux-templates.ts +4 -4
package/dist/tools/search.d.ts
CHANGED
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
import { z } from "zod
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
//#region src/tools/search.d.ts
|
|
3
3
|
declare const searchInputSchema: z.ZodObject<{
|
|
4
4
|
query: z.ZodString;
|
|
5
5
|
limit: z.ZodDefault<z.ZodNumber>;
|
|
6
|
-
},
|
|
7
|
-
query: string;
|
|
8
|
-
limit: number;
|
|
9
|
-
}, {
|
|
10
|
-
query: string;
|
|
11
|
-
limit?: number | undefined;
|
|
12
|
-
}>;
|
|
6
|
+
}, z.core.$strip>;
|
|
13
7
|
declare const searchTools: {
|
|
14
8
|
name: string;
|
|
15
9
|
description: string;
|
|
16
|
-
parameters: {
|
|
10
|
+
parameters: z.ZodObject<{
|
|
17
11
|
query: z.ZodString;
|
|
18
12
|
limit: z.ZodDefault<z.ZodNumber>;
|
|
19
|
-
}
|
|
13
|
+
}, z.core.$strip>;
|
|
20
14
|
execute: ({ query, limit }: z.infer<typeof searchInputSchema>) => Promise<{
|
|
21
15
|
content: Array<{
|
|
22
16
|
type: "text";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","names":[],"sources":["../../src/tools/search.ts"],"mappings":";;cAKM,mBAAiB,EAAA
|
|
1
|
+
{"version":3,"file":"search.d.ts","names":[],"sources":["../../src/tools/search.ts"],"mappings":";;cAKM,mBAAiB,EAAA;;;GAYrB,EAAA,KAAA;cAEW;;;;;;;EAKuB,YAAA,OAAA,SAAA,EAAE,aAAa,uBAAkB"}
|
package/dist/tools/search.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { logger } from "../utils/logger.js";
|
|
2
2
|
import { formatMCPResponse } from "../utils/mcp-format.js";
|
|
3
3
|
import { searchDocs } from "../utils/search.js";
|
|
4
|
-
import { z } from "zod
|
|
4
|
+
import { z } from "zod";
|
|
5
5
|
const searchTools = {
|
|
6
6
|
name: "assistantUISearch",
|
|
7
7
|
description: "Search assistant-ui documentation by keyword. Returns ranked matches with their doc path, title, and a snippet. Fetch full content with assistantUIDocs using a returned path.",
|
|
8
8
|
parameters: z.object({
|
|
9
9
|
query: z.string().min(1).describe("Keyword(s) to search assistant-ui documentation for."),
|
|
10
10
|
limit: z.number().int().min(1).max(25).default(10).describe("Maximum number of results to return (default 10).")
|
|
11
|
-
})
|
|
11
|
+
}),
|
|
12
12
|
execute: async ({ query, limit }) => {
|
|
13
13
|
logger.info(`Searching documentation for: ${query}`);
|
|
14
14
|
try {
|
package/dist/tools/search.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.js","names":[],"sources":["../../src/tools/search.ts"],"sourcesContent":["import { z } from \"zod
|
|
1
|
+
{"version":3,"file":"search.js","names":[],"sources":["../../src/tools/search.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { logger } from \"../utils/logger.js\";\nimport { formatMCPResponse } from \"../utils/mcp-format.js\";\nimport { searchDocs } from \"../utils/search.js\";\n\nconst searchInputSchema = z.object({\n query: z\n .string()\n .min(1)\n .describe(\"Keyword(s) to search assistant-ui documentation for.\"),\n limit: z\n .number()\n .int()\n .min(1)\n .max(25)\n .default(10)\n .describe(\"Maximum number of results to return (default 10).\"),\n});\n\nexport const searchTools = {\n name: \"assistantUISearch\",\n description:\n \"Search assistant-ui documentation by keyword. Returns ranked matches with their doc path, title, and a snippet. Fetch full content with assistantUIDocs using a returned path.\",\n parameters: searchInputSchema,\n execute: async ({ query, limit }: z.infer<typeof searchInputSchema>) => {\n logger.info(`Searching documentation for: ${query}`);\n try {\n const results = await searchDocs(query, limit);\n if (results.length === 0) {\n return formatMCPResponse({\n query,\n results: [],\n total: 0,\n hint: 'No matches. Use assistantUIDocs with \"/\" to list all sections.',\n });\n }\n return formatMCPResponse({ query, results, total: results.length });\n } catch (error) {\n logger.error(\"Failed to search documentation\", error);\n return formatMCPResponse({\n error: \"Failed to search documentation\",\n message: error instanceof Error ? error.message : String(error),\n });\n }\n },\n};\n"],"mappings":";;;;AAmBA,MAAa,cAAc;CACzB,MAAM;CACN,aACE;CACF,YAlBwB,EAAE,OAAO;EACjC,OAAO,EACJ,OAAO,CAAC,CACR,IAAI,CAAC,CAAC,CACN,SAAS,sDAAsD;EAClE,OAAO,EACJ,OAAO,CAAC,CACR,IAAI,CAAC,CACL,IAAI,CAAC,CAAC,CACN,IAAI,EAAE,CAAC,CACP,QAAQ,EAAE,CAAC,CACX,SAAS,mDAAmD;CACjE,CAMc;CACZ,SAAS,OAAO,EAAE,OAAO,YAA+C;EACtE,OAAO,KAAK,gCAAgC,OAAO;EACnD,IAAI;GACF,MAAM,UAAU,MAAM,WAAW,OAAO,KAAK;GAC7C,IAAI,QAAQ,WAAW,GACrB,OAAO,kBAAkB;IACvB;IACA,SAAS,CAAC;IACV,OAAO;IACP,MAAM;GACR,CAAC;GAEH,OAAO,kBAAkB;IAAE;IAAO;IAAS,OAAO,QAAQ;GAAO,CAAC;EACpE,SAAS,OAAO;GACd,OAAO,MAAM,kCAAkC,KAAK;GACpD,OAAO,kBAAkB;IACvB,OAAO;IACP,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GAChE,CAAC;EACH;CACF;AACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/server";
|
|
2
|
+
//#region src/tools/tests/mcp-test-client.d.ts
|
|
3
|
+
type RawMcpRequest = {
|
|
4
|
+
method: string;
|
|
5
|
+
params?: unknown;
|
|
6
|
+
};
|
|
7
|
+
type McpTestClient = {
|
|
8
|
+
initialize: () => Promise<unknown>;
|
|
9
|
+
request: <Result>(request: RawMcpRequest) => Promise<Result>;
|
|
10
|
+
close: () => Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
declare function createMcpTestClient(server: McpServer): Promise<McpTestClient>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { McpTestClient, createMcpTestClient };
|
|
15
|
+
//# sourceMappingURL=mcp-test-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-test-client.d.ts","names":[],"sources":["../../../src/tools/tests/mcp-test-client.ts"],"mappings":";;KAKK;EACH;EACA;;KAiBU;EACV,kBAAkB;EAClB,UAAU,QAAQ,SAAS,kBAAkB,QAAQ;EACrD,aAAa;;iBAaO,oBACpB,QAAQ,YACP,QAAQ"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { InMemoryTransport } from "@modelcontextprotocol/server";
|
|
2
|
+
//#region src/tools/tests/mcp-test-client.ts
|
|
3
|
+
function isJsonRpcResponse(message) {
|
|
4
|
+
return typeof message === "object" && message !== null && "id" in message && typeof message.id === "number" && ("result" in message || "error" in message);
|
|
5
|
+
}
|
|
6
|
+
async function createMcpTestClient(server) {
|
|
7
|
+
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
|
8
|
+
const pendingRequests = /* @__PURE__ */ new Map();
|
|
9
|
+
let nextRequestId = 1;
|
|
10
|
+
clientTransport.onmessage = (message) => {
|
|
11
|
+
if (!isJsonRpcResponse(message)) return;
|
|
12
|
+
const pendingRequest = pendingRequests.get(message.id);
|
|
13
|
+
if (!pendingRequest) return;
|
|
14
|
+
pendingRequests.delete(message.id);
|
|
15
|
+
if (message.error) {
|
|
16
|
+
pendingRequest.reject(/* @__PURE__ */ new Error(`MCP request failed (${message.error.code}): ${message.error.message}`));
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
pendingRequest.resolve(message.result);
|
|
20
|
+
};
|
|
21
|
+
await clientTransport.start();
|
|
22
|
+
await server.connect(serverTransport);
|
|
23
|
+
const request = (rawRequest) => {
|
|
24
|
+
const id = nextRequestId++;
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
pendingRequests.set(id, {
|
|
27
|
+
resolve,
|
|
28
|
+
reject
|
|
29
|
+
});
|
|
30
|
+
clientTransport.send({
|
|
31
|
+
jsonrpc: "2.0",
|
|
32
|
+
id,
|
|
33
|
+
...rawRequest
|
|
34
|
+
}).catch((error) => {
|
|
35
|
+
pendingRequests.delete(id);
|
|
36
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
initialize: async () => {
|
|
42
|
+
const result = await request({
|
|
43
|
+
method: "initialize",
|
|
44
|
+
params: {
|
|
45
|
+
protocolVersion: "2025-11-25",
|
|
46
|
+
capabilities: {},
|
|
47
|
+
clientInfo: {
|
|
48
|
+
name: "mcp-docs-server-tests",
|
|
49
|
+
version: "1.0.0"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
await clientTransport.send({
|
|
54
|
+
jsonrpc: "2.0",
|
|
55
|
+
method: "notifications/initialized"
|
|
56
|
+
});
|
|
57
|
+
return result;
|
|
58
|
+
},
|
|
59
|
+
request,
|
|
60
|
+
close: async () => {
|
|
61
|
+
await clientTransport.close();
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
export { createMcpTestClient };
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=mcp-test-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-test-client.js","names":[],"sources":["../../../src/tools/tests/mcp-test-client.ts"],"sourcesContent":["import {\n InMemoryTransport,\n type McpServer,\n} from \"@modelcontextprotocol/server\";\n\ntype RawMcpRequest = {\n method: string;\n params?: unknown;\n};\n\ntype JsonRpcResponse = {\n id: number;\n result?: unknown;\n error?: {\n code: number;\n message: string;\n };\n};\n\ntype PendingRequest = {\n resolve: (result: unknown) => void;\n reject: (error: Error) => void;\n};\n\nexport type McpTestClient = {\n initialize: () => Promise<unknown>;\n request: <Result>(request: RawMcpRequest) => Promise<Result>;\n close: () => Promise<void>;\n};\n\nfunction isJsonRpcResponse(message: unknown): message is JsonRpcResponse {\n return (\n typeof message === \"object\" &&\n message !== null &&\n \"id\" in message &&\n typeof message.id === \"number\" &&\n (\"result\" in message || \"error\" in message)\n );\n}\n\nexport async function createMcpTestClient(\n server: McpServer,\n): Promise<McpTestClient> {\n const [clientTransport, serverTransport] =\n InMemoryTransport.createLinkedPair();\n const pendingRequests = new Map<number, PendingRequest>();\n let nextRequestId = 1;\n\n clientTransport.onmessage = (message) => {\n if (!isJsonRpcResponse(message)) return;\n\n const pendingRequest = pendingRequests.get(message.id);\n if (!pendingRequest) return;\n\n pendingRequests.delete(message.id);\n if (message.error) {\n pendingRequest.reject(\n new Error(\n `MCP request failed (${message.error.code}): ${message.error.message}`,\n ),\n );\n return;\n }\n\n pendingRequest.resolve(message.result);\n };\n\n await clientTransport.start();\n await server.connect(serverTransport);\n\n const request = <Result>(rawRequest: RawMcpRequest): Promise<Result> => {\n const id = nextRequestId++;\n\n return new Promise((resolve, reject) => {\n pendingRequests.set(id, { resolve, reject });\n void clientTransport\n .send({ jsonrpc: \"2.0\", id, ...rawRequest })\n .catch((error: unknown) => {\n pendingRequests.delete(id);\n reject(error instanceof Error ? error : new Error(String(error)));\n });\n }) as Promise<Result>;\n };\n\n return {\n initialize: async () => {\n const result = await request({\n method: \"initialize\",\n params: {\n protocolVersion: \"2025-11-25\",\n capabilities: {},\n clientInfo: {\n name: \"mcp-docs-server-tests\",\n version: \"1.0.0\",\n },\n },\n });\n\n await clientTransport.send({\n jsonrpc: \"2.0\",\n method: \"notifications/initialized\",\n });\n\n return result;\n },\n request,\n close: async () => {\n await clientTransport.close();\n },\n };\n}\n"],"mappings":";;AA8BA,SAAS,kBAAkB,SAA8C;CACvE,OACE,OAAO,YAAY,YACnB,YAAY,QACZ,QAAQ,WACR,OAAO,QAAQ,OAAO,aACrB,YAAY,WAAW,WAAW;AAEvC;AAEA,eAAsB,oBACpB,QACwB;CACxB,MAAM,CAAC,iBAAiB,mBACtB,kBAAkB,iBAAiB;CACrC,MAAM,kCAAkB,IAAI,IAA4B;CACxD,IAAI,gBAAgB;CAEpB,gBAAgB,aAAa,YAAY;EACvC,IAAI,CAAC,kBAAkB,OAAO,GAAG;EAEjC,MAAM,iBAAiB,gBAAgB,IAAI,QAAQ,EAAE;EACrD,IAAI,CAAC,gBAAgB;EAErB,gBAAgB,OAAO,QAAQ,EAAE;EACjC,IAAI,QAAQ,OAAO;GACjB,eAAe,uBACb,IAAI,MACF,uBAAuB,QAAQ,MAAM,KAAK,KAAK,QAAQ,MAAM,SAC/D,CACF;GACA;EACF;EAEA,eAAe,QAAQ,QAAQ,MAAM;CACvC;CAEA,MAAM,gBAAgB,MAAM;CAC5B,MAAM,OAAO,QAAQ,eAAe;CAEpC,MAAM,WAAmB,eAA+C;EACtE,MAAM,KAAK;EAEX,OAAO,IAAI,SAAS,SAAS,WAAW;GACtC,gBAAgB,IAAI,IAAI;IAAE;IAAS;GAAO,CAAC;GAC3C,gBACG,KAAK;IAAE,SAAS;IAAO;IAAI,GAAG;GAAW,CAAC,CAAC,CAC3C,OAAO,UAAmB;IACzB,gBAAgB,OAAO,EAAE;IACzB,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC,CAAC;GAClE,CAAC;EACL,CAAC;CACH;CAEA,OAAO;EACL,YAAY,YAAY;GACtB,MAAM,SAAS,MAAM,QAAQ;IAC3B,QAAQ;IACR,QAAQ;KACN,iBAAiB;KACjB,cAAc,CAAC;KACf,YAAY;MACV,MAAM;MACN,SAAS;KACX;IACF;GACF,CAAC;GAED,MAAM,gBAAgB,KAAK;IACzB,SAAS;IACT,QAAQ;GACV,CAAC;GAED,OAAO;EACT;EACA;EACA,OAAO,YAAY;GACjB,MAAM,gBAAgB,MAAM;EAC9B;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-setup.d.ts","names":[],"sources":["../../../src/tools/tests/test-setup.ts"],"mappings":";cAsBa;
|
|
1
|
+
{"version":3,"file":"test-setup.d.ts","names":[],"sources":["../../../src/tools/tests/test-setup.ts"],"mappings":";cAsBa;EACY,WAAA,cAAM,cAAW"}
|
|
@@ -27,7 +27,8 @@ const testContext = { callTool: async (name, args) => {
|
|
|
27
27
|
}
|
|
28
28
|
} };
|
|
29
29
|
beforeAll(() => {
|
|
30
|
-
|
|
30
|
+
const docsPath = join(PACKAGE_DIR, ".docs");
|
|
31
|
+
if (!existsSync(docsPath)) throw new Error("Documentation not prepared. Run: pnpm build");
|
|
31
32
|
});
|
|
32
33
|
//#endregion
|
|
33
34
|
export { testContext };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-setup.js","names":[],"sources":["../../../src/tools/tests/test-setup.ts"],"sourcesContent":["import { beforeAll } from \"vitest\";\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { PACKAGE_DIR } from \"../../constants.js\";\nimport { docsTools } from \"../docs.js\";\nimport { examplesTools } from \"../examples.js\";\nimport { searchTools } from \"../search.js\";\nimport {\n xuluxTemplatesListTool,\n xuluxTemplateDetailsTool,\n xuluxTemplatePreviewTool,\n} from \"../xulux-templates.js\";\n\nconst tools = {\n assistantUIDocs: docsTools,\n assistantUIExamples: examplesTools,\n assistantUISearch: searchTools,\n assistantUITemplates: xuluxTemplatesListTool,\n assistantUITemplateDetails: xuluxTemplateDetailsTool,\n assistantUITemplatePreview: xuluxTemplatePreviewTool,\n};\n\nexport const testContext = {\n callTool: async (name: string, args: any) => {\n const tool = tools[name as keyof typeof tools];\n if (!tool) {\n throw new Error(`Tool ${name} not found`);\n }\n const result = await tool.execute(args);\n\n const text = result.content?.[0]?.text;\n if (text === undefined) {\n throw new Error(`Tool ${name} returned no content`);\n }\n try {\n return JSON.parse(text);\n } catch (error) {\n throw new Error(\n `Tool ${name} returned invalid JSON. Output: ${text}\\nParse error: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n};\n\nbeforeAll(() => {\n const docsPath = join(PACKAGE_DIR, \".docs\");\n if (!existsSync(docsPath)) {\n throw new Error(\"Documentation not prepared. Run: pnpm build\");\n }\n});\n"],"mappings":";;;;;;;;;AAaA,MAAM,QAAQ;CACZ,iBAAiB;CACjB,qBAAqB;CACrB,mBAAmB;CACnB,sBAAsB;CACtB,4BAA4B;CAC5B,4BAA4B;AAC9B;AAEA,MAAa,cAAc,EACzB,UAAU,OAAO,MAAc,SAAc;CAC3C,MAAM,OAAO,MAAM;CACnB,IAAI,CAAC,MACH,MAAM,IAAI,MAAM,QAAQ,KAAK,WAAW;CAI1C,MAAM,QAAO,MAFQ,KAAK,QAAQ,IAAI,EAAA,CAElB,UAAU,EAAE,EAAE;CAClC,IAAI,SAAS,KAAA,GACX,MAAM,IAAI,MAAM,QAAQ,KAAK,qBAAqB;CAEpD,IAAI;EACF,OAAO,KAAK,MAAM,IAAI;CACxB,SAAS,OAAO;EACd,MAAM,IAAI,MACR,QAAQ,KAAK,kCAAkC,KAAK,iBAAiB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAC5H;CACF;AACF,EACF;AAEA,gBAAgB;
|
|
1
|
+
{"version":3,"file":"test-setup.js","names":[],"sources":["../../../src/tools/tests/test-setup.ts"],"sourcesContent":["import { beforeAll } from \"vitest\";\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { PACKAGE_DIR } from \"../../constants.js\";\nimport { docsTools } from \"../docs.js\";\nimport { examplesTools } from \"../examples.js\";\nimport { searchTools } from \"../search.js\";\nimport {\n xuluxTemplatesListTool,\n xuluxTemplateDetailsTool,\n xuluxTemplatePreviewTool,\n} from \"../xulux-templates.js\";\n\nconst tools = {\n assistantUIDocs: docsTools,\n assistantUIExamples: examplesTools,\n assistantUISearch: searchTools,\n assistantUITemplates: xuluxTemplatesListTool,\n assistantUITemplateDetails: xuluxTemplateDetailsTool,\n assistantUITemplatePreview: xuluxTemplatePreviewTool,\n};\n\nexport const testContext = {\n callTool: async (name: string, args: any) => {\n const tool = tools[name as keyof typeof tools];\n if (!tool) {\n throw new Error(`Tool ${name} not found`);\n }\n const result = await tool.execute(args);\n\n const text = result.content?.[0]?.text;\n if (text === undefined) {\n throw new Error(`Tool ${name} returned no content`);\n }\n try {\n return JSON.parse(text);\n } catch (error) {\n throw new Error(\n `Tool ${name} returned invalid JSON. Output: ${text}\\nParse error: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n};\n\nbeforeAll(() => {\n const docsPath = join(PACKAGE_DIR, \".docs\");\n if (!existsSync(docsPath)) {\n throw new Error(\"Documentation not prepared. Run: pnpm build\");\n }\n});\n"],"mappings":";;;;;;;;;AAaA,MAAM,QAAQ;CACZ,iBAAiB;CACjB,qBAAqB;CACrB,mBAAmB;CACnB,sBAAsB;CACtB,4BAA4B;CAC5B,4BAA4B;AAC9B;AAEA,MAAa,cAAc,EACzB,UAAU,OAAO,MAAc,SAAc;CAC3C,MAAM,OAAO,MAAM;CACnB,IAAI,CAAC,MACH,MAAM,IAAI,MAAM,QAAQ,KAAK,WAAW;CAI1C,MAAM,QAAO,MAFQ,KAAK,QAAQ,IAAI,EAAA,CAElB,UAAU,EAAE,EAAE;CAClC,IAAI,SAAS,KAAA,GACX,MAAM,IAAI,MAAM,QAAQ,KAAK,qBAAqB;CAEpD,IAAI;EACF,OAAO,KAAK,MAAM,IAAI;CACxB,SAAS,OAAO;EACd,MAAM,IAAI,MACR,QAAQ,KAAK,kCAAkC,KAAK,iBAAiB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAC5H;CACF;AACF,EACF;AAEA,gBAAgB;CACd,MAAM,WAAW,KAAK,aAAa,OAAO;CAC1C,IAAI,CAAC,WAAW,QAAQ,GACtB,MAAM,IAAI,MAAM,6CAA6C;AAEjE,CAAC"}
|
|
@@ -1,33 +1,19 @@
|
|
|
1
|
-
import { z } from "zod
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
//#region src/tools/xulux-templates.d.ts
|
|
3
|
-
declare const emptyInputSchema: z.ZodObject<{},
|
|
3
|
+
declare const emptyInputSchema: z.ZodObject<{}, z.core.$strip>;
|
|
4
4
|
declare const detailsInputSchema: z.ZodObject<{
|
|
5
5
|
templateId: z.ZodString;
|
|
6
6
|
versionId: z.ZodOptional<z.ZodString>;
|
|
7
|
-
},
|
|
8
|
-
templateId: string;
|
|
9
|
-
versionId?: string | undefined;
|
|
10
|
-
}, {
|
|
11
|
-
templateId: string;
|
|
12
|
-
versionId?: string | undefined;
|
|
13
|
-
}>;
|
|
7
|
+
}, z.core.$strip>;
|
|
14
8
|
declare const previewInputSchema: z.ZodObject<{
|
|
15
9
|
templateId: z.ZodString;
|
|
16
10
|
versionId: z.ZodOptional<z.ZodString>;
|
|
17
11
|
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
18
|
-
},
|
|
19
|
-
templateId: string;
|
|
20
|
-
versionId?: string | undefined;
|
|
21
|
-
config?: Record<string, unknown> | undefined;
|
|
22
|
-
}, {
|
|
23
|
-
templateId: string;
|
|
24
|
-
versionId?: string | undefined;
|
|
25
|
-
config?: Record<string, unknown> | undefined;
|
|
26
|
-
}>;
|
|
12
|
+
}, z.core.$strip>;
|
|
27
13
|
declare const xuluxTemplatesListTool: {
|
|
28
14
|
name: string;
|
|
29
15
|
description: string;
|
|
30
|
-
parameters: {}
|
|
16
|
+
parameters: z.ZodObject<{}, z.core.$strip>;
|
|
31
17
|
execute: (_args: z.infer<typeof emptyInputSchema>) => Promise<{
|
|
32
18
|
content: Array<{
|
|
33
19
|
type: "text";
|
|
@@ -39,10 +25,10 @@ declare const xuluxTemplatesListTool: {
|
|
|
39
25
|
declare const xuluxTemplateDetailsTool: {
|
|
40
26
|
name: string;
|
|
41
27
|
description: string;
|
|
42
|
-
parameters: {
|
|
28
|
+
parameters: z.ZodObject<{
|
|
43
29
|
templateId: z.ZodString;
|
|
44
30
|
versionId: z.ZodOptional<z.ZodString>;
|
|
45
|
-
}
|
|
31
|
+
}, z.core.$strip>;
|
|
46
32
|
execute: (args: z.infer<typeof detailsInputSchema>) => Promise<{
|
|
47
33
|
content: Array<{
|
|
48
34
|
type: "text";
|
|
@@ -54,11 +40,11 @@ declare const xuluxTemplateDetailsTool: {
|
|
|
54
40
|
declare const xuluxTemplatePreviewTool: {
|
|
55
41
|
name: string;
|
|
56
42
|
description: string;
|
|
57
|
-
parameters: {
|
|
43
|
+
parameters: z.ZodObject<{
|
|
58
44
|
templateId: z.ZodString;
|
|
59
45
|
versionId: z.ZodOptional<z.ZodString>;
|
|
60
46
|
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
61
|
-
}
|
|
47
|
+
}, z.core.$strip>;
|
|
62
48
|
execute: (args: z.infer<typeof previewInputSchema>) => Promise<{
|
|
63
49
|
content: Array<{
|
|
64
50
|
type: "text";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xulux-templates.d.ts","names":[],"sources":["../../src/tools/xulux-templates.ts"],"mappings":";;cAUM,kBAAgB,EAAA,
|
|
1
|
+
{"version":3,"file":"xulux-templates.d.ts","names":[],"sources":["../../src/tools/xulux-templates.ts"],"mappings":";;cAUM,kBAAgB,EAAA,cAAA,EAAA,KAAA;cAEhB,oBAAkB,EAAA;;;GAQtB,EAAA,KAAA;cAEI,oBAAkB,EAAA;;;;GActB,EAAA,KAAA;cAeW;;;;EAQY,UAAA,OAAA,EAAE,aAAa,sBAAiB;;;;;;;;cAiB5C;;;;;;;EASW,UAAA,MAAA,EAAE,aAAa,wBAAmB;;;;;;;;cAwB7C;;;;;;;;EASW,UAAA,MAAA,EAAE,aAAa,wBAAmB"}
|
|
@@ -2,7 +2,7 @@ import { logger } from "../utils/logger.js";
|
|
|
2
2
|
import { formatMCPResponse } from "../utils/mcp-format.js";
|
|
3
3
|
import { getXuluxCatalog } from "../xulux/catalog-client.js";
|
|
4
4
|
import { createTemplatePreview, getTemplateDetails, listTemplates } from "../xulux/template-service.js";
|
|
5
|
-
import { z } from "zod
|
|
5
|
+
import { z } from "zod";
|
|
6
6
|
//#region src/tools/xulux-templates.ts
|
|
7
7
|
const emptyInputSchema = z.object({});
|
|
8
8
|
const detailsInputSchema = z.object({
|
|
@@ -25,7 +25,7 @@ function withDegradedNote(payload, degraded, degradedReason) {
|
|
|
25
25
|
const xuluxTemplatesListTool = {
|
|
26
26
|
name: "assistantUITemplates",
|
|
27
27
|
description: "List the available assistant-ui hosted app templates and fixed demos with their features, customizable surfaces, and versions. Call this first for any assistant-ui app-building request. Use the features and customizable fields to decide which template fits. If customizable is empty, the entry is a fixed demo that should be used as-is rather than configured. Call assistantUITemplateDetails on the chosen template before requesting a preview.",
|
|
28
|
-
parameters: emptyInputSchema
|
|
28
|
+
parameters: emptyInputSchema,
|
|
29
29
|
execute: async (_args) => {
|
|
30
30
|
logger.info("Listing assistant-ui templates");
|
|
31
31
|
try {
|
|
@@ -43,12 +43,13 @@ const xuluxTemplatesListTool = {
|
|
|
43
43
|
const xuluxTemplateDetailsTool = {
|
|
44
44
|
name: "assistantUITemplateDetails",
|
|
45
45
|
description: "Get the full authoring surface for a specific assistant-ui hosted template. Returns configRoots schemas (with types, defaults, and enums), rules, built-in tool input/outputShape, renderer contracts, and an exampleConfig. Fixed demos return no configRoots; use those as-is without config. Use this before calling assistantUITemplatePreview to understand exactly what config to write. If assistantUITemplatePreview returns validationWarnings, call this again and cross-reference configRoots to correct the config.",
|
|
46
|
-
parameters: detailsInputSchema
|
|
46
|
+
parameters: detailsInputSchema,
|
|
47
47
|
execute: async (args) => {
|
|
48
48
|
logger.info(`Getting assistant-ui template details for: ${args.templateId}`);
|
|
49
49
|
try {
|
|
50
50
|
const { catalog, degraded, degradedReason } = await getXuluxCatalog();
|
|
51
|
-
|
|
51
|
+
const details = await getTemplateDetails(catalog, args);
|
|
52
|
+
return formatMCPResponse(withDegradedNote(details, degraded, degradedReason));
|
|
52
53
|
} catch (error) {
|
|
53
54
|
logger.error("Failed to get assistant-ui template details", error);
|
|
54
55
|
return formatMCPResponse({
|
|
@@ -61,12 +62,13 @@ const xuluxTemplateDetailsTool = {
|
|
|
61
62
|
const xuluxTemplatePreviewTool = {
|
|
62
63
|
name: "assistantUITemplatePreview",
|
|
63
64
|
description: "Return preview and download URLs for a selected assistant-ui hosted template. The previewUrl is a hosted app URL; show it to the user first, or open it with an available browser/in-app-browser tool if your client provides one. If you pass config, a preview session is created on the hosted template sandbox and the returned URLs reflect that configuration. Do not pass config for fixed demos that have no configRoots in assistantUITemplateDetails. This tool only returns URLs.",
|
|
64
|
-
parameters: previewInputSchema
|
|
65
|
+
parameters: previewInputSchema,
|
|
65
66
|
execute: async (args) => {
|
|
66
67
|
logger.info(`Creating assistant-ui template preview for: ${args.templateId}`);
|
|
67
68
|
try {
|
|
68
69
|
const { catalog, degraded, degradedReason } = await getXuluxCatalog();
|
|
69
|
-
|
|
70
|
+
const result = await createTemplatePreview(catalog, args);
|
|
71
|
+
return formatMCPResponse(withDegradedNote(result, degraded, degradedReason));
|
|
70
72
|
} catch (error) {
|
|
71
73
|
logger.error("Failed to create assistant-ui template preview", error);
|
|
72
74
|
return formatMCPResponse({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xulux-templates.js","names":[],"sources":["../../src/tools/xulux-templates.ts"],"sourcesContent":["import { z } from \"zod
|
|
1
|
+
{"version":3,"file":"xulux-templates.js","names":[],"sources":["../../src/tools/xulux-templates.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { logger } from \"../utils/logger.js\";\nimport { formatMCPResponse } from \"../utils/mcp-format.js\";\nimport { getXuluxCatalog } from \"../xulux/catalog-client.js\";\nimport {\n createTemplatePreview,\n getTemplateDetails,\n listTemplates,\n} from \"../xulux/template-service.js\";\n\nconst emptyInputSchema = z.object({});\n\nconst detailsInputSchema = z.object({\n templateId: z.string().describe(\"The template id from assistantUITemplates\"),\n versionId: z\n .string()\n .optional()\n .describe(\n \"Optional version id. When provided, exampleConfig reflects that version's resolved defaults.\",\n ),\n});\n\nconst previewInputSchema = z.object({\n templateId: z.string().describe(\"The template id from assistantUITemplates\"),\n versionId: z\n .string()\n .optional()\n .describe(\"Version id to use. Uses the template default if omitted.\"),\n config: z\n .record(z.string(), z.unknown())\n .optional()\n .describe(\n \"Customization config for the preview. Must contain only the top-level keys: hostUi, assistant, and brandTheme. \" +\n \"Use the schemas from assistantUITemplateDetails.configRoots as the source of truth for each root. \" +\n \"Do not pass any other root keys.\",\n ),\n});\n\nfunction withDegradedNote<T extends Record<string, unknown>>(\n payload: T,\n degraded: boolean,\n degradedReason?: string,\n): T & { catalogDegraded?: true; catalogDegradedReason?: string } {\n if (!degraded) return payload;\n return {\n ...payload,\n catalogDegraded: true,\n ...(degradedReason ? { catalogDegradedReason: degradedReason } : {}),\n };\n}\n\nexport const xuluxTemplatesListTool = {\n name: \"assistantUITemplates\",\n description:\n \"List the available assistant-ui hosted app templates and fixed demos with their features, customizable surfaces, and versions. \" +\n \"Call this first for any assistant-ui app-building request. Use the features and customizable fields to decide which template fits. \" +\n \"If customizable is empty, the entry is a fixed demo that should be used as-is rather than configured. \" +\n \"Call assistantUITemplateDetails on the chosen template before requesting a preview.\",\n parameters: emptyInputSchema,\n execute: async (_args: z.infer<typeof emptyInputSchema>) => {\n logger.info(\"Listing assistant-ui templates\");\n try {\n const { catalog, degraded, degradedReason } = await getXuluxCatalog();\n return formatMCPResponse(\n withDegradedNote(listTemplates(catalog), degraded, degradedReason),\n );\n } catch (error) {\n logger.error(\"Failed to list assistant-ui templates\", error);\n return formatMCPResponse({\n error: \"Failed to list assistant-ui templates\",\n message: error instanceof Error ? error.message : String(error),\n });\n }\n },\n};\n\nexport const xuluxTemplateDetailsTool = {\n name: \"assistantUITemplateDetails\",\n description:\n \"Get the full authoring surface for a specific assistant-ui hosted template. \" +\n \"Returns configRoots schemas (with types, defaults, and enums), rules, built-in tool input/outputShape, renderer contracts, and an exampleConfig. \" +\n \"Fixed demos return no configRoots; use those as-is without config. \" +\n \"Use this before calling assistantUITemplatePreview to understand exactly what config to write. \" +\n \"If assistantUITemplatePreview returns validationWarnings, call this again and cross-reference configRoots to correct the config.\",\n parameters: detailsInputSchema,\n execute: async (args: z.infer<typeof detailsInputSchema>) => {\n logger.info(\n `Getting assistant-ui template details for: ${args.templateId}`,\n );\n try {\n const { catalog, degraded, degradedReason } = await getXuluxCatalog();\n const details = await getTemplateDetails(catalog, args);\n return formatMCPResponse(\n withDegradedNote(\n details as unknown as Record<string, unknown>,\n degraded,\n degradedReason,\n ),\n );\n } catch (error) {\n logger.error(\"Failed to get assistant-ui template details\", error);\n return formatMCPResponse({\n error: \"Failed to get assistant-ui template details\",\n message: error instanceof Error ? error.message : String(error),\n });\n }\n },\n};\n\nexport const xuluxTemplatePreviewTool = {\n name: \"assistantUITemplatePreview\",\n description:\n \"Return preview and download URLs for a selected assistant-ui hosted template. \" +\n \"The previewUrl is a hosted app URL; show it to the user first, or open it with an available browser/in-app-browser tool if your client provides one. \" +\n \"If you pass config, a preview session is created on the hosted template sandbox and the returned URLs reflect that configuration. \" +\n \"Do not pass config for fixed demos that have no configRoots in assistantUITemplateDetails. \" +\n \"This tool only returns URLs.\",\n parameters: previewInputSchema,\n execute: async (args: z.infer<typeof previewInputSchema>) => {\n logger.info(\n `Creating assistant-ui template preview for: ${args.templateId}`,\n );\n try {\n const { catalog, degraded, degradedReason } = await getXuluxCatalog();\n const result = await createTemplatePreview(catalog, args);\n return formatMCPResponse(\n withDegradedNote(\n result as unknown as Record<string, unknown>,\n degraded,\n degradedReason,\n ),\n );\n } catch (error) {\n logger.error(\"Failed to create assistant-ui template preview\", error);\n return formatMCPResponse({\n error: \"Failed to create assistant-ui template preview\",\n message: error instanceof Error ? error.message : String(error),\n });\n }\n },\n};\n"],"mappings":";;;;;;AAUA,MAAM,mBAAmB,EAAE,OAAO,CAAC,CAAC;AAEpC,MAAM,qBAAqB,EAAE,OAAO;CAClC,YAAY,EAAE,OAAO,CAAC,CAAC,SAAS,2CAA2C;CAC3E,WAAW,EACR,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SACC,8FACF;AACJ,CAAC;AAED,MAAM,qBAAqB,EAAE,OAAO;CAClC,YAAY,EAAE,OAAO,CAAC,CAAC,SAAS,2CAA2C;CAC3E,WAAW,EACR,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SAAS,0DAA0D;CACtE,QAAQ,EACL,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC,CAC/B,SAAS,CAAC,CACV,SACC,mPAGF;AACJ,CAAC;AAED,SAAS,iBACP,SACA,UACA,gBACgE;CAChE,IAAI,CAAC,UAAU,OAAO;CACtB,OAAO;EACL,GAAG;EACH,iBAAiB;EACjB,GAAI,iBAAiB,EAAE,uBAAuB,eAAe,IAAI,CAAC;CACpE;AACF;AAEA,MAAa,yBAAyB;CACpC,MAAM;CACN,aACE;CAIF,YAAY;CACZ,SAAS,OAAO,UAA4C;EAC1D,OAAO,KAAK,gCAAgC;EAC5C,IAAI;GACF,MAAM,EAAE,SAAS,UAAU,mBAAmB,MAAM,gBAAgB;GACpE,OAAO,kBACL,iBAAiB,cAAc,OAAO,GAAG,UAAU,cAAc,CACnE;EACF,SAAS,OAAO;GACd,OAAO,MAAM,yCAAyC,KAAK;GAC3D,OAAO,kBAAkB;IACvB,OAAO;IACP,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GAChE,CAAC;EACH;CACF;AACF;AAEA,MAAa,2BAA2B;CACtC,MAAM;CACN,aACE;CAKF,YAAY;CACZ,SAAS,OAAO,SAA6C;EAC3D,OAAO,KACL,8CAA8C,KAAK,YACrD;EACA,IAAI;GACF,MAAM,EAAE,SAAS,UAAU,mBAAmB,MAAM,gBAAgB;GACpE,MAAM,UAAU,MAAM,mBAAmB,SAAS,IAAI;GACtD,OAAO,kBACL,iBACE,SACA,UACA,cACF,CACF;EACF,SAAS,OAAO;GACd,OAAO,MAAM,+CAA+C,KAAK;GACjE,OAAO,kBAAkB;IACvB,OAAO;IACP,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GAChE,CAAC;EACH;CACF;AACF;AAEA,MAAa,2BAA2B;CACtC,MAAM;CACN,aACE;CAKF,YAAY;CACZ,SAAS,OAAO,SAA6C;EAC3D,OAAO,KACL,+CAA+C,KAAK,YACtD;EACA,IAAI;GACF,MAAM,EAAE,SAAS,UAAU,mBAAmB,MAAM,gBAAgB;GACpE,MAAM,SAAS,MAAM,sBAAsB,SAAS,IAAI;GACxD,OAAO,kBACL,iBACE,QACA,UACA,cACF,CACF;EACF,SAAS,OAAO;GACd,OAAO,MAAM,kDAAkD,KAAK;GACpE,OAAO,kBAAkB;IACvB,OAAO;IACP,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GAChE,CAAC;EACH;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","names":[],"sources":["../../src/utils/logger.ts"],"mappings":";cAEa;
|
|
1
|
+
{"version":3,"file":"logger.d.ts","names":[],"sources":["../../src/utils/logger.ts"],"mappings":";cAEa;EACM,QAAA,oBAAM;EAKP,OAAA,oBAAM;EAKL,QAAA,oBAAM;EAGP,OAAA,oBAAM"}
|
package/dist/utils/mdx.js
CHANGED
|
@@ -5,7 +5,8 @@ import matter from "gray-matter";
|
|
|
5
5
|
//#region src/utils/mdx.ts
|
|
6
6
|
async function readMDXFile(filePath) {
|
|
7
7
|
try {
|
|
8
|
-
const
|
|
8
|
+
const fileContent = await readFile(filePath, "utf-8");
|
|
9
|
+
const { content, data } = matter(fileContent);
|
|
9
10
|
const excerptMatch = content.match(/^(.+?)(?:\n\n|$)/);
|
|
10
11
|
const excerpt = excerptMatch?.[1] !== void 0 ? excerptMatch[1].replace(/^#+ /, "") : void 0;
|
|
11
12
|
return {
|
package/dist/utils/mdx.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mdx.js","names":[],"sources":["../../src/utils/mdx.ts"],"sourcesContent":["import { readFile, lstat } from \"node:fs/promises\";\nimport matter from \"gray-matter\";\nimport { MAX_FILE_SIZE } from \"../constants.js\";\nimport { logger } from \"./logger.js\";\n\ninterface MDXContent {\n content: string;\n frontmatter: Record<string, any>;\n excerpt?: string;\n}\n\nexport async function readMDXFile(\n filePath: string,\n): Promise<MDXContent | null> {\n try {\n const fileContent = await readFile(filePath, \"utf-8\");\n const { content, data } = matter(fileContent);\n\n const excerptMatch = content.match(/^(.+?)(?:\\n\\n|$)/);\n const excerpt =\n excerptMatch?.[1] !== undefined\n ? excerptMatch[1].replace(/^#+ /, \"\")\n : undefined;\n\n return {\n content,\n frontmatter: data,\n ...(excerpt !== undefined && { excerpt }),\n };\n } catch (error) {\n logger.error(`Failed to read MDX file: ${filePath}`, error);\n return null;\n }\n}\n\nexport async function readMDXFileSafe(\n filePath: string,\n): Promise<MDXContent | null> {\n try {\n const stats = await lstat(filePath);\n if (stats.isSymbolicLink()) {\n logger.warn(`Attempted to read symlink: ${filePath}`);\n return null;\n }\n if (stats.size > MAX_FILE_SIZE) {\n logger.warn(`File size exceeds limit: ${filePath} (${stats.size} bytes)`);\n return null;\n }\n } catch {\n return null;\n }\n return readMDXFile(filePath);\n}\n\nexport function formatMDXContent(mdxContent: MDXContent): string {\n const { content, frontmatter } = mdxContent;\n\n return matter.stringify(content, frontmatter);\n}\n"],"mappings":";;;;;AAWA,eAAsB,YACpB,UAC4B;CAC5B,IAAI;
|
|
1
|
+
{"version":3,"file":"mdx.js","names":[],"sources":["../../src/utils/mdx.ts"],"sourcesContent":["import { readFile, lstat } from \"node:fs/promises\";\nimport matter from \"gray-matter\";\nimport { MAX_FILE_SIZE } from \"../constants.js\";\nimport { logger } from \"./logger.js\";\n\ninterface MDXContent {\n content: string;\n frontmatter: Record<string, any>;\n excerpt?: string;\n}\n\nexport async function readMDXFile(\n filePath: string,\n): Promise<MDXContent | null> {\n try {\n const fileContent = await readFile(filePath, \"utf-8\");\n const { content, data } = matter(fileContent);\n\n const excerptMatch = content.match(/^(.+?)(?:\\n\\n|$)/);\n const excerpt =\n excerptMatch?.[1] !== undefined\n ? excerptMatch[1].replace(/^#+ /, \"\")\n : undefined;\n\n return {\n content,\n frontmatter: data,\n ...(excerpt !== undefined && { excerpt }),\n };\n } catch (error) {\n logger.error(`Failed to read MDX file: ${filePath}`, error);\n return null;\n }\n}\n\nexport async function readMDXFileSafe(\n filePath: string,\n): Promise<MDXContent | null> {\n try {\n const stats = await lstat(filePath);\n if (stats.isSymbolicLink()) {\n logger.warn(`Attempted to read symlink: ${filePath}`);\n return null;\n }\n if (stats.size > MAX_FILE_SIZE) {\n logger.warn(`File size exceeds limit: ${filePath} (${stats.size} bytes)`);\n return null;\n }\n } catch {\n return null;\n }\n return readMDXFile(filePath);\n}\n\nexport function formatMDXContent(mdxContent: MDXContent): string {\n const { content, frontmatter } = mdxContent;\n\n return matter.stringify(content, frontmatter);\n}\n"],"mappings":";;;;;AAWA,eAAsB,YACpB,UAC4B;CAC5B,IAAI;EACF,MAAM,cAAc,MAAM,SAAS,UAAU,OAAO;EACpD,MAAM,EAAE,SAAS,SAAS,OAAO,WAAW;EAE5C,MAAM,eAAe,QAAQ,MAAM,kBAAkB;EACrD,MAAM,UACJ,eAAe,OAAO,KAAA,IAClB,aAAa,EAAE,CAAC,QAAQ,QAAQ,EAAE,IAClC,KAAA;EAEN,OAAO;GACL;GACA,aAAa;GACb,GAAI,YAAY,KAAA,KAAa,EAAE,QAAQ;EACzC;CACF,SAAS,OAAO;EACd,OAAO,MAAM,4BAA4B,YAAY,KAAK;EAC1D,OAAO;CACT;AACF;AAEA,eAAsB,gBACpB,UAC4B;CAC5B,IAAI;EACF,MAAM,QAAQ,MAAM,MAAM,QAAQ;EAClC,IAAI,MAAM,eAAe,GAAG;GAC1B,OAAO,KAAK,8BAA8B,UAAU;GACpD,OAAO;EACT;EACA,IAAI,MAAM,OAAA,UAAsB;GAC9B,OAAO,KAAK,4BAA4B,SAAS,IAAI,MAAM,KAAK,QAAQ;GACxE,OAAO;EACT;CACF,QAAQ;EACN,OAAO;CACT;CACA,OAAO,YAAY,QAAQ;AAC7B;AAEA,SAAgB,iBAAiB,YAAgC;CAC/D,MAAM,EAAE,SAAS,gBAAgB;CAEjC,OAAO,OAAO,UAAU,SAAS,WAAW;AAC9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.js","names":[],"sources":["../../src/utils/security.ts"],"sourcesContent":["import path from \"node:path\";\n\nexport function sanitizePath(userPath: string): string {\n if (!userPath || typeof userPath !== \"string\") {\n throw new Error(\"Invalid path: Path must be a non-empty string\");\n }\n\n // Check for traversal patterns before normalization - defense in depth\n if (userPath.includes(\"../\") || userPath.includes(\"..\\\\\")) {\n throw new Error(\"Invalid path: Directory traversal attempt detected\");\n }\n\n const normalized = path.normalize(userPath);\n\n if (path.isAbsolute(normalized)) {\n throw new Error(\"Invalid path: Absolute paths are not allowed\");\n }\n\n const relativePath = path.relative(\"\", normalized);\n\n if (relativePath.startsWith(\"..\")) {\n throw new Error(\"Invalid path: Directory traversal attempt detected\");\n }\n\n if (relativePath.includes(\"..\")) {\n throw new Error(\"Invalid path: Path contains invalid traversal sequences\");\n }\n\n if (relativePath.includes(\"\\0\")) {\n throw new Error(\"Invalid path: Path contains null bytes\");\n }\n\n if (process.platform !== \"win32\") {\n if (normalized.includes(\"\\\\\")) {\n throw new Error(\"Invalid path: Backslashes not allowed\");\n }\n } else {\n if (normalized.includes(\":\") || normalized.startsWith(\"\\\\\\\\\")) {\n throw new Error(\"Invalid path: Path contains invalid Windows characters\");\n }\n }\n\n const segments = relativePath.split(path.sep);\n for (const segment of segments) {\n if (segment.startsWith(\".\") && segment !== \".\") {\n throw new Error(\"Invalid path: Hidden files are not allowed\");\n }\n }\n\n // Always return Unix-style paths for consistency across platforms\n return relativePath.replace(/\\\\/g, \"/\");\n}\n"],"mappings":";;AAEA,SAAgB,aAAa,UAA0B;CACrD,IAAI,CAAC,YAAY,OAAO,aAAa,UACnC,MAAM,IAAI,MAAM,+CAA+C;CAIjE,IAAI,SAAS,SAAS,KAAK,KAAK,SAAS,SAAS,MAAM,GACtD,MAAM,IAAI,MAAM,oDAAoD;CAGtE,MAAM,aAAa,KAAK,UAAU,QAAQ;CAE1C,IAAI,KAAK,WAAW,UAAU,GAC5B,MAAM,IAAI,MAAM,8CAA8C;CAGhE,MAAM,eAAe,KAAK,SAAS,IAAI,UAAU;CAEjD,IAAI,aAAa,WAAW,IAAI,GAC9B,MAAM,IAAI,MAAM,oDAAoD;CAGtE,IAAI,aAAa,SAAS,IAAI,GAC5B,MAAM,IAAI,MAAM,yDAAyD;CAG3E,IAAI,aAAa,SAAS,IAAI,GAC5B,MAAM,IAAI,MAAM,wCAAwC;CAG1D,IAAI,QAAQ,aAAa;
|
|
1
|
+
{"version":3,"file":"security.js","names":[],"sources":["../../src/utils/security.ts"],"sourcesContent":["import path from \"node:path\";\n\nexport function sanitizePath(userPath: string): string {\n if (!userPath || typeof userPath !== \"string\") {\n throw new Error(\"Invalid path: Path must be a non-empty string\");\n }\n\n // Check for traversal patterns before normalization - defense in depth\n if (userPath.includes(\"../\") || userPath.includes(\"..\\\\\")) {\n throw new Error(\"Invalid path: Directory traversal attempt detected\");\n }\n\n const normalized = path.normalize(userPath);\n\n if (path.isAbsolute(normalized)) {\n throw new Error(\"Invalid path: Absolute paths are not allowed\");\n }\n\n const relativePath = path.relative(\"\", normalized);\n\n if (relativePath.startsWith(\"..\")) {\n throw new Error(\"Invalid path: Directory traversal attempt detected\");\n }\n\n if (relativePath.includes(\"..\")) {\n throw new Error(\"Invalid path: Path contains invalid traversal sequences\");\n }\n\n if (relativePath.includes(\"\\0\")) {\n throw new Error(\"Invalid path: Path contains null bytes\");\n }\n\n if (process.platform !== \"win32\") {\n if (normalized.includes(\"\\\\\")) {\n throw new Error(\"Invalid path: Backslashes not allowed\");\n }\n } else {\n if (normalized.includes(\":\") || normalized.startsWith(\"\\\\\\\\\")) {\n throw new Error(\"Invalid path: Path contains invalid Windows characters\");\n }\n }\n\n const segments = relativePath.split(path.sep);\n for (const segment of segments) {\n if (segment.startsWith(\".\") && segment !== \".\") {\n throw new Error(\"Invalid path: Hidden files are not allowed\");\n }\n }\n\n // Always return Unix-style paths for consistency across platforms\n return relativePath.replace(/\\\\/g, \"/\");\n}\n"],"mappings":";;AAEA,SAAgB,aAAa,UAA0B;CACrD,IAAI,CAAC,YAAY,OAAO,aAAa,UACnC,MAAM,IAAI,MAAM,+CAA+C;CAIjE,IAAI,SAAS,SAAS,KAAK,KAAK,SAAS,SAAS,MAAM,GACtD,MAAM,IAAI,MAAM,oDAAoD;CAGtE,MAAM,aAAa,KAAK,UAAU,QAAQ;CAE1C,IAAI,KAAK,WAAW,UAAU,GAC5B,MAAM,IAAI,MAAM,8CAA8C;CAGhE,MAAM,eAAe,KAAK,SAAS,IAAI,UAAU;CAEjD,IAAI,aAAa,WAAW,IAAI,GAC9B,MAAM,IAAI,MAAM,oDAAoD;CAGtE,IAAI,aAAa,SAAS,IAAI,GAC5B,MAAM,IAAI,MAAM,yDAAyD;CAG3E,IAAI,aAAa,SAAS,IAAI,GAC5B,MAAM,IAAI,MAAM,wCAAwC;CAG1D,IAAI,QAAQ,aAAa,SACnB;MAAA,WAAW,SAAS,IAAI,GAC1B,MAAM,IAAI,MAAM,uCAAuC;CAAA,OAGzD,IAAI,WAAW,SAAS,GAAG,KAAK,WAAW,WAAW,MAAM,GAC1D,MAAM,IAAI,MAAM,wDAAwD;CAI5E,MAAM,WAAW,aAAa,MAAM,KAAK,GAAG;CAC5C,KAAK,MAAM,WAAW,UACpB,IAAI,QAAQ,WAAW,GAAG,KAAK,YAAY,KACzC,MAAM,IAAI,MAAM,4CAA4C;CAKhE,OAAO,aAAa,QAAQ,OAAO,GAAG;AACxC"}
|
|
@@ -2,7 +2,7 @@ import { logger } from "../utils/logger.js";
|
|
|
2
2
|
import { FALLBACK_CATALOG, FALLBACK_NOTE } from "./fallback-catalog.js";
|
|
3
3
|
//#region src/xulux/catalog-client.ts
|
|
4
4
|
const DEFAULT_CATALOG_URL = "https://www.assistant-ui.com/api/xulux/mcp-catalog";
|
|
5
|
-
const CATALOG_TTL_MS =
|
|
5
|
+
const CATALOG_TTL_MS = 3e5;
|
|
6
6
|
function getCatalogUrl() {
|
|
7
7
|
return process.env.XULUX_CATALOG_URL?.trim() || "https://www.assistant-ui.com/api/xulux/mcp-catalog";
|
|
8
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog-client.js","names":[],"sources":["../../src/xulux/catalog-client.ts"],"sourcesContent":["import { logger } from \"../utils/logger.js\";\nimport { FALLBACK_CATALOG, FALLBACK_NOTE } from \"./fallback-catalog.js\";\nimport type { XuluxCatalog, XuluxCatalogResult } from \"./types.js\";\n\nexport const DEFAULT_CATALOG_URL =\n \"https://www.assistant-ui.com/api/xulux/mcp-catalog\";\n\nconst CATALOG_TTL_MS = 5 * 60 * 1000;\n\nexport function getCatalogUrl(): string {\n const override = process.env.XULUX_CATALOG_URL?.trim();\n return override || DEFAULT_CATALOG_URL;\n}\n\nfunction validateCatalog(data: unknown): XuluxCatalog {\n if (!data || typeof data !== \"object\" || Array.isArray(data)) {\n throw new Error(\"Catalog response is not a JSON object.\");\n }\n const catalog = data as XuluxCatalog;\n if (catalog.version !== 1) {\n throw new Error(\n `Unsupported catalog version: ${String(catalog.version)}. Expected 1.`,\n );\n }\n if (!Array.isArray(catalog.templates)) {\n throw new Error(\"Catalog response has no templates array.\");\n }\n for (const template of catalog.templates) {\n if (\n !template ||\n typeof template !== \"object\" ||\n typeof template.id !== \"string\" ||\n typeof template.templateId !== \"string\" ||\n (template.kind !== \"template\" && template.kind !== \"example\")\n ) {\n throw new Error(\n \"Catalog response contains a malformed template entry (missing id/templateId/kind).\",\n );\n }\n }\n return catalog;\n}\n\ninterface CacheEntry {\n catalog: XuluxCatalog;\n fetchedAt: number;\n url: string;\n}\n\nlet cache: CacheEntry | null = null;\n\nexport function clearCatalogCache(): void {\n cache = null;\n}\n\nasync function fetchCatalog(url: string): Promise<XuluxCatalog> {\n const res = await fetch(url, {\n headers: { Accept: \"application/json\" },\n });\n if (!res.ok) {\n throw new Error(`Catalog fetch failed: HTTP ${res.status}`);\n }\n const data: unknown = await res.json();\n return validateCatalog(data);\n}\n\n/**\n * Returns the assistant-ui template catalog. Uses an in-memory five-minute cache, and falls\n * back to a minimal bundled catalog (marked degraded) when the live fetch\n * fails and no cached copy exists.\n */\nexport async function getXuluxCatalog(): Promise<XuluxCatalogResult> {\n const url = getCatalogUrl();\n const now = Date.now();\n\n if (cache && cache.url === url && now - cache.fetchedAt < CATALOG_TTL_MS) {\n return { catalog: cache.catalog, degraded: false };\n }\n\n try {\n const catalog = await fetchCatalog(url);\n cache = { catalog, fetchedAt: now, url };\n return { catalog, degraded: false };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.warn(\n `assistant-ui template catalog fetch failed (${url}): ${message}`,\n );\n\n // Prefer a stale cached copy over the minimal fallback.\n if (cache && cache.url === url) {\n return {\n catalog: cache.catalog,\n degraded: true,\n degradedReason: `Live catalog refresh failed (${message}); using previously fetched catalog.`,\n };\n }\n\n return {\n catalog: FALLBACK_CATALOG,\n degraded: true,\n degradedReason: `${message} ${FALLBACK_NOTE}`,\n };\n }\n}\n"],"mappings":";;;AAIA,MAAa,sBACX;AAEF,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"catalog-client.js","names":[],"sources":["../../src/xulux/catalog-client.ts"],"sourcesContent":["import { logger } from \"../utils/logger.js\";\nimport { FALLBACK_CATALOG, FALLBACK_NOTE } from \"./fallback-catalog.js\";\nimport type { XuluxCatalog, XuluxCatalogResult } from \"./types.js\";\n\nexport const DEFAULT_CATALOG_URL =\n \"https://www.assistant-ui.com/api/xulux/mcp-catalog\";\n\nconst CATALOG_TTL_MS = 5 * 60 * 1000;\n\nexport function getCatalogUrl(): string {\n const override = process.env.XULUX_CATALOG_URL?.trim();\n return override || DEFAULT_CATALOG_URL;\n}\n\nfunction validateCatalog(data: unknown): XuluxCatalog {\n if (!data || typeof data !== \"object\" || Array.isArray(data)) {\n throw new Error(\"Catalog response is not a JSON object.\");\n }\n const catalog = data as XuluxCatalog;\n if (catalog.version !== 1) {\n throw new Error(\n `Unsupported catalog version: ${String(catalog.version)}. Expected 1.`,\n );\n }\n if (!Array.isArray(catalog.templates)) {\n throw new Error(\"Catalog response has no templates array.\");\n }\n for (const template of catalog.templates) {\n if (\n !template ||\n typeof template !== \"object\" ||\n typeof template.id !== \"string\" ||\n typeof template.templateId !== \"string\" ||\n (template.kind !== \"template\" && template.kind !== \"example\")\n ) {\n throw new Error(\n \"Catalog response contains a malformed template entry (missing id/templateId/kind).\",\n );\n }\n }\n return catalog;\n}\n\ninterface CacheEntry {\n catalog: XuluxCatalog;\n fetchedAt: number;\n url: string;\n}\n\nlet cache: CacheEntry | null = null;\n\nexport function clearCatalogCache(): void {\n cache = null;\n}\n\nasync function fetchCatalog(url: string): Promise<XuluxCatalog> {\n const res = await fetch(url, {\n headers: { Accept: \"application/json\" },\n });\n if (!res.ok) {\n throw new Error(`Catalog fetch failed: HTTP ${res.status}`);\n }\n const data: unknown = await res.json();\n return validateCatalog(data);\n}\n\n/**\n * Returns the assistant-ui template catalog. Uses an in-memory five-minute cache, and falls\n * back to a minimal bundled catalog (marked degraded) when the live fetch\n * fails and no cached copy exists.\n */\nexport async function getXuluxCatalog(): Promise<XuluxCatalogResult> {\n const url = getCatalogUrl();\n const now = Date.now();\n\n if (cache && cache.url === url && now - cache.fetchedAt < CATALOG_TTL_MS) {\n return { catalog: cache.catalog, degraded: false };\n }\n\n try {\n const catalog = await fetchCatalog(url);\n cache = { catalog, fetchedAt: now, url };\n return { catalog, degraded: false };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.warn(\n `assistant-ui template catalog fetch failed (${url}): ${message}`,\n );\n\n // Prefer a stale cached copy over the minimal fallback.\n if (cache && cache.url === url) {\n return {\n catalog: cache.catalog,\n degraded: true,\n degradedReason: `Live catalog refresh failed (${message}); using previously fetched catalog.`,\n };\n }\n\n return {\n catalog: FALLBACK_CATALOG,\n degraded: true,\n degradedReason: `${message} ${FALLBACK_NOTE}`,\n };\n }\n}\n"],"mappings":";;;AAIA,MAAa,sBACX;AAEF,MAAM,iBAAiB;AAEvB,SAAgB,gBAAwB;CAEtC,OADiB,QAAQ,IAAI,mBAAmB,KAAK,KAAA;AAEvD;AAEA,SAAS,gBAAgB,MAA6B;CACpD,IAAI,CAAC,QAAQ,OAAO,SAAS,YAAY,MAAM,QAAQ,IAAI,GACzD,MAAM,IAAI,MAAM,wCAAwC;CAE1D,MAAM,UAAU;CAChB,IAAI,QAAQ,YAAY,GACtB,MAAM,IAAI,MACR,gCAAgC,OAAO,QAAQ,OAAO,EAAE,cAC1D;CAEF,IAAI,CAAC,MAAM,QAAQ,QAAQ,SAAS,GAClC,MAAM,IAAI,MAAM,0CAA0C;CAE5D,KAAK,MAAM,YAAY,QAAQ,WAC7B,IACE,CAAC,YACD,OAAO,aAAa,YACpB,OAAO,SAAS,OAAO,YACvB,OAAO,SAAS,eAAe,YAC9B,SAAS,SAAS,cAAc,SAAS,SAAS,WAEnD,MAAM,IAAI,MACR,oFACF;CAGJ,OAAO;AACT;AAQA,IAAI,QAA2B;AAE/B,SAAgB,oBAA0B;CACxC,QAAQ;AACV;AAEA,eAAe,aAAa,KAAoC;CAC9D,MAAM,MAAM,MAAM,MAAM,KAAK,EAC3B,SAAS,EAAE,QAAQ,mBAAmB,EACxC,CAAC;CACD,IAAI,CAAC,IAAI,IACP,MAAM,IAAI,MAAM,8BAA8B,IAAI,QAAQ;CAG5D,OAAO,gBAAgB,MADK,IAAI,KAAK,CACV;AAC7B;;;;;;AAOA,eAAsB,kBAA+C;CACnE,MAAM,MAAM,cAAc;CAC1B,MAAM,MAAM,KAAK,IAAI;CAErB,IAAI,SAAS,MAAM,QAAQ,OAAO,MAAM,MAAM,YAAY,gBACxD,OAAO;EAAE,SAAS,MAAM;EAAS,UAAU;CAAM;CAGnD,IAAI;EACF,MAAM,UAAU,MAAM,aAAa,GAAG;EACtC,QAAQ;GAAE;GAAS,WAAW;GAAK;EAAI;EACvC,OAAO;GAAE;GAAS,UAAU;EAAM;CACpC,SAAS,OAAO;EACd,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EACrE,OAAO,KACL,+CAA+C,IAAI,KAAK,SAC1D;EAGA,IAAI,SAAS,MAAM,QAAQ,KACzB,OAAO;GACL,SAAS,MAAM;GACf,UAAU;GACV,gBAAgB,gCAAgC,QAAQ;EAC1D;EAGF,OAAO;GACL,SAAS;GACT,UAAU;GACV,gBAAgB,GAAG,QAAQ,GAAG;EAChC;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@assistant-ui/mcp-docs-server",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "MCP server for assistant-ui documentation and examples",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|
|
@@ -32,15 +32,16 @@
|
|
|
32
32
|
],
|
|
33
33
|
"sideEffects": false,
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@modelcontextprotocol/
|
|
35
|
+
"@modelcontextprotocol/server": "^2.0.0",
|
|
36
36
|
"gray-matter": "^4.0.3",
|
|
37
37
|
"zod": "^4.4.3"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@
|
|
41
|
-
"
|
|
40
|
+
"@modelcontextprotocol/core": "^2.0.0",
|
|
41
|
+
"@types/node": "^26.1.2",
|
|
42
|
+
"tsx": "^4.23.10",
|
|
42
43
|
"vitest": "^4.1.10",
|
|
43
|
-
"@assistant-ui/x-buildutils": "0.0.
|
|
44
|
+
"@assistant-ui/x-buildutils": "0.0.22"
|
|
44
45
|
},
|
|
45
46
|
"publishConfig": {
|
|
46
47
|
"access": "public",
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { McpServer } from "@modelcontextprotocol/
|
|
2
|
-
import { StdioServerTransport } from "@modelcontextprotocol/
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/server";
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/server/stdio";
|
|
3
3
|
import { docsTools } from "./tools/docs.js";
|
|
4
4
|
import { examplesTools } from "./tools/examples.js";
|
|
5
5
|
import { searchTools } from "./tools/search.js";
|
package/src/tools/docs.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z } from "zod
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
import { stat, lstat } from "node:fs/promises";
|
|
3
3
|
import { join, extname } from "node:path";
|
|
4
4
|
import {
|
|
@@ -213,7 +213,7 @@ export const docsTools = {
|
|
|
213
213
|
name: "assistantUIDocs",
|
|
214
214
|
description:
|
|
215
215
|
'Retrieve assistant-ui documentation by path. Use "/" to list all sections. Supports multiple paths in a single request.',
|
|
216
|
-
parameters: docsInputSchema
|
|
216
|
+
parameters: docsInputSchema,
|
|
217
217
|
execute: async ({ paths }: z.infer<typeof docsInputSchema>) => {
|
|
218
218
|
logger.info(`Retrieving documentation for paths: ${paths.join(", ")}`);
|
|
219
219
|
|
package/src/tools/examples.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z } from "zod
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
import { readFile, readdir, lstat } from "node:fs/promises";
|
|
3
3
|
import { join, extname } from "node:path";
|
|
4
4
|
import { CODE_EXAMPLES_PATH, MAX_FILE_SIZE } from "../constants.js";
|
|
@@ -63,7 +63,7 @@ export const examplesTools = {
|
|
|
63
63
|
name: "assistantUIExamples",
|
|
64
64
|
description:
|
|
65
65
|
"List available examples or retrieve complete code for a specific example",
|
|
66
|
-
parameters: examplesInputSchema
|
|
66
|
+
parameters: examplesInputSchema,
|
|
67
67
|
execute: async ({ example }: z.infer<typeof examplesInputSchema>) => {
|
|
68
68
|
try {
|
|
69
69
|
if (!example) {
|
package/src/tools/resources.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
McpServer,
|
|
3
|
-
ResourceTemplate,
|
|
4
|
-
} from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
1
|
+
import { type McpServer, ResourceTemplate } from "@modelcontextprotocol/server";
|
|
5
2
|
import { join } from "node:path";
|
|
6
3
|
import { DOCS_PATH, MDX_EXTENSION } from "../constants.js";
|
|
7
4
|
import { getAvailableDocFiles } from "../utils/paths.js";
|
package/src/tools/search.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z } from "zod
|
|
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 { searchDocs } from "../utils/search.js";
|
|
@@ -21,7 +21,7 @@ export const searchTools = {
|
|
|
21
21
|
name: "assistantUISearch",
|
|
22
22
|
description:
|
|
23
23
|
"Search assistant-ui documentation by keyword. Returns ranked matches with their doc path, title, and a snippet. Fetch full content with assistantUIDocs using a returned path.",
|
|
24
|
-
parameters: searchInputSchema
|
|
24
|
+
parameters: searchInputSchema,
|
|
25
25
|
execute: async ({ query, limit }: z.infer<typeof searchInputSchema>) => {
|
|
26
26
|
logger.info(`Searching documentation for: ${query}`);
|
|
27
27
|
try {
|