aui-mcp-server 0.0.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.
Files changed (62) hide show
  1. package/README.md +122 -0
  2. package/dist/cli.cjs +1088 -0
  3. package/dist/cli.cjs.map +1 -0
  4. package/dist/cli.d.cts +1 -0
  5. package/dist/cli.d.ts +1 -0
  6. package/dist/cli.js +1076 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/client/index.cjs +619 -0
  9. package/dist/client/index.cjs.map +1 -0
  10. package/dist/client/index.d.cts +194 -0
  11. package/dist/client/index.d.ts +194 -0
  12. package/dist/client/index.js +584 -0
  13. package/dist/client/index.js.map +1 -0
  14. package/dist/index.cjs +1053 -0
  15. package/dist/index.cjs.map +1 -0
  16. package/dist/index.d.cts +163 -0
  17. package/dist/index.d.ts +163 -0
  18. package/dist/index.js +1036 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/rsbuild.cjs +1049 -0
  21. package/dist/rsbuild.cjs.map +1 -0
  22. package/dist/rsbuild.d.cts +12 -0
  23. package/dist/rsbuild.d.ts +12 -0
  24. package/dist/rsbuild.js +1038 -0
  25. package/dist/rsbuild.js.map +1 -0
  26. package/dist/rspack.cjs +1016 -0
  27. package/dist/rspack.cjs.map +1 -0
  28. package/dist/rspack.d.cts +40 -0
  29. package/dist/rspack.d.ts +40 -0
  30. package/dist/rspack.js +1005 -0
  31. package/dist/rspack.js.map +1 -0
  32. package/dist/server.cjs +304 -0
  33. package/dist/server.cjs.map +1 -0
  34. package/dist/server.d.cts +16 -0
  35. package/dist/server.d.ts +16 -0
  36. package/dist/server.js +297 -0
  37. package/dist/server.js.map +1 -0
  38. package/package.json +72 -0
  39. package/src/catalog/build.ts +89 -0
  40. package/src/catalog/entry.ts +183 -0
  41. package/src/catalog/parser.ts +173 -0
  42. package/src/catalog/tool_parser.ts +145 -0
  43. package/src/cli.ts +318 -0
  44. package/src/client/handshake.ts +166 -0
  45. package/src/client/index.ts +6 -0
  46. package/src/client/registry.tsx +184 -0
  47. package/src/client/types.ts +136 -0
  48. package/src/client/useA2UIStream.ts +378 -0
  49. package/src/client/useLogger.ts +147 -0
  50. package/src/generator.ts +100 -0
  51. package/src/index.ts +17 -0
  52. package/src/mcp-app-poc.html +69 -0
  53. package/src/poc.ts +88 -0
  54. package/src/rsbuild.ts +46 -0
  55. package/src/rspack.ts +282 -0
  56. package/src/server.ts +391 -0
  57. package/src/templates.ts +51 -0
  58. package/src/types.ts +195 -0
  59. package/src/utils.ts +29 -0
  60. package/test.js +16 -0
  61. package/tsconfig.json +19 -0
  62. package/tsup.config.ts +27 -0
