@assistant-ui/mcp-docs-server 0.1.38 → 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.
- package/.docs/organized/code-examples/waterfall.md +11 -12
- package/.docs/organized/code-examples/with-a2a.md +18 -13
- package/.docs/organized/code-examples/with-ag-ui.md +19 -14
- package/.docs/organized/code-examples/{with-ai-sdk-v6.md → with-ai-sdk-v7.md} +34 -23
- package/.docs/organized/code-examples/with-artifacts.md +473 -141
- package/.docs/organized/code-examples/with-assistant-transport.md +17 -10
- package/.docs/organized/code-examples/with-browser-extension.md +17 -10
- package/.docs/organized/code-examples/with-chain-of-thought.md +21 -14
- package/.docs/organized/code-examples/with-cloud-standalone.md +12 -11
- package/.docs/organized/code-examples/with-cloud.md +20 -15
- package/.docs/organized/code-examples/with-custom-thread-list.md +19 -12
- package/.docs/organized/code-examples/with-elevenlabs-conversational.md +22 -15
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +22 -15
- package/.docs/organized/code-examples/with-eve.md +18 -11
- package/.docs/organized/code-examples/with-expo.md +35 -52
- package/.docs/organized/code-examples/with-external-store.md +18 -13
- package/.docs/organized/code-examples/with-ffmpeg.md +20 -15
- package/.docs/organized/code-examples/with-generative-ui.md +22 -17
- package/.docs/organized/code-examples/with-google-adk.md +18 -11
- package/.docs/organized/code-examples/with-heat-graph.md +10 -11
- package/.docs/organized/code-examples/with-image-generation.md +19 -12
- package/.docs/organized/code-examples/with-interactables.md +21 -17
- package/.docs/organized/code-examples/with-langchain.md +19 -12
- package/.docs/organized/code-examples/with-langgraph.md +19 -12
- package/.docs/organized/code-examples/with-livekit.md +23 -16
- package/.docs/organized/code-examples/with-mcp.md +46 -28
- package/.docs/organized/code-examples/with-opencode.md +25 -23
- package/.docs/organized/code-examples/with-pi.md +54 -19
- package/.docs/organized/code-examples/with-react-hook-form.md +21 -16
- package/.docs/organized/code-examples/with-react-ink-web.md +9 -9
- package/.docs/organized/code-examples/with-react-ink.md +4 -4
- package/.docs/organized/code-examples/with-react-router.md +22 -17
- package/.docs/organized/code-examples/with-resumable-stream.md +21 -14
- package/.docs/organized/code-examples/with-store.md +10 -11
- package/.docs/organized/code-examples/with-tanstack.md +19 -13
- package/.docs/organized/code-examples/with-tap-runtime.md +18 -13
- package/.docs/organized/code-examples/with-virtualized-thread.md +19 -14
- package/.docs/raw/docs/(docs)/base-ui.mdx +39 -0
- package/.docs/raw/docs/(docs)/cli.mdx +19 -1
- package/.docs/raw/docs/(docs)/devtools.mdx +7 -2
- package/.docs/raw/docs/(docs)/installation.mdx +15 -1
- package/.docs/raw/docs/(docs)/rtl.mdx +2 -4
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/a2ui.mdx +40 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/actions.mdx +56 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/components.mdx +86 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/index.mdx +22 -1
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/json-generative-ui.mdx +42 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/rendering.mdx +53 -2
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/slack.mdx +81 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/teams.mdx +86 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/tokens.mdx +62 -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/index.mdx +4 -1
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-ai-sdk.mdx +25 -2
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-data-stream.mdx +37 -0
- package/.docs/raw/docs/(reference)/api-reference/model-context/context.mdx +1 -9
- package/.docs/raw/docs/(reference)/api-reference/overview.mdx +1 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-if.mdx +14 -31
- package/.docs/raw/docs/(reference)/api-reference/primitives/composition.mdx +1 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/index.mdx +3 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/selection-toolbar.mdx +2 -0
- package/.docs/raw/docs/(reference)/api-reference/tools/status.mdx +0 -2
- package/.docs/raw/docs/(reference)/api-reference/tools/toolkits.mdx +12 -9
- package/.docs/raw/docs/(reference)/api-reference/utilities/miscellaneous.mdx +4 -0
- package/.docs/raw/docs/cloud/ai-sdk-assistant-ui.mdx +7 -1
- package/.docs/raw/docs/cloud/langgraph.mdx +4 -2
- package/.docs/raw/docs/copilots/model-context.mdx +1 -1
- package/.docs/raw/docs/copilots/motivation.mdx +1 -1
- package/.docs/raw/docs/guides/attachments.mdx +3 -3
- package/.docs/raw/docs/guides/branching.mdx +2 -2
- package/.docs/raw/docs/guides/chatgpt-subscription.mdx +108 -0
- package/.docs/raw/docs/guides/context-api.mdx +89 -111
- package/.docs/raw/docs/guides/dictation.mdx +185 -257
- 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 +20 -0
- package/.docs/raw/docs/guides/mentions.mdx +31 -3
- 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 +12 -1
- package/.docs/raw/docs/guides/speech.mdx +47 -29
- package/.docs/raw/docs/guides/suggestions.mdx +70 -1
- package/.docs/raw/docs/guides/voice.mdx +197 -267
- package/.docs/raw/docs/ink/hooks.mdx +3 -3
- package/.docs/raw/docs/ink/primitives.mdx +49 -8
- package/.docs/raw/docs/integrations/auth/better-auth.mdx +2 -2
- package/.docs/raw/docs/integrations/auth/clerk.mdx +2 -2
- package/.docs/raw/docs/integrations/auth/next-auth.mdx +3 -3
- package/.docs/raw/docs/integrations/frameworks/ai-sdk.mdx +10 -4
- package/.docs/raw/docs/integrations/frameworks/cloudflare-agents/overview.mdx +3 -3
- package/.docs/raw/docs/integrations/frameworks/mastra/full-stack.mdx +1 -1
- package/.docs/raw/docs/integrations/frameworks/mastra/overview.mdx +3 -3
- 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 +1 -1
- package/.docs/raw/docs/integrations/observability/langfuse.mdx +1 -1
- package/.docs/raw/docs/integrations/observability/langsmith.mdx +2 -2
- package/.docs/raw/docs/integrations/persistence/custom-adapter.mdx +36 -9
- package/.docs/raw/docs/migrations/index.mdx +50 -0
- package/.docs/raw/docs/migrations/toolkit-tools.mdx +4 -2
- package/.docs/raw/docs/migrations/v0-15.mdx +156 -0
- package/.docs/raw/docs/primitives/chain-of-thought.mdx +6 -1
- package/.docs/raw/docs/primitives/composer.mdx +17 -1
- package/.docs/raw/docs/primitives/selection-toolbar.mdx +25 -0
- package/.docs/raw/docs/primitives/thread-list.mdx +2 -2
- package/.docs/raw/docs/react-native/hooks.mdx +3 -3
- package/.docs/raw/docs/react-native/index.mdx +2 -2
- package/.docs/raw/docs/react-native/primitives.mdx +62 -5
- package/.docs/raw/docs/runtimes/ag-ui/agent-state.mdx +124 -0
- package/.docs/raw/docs/runtimes/ag-ui/runtime-options.mdx +10 -1
- package/.docs/raw/docs/runtimes/ai-sdk/overview.mdx +14 -5
- package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +15 -15
- package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +8 -8
- package/.docs/raw/docs/runtimes/ai-sdk/{v6.mdx → v6-legacy.mdx} +11 -9
- package/.docs/raw/docs/runtimes/ai-sdk/v7.mdx +717 -0
- package/.docs/raw/docs/runtimes/concepts/adapters.mdx +1 -1
- package/.docs/raw/docs/runtimes/concepts/architecture.mdx +1 -1
- package/.docs/raw/docs/runtimes/concepts/threads.mdx +10 -10
- package/.docs/raw/docs/runtimes/custom/assistant-transport.mdx +2 -2
- package/.docs/raw/docs/runtimes/custom/data-stream.mdx +10 -19
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +2 -2
- package/.docs/raw/docs/runtimes/custom/local-runtime.mdx +5 -3
- package/.docs/raw/docs/runtimes/eve/overview.mdx +1 -1
- package/.docs/raw/docs/runtimes/langchain.mdx +2 -2
- package/.docs/raw/docs/runtimes/langgraph/agent-state.mdx +181 -0
- package/.docs/raw/docs/runtimes/langgraph/overview.mdx +1 -1
- package/.docs/raw/docs/runtimes/opencode/hooks.mdx +3 -1
- package/.docs/raw/docs/tools/a2ui.mdx +107 -0
- package/.docs/raw/docs/tools/backend.mdx +6 -3
- package/.docs/raw/docs/tools/defining-tools.mdx +7 -1
- package/.docs/raw/docs/tools/generative-ui.mdx +60 -2
- package/.docs/raw/docs/tools/interactables-legacy.mdx +4 -4
- package/.docs/raw/docs/tools/interactables.mdx +3 -3
- package/.docs/raw/docs/tools/mcp-apps.mdx +90 -13
- package/.docs/raw/docs/tools/mcp.mdx +100 -3
- package/.docs/raw/docs/tools/tool-ui.mdx +6 -4
- package/.docs/raw/docs/tools/user-managed-mcp.mdx +77 -9
- package/.docs/raw/docs/ui/accordion.mdx +16 -10
- package/.docs/raw/docs/ui/assistant-modal.mdx +8 -4
- package/.docs/raw/docs/ui/attachment.mdx +5 -1
- package/.docs/raw/docs/ui/badge.mdx +23 -12
- package/.docs/raw/docs/ui/follow-up-suggestions.mdx +4 -2
- package/.docs/raw/docs/ui/model-selector.mdx +33 -3
- package/.docs/raw/docs/ui/part-grouping.mdx +0 -4
- package/.docs/raw/docs/ui/reasoning.mdx +1 -1
- package/.docs/raw/docs/ui/select.mdx +22 -14
- package/.docs/raw/docs/ui/sources.mdx +1 -1
- package/.docs/raw/docs/ui/tabs.mdx +25 -14
- package/.docs/raw/docs/utilities/heat-graph.mdx +2 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -2
- package/dist/index.js.map +1 -1
- package/dist/prepare-docs/code-examples.d.ts.map +1 -1
- package/dist/prepare-docs/code-examples.js.map +1 -1
- package/dist/prepare-docs/copy-raw.d.ts.map +1 -1
- package/dist/prepare-docs/prepare.d.ts +1 -1
- package/dist/prompts/xulux-playground.d.ts +12 -0
- package/dist/prompts/xulux-playground.d.ts.map +1 -0
- package/dist/prompts/xulux-playground.js +33 -0
- package/dist/prompts/xulux-playground.js.map +1 -0
- package/dist/stdio.d.ts +1 -1
- package/dist/tools/docs.d.ts +8 -14
- package/dist/tools/docs.d.ts.map +1 -1
- package/dist/tools/docs.js +26 -10
- package/dist/tools/docs.js.map +1 -1
- package/dist/tools/examples.d.ts +6 -12
- package/dist/tools/examples.d.ts.map +1 -1
- package/dist/tools/examples.js +11 -8
- package/dist/tools/examples.js.map +1 -1
- package/dist/tools/resources.d.ts +1 -2
- package/dist/tools/resources.d.ts.map +1 -1
- package/dist/tools/resources.js +1 -1
- package/dist/tools/resources.js.map +1 -1
- package/dist/tools/search.d.ts +6 -15
- 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 +5 -1
- package/dist/tools/tests/test-setup.js.map +1 -1
- package/dist/tools/xulux-templates.d.ts +58 -0
- package/dist/tools/xulux-templates.d.ts.map +1 -0
- package/dist/tools/xulux-templates.js +82 -0
- package/dist/tools/xulux-templates.js.map +1 -0
- package/dist/utils/cache.d.ts +5 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +18 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/mcp-format.d.ts +1 -0
- package/dist/utils/mcp-format.d.ts.map +1 -1
- package/dist/utils/mcp-format.js +7 -4
- package/dist/utils/mcp-format.js.map +1 -1
- package/dist/utils/mdx.d.ts.map +1 -1
- package/dist/utils/paths.d.ts +1 -1
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +3 -1
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/search.d.ts.map +1 -1
- package/dist/utils/security.d.ts.map +1 -1
- package/dist/utils/security.js.map +1 -1
- package/dist/xulux/catalog-client.d.ts +14 -0
- package/dist/xulux/catalog-client.d.ts.map +1 -0
- package/dist/xulux/catalog-client.js +67 -0
- package/dist/xulux/catalog-client.js.map +1 -0
- package/dist/xulux/fallback-catalog.d.ts +7 -0
- package/dist/xulux/fallback-catalog.d.ts.map +1 -0
- package/dist/xulux/fallback-catalog.js +47 -0
- package/dist/xulux/fallback-catalog.js.map +1 -0
- package/dist/xulux/fetch-sandbox.d.ts +5 -0
- package/dist/xulux/fetch-sandbox.d.ts.map +1 -0
- package/dist/xulux/fetch-sandbox.js +40 -0
- package/dist/xulux/fetch-sandbox.js.map +1 -0
- package/dist/xulux/template-service.d.ts +84 -0
- package/dist/xulux/template-service.d.ts.map +1 -0
- package/dist/xulux/template-service.js +223 -0
- package/dist/xulux/template-service.js.map +1 -0
- package/dist/xulux/types.d.ts +55 -0
- package/dist/xulux/types.d.ts.map +1 -0
- package/dist/xulux/types.js +6 -0
- package/dist/xulux/types.js.map +1 -0
- package/package.json +7 -6
- package/src/index.ts +55 -2
- package/src/prompts/xulux-playground.ts +36 -0
- package/src/tools/docs.ts +27 -5
- package/src/tools/examples.ts +17 -12
- 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 +20 -0
- package/src/tools/tests/examples.test.ts +5 -5
- package/src/tools/tests/integration.test.ts +3 -4
- package/src/tools/tests/listings-cache.test.ts +19 -0
- package/src/tools/tests/mcp-protocol.test.ts +173 -108
- package/src/tools/tests/mcp-test-client.ts +111 -0
- package/src/tools/tests/resources.test.ts +97 -66
- package/src/tools/tests/test-setup.ts +8 -0
- package/src/tools/tests/xulux-templates.test.ts +262 -0
- package/src/tools/xulux-templates.ts +141 -0
- package/src/utils/cache.ts +20 -0
- package/src/utils/mcp-format.ts +8 -6
- package/src/utils/paths.ts +4 -1
- package/src/utils/tests/cache.test.ts +51 -0
- package/src/utils/tests/mcp-format.test.ts +22 -0
- package/src/utils/tests/security.test.ts +1 -1
- package/src/xulux/catalog-client.ts +105 -0
- package/src/xulux/fallback-catalog.ts +63 -0
- package/src/xulux/fetch-sandbox.ts +56 -0
- package/src/xulux/template-service.ts +406 -0
- package/src/xulux/types.ts +60 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/utilities.mdx +0 -464
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { McpServer } from \"@modelcontextprotocol/
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { McpServer } from \"@modelcontextprotocol/server\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/server/stdio\";\nimport { docsTools } from \"./tools/docs.js\";\nimport { examplesTools } from \"./tools/examples.js\";\nimport { searchTools } from \"./tools/search.js\";\nimport {\n xuluxTemplatesListTool,\n xuluxTemplateDetailsTool,\n xuluxTemplatePreviewTool,\n} from \"./tools/xulux-templates.js\";\nimport { xuluxPlaygroundPrompt } from \"./prompts/xulux-playground.js\";\nimport { registerResources } from \"./tools/resources.js\";\nimport { logger } from \"./utils/logger.js\";\nimport { PACKAGE_DIR } from \"./constants.js\";\n\nimport { readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\nconst packageJson = JSON.parse(\n readFileSync(join(PACKAGE_DIR, \"package.json\"), \"utf-8\"),\n);\n\nexport const server = new McpServer({\n name: \"assistant-ui-docs\",\n version: packageJson.version,\n});\n\nserver.registerTool(\n docsTools.name,\n {\n title: \"assistant-ui Documentation\",\n description: docsTools.description,\n inputSchema: docsTools.parameters,\n annotations: { readOnlyHint: true, openWorldHint: false },\n },\n docsTools.execute,\n);\nserver.registerTool(\n examplesTools.name,\n {\n title: \"assistant-ui Examples\",\n description: examplesTools.description,\n inputSchema: examplesTools.parameters,\n annotations: { readOnlyHint: true, openWorldHint: false },\n },\n examplesTools.execute,\n);\nserver.registerTool(\n searchTools.name,\n {\n title: \"Search assistant-ui Documentation\",\n description: searchTools.description,\n inputSchema: searchTools.parameters,\n annotations: { readOnlyHint: true, openWorldHint: false },\n },\n searchTools.execute,\n);\n\nserver.registerTool(\n xuluxTemplatesListTool.name,\n {\n title: \"assistant-ui Templates\",\n description: xuluxTemplatesListTool.description,\n inputSchema: xuluxTemplatesListTool.parameters,\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n xuluxTemplatesListTool.execute,\n);\nserver.registerTool(\n xuluxTemplateDetailsTool.name,\n {\n title: \"assistant-ui Template Details\",\n description: xuluxTemplateDetailsTool.description,\n inputSchema: xuluxTemplateDetailsTool.parameters,\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n xuluxTemplateDetailsTool.execute,\n);\nserver.registerTool(\n xuluxTemplatePreviewTool.name,\n {\n title: \"assistant-ui Template Preview URLs\",\n description: xuluxTemplatePreviewTool.description,\n inputSchema: xuluxTemplatePreviewTool.parameters,\n annotations: { readOnlyHint: false, openWorldHint: true },\n },\n xuluxTemplatePreviewTool.execute,\n);\n\nserver.registerPrompt(\n xuluxPlaygroundPrompt.name,\n {\n title: \"assistant-ui Template Workflow\",\n description: xuluxPlaygroundPrompt.description,\n },\n () => ({\n messages: [\n {\n role: \"user\" as const,\n content: { type: \"text\" as const, text: xuluxPlaygroundPrompt.text },\n },\n ],\n }),\n);\n\nregisterResources(server);\n\nexport async function runServer() {\n try {\n logger.info(\n `Starting assistant-ui MCP docs server v${packageJson.version}`,\n );\n const transport = new StdioServerTransport();\n await server.connect(transport);\n } catch (error) {\n logger.error(\"Failed to start MCP server\", error);\n process.exit(1);\n }\n}\n\nif (import.meta.url === `file://${process.argv[1]}`) {\n void runServer().catch((error) => {\n console.error(\"Failed to start server:\", error);\n process.exit(1);\n });\n}\n"],"mappings":";;;;;;;;;;;;;AAkBA,MAAM,cAAc,KAAK,MACvB,aAAa,KAAK,aAAa,cAAc,GAAG,OAAO,CACzD;AAEA,MAAa,SAAS,IAAI,UAAU;CAClC,MAAM;CACN,SAAS,YAAY;AACvB,CAAC;AAED,OAAO,aACL,UAAU,MACV;CACE,OAAO;CACP,aAAa,UAAU;CACvB,aAAa,UAAU;CACvB,aAAa;EAAE,cAAc;EAAM,eAAe;CAAM;AAC1D,GACA,UAAU,OACZ;AACA,OAAO,aACL,cAAc,MACd;CACE,OAAO;CACP,aAAa,cAAc;CAC3B,aAAa,cAAc;CAC3B,aAAa;EAAE,cAAc;EAAM,eAAe;CAAM;AAC1D,GACA,cAAc,OAChB;AACA,OAAO,aACL,YAAY,MACZ;CACE,OAAO;CACP,aAAa,YAAY;CACzB,aAAa,YAAY;CACzB,aAAa;EAAE,cAAc;EAAM,eAAe;CAAM;AAC1D,GACA,YAAY,OACd;AAEA,OAAO,aACL,uBAAuB,MACvB;CACE,OAAO;CACP,aAAa,uBAAuB;CACpC,aAAa,uBAAuB;CACpC,aAAa;EAAE,cAAc;EAAM,eAAe;CAAK;AACzD,GACA,uBAAuB,OACzB;AACA,OAAO,aACL,yBAAyB,MACzB;CACE,OAAO;CACP,aAAa,yBAAyB;CACtC,aAAa,yBAAyB;CACtC,aAAa;EAAE,cAAc;EAAM,eAAe;CAAK;AACzD,GACA,yBAAyB,OAC3B;AACA,OAAO,aACL,yBAAyB,MACzB;CACE,OAAO;CACP,aAAa,yBAAyB;CACtC,aAAa,yBAAyB;CACtC,aAAa;EAAE,cAAc;EAAO,eAAe;CAAK;AAC1D,GACA,yBAAyB,OAC3B;AAEA,OAAO,eACL,sBAAsB,MACtB;CACE,OAAO;CACP,aAAa,sBAAsB;AACrC,UACO,EACL,UAAU,CACR;CACE,MAAM;CACN,SAAS;EAAE,MAAM;EAAiB,MAAM,sBAAsB;CAAK;AACrE,CACF,EACF,EACF;AAEA,kBAAkB,MAAM;AAExB,eAAsB,YAAY;CAChC,IAAI;EACF,OAAO,KACL,0CAA0C,YAAY,SACxD;EACA,MAAM,YAAY,IAAI,qBAAqB;EAC3C,MAAM,OAAO,QAAQ,SAAS;CAChC,SAAS,OAAO;EACd,OAAO,MAAM,8BAA8B,KAAK;EAChD,QAAQ,KAAK,CAAC;CAChB;AACF;AAEA,IAAI,OAAO,KAAK,QAAQ,UAAU,QAAQ,KAAK,MAC7C,UAAe,CAAC,CAAC,OAAO,UAAU;CAChC,QAAQ,MAAM,2BAA2B,KAAK;CAC9C,QAAQ,KAAK,CAAC;AAChB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-examples.d.ts","names":[],"sources":["../../src/prepare-docs/code-examples.ts"],"mappings":";iBA2FsB,
|
|
1
|
+
{"version":3,"file":"code-examples.d.ts","names":[],"sources":["../../src/prepare-docs/code-examples.ts"],"mappings":";iBA2FsB,uBAAuB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-examples.js","names":[],"sources":["../../src/prepare-docs/code-examples.ts"],"sourcesContent":["import { rm, mkdir, readdir, readFile, writeFile } from \"node:fs/promises\";\nimport { join, relative, extname } from \"node:path\";\nimport { logger } from \"../utils/logger.js\";\nimport { ROOT_DIR, EXAMPLES_PATH } from \"../constants.js\";\n\nconst OUTPUT_DIR = join(\n ROOT_DIR,\n \"packages/mcp-docs-server/.docs/organized/code-examples\",\n);\nconst MAX_LINES = 10000;\n\ninterface FileContent {\n path: string;\n content: string;\n}\n\nasync function scanDirectory(\n dir: string,\n baseDir: string,\n): Promise<FileContent[]> {\n const files: FileContent[] = [];\n\n try {\n const entries = await readdir(dir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = join(dir, entry.name);\n\n if (entry.isDirectory()) {\n const skipDirs = [\n \"node_modules\",\n \"dist\",\n \"build\",\n \".next\",\n \".git\",\n \".turbo\",\n ];\n if (!skipDirs.includes(entry.name)) {\n const subFiles = await scanDirectory(fullPath, baseDir);\n files.push(...subFiles);\n }\n } else if (entry.isFile()) {\n const includeExts = [\n \".ts\",\n \".tsx\",\n \".js\",\n \".jsx\",\n \".json\",\n \".css\",\n \".md\",\n \".mdx\",\n ];\n const ext = extname(entry.name).toLowerCase();\n\n if (\n includeExts.includes(ext) ||\n entry.name === \"package.json\" ||\n entry.name === \"tsconfig.json\"\n ) {\n try {\n const content = await readFile(fullPath, \"utf-8\");\n const relativePath = relative(baseDir, fullPath);\n files.push({ path: relativePath, content });\n } catch (error) {\n logger.warn(`Failed to read file: ${fullPath}`, error);\n }\n }\n }\n }\n } catch (error) {\n logger.error(`Failed to scan directory: ${dir}`, error);\n }\n\n return files;\n}\n\nfunction getFileType(filename: string): string {\n const ext = extname(filename).toLowerCase();\n const extMap: Record<string, string> = {\n \".ts\": \"typescript\",\n \".tsx\": \"tsx\",\n \".js\": \"javascript\",\n \".jsx\": \"jsx\",\n \".json\": \"json\",\n \".css\": \"css\",\n \".md\": \"markdown\",\n \".mdx\": \"mdx\",\n };\n return extMap[ext] || \"text\";\n}\n\nexport async function prepareCodeExamples(): Promise<void> {\n logger.info(\"Preparing code examples...\");\n\n try {\n await rm(OUTPUT_DIR, { recursive: true, force: true });\n await mkdir(OUTPUT_DIR, { recursive: true });\n\n const exampleDirs = await readdir(EXAMPLES_PATH, { withFileTypes: true });\n\n for (const dir of exampleDirs) {\n if (dir.isDirectory() && !dir.name.startsWith(\".\")) {\n const examplePath = join(EXAMPLES_PATH, dir.name);\n logger.info(`Processing example: ${dir.name}`);\n\n let description = \"\";\n try {\n const packageJsonPath = join(examplePath, \"package.json\");\n const packageJson = JSON.parse(\n await readFile(packageJsonPath, \"utf-8\"),\n );\n description = packageJson.description || \"\";\n } catch (error: any) {\n if (error?.code !== \"ENOENT\") {\n logger.warn(`Failed to read package.json for ${dir.name}:`, error);\n } else {\n logger.debug(`No package.json found for example: ${dir.name}`);\n }\n }\n\n const files = await scanDirectory(examplePath, examplePath);\n\n files.sort((a, b) => a.path.localeCompare(b.path));\n\n let markdown = `# Example: ${dir.name}\\n\\n`;\n if (description) {\n markdown += `${description}\\n\\n`;\n }\n\n let totalLines = 0;\n for (const file of files) {\n const lines = file.content.split(\"\\n\").length;\n if (totalLines + lines > MAX_LINES) {\n markdown += `\\n_Note: Additional files truncated due to size limits_\\n`;\n break;\n }\n\n // Normalize Windows backslashes to forward slashes for consistent markdown output\n markdown += `## ${file.path.replace(/\\\\/g, \"/\")}\\n\\n`;\n markdown += `\\`\\`\\`${getFileType(file.path)}\\n`;\n markdown += file.content;\n markdown += `\\n\\`\\`\\`\\n\\n`;\n\n totalLines += lines;\n }\n\n const outputPath = join(OUTPUT_DIR, `${dir.name}.md`);\n await writeFile(outputPath, markdown, \"utf-8\");\n logger.debug(`Created example: ${outputPath}`);\n }\n }\n\n logger.info(\"Code examples preparation complete\");\n } catch (error) {\n logger.error(\"Failed to prepare code examples\", error);\n throw error;\n }\n}\n"],"mappings":";;;;;AAKA,MAAM,aAAa,KACjB,UACA,wDACF;AACA,MAAM,YAAY;AAOlB,eAAe,cACb,KACA,SACwB;CACxB,MAAM,QAAuB,CAAC;CAE9B,IAAI;EACF,MAAM,UAAU,MAAM,QAAQ,KAAK,EAAE,eAAe,KAAK,CAAC;EAE1D,KAAK,MAAM,SAAS,SAAS;GAC3B,MAAM,WAAW,KAAK,KAAK,MAAM,IAAI;GAErC,IAAI,MAAM,YAAY;
|
|
1
|
+
{"version":3,"file":"code-examples.js","names":[],"sources":["../../src/prepare-docs/code-examples.ts"],"sourcesContent":["import { rm, mkdir, readdir, readFile, writeFile } from \"node:fs/promises\";\nimport { join, relative, extname } from \"node:path\";\nimport { logger } from \"../utils/logger.js\";\nimport { ROOT_DIR, EXAMPLES_PATH } from \"../constants.js\";\n\nconst OUTPUT_DIR = join(\n ROOT_DIR,\n \"packages/mcp-docs-server/.docs/organized/code-examples\",\n);\nconst MAX_LINES = 10000;\n\ninterface FileContent {\n path: string;\n content: string;\n}\n\nasync function scanDirectory(\n dir: string,\n baseDir: string,\n): Promise<FileContent[]> {\n const files: FileContent[] = [];\n\n try {\n const entries = await readdir(dir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = join(dir, entry.name);\n\n if (entry.isDirectory()) {\n const skipDirs = [\n \"node_modules\",\n \"dist\",\n \"build\",\n \".next\",\n \".git\",\n \".turbo\",\n ];\n if (!skipDirs.includes(entry.name)) {\n const subFiles = await scanDirectory(fullPath, baseDir);\n files.push(...subFiles);\n }\n } else if (entry.isFile()) {\n const includeExts = [\n \".ts\",\n \".tsx\",\n \".js\",\n \".jsx\",\n \".json\",\n \".css\",\n \".md\",\n \".mdx\",\n ];\n const ext = extname(entry.name).toLowerCase();\n\n if (\n includeExts.includes(ext) ||\n entry.name === \"package.json\" ||\n entry.name === \"tsconfig.json\"\n ) {\n try {\n const content = await readFile(fullPath, \"utf-8\");\n const relativePath = relative(baseDir, fullPath);\n files.push({ path: relativePath, content });\n } catch (error) {\n logger.warn(`Failed to read file: ${fullPath}`, error);\n }\n }\n }\n }\n } catch (error) {\n logger.error(`Failed to scan directory: ${dir}`, error);\n }\n\n return files;\n}\n\nfunction getFileType(filename: string): string {\n const ext = extname(filename).toLowerCase();\n const extMap: Record<string, string> = {\n \".ts\": \"typescript\",\n \".tsx\": \"tsx\",\n \".js\": \"javascript\",\n \".jsx\": \"jsx\",\n \".json\": \"json\",\n \".css\": \"css\",\n \".md\": \"markdown\",\n \".mdx\": \"mdx\",\n };\n return extMap[ext] || \"text\";\n}\n\nexport async function prepareCodeExamples(): Promise<void> {\n logger.info(\"Preparing code examples...\");\n\n try {\n await rm(OUTPUT_DIR, { recursive: true, force: true });\n await mkdir(OUTPUT_DIR, { recursive: true });\n\n const exampleDirs = await readdir(EXAMPLES_PATH, { withFileTypes: true });\n\n for (const dir of exampleDirs) {\n if (dir.isDirectory() && !dir.name.startsWith(\".\")) {\n const examplePath = join(EXAMPLES_PATH, dir.name);\n logger.info(`Processing example: ${dir.name}`);\n\n let description = \"\";\n try {\n const packageJsonPath = join(examplePath, \"package.json\");\n const packageJson = JSON.parse(\n await readFile(packageJsonPath, \"utf-8\"),\n );\n description = packageJson.description || \"\";\n } catch (error: any) {\n if (error?.code !== \"ENOENT\") {\n logger.warn(`Failed to read package.json for ${dir.name}:`, error);\n } else {\n logger.debug(`No package.json found for example: ${dir.name}`);\n }\n }\n\n const files = await scanDirectory(examplePath, examplePath);\n\n files.sort((a, b) => a.path.localeCompare(b.path));\n\n let markdown = `# Example: ${dir.name}\\n\\n`;\n if (description) {\n markdown += `${description}\\n\\n`;\n }\n\n let totalLines = 0;\n for (const file of files) {\n const lines = file.content.split(\"\\n\").length;\n if (totalLines + lines > MAX_LINES) {\n markdown += `\\n_Note: Additional files truncated due to size limits_\\n`;\n break;\n }\n\n // Normalize Windows backslashes to forward slashes for consistent markdown output\n markdown += `## ${file.path.replace(/\\\\/g, \"/\")}\\n\\n`;\n markdown += `\\`\\`\\`${getFileType(file.path)}\\n`;\n markdown += file.content;\n markdown += `\\n\\`\\`\\`\\n\\n`;\n\n totalLines += lines;\n }\n\n const outputPath = join(OUTPUT_DIR, `${dir.name}.md`);\n await writeFile(outputPath, markdown, \"utf-8\");\n logger.debug(`Created example: ${outputPath}`);\n }\n }\n\n logger.info(\"Code examples preparation complete\");\n } catch (error) {\n logger.error(\"Failed to prepare code examples\", error);\n throw error;\n }\n}\n"],"mappings":";;;;;AAKA,MAAM,aAAa,KACjB,UACA,wDACF;AACA,MAAM,YAAY;AAOlB,eAAe,cACb,KACA,SACwB;CACxB,MAAM,QAAuB,CAAC;CAE9B,IAAI;EACF,MAAM,UAAU,MAAM,Q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ts","names":[],"sources":["../../src/prepare-docs/copy-raw.ts"],"mappings":";iBAiCsB,
|
|
1
|
+
{"version":3,"file":"copy-raw.d.ts","names":[],"sources":["../../src/prepare-docs/copy-raw.ts"],"mappings":";iBAiCsB,WAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/prompts/xulux-playground.d.ts
|
|
2
|
+
declare const XULUX_PLAYGROUND_PROMPT_NAME = "assistant-ui-template-workflow";
|
|
3
|
+
declare const XULUX_PLAYGROUND_PROMPT_DESCRIPTION = "How to use the assistant-ui template tools to discover hosted templates, inspect their customization contracts, and retrieve preview/download URLs.";
|
|
4
|
+
declare const XULUX_PLAYGROUND_PROMPT = "You have access to assistant-ui template tools for hosted app templates.\n\n<workflow>\nFollow this template-first workflow for any assistant-ui app-building request:\n\n1. Call **assistantUITemplates** FIRST. Never decide on a template or claim one exists without listing.\n2. Call **assistantUITemplateDetails** on any candidate template before deciding whether it fits.\n - Review the whole template shape: features, assistantPlacement, configRoots schemas, rules, built-in tools, renderers, and exampleConfig.\n - If `customizable` is empty, the entry is a fixed demo. Use it as-is; never pass a config for it.\n3. Decide one of three paths:\n - The template fits as-is: call **assistantUITemplatePreview** with templateId and optional versionId.\n - The template fits with supported customization: author a config using the configRoots schemas and rules from assistantUITemplateDetails, then call **assistantUITemplatePreview** with that config.\n - No template fits: do NOT call assistantUITemplatePreview. Do not force the request into a template or fake domain content with mock config. Instead, ground yourself in the assistant-ui docs (assistantUIDocs, assistantUISearch, assistantUIExamples) and produce an honest, docs-grounded build guide or prompt for the user.\n</workflow>\n\n<important_constraints>\n- Only use URLs copied exactly from tool results. Never guess, fabricate, or use placeholder URLs.\n- If assistantUITemplatePreview returns validationWarnings or an error, call assistantUITemplateDetails again and correct the config against configRoots. Pass only the documented top-level config roots.\n- Customization is for supported adaptation within a template's shape, not for turning it into a completely different kind of product.\n- Responses may include `catalogDegraded: true` when the live template catalog is unreachable. In that mode, template details and preview URLs may be unavailable; tell the user rather than improvising.\n</important_constraints>";
|
|
5
|
+
declare const xuluxPlaygroundPrompt: {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
text: string;
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { XULUX_PLAYGROUND_PROMPT, XULUX_PLAYGROUND_PROMPT_DESCRIPTION, XULUX_PLAYGROUND_PROMPT_NAME, xuluxPlaygroundPrompt };
|
|
12
|
+
//# sourceMappingURL=xulux-playground.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xulux-playground.d.ts","names":[],"sources":["../../src/prompts/xulux-playground.ts"],"mappings":";cAIa;cAEA;cAGA;cAsBA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region src/prompts/xulux-playground.ts
|
|
2
|
+
const XULUX_PLAYGROUND_PROMPT_NAME = "assistant-ui-template-workflow";
|
|
3
|
+
const XULUX_PLAYGROUND_PROMPT_DESCRIPTION = "How to use the assistant-ui template tools to discover hosted templates, inspect their customization contracts, and retrieve preview/download URLs.";
|
|
4
|
+
const XULUX_PLAYGROUND_PROMPT = `You have access to assistant-ui template tools for hosted app templates.
|
|
5
|
+
|
|
6
|
+
<workflow>
|
|
7
|
+
Follow this template-first workflow for any assistant-ui app-building request:
|
|
8
|
+
|
|
9
|
+
1. Call **assistantUITemplates** FIRST. Never decide on a template or claim one exists without listing.
|
|
10
|
+
2. Call **assistantUITemplateDetails** on any candidate template before deciding whether it fits.
|
|
11
|
+
- Review the whole template shape: features, assistantPlacement, configRoots schemas, rules, built-in tools, renderers, and exampleConfig.
|
|
12
|
+
- If \`customizable\` is empty, the entry is a fixed demo. Use it as-is; never pass a config for it.
|
|
13
|
+
3. Decide one of three paths:
|
|
14
|
+
- The template fits as-is: call **assistantUITemplatePreview** with templateId and optional versionId.
|
|
15
|
+
- The template fits with supported customization: author a config using the configRoots schemas and rules from assistantUITemplateDetails, then call **assistantUITemplatePreview** with that config.
|
|
16
|
+
- No template fits: do NOT call assistantUITemplatePreview. Do not force the request into a template or fake domain content with mock config. Instead, ground yourself in the assistant-ui docs (assistantUIDocs, assistantUISearch, assistantUIExamples) and produce an honest, docs-grounded build guide or prompt for the user.
|
|
17
|
+
</workflow>
|
|
18
|
+
|
|
19
|
+
<important_constraints>
|
|
20
|
+
- Only use URLs copied exactly from tool results. Never guess, fabricate, or use placeholder URLs.
|
|
21
|
+
- If assistantUITemplatePreview returns validationWarnings or an error, call assistantUITemplateDetails again and correct the config against configRoots. Pass only the documented top-level config roots.
|
|
22
|
+
- Customization is for supported adaptation within a template's shape, not for turning it into a completely different kind of product.
|
|
23
|
+
- Responses may include \`catalogDegraded: true\` when the live template catalog is unreachable. In that mode, template details and preview URLs may be unavailable; tell the user rather than improvising.
|
|
24
|
+
</important_constraints>`;
|
|
25
|
+
const xuluxPlaygroundPrompt = {
|
|
26
|
+
name: XULUX_PLAYGROUND_PROMPT_NAME,
|
|
27
|
+
description: XULUX_PLAYGROUND_PROMPT_DESCRIPTION,
|
|
28
|
+
text: XULUX_PLAYGROUND_PROMPT
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
export { XULUX_PLAYGROUND_PROMPT, XULUX_PLAYGROUND_PROMPT_DESCRIPTION, XULUX_PLAYGROUND_PROMPT_NAME, xuluxPlaygroundPrompt };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=xulux-playground.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xulux-playground.js","names":[],"sources":["../../src/prompts/xulux-playground.ts"],"sourcesContent":["// Skill-style MCP prompt teaching agents the assistant-ui template workflow.\n// Adapted for MCP clients: tools return URLs and data only; there is no\n// browser canvas UI here.\n\nexport const XULUX_PLAYGROUND_PROMPT_NAME = \"assistant-ui-template-workflow\";\n\nexport const XULUX_PLAYGROUND_PROMPT_DESCRIPTION =\n \"How to use the assistant-ui template tools to discover hosted templates, inspect their customization contracts, and retrieve preview/download URLs.\";\n\nexport const XULUX_PLAYGROUND_PROMPT = `You have access to assistant-ui template tools for hosted app templates.\n\n<workflow>\nFollow this template-first workflow for any assistant-ui app-building request:\n\n1. Call **assistantUITemplates** FIRST. Never decide on a template or claim one exists without listing.\n2. Call **assistantUITemplateDetails** on any candidate template before deciding whether it fits.\n - Review the whole template shape: features, assistantPlacement, configRoots schemas, rules, built-in tools, renderers, and exampleConfig.\n - If \\`customizable\\` is empty, the entry is a fixed demo. Use it as-is; never pass a config for it.\n3. Decide one of three paths:\n - The template fits as-is: call **assistantUITemplatePreview** with templateId and optional versionId.\n - The template fits with supported customization: author a config using the configRoots schemas and rules from assistantUITemplateDetails, then call **assistantUITemplatePreview** with that config.\n - No template fits: do NOT call assistantUITemplatePreview. Do not force the request into a template or fake domain content with mock config. Instead, ground yourself in the assistant-ui docs (assistantUIDocs, assistantUISearch, assistantUIExamples) and produce an honest, docs-grounded build guide or prompt for the user.\n</workflow>\n\n<important_constraints>\n- Only use URLs copied exactly from tool results. Never guess, fabricate, or use placeholder URLs.\n- If assistantUITemplatePreview returns validationWarnings or an error, call assistantUITemplateDetails again and correct the config against configRoots. Pass only the documented top-level config roots.\n- Customization is for supported adaptation within a template's shape, not for turning it into a completely different kind of product.\n- Responses may include \\`catalogDegraded: true\\` when the live template catalog is unreachable. In that mode, template details and preview URLs may be unavailable; tell the user rather than improvising.\n</important_constraints>`;\n\nexport const xuluxPlaygroundPrompt = {\n name: XULUX_PLAYGROUND_PROMPT_NAME,\n description: XULUX_PLAYGROUND_PROMPT_DESCRIPTION,\n text: XULUX_PLAYGROUND_PROMPT,\n};\n"],"mappings":";AAIA,MAAa,+BAA+B;AAE5C,MAAa,sCACX;AAEF,MAAa,0BAA0B;;;;;;;;;;;;;;;;;;;;;AAsBvC,MAAa,wBAAwB;CACnC,MAAM;CACN,aAAa;CACb,MAAM;AACR"}
|
package/dist/stdio.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {}
|
package/dist/tools/docs.d.ts
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
|
-
import { z } from "zod
|
|
2
|
-
|
|
1
|
+
import { z } from "zod";
|
|
3
2
|
//#region src/tools/docs.d.ts
|
|
4
3
|
declare const docsInputSchema: z.ZodObject<{
|
|
5
|
-
paths: z.ZodArray<z.ZodString
|
|
6
|
-
},
|
|
7
|
-
paths: string[];
|
|
8
|
-
}, {
|
|
9
|
-
paths: string[];
|
|
10
|
-
}>;
|
|
4
|
+
paths: z.ZodArray<z.ZodString>;
|
|
5
|
+
}, z.core.$strip>;
|
|
11
6
|
declare const docsTools: {
|
|
12
7
|
name: string;
|
|
13
8
|
description: string;
|
|
14
|
-
parameters: {
|
|
15
|
-
paths: z.ZodArray<z.ZodString
|
|
16
|
-
}
|
|
17
|
-
execute: ({
|
|
18
|
-
paths
|
|
19
|
-
}: z.infer<typeof docsInputSchema>) => Promise<{
|
|
9
|
+
parameters: z.ZodObject<{
|
|
10
|
+
paths: z.ZodArray<z.ZodString>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
execute: ({ paths }: z.infer<typeof docsInputSchema>) => Promise<{
|
|
20
13
|
content: Array<{
|
|
21
14
|
type: "text";
|
|
22
15
|
text: string;
|
|
23
16
|
}>;
|
|
17
|
+
structuredContent?: Record<string, unknown>;
|
|
24
18
|
}>;
|
|
25
19
|
};
|
|
26
20
|
//#endregion
|
package/dist/tools/docs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs.d.ts","names":[],"sources":["../../src/tools/docs.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"docs.d.ts","names":[],"sources":["../../src/tools/docs.ts"],"mappings":";;cAoBM,iBAAe,EAAA;;GAOnB,EAAA,KAAA;cAwLW;;;;;;EAKgB,YAAA,SAAA,EAAE,aAAa,qBAAgB"}
|
package/dist/tools/docs.js
CHANGED
|
@@ -5,7 +5,7 @@ import { formatMDXContent, readMDXFile } from "../utils/mdx.js";
|
|
|
5
5
|
import { formatMCPResponse } from "../utils/mcp-format.js";
|
|
6
6
|
import { sanitizePath } from "../utils/security.js";
|
|
7
7
|
import { extname, join } from "node:path";
|
|
8
|
-
import { z } from "zod
|
|
8
|
+
import { z } from "zod";
|
|
9
9
|
import { lstat, stat } from "node:fs/promises";
|
|
10
10
|
//#region src/tools/docs.ts
|
|
11
11
|
const docsInputSchema = z.object({ paths: z.array(z.string()).min(1).describe("Documentation paths to retrieve (e.g., [\"getting-started\", \"api-reference/primitives/thread\"])") });
|
|
@@ -46,6 +46,7 @@ async function readDocumentation(docPath) {
|
|
|
46
46
|
if (stats.isDirectory()) {
|
|
47
47
|
const { directories, files } = await listDirContents(fullPath);
|
|
48
48
|
const contents = {};
|
|
49
|
+
const summaries = [];
|
|
49
50
|
let aggregateSize = 0;
|
|
50
51
|
let truncated = false;
|
|
51
52
|
for (const file of files) {
|
|
@@ -62,7 +63,16 @@ async function readDocumentation(docPath) {
|
|
|
62
63
|
break;
|
|
63
64
|
}
|
|
64
65
|
const mdxContent = await readMDXFile(join(fullPath, file));
|
|
65
|
-
if (mdxContent)
|
|
66
|
+
if (mdxContent) {
|
|
67
|
+
const name = file.replace(MDX_EXTENSION, "");
|
|
68
|
+
contents[name] = formatMDXContent(mdxContent);
|
|
69
|
+
const title = mdxContent.frontmatter["title"];
|
|
70
|
+
summaries.push({
|
|
71
|
+
name,
|
|
72
|
+
...typeof title === "string" && { title },
|
|
73
|
+
...mdxContent.excerpt !== void 0 && { excerpt: mdxContent.excerpt }
|
|
74
|
+
});
|
|
75
|
+
}
|
|
66
76
|
}
|
|
67
77
|
const content = !truncated && Object.keys(contents).length > 0 ? JSON.stringify(contents, null, 2) : void 0;
|
|
68
78
|
return {
|
|
@@ -71,8 +81,9 @@ async function readDocumentation(docPath) {
|
|
|
71
81
|
type: "directory",
|
|
72
82
|
directories,
|
|
73
83
|
files: files.map((f) => f.replace(MDX_EXTENSION, "")),
|
|
84
|
+
...summaries.length > 0 && { summaries },
|
|
74
85
|
...content !== void 0 && { content },
|
|
75
|
-
...truncated && { hint: `Directory content exceeds 1048576 bytes and was omitted;
|
|
86
|
+
...truncated && { hint: `Directory content exceeds 1048576 bytes and was omitted; summaries cover only the files read before the limit. Request individual files by path to retrieve their content.` }
|
|
76
87
|
};
|
|
77
88
|
}
|
|
78
89
|
}
|
|
@@ -98,12 +109,17 @@ async function readDocumentation(docPath) {
|
|
|
98
109
|
} catch {}
|
|
99
110
|
if (await pathExists(mdxPath)) {
|
|
100
111
|
const mdxContent = await readMDXFile(mdxPath);
|
|
101
|
-
if (mdxContent)
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
112
|
+
if (mdxContent) {
|
|
113
|
+
const title = mdxContent.frontmatter["title"];
|
|
114
|
+
return {
|
|
115
|
+
path: docPath,
|
|
116
|
+
found: true,
|
|
117
|
+
type: "file",
|
|
118
|
+
content: formatMDXContent(mdxContent),
|
|
119
|
+
...typeof title === "string" && { title },
|
|
120
|
+
...mdxContent.excerpt !== void 0 && { excerpt: mdxContent.excerpt }
|
|
121
|
+
};
|
|
122
|
+
}
|
|
107
123
|
}
|
|
108
124
|
return {
|
|
109
125
|
path: docPath,
|
|
@@ -122,7 +138,7 @@ async function readDocumentation(docPath) {
|
|
|
122
138
|
const docsTools = {
|
|
123
139
|
name: "assistantUIDocs",
|
|
124
140
|
description: "Retrieve assistant-ui documentation by path. Use \"/\" to list all sections. Supports multiple paths in a single request.",
|
|
125
|
-
parameters: docsInputSchema
|
|
141
|
+
parameters: docsInputSchema,
|
|
126
142
|
execute: async ({ paths }) => {
|
|
127
143
|
logger.info(`Retrieving documentation for paths: ${paths.join(", ")}`);
|
|
128
144
|
try {
|
package/dist/tools/docs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs.js","names":[],"sources":["../../src/tools/docs.ts"],"sourcesContent":["import { z } from \"zod/v3\";\nimport { stat, lstat } from \"node:fs/promises\";\nimport { join, extname } from \"node:path\";\nimport {\n DOCS_PATH,\n MDX_EXTENSION,\n MAX_FILE_SIZE,\n MAX_DIRECTORY_CONTENT_SIZE,\n} from \"../constants.js\";\nimport { logger } from \"../utils/logger.js\";\nimport {\n listDirContents,\n getAvailablePaths,\n findNearestPaths,\n pathExists,\n} from \"../utils/paths.js\";\nimport { readMDXFile, formatMDXContent } from \"../utils/mdx.js\";\nimport { formatMCPResponse } from \"../utils/mcp-format.js\";\nimport { sanitizePath } from \"../utils/security.js\";\n\nconst docsInputSchema = z.object({\n paths: z\n .array(z.string())\n .min(1)\n .describe(\n 'Documentation paths to retrieve (e.g., [\"getting-started\", \"api-reference/primitives/thread\"])',\n ),\n});\n\ninterface DocResult {\n path: string;\n found: boolean;\n type?: \"file\" | \"directory\";\n content?: string;\n files?: string[];\n directories?: string[];\n suggestions?: string[];\n hint?: string;\n error?: string;\n}\n\nasync function readDocumentation(docPath: string): Promise<DocResult> {\n logger.debug(`Reading documentation for path: ${docPath}`);\n\n if (docPath === \"/\" || docPath === \"\") {\n const { directories, files } = await listDirContents(DOCS_PATH);\n return {\n path: \"/\",\n found: true,\n type: \"directory\",\n directories,\n files: files.map((f) => f.replace(MDX_EXTENSION, \"\")),\n };\n }\n\n try {\n const sanitized = sanitizePath(docPath);\n const fullPath = join(DOCS_PATH, sanitized);\n\n try {\n const lstats = await lstat(fullPath);\n if (lstats.isSymbolicLink()) {\n logger.warn(`Symlink detected at path: ${fullPath}`);\n return {\n path: docPath,\n found: false,\n error: \"Symlinks are not allowed for security reasons\",\n };\n }\n } catch {}\n\n if (await pathExists(fullPath)) {\n const stats = await stat(fullPath);\n\n if (stats.isFile() && stats.size > MAX_FILE_SIZE) {\n logger.warn(`File too large: ${fullPath} (${stats.size} bytes)`);\n return {\n path: docPath,\n found: false,\n error: `File size exceeds maximum allowed size of ${MAX_FILE_SIZE} bytes`,\n };\n }\n\n if (stats.isDirectory()) {\n const { directories, files } = await listDirContents(fullPath);\n\n const contents: Record<string, string> = {};\n let aggregateSize = 0;\n let truncated = false;\n for (const file of files) {\n let fileSize: number;\n try {\n fileSize = (await stat(join(fullPath, file))).size;\n } catch (error) {\n logger.warn(\n `Failed to stat MDX file: ${join(fullPath, file)}`,\n error,\n );\n continue;\n }\n aggregateSize += fileSize;\n if (aggregateSize > MAX_DIRECTORY_CONTENT_SIZE) {\n truncated = true;\n break;\n }\n const mdxContent = await readMDXFile(join(fullPath, file));\n if (mdxContent) {\n contents[file.replace(MDX_EXTENSION, \"\")] =\n formatMDXContent(mdxContent);\n }\n }\n\n const content =\n !truncated && Object.keys(contents).length > 0\n ? JSON.stringify(contents, null, 2)\n : undefined;\n return {\n path: docPath,\n found: true,\n type: \"directory\",\n directories,\n files: files.map((f) => f.replace(MDX_EXTENSION, \"\")),\n ...(content !== undefined && { content }),\n ...(truncated && {\n hint: `Directory content exceeds ${MAX_DIRECTORY_CONTENT_SIZE} bytes and was omitted; request individual files by path to retrieve their content.`,\n }),\n };\n }\n }\n\n const mdxPath =\n extname(fullPath) === MDX_EXTENSION\n ? fullPath\n : `${fullPath}${MDX_EXTENSION}`;\n\n try {\n const mdxLstats = await lstat(mdxPath);\n if (mdxLstats.isSymbolicLink()) {\n logger.warn(`Symlink detected at MDX path: ${mdxPath}`);\n return {\n path: docPath,\n found: false,\n error: \"Symlinks are not allowed for security reasons\",\n };\n }\n\n if (mdxLstats.size > MAX_FILE_SIZE) {\n logger.warn(`MDX file too large: ${mdxPath} (${mdxLstats.size} bytes)`);\n return {\n path: docPath,\n found: false,\n error: `File size exceeds maximum allowed size of ${MAX_FILE_SIZE} bytes`,\n };\n }\n } catch {}\n\n if (await pathExists(mdxPath)) {\n const mdxContent = await readMDXFile(mdxPath);\n\n if (mdxContent) {\n return {\n path: docPath,\n found: true,\n type: \"file\",\n content: formatMDXContent(mdxContent),\n };\n }\n }\n\n const availablePaths = await getAvailablePaths();\n const suggestions = findNearestPaths(docPath, availablePaths);\n\n return {\n path: docPath,\n found: false,\n suggestions,\n };\n } catch (error) {\n if (error instanceof Error && error.message.includes(\"Invalid path\")) {\n return {\n path: docPath,\n found: false,\n error: error.message,\n };\n }\n throw error;\n }\n}\n\nexport const docsTools = {\n name: \"assistantUIDocs\",\n description:\n 'Retrieve assistant-ui documentation by path. Use \"/\" to list all sections. Supports multiple paths in a single request.',\n parameters: docsInputSchema.shape,\n execute: async ({ paths }: z.infer<typeof docsInputSchema>) => {\n logger.info(`Retrieving documentation for paths: ${paths.join(\", \")}`);\n\n try {\n const results = await Promise.all(\n paths.map((path) => readDocumentation(path)),\n );\n\n if (results.length === 1) {\n const result = results[0]!;\n if (result.error) {\n return formatMCPResponse({\n error: result.error,\n path: result.path,\n });\n }\n if (!result.found) {\n return formatMCPResponse({\n error: `Documentation not found for path: ${result.path}`,\n suggestions: result.suggestions,\n hint: 'Use \"/\" to list all available documentation sections',\n });\n }\n return formatMCPResponse(result);\n }\n\n return formatMCPResponse({\n results,\n summary: `Retrieved ${results.filter((r) => r.found).length} of ${results.length} requested paths`,\n });\n } catch (error) {\n logger.error(\"Failed to retrieve documentation\", error);\n return formatMCPResponse({\n error: \"Failed to retrieve documentation\",\n message: error instanceof Error ? error.message : String(error),\n });\n }\n },\n};\n"],"mappings":";;;;;;;;;;AAoBA,MAAM,kBAAkB,EAAE,OAAO,EAC/B,OAAO,EACJ,MAAM,EAAE,OAAO,CAAC,CAAC,CACjB,IAAI,CAAC,CAAC,CACN,SACC,oGACF,EACJ,CAAC;AAcD,eAAe,kBAAkB,SAAqC;CACpE,OAAO,MAAM,mCAAmC,SAAS;CAEzD,IAAI,YAAY,OAAO,YAAY,IAAI;EACrC,MAAM,EAAE,aAAa,UAAU,MAAM,gBAAgB,SAAS;EAC9D,OAAO;GACL,MAAM;GACN,OAAO;GACP,MAAM;GACN;GACA,OAAO,MAAM,KAAK,MAAM,EAAE,QAAQ,eAAe,EAAE,CAAC;EACtD;CACF;CAEA,I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AAkB;KACvB,OAAO,OAAO;KACd,MAAM,OAAO;IACf,CAAC;IAEH,IAAI,CAAC,OAAO,OACV,OAAO,kBAAkB;KACvB,OAAO,qCAAqC,OAAO;KACnD,aAAa,OAAO;KACpB,MAAM;IACR,CAAC;IAEH,OAAO,kBAAkB,MAAM;GACjC;GAEA,OAAO,kBAAkB;IACvB;IACA,SAAS,aAAa,QAAQ,QAAQ,MAAM,EAAE,KAAK,CAAC,CAAC,OAAO,MAAM,QAAQ,OAAO;GACnF,CAAC;EACH,SAAS,OAAO;GACd,OAAO,MAAM,oCAAoC,KAAK;GACtD,OAAO,kBAAkB;IACvB,OAAO;IACP,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GAChE,CAAC;EACH;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"docs.js","names":[],"sources":["../../src/tools/docs.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { stat, lstat } from \"node:fs/promises\";\nimport { join, extname } from \"node:path\";\nimport {\n DOCS_PATH,\n MDX_EXTENSION,\n MAX_FILE_SIZE,\n MAX_DIRECTORY_CONTENT_SIZE,\n} from \"../constants.js\";\nimport { logger } from \"../utils/logger.js\";\nimport {\n listDirContents,\n getAvailablePaths,\n findNearestPaths,\n pathExists,\n} from \"../utils/paths.js\";\nimport { readMDXFile, formatMDXContent } from \"../utils/mdx.js\";\nimport { formatMCPResponse } from \"../utils/mcp-format.js\";\nimport { sanitizePath } from \"../utils/security.js\";\n\nconst docsInputSchema = z.object({\n paths: z\n .array(z.string())\n .min(1)\n .describe(\n 'Documentation paths to retrieve (e.g., [\"getting-started\", \"api-reference/primitives/thread\"])',\n ),\n});\n\ninterface DocResult {\n path: string;\n found: boolean;\n type?: \"file\" | \"directory\";\n content?: string;\n files?: string[];\n directories?: string[];\n summaries?: Array<{ name: string; title?: string; excerpt?: string }>;\n title?: string;\n excerpt?: string;\n suggestions?: string[];\n hint?: string;\n error?: string;\n}\n\nasync function readDocumentation(docPath: string): Promise<DocResult> {\n logger.debug(`Reading documentation for path: ${docPath}`);\n\n if (docPath === \"/\" || docPath === \"\") {\n const { directories, files } = await listDirContents(DOCS_PATH);\n return {\n path: \"/\",\n found: true,\n type: \"directory\",\n directories,\n files: files.map((f) => f.replace(MDX_EXTENSION, \"\")),\n };\n }\n\n try {\n const sanitized = sanitizePath(docPath);\n const fullPath = join(DOCS_PATH, sanitized);\n\n try {\n const lstats = await lstat(fullPath);\n if (lstats.isSymbolicLink()) {\n logger.warn(`Symlink detected at path: ${fullPath}`);\n return {\n path: docPath,\n found: false,\n error: \"Symlinks are not allowed for security reasons\",\n };\n }\n } catch {}\n\n if (await pathExists(fullPath)) {\n const stats = await stat(fullPath);\n\n if (stats.isFile() && stats.size > MAX_FILE_SIZE) {\n logger.warn(`File too large: ${fullPath} (${stats.size} bytes)`);\n return {\n path: docPath,\n found: false,\n error: `File size exceeds maximum allowed size of ${MAX_FILE_SIZE} bytes`,\n };\n }\n\n if (stats.isDirectory()) {\n const { directories, files } = await listDirContents(fullPath);\n\n const contents: Record<string, string> = {};\n const summaries: Array<{\n name: string;\n title?: string;\n excerpt?: string;\n }> = [];\n let aggregateSize = 0;\n let truncated = false;\n for (const file of files) {\n let fileSize: number;\n try {\n fileSize = (await stat(join(fullPath, file))).size;\n } catch (error) {\n logger.warn(\n `Failed to stat MDX file: ${join(fullPath, file)}`,\n error,\n );\n continue;\n }\n aggregateSize += fileSize;\n if (aggregateSize > MAX_DIRECTORY_CONTENT_SIZE) {\n truncated = true;\n break;\n }\n const mdxContent = await readMDXFile(join(fullPath, file));\n if (mdxContent) {\n const name = file.replace(MDX_EXTENSION, \"\");\n contents[name] = formatMDXContent(mdxContent);\n const title = mdxContent.frontmatter[\"title\"];\n summaries.push({\n name,\n ...(typeof title === \"string\" && { title }),\n ...(mdxContent.excerpt !== undefined && {\n excerpt: mdxContent.excerpt,\n }),\n });\n }\n }\n\n const content =\n !truncated && Object.keys(contents).length > 0\n ? JSON.stringify(contents, null, 2)\n : undefined;\n return {\n path: docPath,\n found: true,\n type: \"directory\",\n directories,\n files: files.map((f) => f.replace(MDX_EXTENSION, \"\")),\n ...(summaries.length > 0 && { summaries }),\n ...(content !== undefined && { content }),\n ...(truncated && {\n hint: `Directory content exceeds ${MAX_DIRECTORY_CONTENT_SIZE} bytes and was omitted; summaries cover only the files read before the limit. Request individual files by path to retrieve their content.`,\n }),\n };\n }\n }\n\n const mdxPath =\n extname(fullPath) === MDX_EXTENSION\n ? fullPath\n : `${fullPath}${MDX_EXTENSION}`;\n\n try {\n const mdxLstats = await lstat(mdxPath);\n if (mdxLstats.isSymbolicLink()) {\n logger.warn(`Symlink detected at MDX path: ${mdxPath}`);\n return {\n path: docPath,\n found: false,\n error: \"Symlinks are not allowed for security reasons\",\n };\n }\n\n if (mdxLstats.size > MAX_FILE_SIZE) {\n logger.warn(`MDX file too large: ${mdxPath} (${mdxLstats.size} bytes)`);\n return {\n path: docPath,\n found: false,\n error: `File size exceeds maximum allowed size of ${MAX_FILE_SIZE} bytes`,\n };\n }\n } catch {}\n\n if (await pathExists(mdxPath)) {\n const mdxContent = await readMDXFile(mdxPath);\n\n if (mdxContent) {\n const title = mdxContent.frontmatter[\"title\"];\n return {\n path: docPath,\n found: true,\n type: \"file\",\n content: formatMDXContent(mdxContent),\n ...(typeof title === \"string\" && { title }),\n ...(mdxContent.excerpt !== undefined && {\n excerpt: mdxContent.excerpt,\n }),\n };\n }\n }\n\n const availablePaths = await getAvailablePaths();\n const suggestions = findNearestPaths(docPath, availablePaths);\n\n return {\n path: docPath,\n found: false,\n suggestions,\n };\n } catch (error) {\n if (error instanceof Error && error.message.includes(\"Invalid path\")) {\n return {\n path: docPath,\n found: false,\n error: error.message,\n };\n }\n throw error;\n }\n}\n\nexport const docsTools = {\n name: \"assistantUIDocs\",\n description:\n 'Retrieve assistant-ui documentation by path. Use \"/\" to list all sections. Supports multiple paths in a single request.',\n parameters: docsInputSchema,\n execute: async ({ paths }: z.infer<typeof docsInputSchema>) => {\n logger.info(`Retrieving documentation for paths: ${paths.join(\", \")}`);\n\n try {\n const results = await Promise.all(\n paths.map((path) => readDocumentation(path)),\n );\n\n if (results.length === 1) {\n const result = results[0]!;\n if (result.error) {\n return formatMCPResponse({\n error: result.error,\n path: result.path,\n });\n }\n if (!result.found) {\n return formatMCPResponse({\n error: `Documentation not found for path: ${result.path}`,\n suggestions: result.suggestions,\n hint: 'Use \"/\" to list all available documentation sections',\n });\n }\n return formatMCPResponse(result);\n }\n\n return formatMCPResponse({\n results,\n summary: `Retrieved ${results.filter((r) => r.found).length} of ${results.length} requested paths`,\n });\n } catch (error) {\n logger.error(\"Failed to retrieve documentation\", error);\n return formatMCPResponse({\n error: \"Failed to retrieve documentation\",\n message: error instanceof Error ? error.message : String(error),\n });\n }\n },\n};\n"],"mappings":";;;;;;;;;;AAoBA,MAAM,kBAAkB,EAAE,OAAO,EAC/B,OAAO,EACJ,MAAM,EAAE,OAAO,CAAC,CAAC,CACjB,IAAI,CAAC,CAAC,CACN,SACC,oGACF,EACJ,CAAC;AAiBD,eAAe,kBAAkB,SAAqC;CACpE,OAAO,MAAM,mCAAmC,SAAS;CAEzD,IAAI,YAAY,OAAO,YAAY,IAAI;EACrC,MAAM,EAAE,aAAa,UAAU,MAAM,gBAAgB,SAAS;EAC9D,OAAO;GACL,MAAM;GACN,OAAO;GACP,MAAM;GACN;GACA,OAAO,MAAM,KAAK,MAAM,EAAE,QAAQ,eAAe,EAAE,CAAC;EACtD;CACF;CAEA,IAAI;EAEF,MAAM,WAAW,KAAK,WADJ,aAAa,OACU,CAAC;EAE1C,IAAI;GAEF,KAAI,MADiB,MAAM,QAAQ,EAAA,CACxB,eAAe,GAAG;IAC3B,OAAO,KAAK,6BAA6B,UAAU;IACnD,OAAO;KACL,MAAM;KACN,OAAO;KACP,OAAO;IACT;GACF;EACF,QAAQ,CAAC;EAET,IAAI,MAAM,WAAW,QAAQ,GAAG;GAC9B,MAAM,QAAQ,MAAM,KAAK,QAAQ;GAEjC,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IAAI,QAAQ,WAAW,GAAG;IACxB,MAAM,SAAS,QAAQ;IACvB,IAAI,OAAO,OACT,OAAO,kBAAkB;KACvB,OAAO,OAAO;KACd,MAAM,OAAO;IACf,CAAC;IAEH,IAAI,CAAC,OAAO,OACV,OAAO,kBAAkB;KACvB,OAAO,qCAAqC,OAAO;KACnD,aAAa,OAAO;KACpB,MAAM;IACR,CAAC;IAEH,OAAO,kBAAkB,MAAM;GACjC;GAEA,OAAO,kBAAkB;IACvB;IACA,SAAS,aAAa,QAAQ,QAAQ,MAAM,EAAE,KAAK,CAAC,CAAC,OAAO,MAAM,QAAQ,OAAO;GACnF,CAAC;EACH,SAAS,OAAO;GACd,OAAO,MAAM,oCAAoC,KAAK;GACtD,OAAO,kBAAkB;IACvB,OAAO;IACP,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GAChE,CAAC;EACH;CACF;AACF"}
|
package/dist/tools/examples.d.ts
CHANGED
|
@@ -1,28 +1,22 @@
|
|
|
1
|
-
import { z } from "zod
|
|
2
|
-
|
|
1
|
+
import { z } from "zod";
|
|
3
2
|
//#region src/tools/examples.d.ts
|
|
4
3
|
declare const examplesInputSchema: z.ZodObject<{
|
|
5
4
|
example: z.ZodOptional<z.ZodString>;
|
|
6
|
-
},
|
|
7
|
-
example?: string | undefined;
|
|
8
|
-
}, {
|
|
9
|
-
example?: string | undefined;
|
|
10
|
-
}>;
|
|
5
|
+
}, z.core.$strip>;
|
|
11
6
|
declare function listCodeExamples(): Promise<string[]>;
|
|
12
7
|
declare function readCodeExample(exampleName: string): Promise<string | null>;
|
|
13
8
|
declare const examplesTools: {
|
|
14
9
|
name: string;
|
|
15
10
|
description: string;
|
|
16
|
-
parameters: {
|
|
11
|
+
parameters: z.ZodObject<{
|
|
17
12
|
example: z.ZodOptional<z.ZodString>;
|
|
18
|
-
}
|
|
19
|
-
execute: ({
|
|
20
|
-
example
|
|
21
|
-
}: z.infer<typeof examplesInputSchema>) => Promise<{
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
execute: ({ example }: z.infer<typeof examplesInputSchema>) => Promise<{
|
|
22
15
|
content: Array<{
|
|
23
16
|
type: "text";
|
|
24
17
|
text: string;
|
|
25
18
|
}>;
|
|
19
|
+
structuredContent?: Record<string, unknown>;
|
|
26
20
|
}>;
|
|
27
21
|
};
|
|
28
22
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"examples.d.ts","names":[],"sources":["../../src/tools/examples.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"examples.d.ts","names":[],"sources":["../../src/tools/examples.ts"],"mappings":";;cASM,qBAAmB,EAAA;;GAOvB,EAAA,KAAA;iBAIc,oBAAoB;iBAed,gBACpB,sBACC;cAwBU;;;;;;EAKkB,YAAA,WAAA,EAAE,aAAa,yBAAoB"}
|
package/dist/tools/examples.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { CODE_EXAMPLES_PATH } from "../constants.js";
|
|
2
2
|
import { logger } from "../utils/logger.js";
|
|
3
|
+
import { cacheListing } from "../utils/cache.js";
|
|
3
4
|
import { formatMCPResponse } from "../utils/mcp-format.js";
|
|
4
5
|
import { sanitizePath } from "../utils/security.js";
|
|
5
6
|
import { extname, join } from "node:path";
|
|
6
|
-
import { z } from "zod
|
|
7
|
+
import { z } from "zod";
|
|
7
8
|
import { lstat, readFile, readdir } from "node:fs/promises";
|
|
8
9
|
//#region src/tools/examples.ts
|
|
9
|
-
const examplesInputSchema = z.object({ example: z.string().optional().describe("Example name (e.g., \"with-ai-sdk-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} catch (error) {
|
|
10
|
+
const examplesInputSchema = z.object({ example: z.string().optional().describe("Example name (e.g., \"with-ai-sdk-v7\"). Leave empty to list all examples.") });
|
|
11
|
+
const loadCodeExamples = cacheListing(scanCodeExamples);
|
|
12
|
+
function listCodeExamples() {
|
|
13
|
+
return loadCodeExamples().catch((error) => {
|
|
14
14
|
logger.error("Failed to list code examples", error);
|
|
15
15
|
return [];
|
|
16
|
-
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
async function scanCodeExamples() {
|
|
19
|
+
return (await readdir(CODE_EXAMPLES_PATH)).filter((file) => extname(file) === ".md").map((file) => file.replace(".md", "")).sort();
|
|
17
20
|
}
|
|
18
21
|
async function readCodeExample(exampleName) {
|
|
19
22
|
try {
|
|
@@ -36,7 +39,7 @@ async function readCodeExample(exampleName) {
|
|
|
36
39
|
const examplesTools = {
|
|
37
40
|
name: "assistantUIExamples",
|
|
38
41
|
description: "List available examples or retrieve complete code for a specific example",
|
|
39
|
-
parameters: examplesInputSchema
|
|
42
|
+
parameters: examplesInputSchema,
|
|
40
43
|
execute: async ({ example }) => {
|
|
41
44
|
try {
|
|
42
45
|
if (!example) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"examples.js","names":[],"sources":["../../src/tools/examples.ts"],"sourcesContent":["import { z } from \"zod
|
|
1
|
+
{"version":3,"file":"examples.js","names":[],"sources":["../../src/tools/examples.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { readFile, readdir, lstat } from \"node:fs/promises\";\nimport { join, extname } from \"node:path\";\nimport { CODE_EXAMPLES_PATH, MAX_FILE_SIZE } from \"../constants.js\";\nimport { cacheListing } from \"../utils/cache.js\";\nimport { logger } from \"../utils/logger.js\";\nimport { formatMCPResponse } from \"../utils/mcp-format.js\";\nimport { sanitizePath } from \"../utils/security.js\";\n\nconst examplesInputSchema = z.object({\n example: z\n .string()\n .optional()\n .describe(\n 'Example name (e.g., \"with-ai-sdk-v7\"). Leave empty to list all examples.',\n ),\n});\n\nconst loadCodeExamples = cacheListing(scanCodeExamples);\n\nexport function listCodeExamples(): Promise<string[]> {\n return loadCodeExamples().catch((error) => {\n logger.error(\"Failed to list code examples\", error);\n return [];\n });\n}\n\nasync function scanCodeExamples(): Promise<string[]> {\n const files = await readdir(CODE_EXAMPLES_PATH);\n return files\n .filter((file) => extname(file) === \".md\")\n .map((file) => file.replace(\".md\", \"\"))\n .sort();\n}\n\nexport async function readCodeExample(\n exampleName: string,\n): Promise<string | null> {\n try {\n const sanitized = sanitizePath(exampleName);\n const filePath = join(CODE_EXAMPLES_PATH, `${sanitized}.md`);\n\n const stats = await lstat(filePath);\n if (stats.isSymbolicLink()) {\n logger.warn(`Attempted to read symlink: ${filePath}`);\n return null;\n }\n\n if (stats.size > MAX_FILE_SIZE) {\n logger.warn(`File size exceeds limit: ${filePath} (${stats.size} bytes)`);\n return null;\n }\n\n const content = await readFile(filePath, \"utf-8\");\n return content;\n } catch (error) {\n logger.error(`Failed to read example: ${exampleName}`, error);\n return null;\n }\n}\n\nexport const examplesTools = {\n name: \"assistantUIExamples\",\n description:\n \"List available examples or retrieve complete code for a specific example\",\n parameters: examplesInputSchema,\n execute: async ({ example }: z.infer<typeof examplesInputSchema>) => {\n try {\n if (!example) {\n logger.info(\"Listing all available examples\");\n const examples = await listCodeExamples();\n\n if (examples.length === 0) {\n return formatMCPResponse({\n error:\n \"No examples found. Please run documentation preparation first.\",\n hint: \"Run: pnpm prepare-docs\",\n });\n }\n\n return formatMCPResponse({\n type: \"list\",\n examples,\n total: examples.length,\n hint: \"Use example parameter to get complete code for any example\",\n });\n }\n\n logger.info(`Retrieving example: ${example}`);\n const content = await readCodeExample(example);\n\n if (!content) {\n const availableExamples = await listCodeExamples();\n return formatMCPResponse({\n error: `Example not found: ${example}`,\n availableExamples,\n hint: \"Use without example parameter to list all available examples\",\n });\n }\n\n return formatMCPResponse({\n type: \"example\",\n name: example,\n content,\n });\n } catch (error) {\n logger.error(\"Failed to retrieve examples\", error);\n return formatMCPResponse({\n error: \"Failed to retrieve examples\",\n message: error instanceof Error ? error.message : String(error),\n });\n }\n },\n};\n"],"mappings":";;;;;;;;;AASA,MAAM,sBAAsB,EAAE,OAAO,EACnC,SAAS,EACN,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SACC,4EACF,EACJ,CAAC;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Z,MAAM,oBAAoB,MAAM,iBAAiB;IACjD,OAAO,kBAAkB;KACvB,OAAO,sBAAsB;KAC7B;KACA,MAAM;IACR,CAAC;GACH;GAEA,OAAO,kBAAkB;IACvB,MAAM;IACN,MAAM;IACN;GACF,CAAC;EACH,SAAS,OAAO;GACd,OAAO,MAAM,+BAA+B,KAAK;GACjD,OAAO,kBAAkB;IACvB,OAAO;IACP,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GAChE,CAAC;EACH;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.d.ts","names":[],"sources":["../../src/tools/resources.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"resources.d.ts","names":[],"sources":["../../src/tools/resources.ts"],"mappings":";;iBAoFgB,kBAAkB,QAAQ"}
|
package/dist/tools/resources.js
CHANGED
|
@@ -5,7 +5,7 @@ import { formatMDXContent, readMDXFileSafe } from "../utils/mdx.js";
|
|
|
5
5
|
import { sanitizePath } from "../utils/security.js";
|
|
6
6
|
import { listCodeExamples, readCodeExample } from "./examples.js";
|
|
7
7
|
import { join } from "node:path";
|
|
8
|
-
import { ResourceTemplate } from "@modelcontextprotocol/
|
|
8
|
+
import { ResourceTemplate } from "@modelcontextprotocol/server";
|
|
9
9
|
//#region src/tools/resources.ts
|
|
10
10
|
const MARKDOWN_MIME_TYPE = "text/markdown";
|
|
11
11
|
const DOCS_SCHEME = "aui-docs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.js","names":[],"sources":["../../src/tools/resources.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"resources.js","names":[],"sources":["../../src/tools/resources.ts"],"sourcesContent":["import { type McpServer, ResourceTemplate } from \"@modelcontextprotocol/server\";\nimport { join } from \"node:path\";\nimport { DOCS_PATH, MDX_EXTENSION } from \"../constants.js\";\nimport { getAvailableDocFiles } from \"../utils/paths.js\";\nimport { readMDXFileSafe, formatMDXContent } from \"../utils/mdx.js\";\nimport { sanitizePath } from \"../utils/security.js\";\nimport { listCodeExamples, readCodeExample } from \"./examples.js\";\nimport { logger } from \"../utils/logger.js\";\n\nconst MARKDOWN_MIME_TYPE = \"text/markdown\";\nconst DOCS_SCHEME = \"aui-docs\";\nconst EXAMPLE_SCHEME = \"aui-example\";\n\nfunction templateVarToPath(value: string | string[] | undefined): string {\n if (Array.isArray(value)) return value.join(\"/\");\n return value ?? \"\";\n}\n\ninterface MarkdownResourceConfig {\n name: string;\n scheme: string;\n variable: string;\n title: string;\n description: string;\n notFoundLabel: string;\n list: () => Promise<string[]>;\n read: (key: string) => Promise<string | null>;\n}\n\nfunction registerMarkdownResource(\n server: McpServer,\n config: MarkdownResourceConfig,\n): void {\n const {\n name,\n scheme,\n variable,\n title,\n description,\n notFoundLabel,\n list,\n read,\n } = config;\n server.registerResource(\n name,\n new ResourceTemplate(`${scheme}:///{+${variable}}`, {\n list: async () => ({\n resources: (await list()).map((key) => ({\n uri: `${scheme}:///${key}`,\n name: key,\n mimeType: MARKDOWN_MIME_TYPE,\n })),\n }),\n complete: {\n [variable]: async (value) => {\n const needle = value.toLowerCase();\n return (await list()).filter((key) =>\n key.toLowerCase().includes(needle),\n );\n },\n },\n }),\n { title, description, mimeType: MARKDOWN_MIME_TYPE },\n async (uri, variables) => {\n const key = templateVarToPath(variables[variable]);\n const text = await read(key);\n if (text === null) {\n throw new Error(`${notFoundLabel} not found: ${key}`);\n }\n return {\n contents: [{ uri: uri.href, mimeType: MARKDOWN_MIME_TYPE, text }],\n };\n },\n );\n}\n\nasync function readDocResource(path: string): Promise<string | null> {\n const sanitized = sanitizePath(path);\n const mdx = await readMDXFileSafe(\n join(DOCS_PATH, `${sanitized}${MDX_EXTENSION}`),\n );\n return mdx ? formatMDXContent(mdx) : null;\n}\n\nexport function registerResources(server: McpServer): void {\n registerMarkdownResource(server, {\n name: \"assistant-ui-docs\",\n scheme: DOCS_SCHEME,\n variable: \"path\",\n title: \"assistant-ui Documentation\",\n description:\n \"Individual assistant-ui documentation pages, readable as markdown by path.\",\n notFoundLabel: \"Documentation\",\n list: getAvailableDocFiles,\n read: readDocResource,\n });\n\n registerMarkdownResource(server, {\n name: \"assistant-ui-examples\",\n scheme: EXAMPLE_SCHEME,\n variable: \"name\",\n title: \"assistant-ui Examples\",\n description:\n \"Complete assistant-ui example projects, readable as markdown.\",\n notFoundLabel: \"Example\",\n list: listCodeExamples,\n read: readCodeExample,\n });\n\n logger.debug(\"Registered docs and examples resources\");\n}\n"],"mappings":";;;;;;;;;AASA,MAAM,qBAAqB;AAC3B,MAAM,cAAc;AACpB,MAAM,iBAAiB;AAEvB,SAAS,kBAAkB,OAA8C;CACvE,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,KAAK,GAAG;CAC/C,OAAO,SAAS;AAClB;AAaA,SAAS,yBACP,QACA,QACM;CACN,MAAM,EACJ,MACA,QACA,UACA,OACA,aACA,eACA,MACA,SACE;CACJ,OAAO,iBACL,MACA,IAAI,iBAAiB,GAAG,OAAO,QAAQ,SAAS,IAAI;EAClD,MAAM,aAAa,EACjB,YAAY,MAAM,KAAK,EAAA,CAAG,KAAK,SAAS;GACtC,KAAK,GAAG,OAAO,MAAM;GACrB,MAAM;GACN,UAAU;EACZ,EAAE,EACJ;EACA,UAAU,GACP,WAAW,OAAO,UAAU;GAC3B,MAAM,SAAS,MAAM,YAAY;GACjC,QAAQ,MAAM,KAAK,EAAA,CAAG,QAAQ,QAC5B,IAAI,YAAY,CAAC,CAAC,SAAS,MAAM,CACnC;EACF,EACF;CACF,CAAC,GACD;EAAE;EAAO;EAAa,UAAU;CAAmB,GACnD,OAAO,KAAK,cAAc;EACxB,MAAM,MAAM,kBAAkB,UAAU,SAAS;EACjD,MAAM,OAAO,MAAM,KAAK,GAAG;EAC3B,IAAI,SAAS,MACX,MAAM,IAAI,MAAM,GAAG,cAAc,cAAc,KAAK;EAEtD,OAAO,EACL,UAAU,CAAC;GAAE,KAAK,IAAI;GAAM,UAAU;GAAoB;EAAK,CAAC,EAClE;CACF,CACF;AACF;AAEA,eAAe,gBAAgB,MAAsC;CAEnE,MAAM,MAAM,MAAM,gBAChB,KAAK,WAAW,GAFA,aAAa,IAEF,IAAI,eAAe,CAChD;CACA,OAAO,MAAM,iBAAiB,GAAG,IAAI;AACvC;AAEA,SAAgB,kBAAkB,QAAyB;CACzD,yBAAyB,QAAQ;EAC/B,MAAM;EACN,QAAQ;EACR,UAAU;EACV,OAAO;EACP,aACE;EACF,eAAe;EACf,MAAM;EACN,MAAM;CACR,CAAC;CAED,yBAAyB,QAAQ;EAC/B,MAAM;EACN,QAAQ;EACR,UAAU;EACV,OAAO;EACP,aACE;EACF,eAAe;EACf,MAAM;EACN,MAAM;CACR,CAAC;CAED,OAAO,MAAM,wCAAwC;AACvD"}
|
package/dist/tools/search.d.ts
CHANGED
|
@@ -1,31 +1,22 @@
|
|
|
1
|
-
import { z } from "zod
|
|
2
|
-
|
|
1
|
+
import { z } from "zod";
|
|
3
2
|
//#region src/tools/search.d.ts
|
|
4
3
|
declare const searchInputSchema: z.ZodObject<{
|
|
5
4
|
query: z.ZodString;
|
|
6
5
|
limit: z.ZodDefault<z.ZodNumber>;
|
|
7
|
-
},
|
|
8
|
-
query: string;
|
|
9
|
-
limit: number;
|
|
10
|
-
}, {
|
|
11
|
-
query: string;
|
|
12
|
-
limit?: number | undefined;
|
|
13
|
-
}>;
|
|
6
|
+
}, z.core.$strip>;
|
|
14
7
|
declare const searchTools: {
|
|
15
8
|
name: string;
|
|
16
9
|
description: string;
|
|
17
|
-
parameters: {
|
|
10
|
+
parameters: z.ZodObject<{
|
|
18
11
|
query: z.ZodString;
|
|
19
12
|
limit: z.ZodDefault<z.ZodNumber>;
|
|
20
|
-
}
|
|
21
|
-
execute: ({
|
|
22
|
-
query,
|
|
23
|
-
limit
|
|
24
|
-
}: z.infer<typeof searchInputSchema>) => Promise<{
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
execute: ({ query, limit }: z.infer<typeof searchInputSchema>) => Promise<{
|
|
25
15
|
content: Array<{
|
|
26
16
|
type: "text";
|
|
27
17
|
text: string;
|
|
28
18
|
}>;
|
|
19
|
+
structuredContent?: Record<string, unknown>;
|
|
29
20
|
}>;
|
|
30
21
|
};
|
|
31
22
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","names":[],"sources":["../../src/tools/search.ts"],"mappings":"
|
|
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"}
|