package/README.md ADDED
@@ -0,0 +1,122 @@
1
+ # aui-mcp-server
2
+
3
+ Automatically generates the **AUI-X Catalog** and **MCP server assets** during an MF Remote build.
4
+
5
+ - Input: `dist/mf-stats.json` + `dist/@mf-types/compiled-types/*.d.ts`
6
+ - Default output:
7
+ - `dist/aui-x-catalog.json`
8
+ - `dist/mcp/manifest.json`
9
+ - `dist/mcp/server.mjs`
10
+
11
+ > Note: the generated MCP server only exposes component metadata (including `x-loader`). Actual MF import/rendering should be done by the AUI-X runtime on the client side.
12
+
13
+ ## CLI
14
+
15
+ Install in an MF Remote project:
16
+
17
+ ```bash
18
+ pnpm add -D aui-mcp-server
19
+ ```
20
+
21
+ Generate `aui-x-catalog.json` (from `mf-stats.json`):
22
+
23
+ ```bash
24
+ pnpm exec aui-mcp catalog ./dist/mf-stats.json -o ./aui-x-catalog.json
25
+ ```
26
+
27
+ Generate MCP assets (from `aui-x-catalog.json`):
28
+
29
+ ```bash
30
+ pnpm exec aui-mcp generate --catalog ./aui-x-catalog.json --outDir dist
31
+ ```
32
+
33
+ Serve locally (SSE example):
34
+
35
+ ```bash
36
+ pnpm exec aui-mcp serve \
37
+ --manifest ./dist/mcp/manifest.json \
38
+ --transport sse \
39
+ --port 8001 \
40
+ --watch
41
+ ```
42
+
43
+ ## Build Plugin (recommended)
44
+
45
+ ### Rspack / Webpack
46
+
47
+ Place this plugin after the MF plugin (so `mf-stats.json` already exists in compilation assets).
48
+
49
+ ```ts
50
+ import { AuiMcpRspackPlugin } from 'aui-mcp-server/rspack';
51
+
52
+ export default {
53
+ plugins: [
54
+ // ModuleFederationPlugin / pluginModuleFederation(...) etc.
55
+ new AuiMcpRspackPlugin({
56
+ transport: 'sse',
57
+ port: 8001,
58
+ }),
59
+ ],
60
+ };
61
+ ```
62
+
63
+ In dev mode (`watch` or `mode=development`), it automatically starts the MCP server. Generation failures are reported as warnings and will not fail the build.
64
+
65
+ ### Rsbuild
66
+
67
+ ```ts
68
+ import { defineConfig } from '@rsbuild/core';
69
+ import { auiMcpRsbuildPlugin } from 'aui-mcp-server/rsbuild';
70
+
71
+ export default defineConfig({
72
+ plugins: [
73
+ auiMcpRsbuildPlugin({
74
+ transport: 'sse',
75
+ port: 8001,
76
+ }),
77
+ ],
78
+ });
79
+ ```
80
+
81
+ ## Verify
82
+
83
+ ```bash
84
+ npx @modelcontextprotocol/inspector node dist/mcp/server.mjs
85
+ ```
86
+
87
+ ## React SDK Entry: `aui-mcp-server/react`
88
+
89
+ Install dependencies (example):
90
+
91
+ ```bash
92
+ pnpm add aui-mcp-server @a2ui/react react react-dom @module-federation/enhanced
93
+ ```
94
+
95
+ In a React host app:
96
+
97
+ ```ts
98
+ import {
99
+ performHandshake,
100
+ createMFRegistry,
101
+ syncRegistryFromCatalog,
102
+ registerMFComponent,
103
+ useA2UIStream,
104
+ createLogger,
105
+ useLogger,
106
+ type XLoaderConfig,
107
+ type ChatMessage,
108
+ type A2UIStreamOptions,
109
+ type CreateLoggerOptions,
110
+ } from 'aui-mcp-server/react';
111
+ ```
112
+
113
+ Core capabilities:
114
+
115
+ - `performHandshake(agentUrl)`: fetches A2A AgentCard, parses `inlineCatalogs`, and calls `syncRegistryFromCatalog` to register `x-loader` components as Module Federation remotes.
116
+ - `createMFRegistry(options?)`: creates/returns a `ComponentRegistry` instance. Shares `react` / `react-dom` / `@a2ui/react` as singletons by default; supports `options.shared` for extra shared deps and `options.exposeGlobal` to expose `window.__AUI_REGISTRY__`.
117
+ - `syncRegistryFromCatalog(registry, catalog)`: registers all `x-loader` entries from a Catalog into a registry.
118
+ - `registerMFComponent(registry, componentType, xLoader)`: registers a single MF component on demand, falling back to an inline `ErrorPlaceholder` on failure.
119
+ - `useA2UIStream(options?)`: wraps A2A JSON-RPC 2.0 + SSE streaming. Returns `{ messages, isLoading, sendMessage, processLocalMessages }`. `options.agentUrl` defaults to `/api` and supports `defaultIsActionPayload` mode.
120
+ - `createLogger(options?)` / `useLogger(options?)`: unified frontend logging + remote reporting. `options.endpoint` defaults to `/api/log`; `options.hijackConsole` controls whether `console.*` is hijacked.
121
+
122
+ All SDK types (e.g. `XLoaderConfig`, `ChatMessage`, `A2UIStreamOptions`, `CreateLoggerOptions`) are also exported from `aui-mcp-server/react` to keep host apps fully type-safe.