@agentic-ui-experience/ui-mcp 0.0.1-beta.4 → 0.0.1-beta.6

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/README.md CHANGED
@@ -1,12 +1,14 @@
1
1
  # @agentic-ui-experience/ui-mcp
2
2
 
3
- Generic MCP server adapter for A2UI.
3
+ MCP server adapter for this project's A2UI integration.
4
4
 
5
- This package does not render or ingest UI. It exposes catalog discovery tools
6
- and a `send_ui_to_client` MCP tool that returns validated A2UI messages in
7
- `structuredContent`, so the host can forward them to `@agentic-ui-experience/ui-runtime`.
5
+ This package does not render or ingest UI. It exposes a `send_ui_to_client`
6
+ MCP tool and optional Catalog discovery, depending on the configured Schema
7
+ delivery mode. The send tool returns validated A2UI messages as a canonical MCP
8
+ `EmbeddedResource`. The Host extracts that resource and forwards its messages
9
+ to `@agentic-ui-experience/ui-runtime`.
8
10
 
9
- MCP is one integration path for producing the project's UI Message Contract. The Host app still owns the Transport that forwards the result to the frontend; this package does not choose or operate that Transport. See the [project glossary](../../docs/glossary.md).
11
+ MCP is one integration path for producing the project's UI Message Contract. The Host app still owns the Transport that forwards the result to the frontend and the Runtime still owns Surface state; this package does not choose or operate that Transport. See the [project glossary](../../docs/glossary.md).
10
12
 
11
13
  `@agentic-ui-experience/ui-mcp` is an MCP adapter over
12
14
  `@agentic-ui-experience/ui-core/tool-mode`. Catalog configuration, catalog resource
@@ -14,24 +16,210 @@ payloads, catalog filtering, and `send_ui_to_client` normalization live in
14
16
  `ui-core`; this package only maps those provider-neutral operations onto MCP
15
17
  resources and tools.
16
18
 
19
+ Generated tool and Catalog instructions require A2UI `v0.9.1`, and incoming
20
+ messages accept only `v0.9.1`; legacy `v0.9` wire messages are rejected. This
21
+ wire version negotiates through the official A2UI `"v0.9"` capability family;
22
+ the family key is not a second accepted message version. Dynamic A2UI tool
23
+ results use only the canonical `application/a2ui+json` media type; the client
24
+ helper deliberately does not recognize the legacy `application/json+a2ui`
25
+ media type.
26
+
17
27
  A server serves exactly one catalog. A2UI fixes a surface's catalog at
18
28
  `createSurface` time and never composes two catalogs into one component tree, and
19
29
  the upstream agent SDK selects a single catalog before it prompts the model, so
20
30
  the catalog is a server configuration rather than a model choice. To serve more
21
31
  than one vocabulary, merge them when you define the catalog. Omit `catalog` to
22
- serve the A2UI basic catalog.
32
+ serve this repository's Basic Catalog compatibility unit. Its ID, Core schema,
33
+ and installed Renderer vocabulary move together; this package does not claim
34
+ that local unit is interchangeable with a newer upstream Catalog that happens
35
+ to have a different identity.
23
36
 
24
37
  ```ts
25
38
  import { createUIMCPServer } from "@agentic-ui-experience/ui-mcp";
26
39
 
27
40
  const server = createUIMCPServer({
28
- catalog: weatherPromptDescriptor,
29
- catalogInstructionMode: "compact"
41
+ catalog: weatherPromptDescriptor
30
42
  });
31
43
 
32
44
  await server.connect(transport);
33
45
  ```
34
46
 
47
+ ## Schema delivery
48
+
49
+ Choose how the Agent obtains the generation Schema when creating or starting the
50
+ server, not in individual tool-call arguments:
51
+
52
+ | `schemaDelivery` | Tools registered | Where the model gets component definitions |
53
+ | --- | --- | --- |
54
+ | `"discovery"` (default) | `get_ui_catalog`, `send_ui_to_client` | Structured JSON Schema in selected `get_ui_catalog` results, loaded on demand. |
55
+ | `"inline"` | `send_ui_to_client` only | The complete Catalog-bound `inputSchema` returned by `tools/list`. |
56
+
57
+ ```ts
58
+ const server = createUIMCPServer({
59
+ catalog: weatherPromptDescriptor,
60
+ schemaDelivery: "inline"
61
+ });
62
+ ```
63
+
64
+ ```bash
65
+ ax-ui-mcp --transport stdio --catalog ./weather-catalog.js --schema-delivery inline
66
+ ```
67
+
68
+ In inline mode, the Agent Host supplies the send tool definition to the model.
69
+ The Schema is in **`tools/list` → `send_ui_to_client.inputSchema`**, not copied
70
+ into the description and not passed as a `schema` argument. The model generates
71
+ **`tools/call.arguments: { messages, surfaceId? }`** from those definitions.
72
+ Neither `get_ui_catalog` nor a resource read is a prerequisite. The
73
+ `a2ui://catalog` resource remains available in both modes with complete
74
+ Host-facing metadata.
75
+
76
+ The inline Schema contains the configured Basic and Custom components, all Basic
77
+ catalog functions, and the fixed Catalog ID. The description retains generation
78
+ rules, style guidance, and examples. Use inline when the Agent Host can supply
79
+ the complete JSON Schema, including local `$ref` definitions, to the model; use
80
+ discovery when definitions should be loaded on demand.
81
+
82
+ `schemaDelivery` changes when the Schema is delivered, not its constraints.
83
+ Basic definitions always use structured JSON Schema; there is no separate
84
+ instruction-format option. Invalid delivery values are errors. This is a project
85
+ choice, not a requirement shared by every official sample; see the
86
+ [pinned upstream comparison](../ui-core/README.md#upstream-sample-context).
87
+
88
+ Inline uses Core's [`createUISendToolSpec()`](../ui-core/README.md#standalone-send-definition-inline-schema-delivery),
89
+ not a second execution path. Both modes share capability checks, normalization,
90
+ strict carrier validation, and the EmbeddedResource output described below.
91
+
92
+ **Custom Schema scope:** ordinary props schemas with `type: "object"` and
93
+ compatible nested objects, arrays, unions, and local references are supported,
94
+ as are boolean `true`/`false` schemas. Source `$schema` must be omitted or be
95
+ `http://json-schema.org/draft-07/schema#`. Protocol-common fields
96
+ `id/component/accessibility/weight` must not be declared in props. Complex root
97
+ constraints or root references, IDs/anchors/external references, references back
98
+ to the augmented props root, incompatible dialect keywords (such as Draft 7
99
+ tuple items or dependencies), validation siblings of `$ref`, and duplicate
100
+ component names produce a targeted error recommending discovery. The full
101
+ [Core boundary](../ui-core/README.md#standalone-send-definition-inline-schema-delivery)
102
+ is intentionally conservative; discovery and normalizer support are unchanged.
103
+
104
+ ## Project A2UI-over-MCP contract
105
+
106
+ `send_ui_to_client` transports A2UI messages, while `get_ui_catalog` is this
107
+ project's discovery contract; it is not an official A2UI-over-MCP tool.
108
+
109
+ A successful `send_ui_to_client` call always returns fallback text followed by
110
+ one canonical A2UI embedded resource:
111
+
112
+ ```ts
113
+ {
114
+ content: [
115
+ {
116
+ type: "text",
117
+ text: "Generated an interactive A2UI interface."
118
+ },
119
+ {
120
+ type: "resource",
121
+ resource: {
122
+ uri: "a2ui://surface/main",
123
+ mimeType: "application/a2ui+json",
124
+ text: "[{\"version\":\"v0.9.1\",...}]"
125
+ }
126
+ }
127
+ ]
128
+ }
129
+ ```
130
+
131
+ The send tool has no output schema and successful calls do not duplicate the
132
+ payload in `structuredContent`. A failed call contains `isError: true` and text
133
+ only, never a resource. The emitted `a2ui://surface/<encoded-surface-id>` URI is
134
+ a stable provider identifier for the embedded payload; it is not a registered
135
+ readable resource and clients must not treat that path shape as a protocol
136
+ requirement.
137
+
138
+ A custom normalizer must return JSON-semantically equivalent `uiJson` and
139
+ `uiMessages` values. The server verifies this invariant, then strictly validates
140
+ the parsed carrier against its configured Catalog and the call's optional
141
+ `surfaceId`, before it uses the original `uiJson` as resource text or derives the
142
+ resource URI. Whitespace and object-key order may differ; malformed, divergent,
143
+ or protocol-invalid representations become tool errors.
144
+
145
+ A successful `get_ui_catalog` call exposes its complete logical result through
146
+ both MCP result channels. The text content item's `text` is the JSON serialization
147
+ of that result, and `structuredContent` contains the same full logical object.
148
+ Neither representation is a reduced schema-only projection.
149
+
150
+ ### Catalog capability negotiation
151
+
152
+ Before accepting UI, the server requires the client to advertise the exact
153
+ configured Catalog ID at:
154
+
155
+ ```ts
156
+ {
157
+ clientCapabilities: {
158
+ "v0.9": {
159
+ supportedCatalogIds: [catalogId]
160
+ }
161
+ }
162
+ }
163
+ ```
164
+
165
+ Use the browser-safe `@agentic-ui-experience/ui-mcp/client` entry point to build
166
+ the declaration:
167
+
168
+ ```ts
169
+ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
170
+ import {
171
+ createA2UIClientCapabilities
172
+ } from "@agentic-ui-experience/ui-mcp/client";
173
+
174
+ const capabilities = createA2UIClientCapabilities([catalogId]);
175
+ const client = new Client(
176
+ { name: "my-a2ui-host", version: "1.0.0" },
177
+ { capabilities }
178
+ );
179
+ ```
180
+
181
+ The builder includes the official initialize-time `capabilities.a2ui` shape and
182
+ an `extensions["a2ui/client-capabilities"]` mirror for MCP SDK versions that
183
+ strip unknown top-level Client capabilities. A stateful server prefers the
184
+ official field when available and then checks this bridge.
185
+
186
+ A stateless client must repeat the declaration on every UI tool call because no
187
+ initialize state survives between requests:
188
+
189
+ ```ts
190
+ await client.callTool({
191
+ name: "send_ui_to_client",
192
+ arguments: { messages },
193
+ _meta: { a2ui: capabilities.a2ui }
194
+ });
195
+ ```
196
+
197
+ Request-local `_meta.a2ui` takes precedence over initialized state. If it is
198
+ present but malformed or does not list the server's exact Catalog ID, the call
199
+ fails without running normalization.
200
+
201
+ ### Browser-safe result extraction
202
+
203
+ The same client entry point strictly extracts canonical A2UI resources without
204
+ importing MCP server or Node-only code:
205
+
206
+ ```ts
207
+ import {
208
+ extractUIMCPToolResult
209
+ } from "@agentic-ui-experience/ui-mcp/client";
210
+
211
+ const extracted = extractUIMCPToolResult(toolResult);
212
+ if (extracted) {
213
+ runtime.ingest(extracted.uiMessages);
214
+ }
215
+ ```
216
+
217
+ The extractor accepts any valid absolute provider URI, including
218
+ `a2ui://recipe-card` and `a2ui://surface/main`. It validates the embedded JSON,
219
+ protocol messages, and Catalog. Tool errors and malformed or ambiguous canonical
220
+ resources throw; an ordinary non-A2UI result returns `undefined`. It does not
221
+ fall back to old `structuredContent`, legacy MIME, or binary resource blobs.
222
+
35
223
  ## CLI
36
224
 
37
225
  `@agentic-ui-experience/ui-mcp` also ships a small MCP server CLI:
@@ -72,6 +260,8 @@ pnpm --filter @agentic-ui-experience/ui-mcp inspector
72
260
  The HTTP server is stateless: each MCP request gets a fresh MCP server and
73
261
  `StreamableHTTPServerTransport`. This matches the SDK's stateless Streamable
74
262
  HTTP mode and avoids storing session state inside `@agentic-ui-experience/ui-mcp`.
263
+ Consequently every `send_ui_to_client` request must include `_meta.a2ui`; an
264
+ initialize declaration alone cannot authorize a later request on this server.
75
265
 
76
266
  CORS is closed by default. To expose the HTTP endpoint to browser clients, pass
77
267
  one or more explicit origins:
@@ -97,10 +287,12 @@ A custom catalog can be loaded from an ESM module:
97
287
  ```bash
98
288
  ax-ui-mcp \
99
289
  --transport http \
100
- --catalog ./weather-catalog.js \
101
- --catalog-instruction-mode compact
290
+ --catalog ./weather-catalog.js
102
291
  ```
103
292
 
293
+ The CLI generates `v0.9.1` instructions and accepts only
294
+ `--protocol-version v0.9.1`. Passing legacy `v0.9` is an error.
295
+
104
296
  With the package scripts, append extra CLI flags after `--`:
105
297
 
106
298
  ```bash
@@ -118,82 +310,92 @@ export const catalog = {
118
310
  };
119
311
  ```
120
312
 
121
- The normal agent flow is:
313
+ ## Agent workflow
314
+
315
+ The default discovery flow is:
122
316
 
123
317
  ```ts
124
- // Step 1a: discover what the catalog has. With no componentNames the server
125
- // returns the directory — every component name with one line on what it is for
126
- // — and no schemas, so discovery costs a listing rather than the catalog.
318
+ // Step 1a: discover the catalog. With no componentNames, catalog.kind is
319
+ // "directory", componentPurposes is complete, and component definitions
320
+ // are absent.
127
321
  get_ui_catalog();
128
322
 
129
- // Step 1b: fetch instructions and schemas for the components this UI needs.
130
- // Use instructionMode: "full" when exact fields are needed.
131
- // Name a function in functionNames only when the UI actually calls it.
323
+ // Step 1b: request a "selection". Structured JSON Schema is placed under
324
+ // catalog.definitions, including its shared $defs reference context.
325
+ // Request function definitions only for functions the UI calls.
132
326
  get_ui_catalog({
133
327
  componentNames: ["Card", "Text", "WeatherIcon"],
134
- functionNames: ["formatDate"],
135
- instructionMode: "full"
328
+ functionNames: ["formatDate"]
136
329
  });
137
330
 
138
331
  // Step 2: submit messages built from the catalog returned by get_ui_catalog.
139
332
  send_ui_to_client({
140
333
  surfaceId: "main",
141
334
  messages: [
142
- { version: "v0.9", createSurface: { surfaceId: "main", catalogId: "com.agentic-ui-experience.examples.weather.v1" } },
143
- { version: "v0.9", updateComponents: { surfaceId: "main", components: [{ id: "root", component: "Text", text: "Current weather" }] } }
335
+ { version: "v0.9.1", createSurface: { surfaceId: "main", catalogId: "com.agentic-ui-experience.examples.weather.v1" } },
336
+ { version: "v0.9.1", updateComponents: { surfaceId: "main", components: [{ id: "root", component: "Text", text: "Current weather" }] } }
144
337
  ]
145
338
  });
146
339
  ```
147
340
 
341
+ The MCP client, not the model-visible arguments above, supplies the negotiated
342
+ A2UI capability through initialize state or request `_meta`.
343
+
148
344
  Neither tool takes a `catalogId`. The server pins the catalog, so there is
149
345
  nothing for the model to choose; `createSurface.catalogId` is validated against
150
- the configured catalog.
151
-
152
- `componentNames` is what narrows the response: supply it and the server returns
153
- only those basic and custom component schemas.
154
-
155
- Function schemas are opt-in and are *not* covered by `componentNames`. Components
156
- never reference functions through `$ref`, so no component selection can narrow
157
- them — they have to be named. The instructions always list every function with
158
- its arguments, so an agent can see what exists and then request only the schemas
159
- it needs via `functionNames`. Omit `functionNames` when the UI calls no
160
- functions. This works in both instruction modes, and with or without
161
- `componentNames`: an explicitly requested function schema is returned even in
162
- `"compact"` (which otherwise emits no schemas at all) and even on a directory
163
- call.
164
-
165
- The returned `descriptor` carries component schemas only. The catalog's
166
- `styleGuide` and `examples` are prose that `instructions` already renders, so
167
- repeating them in `descriptor` would have doubled every response; the
168
- `a2ui://catalog` resource still carries the descriptor whole.
169
-
170
- `get_ui_catalog` returns `componentPurposes` on every call — a
171
- `componentName -> what it is for` map covering base and custom components
172
- together, regardless of what the call requested. Component names alone do not say
173
- when to reach for `Tabs` over `List`, or `Card` over `Column`, and field rules
174
- only help once the component is already chosen. Keeping the whole directory in
175
- view also means an agent that under-selected can see what it missed and widen
176
- with a second call, instead of quietly building something worse out of the
177
- components it already has. For custom components the prose is the descriptor's
178
- `description`.
179
-
180
- `get_ui_catalog` returns compact instructions by default. Pass
181
- `instructionMode: "full"` when the agent needs the authoritative JSON schema in
182
- the instructions; this is more precise but costs more tokens. Server owners can
183
- change the default with `createUIMCPServer({ catalogInstructionMode: "full" })`
184
- or the CLI flag `--catalog-instruction-mode full`.
346
+ the configured catalog. Once the Host forwards these messages to its Runtime, a
347
+ `surfaceId` must be unique among active surfaces: a duplicate active
348
+ `createSurface` is an error, while an ID may be reused after `deleteSurface`.
349
+
350
+ `componentNames` selects the result variant. When omitted, `catalog.kind` is
351
+ `"directory"` and the result contains the complete `componentPurposes` map. It
352
+ contains no component definitions; if `functionNames` is explicitly supplied,
353
+ `catalog.definitions` contains the requested functions and their shared reference
354
+ context. Component purposes and lightweight function discovery are retained.
355
+
356
+ When `componentNames` is present, `catalog.kind` is `"selection"`. It omits
357
+ `componentPurposes` and does not expose a model-facing descriptor.
358
+ `catalog.definitions` contains `componentNames`, `functionNames`, `$defs`,
359
+ optional `basicComponents`, and `customComponents` / `functions` maps.
360
+ `basicComponents` always uses `{ format: "json-schema", schema: object }`.
361
+
362
+ Generated Basic and function `$ref` values resolve from **the entire
363
+ `catalog.definitions` object**, not from the internal Basic Schema:
364
+
365
+ - Basic component bodies occur only in `basicComponents.schema.components`.
366
+ - Function bodies occur only in `functions`; the shared `anyFunction` selector
367
+ points to the requested `#/functions/<name>` entries.
368
+ - `$defs.common` carries the Common types document, and `$defs.catalog.$defs`
369
+ carries Catalog shared definitions. The internal Basic Schema has no duplicate
370
+ `$defs` or `functions` and is not independently self-contained.
371
+ - Custom props schemas remain unchanged, with local references resolved from each
372
+ Custom schema's own document root. Inline's Custom projection limits do not
373
+ apply to these raw discovery schemas.
374
+
375
+ Function definitions remain opt-in through `functionNames` and are independent
376
+ of component selection. Omitting `functionNames` returns no function definitions.
377
+ Function-only queries, Custom-only selections with functions, and empty function
378
+ selections use the same shared context.
379
+
380
+ `instructions` refers to `catalog.definitions` and does not contain JSON Schema
381
+ dumps. MCP text and `structuredContent` carry the same logical bundle; delivery
382
+ selection does not change validation constraints.
185
383
 
186
384
  `send_ui_to_client` accepts structured messages. Do not pass `ui_json`, do not
187
385
  serialize the message list into a JSON string, and do not pass static catalog
188
386
  schema such as `customComponents` in the tool call.
189
387
 
190
- `send_ui_to_client` is the final submission tool, not the schema discovery
191
- tool. Agents should call `get_ui_catalog` before using it, then build component
192
- objects from the returned catalog schema.
193
-
194
- The catalog is also exposed as an MCP resource. Resources are read by hosts and
195
- clients rather than picked from by a model, so this payload carries every
196
- component and function:
388
+ In discovery mode, `send_ui_to_client` is the final submission tool, not the
389
+ schema source: call `get_ui_catalog` first and build components from
390
+ `catalog.definitions`. In inline mode, build the same arguments directly from
391
+ the send tool's `inputSchema`; no get tool is registered.
392
+
393
+ The catalog is also exposed as an MCP resource with media type
394
+ `application/json`. This remains JSON catalog metadata, not an A2UI message, so
395
+ the A2UI message media types do not apply. Resources are read by Hosts and
396
+ clients rather than selected from by a model, so this payload remains complete
397
+ Host-facing metadata: it carries every component, every function, and the full
398
+ descriptor, including `styleGuide` and `examples`:
197
399
 
198
400
  ```text
199
401
  a2ui://catalog
package/dist/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- const _0x24bdc9=_0x55a8;function _0x55a8(_0x48c825,_0x5caa02){_0x48c825=_0x48c825-0x19f;const _0x2c4013=_0x2c40();let _0x55a8ad=_0x2c4013[_0x48c825];return _0x55a8ad;}(function(_0x298a60,_0xadd7e3){const _0x3dc739=_0x55a8,_0x2eb83a=_0x298a60();while(!![]){try{const _0x3f1ca2=-parseInt(_0x3dc739(0x1c8))/0x1+parseInt(_0x3dc739(0x1a5))/0x2+parseInt(_0x3dc739(0x1b6))/0x3+-parseInt(_0x3dc739(0x1cc))/0x4+parseInt(_0x3dc739(0x1c4))/0x5+-parseInt(_0x3dc739(0x1b1))/0x6*(-parseInt(_0x3dc739(0x1a2))/0x7)+parseInt(_0x3dc739(0x1d3))/0x8*(-parseInt(_0x3dc739(0x1b9))/0x9);if(_0x3f1ca2===_0xadd7e3)break;else _0x2eb83a['push'](_0x2eb83a['shift']());}catch(_0xc3c2da){_0x2eb83a['push'](_0x2eb83a['shift']());}}}(_0x2c40,0x21699));function _0x2c40(){const _0x2a6b7b=['408AUqXrO','once','stderr','full','message','endpoint','headers','catch','127.0.0.1','1169qDiPqL','string','\x20catalogs.\x20A\x20server\x20serves\x20exactly\x20one;\x20merge\x20them\x20into\x20a\x20single\x20descriptor.','383966vDRogl','catalogInstructionMode','@agentic-ui-experience/ui-mcp\x20listening\x20on\x20http://','\x22\x20exported\x20','values','Access-Control-Allow-Headers','Content-Type,\x20Accept,\x20Authorization,\x20MCP-Protocol-Version,\x20Mcp-Session-Id,\x20Last-Event-ID','GET,POST,DELETE,OPTIONS','catalogs','\x22\x20exported\x20an\x20invalid\x20catalog\x20descriptor.','setHeader','catalog','6942uSijQR','transport','\x22.\x20Expected\x20an\x20integer\x20from\x201\x20to\x2065535.','stdout','2.0','604485iOHyQP','version','write','63081bFhLrf','catalog-instruction-mode','end','compact','OPTIONS','host','SIGTERM','isArray','@agentic-ui-experience/ui-mcp\x0a\x0aUsage:\x0a\x20\x20ax-ui-mcp\x20[options]\x0a\x0aOptions:\x0a\x20\x20--transport\x20<stdio|http>\x20\x20\x20\x20\x20\x20MCP\x20transport\x20to\x20start.\x20Default:\x20stdio\x0a\x20\x20--host\x20<host>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20HTTP\x20bind\x20host.\x20Default:\x20127.0.0.1\x0a\x20\x20--port\x20<port>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20HTTP\x20bind\x20port.\x20Default:\x203001\x0a\x20\x20--endpoint\x20<path>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20HTTP\x20MCP\x20endpoint.\x20Default:\x20/mcp\x0a\x20\x20--cors-origin\x20<origin>\x20\x20\x20\x20\x20\x20\x20\x20Allow\x20a\x20browser\x20origin.\x20Repeatable.\x20Use\x20\x22*\x22\x20for\x20development.\x0a\x20\x20--catalog\x20<module>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ESM\x20module\x20exporting\x20the\x20CatalogPromptDescriptor\x20to\x20serve.\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Defaults\x20to\x20the\x20A2UI\x20basic\x20catalog.\x0a\x20\x20--catalog-instruction-mode\x20<compact|full>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Default\x20get_ui_catalog\x20instruction\x20detail.\x20Default:\x20compact\x0a\x20\x20--name\x20<name>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20MCP\x20server\x20name.\x20Default:\x20@agentic-ui-experience/ui-mcp\x0a\x20\x20--version\x20<version>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20MCP\x20server\x20version.\x20Default:\x200.0.0\x0a\x20\x20--help\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Show\x20this\x20help.\x0a\x0aA\x20server\x20serves\x20exactly\x20one\x20catalog,\x20matching\x20A2UI\x27s\x20model\x20where\x20a\x20surface\x27s\x0acatalog\x20is\x20fixed\x20at\x20createSurface\x20time.\x20Combine\x20vocabularies\x20when\x20you\x20define\x20the\x0acatalog,\x20not\x20at\x20runtime.\x0a\x0aCatalog\x20modules\x20may\x20export\x20one\x20of:\x0a\x20\x20export\x20default\x20descriptor\x0a\x20\x20export\x20const\x20catalog\x20=\x20descriptor\x0a','Not\x20Found','close','461555HGuHNw','Internal\x20MCP\x20server\x20error','length','help','96028KxRKSn','stdio','Access-Control-Allow-Methods','Catalog\x20module\x20\x22','354656enIJyu','Unsupported\x20transport\x20\x22','serverName','connect','port','3001','Access-Control-Allow-Origin'];_0x2c40=function(){return _0x2a6b7b;};return _0x2c40();}import{createServer}from'node:http';import{resolve}from'node:path';import{pathToFileURL}from'node:url';import{parseArgs}from'node:util';import{StreamableHTTPServerTransport}from'@modelcontextprotocol/sdk/server/streamableHttp.js';import{StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import{createUIMCPServer}from'./index.js';const helpText=_0x24bdc9(0x1c1);function stringValue(_0x218783,_0x3507a9){return typeof _0x218783==='string'&&_0x218783['length']>0x0?_0x218783:_0x3507a9;}function optionalStringValue(_0x185ec6){const _0x52150f=_0x24bdc9;return typeof _0x185ec6==='string'&&_0x185ec6[_0x52150f(0x1c6)]>0x0?_0x185ec6:void 0x0;}function stringArrayValue(_0x4643e7){const _0x249eb2=_0x24bdc9;if(Array[_0x249eb2(0x1c0)](_0x4643e7))return _0x4643e7;if(typeof _0x4643e7==='string'&&_0x4643e7['length']>0x0)return[_0x4643e7];return[];}function parseTransport(_0x587053){const _0x5bfdd7=_0x24bdc9;if(_0x587053===_0x5bfdd7(0x1c9)||_0x587053==='http')return _0x587053;throw new Error(_0x5bfdd7(0x1cd)+_0x587053+'\x22.\x20Expected\x20\x22stdio\x22\x20or\x20\x22http\x22.');}function parseCatalogInstructionMode(_0x300f58){const _0x375090=_0x24bdc9;if(_0x300f58===_0x375090(0x1bc)||_0x300f58===_0x375090(0x1d6))return _0x300f58;throw new Error('Unsupported\x20catalog\x20instruction\x20mode\x20\x22'+_0x300f58+'\x22.\x20Expected\x20\x22compact\x22\x20or\x20\x22full\x22.');}function parsePort(_0x126a95){const _0x11f6de=_0x24bdc9,_0x2c8ad0=Number(_0x126a95);if(!Number['isInteger'](_0x2c8ad0)||_0x2c8ad0<0x1||_0x2c8ad0>0xffff)throw new Error('Invalid\x20--port\x20\x22'+_0x126a95+_0x11f6de(0x1b3));return _0x2c8ad0;}function normalizeEndpoint(_0x1385a3){if(!_0x1385a3['startsWith']('/'))return'/'+_0x1385a3;return _0x1385a3;}function isCatalogDescriptor(_0x5d3a88){const _0x111c92=_0x24bdc9;return!!_0x5d3a88&&typeof _0x5d3a88==='object'&&!Array[_0x111c92(0x1c0)](_0x5d3a88)&&typeof _0x5d3a88['id']===_0x111c92(0x1a3)&&Array['isArray'](_0x5d3a88['baseComponentNames']);}function readCatalogExport(_0x4d8171,_0x8c3f41){const _0x55b9e2=_0x24bdc9,_0x2b0dd0=_0x4d8171[_0x55b9e2(0x1ad)]??_0x4d8171['catalog']??_0x4d8171['default'];if(Array[_0x55b9e2(0x1c0)](_0x2b0dd0)){if(_0x2b0dd0['length']!==0x1)throw new Error(_0x55b9e2(0x1cb)+_0x8c3f41+_0x55b9e2(0x1a8)+_0x2b0dd0['length']+_0x55b9e2(0x1a4));const [_0x6e46b2]=_0x2b0dd0;if(!isCatalogDescriptor(_0x6e46b2))throw new Error('Catalog\x20module\x20\x22'+_0x8c3f41+_0x55b9e2(0x1ae));return _0x6e46b2;}if(_0x2b0dd0===void 0x0)throw new Error('Catalog\x20module\x20\x22'+_0x8c3f41+'\x22\x20did\x20not\x20export\x20a\x20catalog\x20descriptor.');if(!isCatalogDescriptor(_0x2b0dd0))throw new Error('Catalog\x20module\x20\x22'+_0x8c3f41+'\x22\x20exported\x20an\x20invalid\x20catalog\x20descriptor.');return _0x2b0dd0;}async function loadCatalog(_0x150693){if(_0x150693===void 0x0)return void 0x0;const _0x1d045d=await import(pathToFileURL(resolve(_0x150693))['href']);return readCatalogExport(_0x1d045d,_0x150693);}async function parseCliOptions(){const _0x93d339=_0x24bdc9,_0x4c2c1c=parseArgs({'allowPositionals':![],'options':{'transport':{'type':'string'},'host':{'type':_0x93d339(0x1a3)},'port':{'type':'string'},'endpoint':{'type':_0x93d339(0x1a3)},'cors-origin':{'type':_0x93d339(0x1a3),'multiple':!![]},'catalog':{'type':_0x93d339(0x1a3)},'catalog-instruction-mode':{'type':_0x93d339(0x1a3)},'name':{'type':'string'},'version':{'type':_0x93d339(0x1a3)},'help':{'type':'boolean','short':'h'}}});_0x4c2c1c[_0x93d339(0x1a9)][_0x93d339(0x1c7)]&&(process[_0x93d339(0x1b4)]['write'](helpText),process['exit'](0x0));const _0x58d483=await loadCatalog(optionalStringValue(_0x4c2c1c[_0x93d339(0x1a9)][_0x93d339(0x1b0)]));return{'transport':parseTransport(stringValue(_0x4c2c1c[_0x93d339(0x1a9)][_0x93d339(0x1b2)],'stdio')),'host':stringValue(_0x4c2c1c[_0x93d339(0x1a9)][_0x93d339(0x1be)],_0x93d339(0x1a1)),'port':parsePort(stringValue(_0x4c2c1c['values'][_0x93d339(0x1d0)],_0x93d339(0x1d1))),'endpoint':normalizeEndpoint(stringValue(_0x4c2c1c['values'][_0x93d339(0x1d8)],'/mcp')),'corsOrigins':stringArrayValue(_0x4c2c1c['values']['cors-origin']),..._0x58d483?{'catalog':_0x58d483}:{},'catalogInstructionMode':parseCatalogInstructionMode(stringValue(_0x4c2c1c['values'][_0x93d339(0x1ba)],'compact')),...optionalStringValue(_0x4c2c1c[_0x93d339(0x1a9)]['name'])?{'serverName':optionalStringValue(_0x4c2c1c['values']['name'])}:{},...optionalStringValue(_0x4c2c1c[_0x93d339(0x1a9)][_0x93d339(0x1b7)])?{'serverVersion':optionalStringValue(_0x4c2c1c['values']['version'])}:{}};}function createServerOptions(_0x3c8f06){const _0x4a28f0=_0x24bdc9;return{..._0x3c8f06[_0x4a28f0(0x1b0)]?{'catalog':_0x3c8f06['catalog']}:{},..._0x3c8f06[_0x4a28f0(0x1a6)]?{'catalogInstructionMode':_0x3c8f06['catalogInstructionMode']}:{},'server':{..._0x3c8f06[_0x4a28f0(0x1ce)]?{'name':_0x3c8f06[_0x4a28f0(0x1ce)]}:{},..._0x3c8f06['serverVersion']?{'version':_0x3c8f06['serverVersion']}:{}}};}function setCorsHeaders(_0x3d36d9,_0x185c18,_0x1eef8b){const _0x41e191=_0x24bdc9;if(_0x1eef8b['length']===0x0)return;const _0x34b696=_0x3d36d9['headers']['origin'],_0xc5ca1d=_0x1eef8b['includes']('*'),_0x1c5288=_0xc5ca1d?'*':typeof _0x34b696===_0x41e191(0x1a3)&&_0x1eef8b['includes'](_0x34b696)?_0x34b696:void 0x0;if(!_0x1c5288)return;_0x185c18['setHeader'](_0x41e191(0x1d2),_0x1c5288),_0x185c18[_0x41e191(0x1af)]('Vary','Origin'),_0x185c18[_0x41e191(0x1af)](_0x41e191(0x1ca),_0x41e191(0x1ac)),_0x185c18['setHeader'](_0x41e191(0x1aa),_0x41e191(0x1ab)),_0x185c18[_0x41e191(0x1af)]('Access-Control-Expose-Headers','Mcp-Session-Id');}function writeJsonRpcError(_0x31b189,_0x457271,_0x326f20){const _0x41e96e=_0x24bdc9;_0x31b189['statusCode']=_0x457271,_0x31b189['setHeader']('content-type','application/json'),_0x31b189[_0x41e96e(0x1bb)](JSON['stringify']({'jsonrpc':_0x41e96e(0x1b5),'error':{'code':-0x7f5b,'message':_0x326f20},'id':null}));}async function startStdio(_0x4475ae){const _0x3822b4=_0x24bdc9,_0x5439a6=createUIMCPServer(createServerOptions(_0x4475ae));await _0x5439a6[_0x3822b4(0x1cf)](new StdioServerTransport());}async function startHttp(_0x18d99d){const _0x4c5c33=_0x24bdc9,_0xe97338=createServer(async(_0x598754,_0x540c7d)=>{const _0x3536ca=_0x55a8,_0x1622a2=new URL(_0x598754['url']??'/','http://'+(_0x598754[_0x3536ca(0x19f)][_0x3536ca(0x1be)]??'localhost'));if(_0x1622a2['pathname']!==_0x18d99d['endpoint']){_0x540c7d['statusCode']=0x194,_0x540c7d['end'](_0x3536ca(0x1c2));return;}setCorsHeaders(_0x598754,_0x540c7d,_0x18d99d['corsOrigins']);if(_0x598754['method']===_0x3536ca(0x1bd)){_0x540c7d['statusCode']=0xcc,_0x540c7d['end']();return;}const _0x33b330=createUIMCPServer(createServerOptions(_0x18d99d)),_0xe29765=new StreamableHTTPServerTransport({'sessionIdGenerator':void 0x0});try{await _0x33b330[_0x3536ca(0x1cf)](_0xe29765),await _0xe29765['handleRequest'](_0x598754,_0x540c7d),_0x540c7d['on'](_0x3536ca(0x1c3),()=>{const _0x412514=_0x3536ca;void _0xe29765[_0x412514(0x1c3)](),void _0x33b330[_0x412514(0x1c3)]();});}catch(_0x2cf789){console['error']('[@agentic-ui-experience/ui-mcp]\x20request\x20failed',_0x2cf789),!_0x540c7d['headersSent']&&writeJsonRpcError(_0x540c7d,0x1f4,_0x2cf789 instanceof Error?_0x2cf789[_0x3536ca(0x1d7)]:_0x3536ca(0x1c5));}});await new Promise((_0xbe04cc,_0x45f9ff)=>{const _0x3b6f3d=_0x55a8;_0xe97338[_0x3b6f3d(0x1d4)]('error',_0x45f9ff),_0xe97338['listen'](_0x18d99d[_0x3b6f3d(0x1d0)],_0x18d99d[_0x3b6f3d(0x1be)],_0xbe04cc);});const _0x310eed=()=>{const _0x15e190=_0x55a8;_0xe97338[_0x15e190(0x1c3)](()=>process['exit'](0x0));};process[_0x4c5c33(0x1d4)]('SIGINT',_0x310eed),process[_0x4c5c33(0x1d4)](_0x4c5c33(0x1bf),_0x310eed),process[_0x4c5c33(0x1d5)][_0x4c5c33(0x1b8)](_0x4c5c33(0x1a7)+_0x18d99d['host']+':'+_0x18d99d['port']+_0x18d99d[_0x4c5c33(0x1d8)]+'\x0a');}async function main(){const _0x2bb58d=_0x24bdc9,_0x35fa3f=await parseCliOptions();if(_0x35fa3f[_0x2bb58d(0x1b2)]===_0x2bb58d(0x1c9)){await startStdio(_0x35fa3f);return;}await startHttp(_0x35fa3f);}main()[_0x24bdc9(0x1a0)](_0x120fb2=>{const _0x5a2ebb=_0x24bdc9;process[_0x5a2ebb(0x1d5)]['write']((_0x120fb2 instanceof Error?_0x120fb2[_0x5a2ebb(0x1d7)]:String(_0x120fb2))+'\x0a'),process['exit'](0x1);});
2
+ (function(_0x3139ef,_0x2bf974){const _0x4521a4=_0x2989,_0x354e86=_0x3139ef();while(!![]){try{const _0x30100b=parseInt(_0x4521a4(0x154))/0x1+parseInt(_0x4521a4(0x13d))/0x2*(-parseInt(_0x4521a4(0x16f))/0x3)+-parseInt(_0x4521a4(0x153))/0x4*(-parseInt(_0x4521a4(0x14f))/0x5)+parseInt(_0x4521a4(0x15e))/0x6*(parseInt(_0x4521a4(0x13a))/0x7)+-parseInt(_0x4521a4(0x13b))/0x8+parseInt(_0x4521a4(0x14c))/0x9+parseInt(_0x4521a4(0x15b))/0xa;if(_0x30100b===_0x2bf974)break;else _0x354e86['push'](_0x354e86['shift']());}catch(_0x4c0ca7){_0x354e86['push'](_0x354e86['shift']());}}}(_0x1a41,0x42d8f));import{createServer}from'node:http';import{resolve}from'node:path';import{pathToFileURL}from'node:url';import{parseArgs}from'node:util';import{A2UI_SUPPORTED_PROTOCOL_VERSIONS}from'@agentic-ui-experience/ui-core';import{StreamableHTTPServerTransport}from'@modelcontextprotocol/sdk/server/streamableHttp.js';function _0x2989(_0x3fa84f,_0x278c51){_0x3fa84f=_0x3fa84f-0x135;const _0x1a41d1=_0x1a41();let _0x298995=_0x1a41d1[_0x3fa84f];return _0x298995;}import{StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import{createUIMCPServer}from'./index.js';const helpText='@agentic-ui-experience/ui-mcp\x0a\x0aUsage:\x0a\x20\x20ax-ui-mcp\x20[options]\x0a\x0aOptions:\x0a\x20\x20--transport\x20<stdio|http>\x20\x20\x20\x20\x20\x20MCP\x20transport\x20to\x20start.\x20Default:\x20stdio\x0a\x20\x20--host\x20<host>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20HTTP\x20bind\x20host.\x20Default:\x20127.0.0.1\x0a\x20\x20--port\x20<port>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20HTTP\x20bind\x20port.\x20Default:\x203001\x0a\x20\x20--endpoint\x20<path>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20HTTP\x20MCP\x20endpoint.\x20Default:\x20/mcp\x0a\x20\x20--cors-origin\x20<origin>\x20\x20\x20\x20\x20\x20\x20\x20Allow\x20a\x20browser\x20origin.\x20Repeatable.\x20Use\x20\x22*\x22\x20for\x20development.\x0a\x20\x20--catalog\x20<module>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ESM\x20module\x20exporting\x20the\x20CatalogPromptDescriptor\x20to\x20serve.\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Defaults\x20to\x20the\x20A2UI\x20basic\x20catalog.\x0a\x20\x20--schema-delivery\x20<discovery|inline>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Default:\x20discovery\x20(get_ui_catalog\x20+\x20send_ui_to_client).\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Inline\x20exposes\x20only\x20send_ui_to_client,\x20with\x20its\x20full\x20inputSchema.\x0a\x20\x20--protocol-version\x20<v0.9.1>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20A2UI\x20version\x20requested\x20in\x20generated\x20UI.\x20Default:\x20v0.9.1\x0a\x20\x20--name\x20<name>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20MCP\x20server\x20name.\x20Default:\x20@agentic-ui-experience/ui-mcp\x0a\x20\x20--version\x20<version>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20MCP\x20server\x20version.\x20Default:\x200.0.0\x0a\x20\x20--help\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Show\x20this\x20help.\x0a\x0aA\x20server\x20serves\x20exactly\x20one\x20catalog,\x20matching\x20A2UI\x27s\x20model\x20where\x20a\x20surface\x27s\x0acatalog\x20is\x20fixed\x20at\x20createSurface\x20time.\x20Combine\x20vocabularies\x20when\x20you\x20define\x20the\x0acatalog,\x20not\x20at\x20runtime.\x0a\x0aA2UI\x20clients\x20must\x20declare\x20clientCapabilities[\x22v0.9\x22].supportedCatalogIds\x20with\x0athis\x20server\x27s\x20exact\x20Catalog\x20ID.\x20Stateful\x20clients\x20send\x20it\x20in\x20initialize\x0acapabilities.a2ui.\x20This\x20HTTP\x20server\x20is\x20stateless,\x20so\x20every\x20send_ui_to_client\x20call\x0amust\x20also\x20carry\x20the\x20declaration\x20in\x20_meta.a2ui.\x0a\x0aCatalog\x20modules\x20may\x20export\x20one\x20of:\x0a\x20\x20export\x20default\x20descriptor\x0a\x20\x20export\x20const\x20catalog\x20=\x20descriptor\x0a';function stringValue(_0x46ba04,_0x3f6cdb){const _0x5852cf=_0x2989;return typeof _0x46ba04==='string'&&_0x46ba04[_0x5852cf(0x144)]>0x0?_0x46ba04:_0x3f6cdb;}function optionalStringValue(_0x267f21){return typeof _0x267f21==='string'&&_0x267f21['length']>0x0?_0x267f21:void 0x0;}function stringArrayValue(_0x411c9e){const _0x15141f=_0x2989;if(Array['isArray'](_0x411c9e))return _0x411c9e;if(typeof _0x411c9e===_0x15141f(0x16c)&&_0x411c9e[_0x15141f(0x144)]>0x0)return[_0x411c9e];return[];}function parseTransport(_0x561da9){const _0x32441b=_0x2989;if(_0x561da9==='stdio'||_0x561da9===_0x32441b(0x138))return _0x561da9;throw new Error(_0x32441b(0x14a)+_0x561da9+'\x22.\x20Expected\x20\x22stdio\x22\x20or\x20\x22http\x22.');}function parseSchemaDelivery(_0x545a42){const _0x2e51cf=_0x2989;if(_0x545a42===_0x2e51cf(0x158)||_0x545a42===_0x2e51cf(0x150))return _0x545a42;throw new Error('Unsupported\x20schema\x20delivery\x20\x22'+_0x545a42+'\x22.\x20Expected\x20\x22discovery\x22\x20or\x20\x22inline\x22.');}function _0x1a41(){const _0x5721fe=['connect','pathname','port','url','Unsupported\x20transport\x20\x22','write','1710225UZRLcx','[@agentic-ui-experience/ui-mcp]\x20request\x20failed','localhost','10KhgCKh','inline','protocolVersion','once','358404toICtG','58260OyakaS','href','map','\x22\x20did\x20not\x20export\x20a\x20catalog\x20descriptor.','discovery','close','message','4618410aofNFN','end','method','986532SYNbIs','Not\x20Found','exit','catalog','endpoint','\x22\x20exported\x20','object','name','stdout','Vary','values','stdio','corsOrigins','Access-Control-Allow-Methods','string','cors-origin','\x22.\x20Expected\x20an\x20integer\x20from\x201\x20to\x2065535.','24NJjaze','protocol-version','listen','host','isArray','http://','http','error','14ivQhxt','4133352CBgGbW','127.0.0.1','106924EbvcsK','origin','\x22\x20exported\x20an\x20invalid\x20catalog\x20descriptor.','handleRequest','setHeader','stderr','Content-Type,\x20Accept,\x20Authorization,\x20MCP-Protocol-Version,\x20Mcp-Session-Id,\x20Last-Event-ID','length','statusCode'];_0x1a41=function(){return _0x5721fe;};return _0x1a41();}function parseProtocolVersion(_0x4ac122){const _0xbcdf62=_0x2989;if(A2UI_SUPPORTED_PROTOCOL_VERSIONS['some'](_0x3d2791=>_0x3d2791===_0x4ac122))return _0x4ac122;throw new Error('Unsupported\x20protocol\x20version\x20\x22'+_0x4ac122+'\x22.\x20Expected\x20'+A2UI_SUPPORTED_PROTOCOL_VERSIONS[_0xbcdf62(0x156)](_0x21696c=>'\x22'+_0x21696c+'\x22')['join']('\x20or\x20')+'.');}function parsePort(_0x1da2ea){const _0x50a7d9=_0x2989,_0x55bf43=Number(_0x1da2ea);if(!Number['isInteger'](_0x55bf43)||_0x55bf43<0x1||_0x55bf43>0xffff)throw new Error('Invalid\x20--port\x20\x22'+_0x1da2ea+_0x50a7d9(0x16e));return _0x55bf43;}function normalizeEndpoint(_0x98b25c){if(!_0x98b25c['startsWith']('/'))return'/'+_0x98b25c;return _0x98b25c;}function isCatalogDescriptor(_0x5c9fa1){const _0x4adeeb=_0x2989;return!!_0x5c9fa1&&typeof _0x5c9fa1===_0x4adeeb(0x164)&&!Array['isArray'](_0x5c9fa1)&&typeof _0x5c9fa1['id']===_0x4adeeb(0x16c)&&Array['isArray'](_0x5c9fa1['baseComponentNames']);}function readCatalogExport(_0x5d1764,_0x4cbdad){const _0x28d328=_0x2989,_0x6af1cc=_0x5d1764['catalogs']??_0x5d1764[_0x28d328(0x161)]??_0x5d1764['default'];if(Array[_0x28d328(0x136)](_0x6af1cc)){if(_0x6af1cc[_0x28d328(0x144)]!==0x1)throw new Error('Catalog\x20module\x20\x22'+_0x4cbdad+_0x28d328(0x163)+_0x6af1cc[_0x28d328(0x144)]+'\x20catalogs.\x20A\x20server\x20serves\x20exactly\x20one;\x20merge\x20them\x20into\x20a\x20single\x20descriptor.');const [_0x263190]=_0x6af1cc;if(!isCatalogDescriptor(_0x263190))throw new Error('Catalog\x20module\x20\x22'+_0x4cbdad+_0x28d328(0x13f));return _0x263190;}if(_0x6af1cc===void 0x0)throw new Error('Catalog\x20module\x20\x22'+_0x4cbdad+_0x28d328(0x157));if(!isCatalogDescriptor(_0x6af1cc))throw new Error('Catalog\x20module\x20\x22'+_0x4cbdad+_0x28d328(0x13f));return _0x6af1cc;}async function loadCatalog(_0x54cbfb){const _0x280e52=_0x2989;if(_0x54cbfb===void 0x0)return void 0x0;const _0x5d6aed=await import(pathToFileURL(resolve(_0x54cbfb))[_0x280e52(0x155)]);return readCatalogExport(_0x5d6aed,_0x54cbfb);}async function parseCliOptions(){const _0x348cd4=_0x2989,_0x235e35=parseArgs({'allowPositionals':![],'options':{'transport':{'type':_0x348cd4(0x16c)},'host':{'type':'string'},'port':{'type':'string'},'endpoint':{'type':_0x348cd4(0x16c)},'cors-origin':{'type':'string','multiple':!![]},'catalog':{'type':_0x348cd4(0x16c)},'schema-delivery':{'type':'string'},'protocol-version':{'type':'string'},'name':{'type':_0x348cd4(0x16c)},'version':{'type':'string'},'help':{'type':'boolean','short':'h'}}});_0x235e35[_0x348cd4(0x168)]['help']&&(process[_0x348cd4(0x166)][_0x348cd4(0x14b)](helpText),process[_0x348cd4(0x160)](0x0));const _0x3fffd2=parseSchemaDelivery(_0x235e35['values']['schema-delivery']??'discovery'),_0x10af34=await loadCatalog(optionalStringValue(_0x235e35[_0x348cd4(0x168)]['catalog'])),_0x24c934=optionalStringValue(_0x235e35['values'][_0x348cd4(0x170)]);return{'transport':parseTransport(stringValue(_0x235e35[_0x348cd4(0x168)]['transport'],_0x348cd4(0x169))),'host':stringValue(_0x235e35[_0x348cd4(0x168)]['host'],_0x348cd4(0x13c)),'port':parsePort(stringValue(_0x235e35[_0x348cd4(0x168)]['port'],'3001')),'endpoint':normalizeEndpoint(stringValue(_0x235e35['values'][_0x348cd4(0x162)],'/mcp')),'corsOrigins':stringArrayValue(_0x235e35['values'][_0x348cd4(0x16d)]),..._0x10af34?{'catalog':_0x10af34}:{},'schemaDelivery':_0x3fffd2,..._0x24c934?{'protocolVersion':parseProtocolVersion(_0x24c934)}:{},...optionalStringValue(_0x235e35['values']['name'])?{'serverName':optionalStringValue(_0x235e35[_0x348cd4(0x168)][_0x348cd4(0x165)])}:{},...optionalStringValue(_0x235e35['values']['version'])?{'serverVersion':optionalStringValue(_0x235e35[_0x348cd4(0x168)]['version'])}:{}};}function createServerOptions(_0x409cf8){const _0x1df27c=_0x2989;return{..._0x409cf8['catalog']?{'catalog':_0x409cf8[_0x1df27c(0x161)]}:{},'schemaDelivery':_0x409cf8['schemaDelivery'],..._0x409cf8[_0x1df27c(0x151)]?{'protocolVersion':_0x409cf8[_0x1df27c(0x151)]}:{},'server':{..._0x409cf8['serverName']?{'name':_0x409cf8['serverName']}:{},..._0x409cf8['serverVersion']?{'version':_0x409cf8['serverVersion']}:{}}};}function setCorsHeaders(_0x36c583,_0x3496fc,_0x4918f3){const _0x2d654e=_0x2989;if(_0x4918f3['length']===0x0)return;const _0x50e7ee=_0x36c583['headers'][_0x2d654e(0x13e)],_0x2bcc44=_0x4918f3['includes']('*'),_0xe8ce10=_0x2bcc44?'*':typeof _0x50e7ee==='string'&&_0x4918f3['includes'](_0x50e7ee)?_0x50e7ee:void 0x0;if(!_0xe8ce10)return;_0x3496fc[_0x2d654e(0x141)]('Access-Control-Allow-Origin',_0xe8ce10),_0x3496fc[_0x2d654e(0x141)](_0x2d654e(0x167),'Origin'),_0x3496fc['setHeader'](_0x2d654e(0x16b),'GET,POST,DELETE,OPTIONS'),_0x3496fc['setHeader']('Access-Control-Allow-Headers',_0x2d654e(0x143)),_0x3496fc[_0x2d654e(0x141)]('Access-Control-Expose-Headers','Mcp-Session-Id');}function writeJsonRpcError(_0x6dafc4,_0x58693d,_0x446720){const _0x5c11d5=_0x2989;_0x6dafc4['statusCode']=_0x58693d,_0x6dafc4[_0x5c11d5(0x141)]('content-type','application/json'),_0x6dafc4['end'](JSON['stringify']({'jsonrpc':'2.0','error':{'code':-0x7f5b,'message':_0x446720},'id':null}));}async function startStdio(_0x1dc3e0){const _0x13d946=createUIMCPServer(createServerOptions(_0x1dc3e0));await _0x13d946['connect'](new StdioServerTransport());}async function startHttp(_0x590c80){const _0x5ee1f7=_0x2989,_0x4da773=createServer(async(_0x32c730,_0x1d4032)=>{const _0x1cbd49=_0x2989,_0x1d1f15=new URL(_0x32c730[_0x1cbd49(0x149)]??'/',_0x1cbd49(0x137)+(_0x32c730['headers'][_0x1cbd49(0x135)]??_0x1cbd49(0x14e)));if(_0x1d1f15[_0x1cbd49(0x147)]!==_0x590c80['endpoint']){_0x1d4032[_0x1cbd49(0x145)]=0x194,_0x1d4032['end'](_0x1cbd49(0x15f));return;}setCorsHeaders(_0x32c730,_0x1d4032,_0x590c80[_0x1cbd49(0x16a)]);if(_0x32c730[_0x1cbd49(0x15d)]==='OPTIONS'){_0x1d4032[_0x1cbd49(0x145)]=0xcc,_0x1d4032[_0x1cbd49(0x15c)]();return;}try{const _0x360d30=createUIMCPServer(createServerOptions(_0x590c80)),_0x1d9d50=new StreamableHTTPServerTransport({'sessionIdGenerator':void 0x0});await _0x360d30[_0x1cbd49(0x146)](_0x1d9d50),await _0x1d9d50[_0x1cbd49(0x140)](_0x32c730,_0x1d4032),_0x1d4032['on']('close',()=>{const _0x11072d=_0x1cbd49;void _0x1d9d50['close'](),void _0x360d30[_0x11072d(0x159)]();});}catch(_0xd3506e){console[_0x1cbd49(0x139)](_0x1cbd49(0x14d),_0xd3506e),!_0x1d4032['headersSent']&&writeJsonRpcError(_0x1d4032,0x1f4,_0xd3506e instanceof Error?_0xd3506e['message']:'Internal\x20MCP\x20server\x20error');}});await new Promise((_0x13ed9c,_0x504d6f)=>{const _0x5f471b=_0x2989;_0x4da773[_0x5f471b(0x152)](_0x5f471b(0x139),_0x504d6f),_0x4da773[_0x5f471b(0x171)](_0x590c80[_0x5f471b(0x148)],_0x590c80['host'],_0x13ed9c);});const _0x4f3dcc=()=>{const _0xf46ae0=_0x2989;_0x4da773[_0xf46ae0(0x159)](()=>process['exit'](0x0));};process[_0x5ee1f7(0x152)]('SIGINT',_0x4f3dcc),process['once']('SIGTERM',_0x4f3dcc),process[_0x5ee1f7(0x142)]['write']('@agentic-ui-experience/ui-mcp\x20listening\x20on\x20http://'+_0x590c80['host']+':'+_0x590c80[_0x5ee1f7(0x148)]+_0x590c80[_0x5ee1f7(0x162)]+'\x0a');}async function main(){const _0xc4acbc=_0x2989,_0x2d3726=await parseCliOptions();if(_0x2d3726['transport']===_0xc4acbc(0x169)){await startStdio(_0x2d3726);return;}await startHttp(_0x2d3726);}main()['catch'](_0x5a5a69=>{const _0x292495=_0x2989;process['stderr']['write']((_0x5a5a69 instanceof Error?_0x5a5a69[_0x292495(0x15a)]:String(_0x5a5a69))+'\x0a'),process[_0x292495(0x160)](0x1);});
@@ -0,0 +1,29 @@
1
+ import type { ClientCapabilities } from "@modelcontextprotocol/sdk/types.js";
2
+ import { A2UI_MESSAGE_MEDIA_TYPE, type CatalogPromptDescriptor, type SpecA2UIMessage } from "@agentic-ui-experience/ui-core";
3
+ import { type UIToolCatalog } from "@agentic-ui-experience/ui-core/tool-mode";
4
+ export declare const A2UI_MCP_CAPABILITY_FAMILY: "v0.9";
5
+ export declare const A2UI_MCP_CAPABILITY_EXTENSION_ID: "a2ui/client-capabilities";
6
+ export interface A2UIClientCapability {
7
+ clientCapabilities: {
8
+ [A2UI_MCP_CAPABILITY_FAMILY]: {
9
+ supportedCatalogIds: string[];
10
+ };
11
+ };
12
+ }
13
+ export type A2UIClientCapabilities = ClientCapabilities & {
14
+ a2ui: A2UIClientCapability;
15
+ extensions: NonNullable<ClientCapabilities["extensions"]> & {
16
+ [A2UI_MCP_CAPABILITY_EXTENSION_ID]: A2UIClientCapability;
17
+ };
18
+ };
19
+ export interface ExtractUIMCPToolResultOptions {
20
+ catalog?: CatalogPromptDescriptor | UIToolCatalog;
21
+ }
22
+ export interface ExtractedUIMCPToolResult {
23
+ uiJson: string;
24
+ uiMessages: SpecA2UIMessage[];
25
+ resourceUri: string;
26
+ mimeType: typeof A2UI_MESSAGE_MEDIA_TYPE;
27
+ }
28
+ export declare function createA2UIClientCapabilities(supportedCatalogIds: readonly string[]): A2UIClientCapabilities;
29
+ export declare function extractUIMCPToolResult(result: unknown, options?: ExtractUIMCPToolResultOptions): ExtractedUIMCPToolResult | undefined;
package/dist/client.js ADDED
@@ -0,0 +1 @@
1
+ (function(_0x4e0851,_0x5c3334){const _0x552900=_0xd85a,_0x2e56fa=_0x4e0851();while(!![]){try{const _0x2327e3=-parseInt(_0x552900(0x9b))/0x1+-parseInt(_0x552900(0x98))/0x2*(parseInt(_0x552900(0x8b))/0x3)+-parseInt(_0x552900(0x9c))/0x4*(parseInt(_0x552900(0x92))/0x5)+-parseInt(_0x552900(0x9d))/0x6+-parseInt(_0x552900(0xa1))/0x7*(parseInt(_0x552900(0x99))/0x8)+-parseInt(_0x552900(0x89))/0x9*(parseInt(_0x552900(0x87))/0xa)+-parseInt(_0x552900(0x96))/0xb*(-parseInt(_0x552900(0x97))/0xc);if(_0x2327e3===_0x5c3334)break;else _0x2e56fa['push'](_0x2e56fa['shift']());}catch(_0x4c3a7f){_0x2e56fa['push'](_0x2e56fa['shift']());}}}(_0x3953,0xc2ea2));import{A2UI_MESSAGE_MEDIA_TYPE}from'@agentic-ui-experience/ui-core';import{createUISendNormalizer}from'@agentic-ui-experience/ui-core/tool-mode';const A2UI_MCP_CAPABILITY_FAMILY='v0.9',A2UI_MCP_CAPABILITY_EXTENSION_ID='a2ui/client-capabilities';function _0xd85a(_0x36a058,_0x20d72a){_0x36a058=_0x36a058-0x87;const _0x3953cd=_0x3953();let _0xd85ab8=_0x3953cd[_0x36a058];return _0xd85ab8;}function isJsonObject(_0x3678ac){const _0x5797ca=_0xd85a;return typeof _0x3678ac==='object'&&_0x3678ac!==null&&!Array[_0x5797ca(0x90)](_0x3678ac);}function textErrorMessage(_0x56bf00){const _0x39828e=_0xd85a;if(!Array[_0x39828e(0x90)](_0x56bf00['content']))return _0x39828e(0x8a);const _0x46226f=_0x56bf00[_0x39828e(0x94)]['filter'](isJsonObject)['filter'](_0x4a0e2b=>_0x4a0e2b['type']==='text'&&typeof _0x4a0e2b['text']==='string')[_0x39828e(0x91)](_0x2a7fc0=>_0x2a7fc0[_0x39828e(0xa0)])[_0x39828e(0x8d)](_0x3e3b7d=>_0x3e3b7d['length']>0x0);return _0x46226f[_0x39828e(0x8e)]('\x0a')||_0x39828e(0x8a);}function isAbsoluteUri(_0x471c13){const _0x287413=_0xd85a;try{return new URL(_0x471c13)[_0x287413(0x9e)][_0x287413(0x8c)]>0x1;}catch{return![];}}function createA2UIClientCapabilities(_0x3364e3){const _0x3b2540=_0xd85a;if(!Array[_0x3b2540(0x90)](_0x3364e3)||_0x3364e3[_0x3b2540(0x8c)]===0x0)throw new Error(_0x3b2540(0x93));const _0x5baadc=[];for(const _0x56c365 of _0x3364e3){if(typeof _0x56c365!=='string'||_0x56c365['trim']()[_0x3b2540(0x8c)]===0x0)throw new Error('A2UI\x20client\x20capability\x20Catalog\x20IDs\x20must\x20be\x20non-empty\x20strings.');if(!_0x5baadc['includes'](_0x56c365))_0x5baadc['push'](_0x56c365);}const _0x1f08fb={'clientCapabilities':{[A2UI_MCP_CAPABILITY_FAMILY]:{'supportedCatalogIds':_0x5baadc}}};return{'a2ui':_0x1f08fb,'extensions':{[A2UI_MCP_CAPABILITY_EXTENSION_ID]:_0x1f08fb}};}function extractUIMCPToolResult(_0x48d2c4,_0x3be242={}){const _0xfc8050=_0xd85a;if(!isJsonObject(_0x48d2c4))return void 0x0;if(_0x48d2c4['isError']===!![])throw new Error(textErrorMessage(_0x48d2c4));if(!Array['isArray'](_0x48d2c4['content']))return void 0x0;const _0x469d42=_0x48d2c4['content'][_0xfc8050(0x8d)](_0x2c1405=>{const _0x4eb05d=_0xfc8050;if(!isJsonObject(_0x2c1405)||_0x2c1405[_0x4eb05d(0x95)]!=='resource')return![];if(!isJsonObject(_0x2c1405[_0x4eb05d(0x9a)]))return![];return _0x2c1405['resource']['mimeType']===A2UI_MESSAGE_MEDIA_TYPE;});if(_0x469d42[_0xfc8050(0x8c)]===0x0)return void 0x0;if(_0x469d42[_0xfc8050(0x8c)]>0x1)throw new Error(_0xfc8050(0xa2));const _0x14da74=_0x469d42[0x0]['resource'];if(!isJsonObject(_0x14da74))throw new Error('A2UI\x20embedded\x20resource\x20is\x20malformed.');if(typeof _0x14da74['uri']!=='string'||!isAbsoluteUri(_0x14da74[_0xfc8050(0x9f)]))throw new Error('A2UI\x20embedded\x20resource\x20must\x20contain\x20a\x20valid\x20absolute\x20URI.');if(typeof _0x14da74['text']!=='string')throw new Error('A2UI\x20embedded\x20resource\x20must\x20contain\x20text\x20content.');let _0x3e8ee9;try{_0x3e8ee9=JSON['parse'](_0x14da74['text']);}catch{throw new Error(_0xfc8050(0x88));}const _0x75928c=createUISendNormalizer({'mode':'strict','catalog':_0x3be242[_0xfc8050(0x8f)]})({'messages':_0x3e8ee9});return{..._0x75928c,'resourceUri':_0x14da74[_0xfc8050(0x9f)],'mimeType':A2UI_MESSAGE_MEDIA_TYPE};}function _0x3953(){const _0x433789=['text','117999wjtNnf','MCP\x20tool\x20result\x20contains\x20multiple\x20A2UI\x20embedded\x20resources.','490lPkLdF','A2UI\x20embedded\x20resource\x20text\x20must\x20contain\x20valid\x20JSON.','197019tUWEaj','MCP\x20tool\x20reported\x20an\x20error.','489OjNqrM','length','filter','join','catalog','isArray','map','6695AByxiN','A2UI\x20client\x20capabilities\x20require\x20at\x20least\x20one\x20Catalog\x20ID.','content','type','10827938kyRqdK','72nEWCLC','3802bVynqI','264qfJKRf','resource','1405735MzHmbW','2696aUfoyF','5164524tuPtTt','protocol','uri'];_0x3953=function(){return _0x433789;};return _0x3953();}export{A2UI_MCP_CAPABILITY_EXTENSION_ID,A2UI_MCP_CAPABILITY_FAMILY,createA2UIClientCapabilities,extractUIMCPToolResult};
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { McpServer, type RegisteredResource, type RegisteredTool } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  import type { CallToolResult, ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
3
- import type { CatalogPromptDescriptor } from "@agentic-ui-experience/ui-core";
4
- import { type UIGetCatalogArguments, type UIGetCatalogResult, type UISendToolArguments, type UISendToolResult, type UIToolCatalog, type UIToolCatalogInstructionMode } from "@agentic-ui-experience/ui-core/tool-mode";
3
+ import { type A2UIProtocolVersion, type CatalogPromptDescriptor } from "@agentic-ui-experience/ui-core";
4
+ import { type UIGetCatalogArguments, type UIGetCatalogResult, type UISendToolArguments, type UISendToolResult, type UIToolCatalog } from "@agentic-ui-experience/ui-core/tool-mode";
5
5
  export type UIMCPToolResult = UISendToolResult & Record<string, unknown>;
6
6
  export type UIMCPToolArguments = UISendToolArguments;
7
- export type UIMCPCatalogInstructionMode = UIToolCatalogInstructionMode;
7
+ export type UIMCPSchemaDelivery = "discovery" | "inline";
8
8
  export type UIMCPCatalogDescription = UIGetCatalogResult["catalog"];
9
9
  export type UIMCPGetCatalogArguments = UIGetCatalogArguments;
10
10
  export type UIMCPGetCatalogResult = UIGetCatalogResult & Record<string, unknown>;
@@ -21,10 +21,17 @@ export interface UIMCPNormalizeMessagesOptions {
21
21
  */
22
22
  catalog?: CatalogPromptDescriptor | UIMCPCatalog;
23
23
  }
24
+ export interface CreateUIToolCallResultOptions {
25
+ /** Catalog used to strictly validate the normalized carrier. Defaults to Basic. */
26
+ catalog?: CatalogPromptDescriptor | UIMCPCatalog;
27
+ }
24
28
  export interface CreateUIMCPServerOptions {
25
29
  /** The single catalog this server serves. Defaults to the A2UI basic catalog. */
26
30
  catalog?: CatalogPromptDescriptor;
27
- catalogInstructionMode?: UIMCPCatalogInstructionMode;
31
+ /** How the model receives schemas. Defaults to discovery via get_ui_catalog. */
32
+ schemaDelivery?: UIMCPSchemaDelivery;
33
+ /** Version requested in generated tool and catalog instructions. Defaults to v0.9.1. */
34
+ protocolVersion?: A2UIProtocolVersion;
28
35
  title?: string;
29
36
  annotations?: ToolAnnotations;
30
37
  normalize?: UIMCPNormalize;
@@ -38,7 +45,7 @@ export declare function createUIMCPNormalize(options?: UIMCPNormalizeMessagesOpt
38
45
  * Execute a UI MCP call. This is intentionally pure: it parses and returns the
39
46
  * UI payload, but does not mutate any UI runtime.
40
47
  */
41
- export declare function createUIToolCallResult(args: UIMCPToolArguments, normalize?: UIMCPNormalize): Promise<CallToolResult>;
48
+ export declare function createUIToolCallResult(args: UIMCPToolArguments, normalize?: UIMCPNormalize, options?: CreateUIToolCallResultOptions): Promise<CallToolResult>;
42
49
  export declare function registerUICatalogResources(server: McpServer, catalog: UIMCPCatalog): {
43
50
  catalog: RegisteredResource;
44
51
  };
@@ -50,7 +57,7 @@ export declare function registerUICatalogTools(server: McpServer, catalog: UIMCP
50
57
  * scenario-independent; catalog-specific schema comes from the one catalog it
51
58
  * was configured with.
52
59
  */
53
- export declare function registerGenericUITool(server: McpServer, catalog: UIMCPCatalog, options?: Pick<CreateUIMCPServerOptions, "title" | "annotations" | "normalize">): RegisteredTool;
60
+ export declare function registerGenericUITool(server: McpServer, catalog: UIMCPCatalog, options?: Pick<CreateUIMCPServerOptions, "title" | "annotations" | "normalize" | "schemaDelivery">): RegisteredTool;
54
61
  /**
55
62
  * Create a generic A2UI MCP server. Transport ownership stays with the caller
56
63
  * so this can be used with stdio, SSE, or streamable HTTP.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- const _0x20fee2=_0x5886;(function(_0x4b7a5a,_0x1c0539){const _0x5499a6=_0x5886,_0x39daf0=_0x4b7a5a();while(!![]){try{const _0x141434=parseInt(_0x5499a6(0x1ed))/0x1+parseInt(_0x5499a6(0x211))/0x2*(-parseInt(_0x5499a6(0x207))/0x3)+-parseInt(_0x5499a6(0x20f))/0x4*(-parseInt(_0x5499a6(0x1ff))/0x5)+parseInt(_0x5499a6(0x1f0))/0x6+parseInt(_0x5499a6(0x1f5))/0x7+parseInt(_0x5499a6(0x212))/0x8*(parseInt(_0x5499a6(0x215))/0x9)+parseInt(_0x5499a6(0x1ef))/0xa*(-parseInt(_0x5499a6(0x1e5))/0xb);if(_0x141434===_0x1c0539)break;else _0x39daf0['push'](_0x39daf0['shift']());}catch(_0x525c22){_0x39daf0['push'](_0x39daf0['shift']());}}}(_0x38a2,0x663b1));import{McpServer}from'@modelcontextprotocol/sdk/server/mcp.js';import{McpServer as _0x5312a8}from'@modelcontextprotocol/sdk/server/mcp.js';function _0x38a2(){const _0x565308=['record','11bMiJNf','@agentic-ui-experience/ui-mcp','Optional\x20expected\x20surface\x20id\x20for\x20this\x20UI\x20call.\x20When\x20supplied,\x20`messages[0].createSurface.surfaceId`\x20must\x20match\x20it.','componentNames','The\x20complete\x20A2UI\x20v0.9-compatible\x20UI\x20message\x20array.','The\x20first\x20entry\x20must\x20be\x20`createSurface`,\x20carrying\x20the\x20catalog\x20id\x20reported\x20by\x20','descriptor','-\x20createSurface.catalogId\x20must\x20be\x20\x22','769910pTCqrr','join','14523620TVLqzI','1111044fZwyfl','Message\x20list\x20rules:','The\x20directory\x20is\x20returned\x20on\x20every\x20call,\x20so\x20you\x20can\x20widen\x20your\x20selection\x20with\x20a\x20second\x20call\x20if\x20the\x20first\x20one\x20missed\x20something.','stringify','Do\x20not\x20send\x20`ui_json`;\x20do\x20not\x20serialize\x20the\x20messages\x20into\x20a\x20JSON\x20string.','462259ySCnuw','catalogInstructionMode','surfaceId','uiMessages','string','catalog','compact','version','server','href','45ZiivrD','object','-\x20Later\x20updateComponents/updateDataModel/deleteSurface\x20messages\x20must\x20target\x20the\x20same\x20surface.','registerTool','unknown','v0.9','Final\x20step:\x20render\x20UI\x20on\x20the\x20client\x20by\x20submitting\x20structured\x20A2UI\x20messages.','union','54iThIkq','application/json','array','Catalog\x20id:\x20','Component\x20names\x20whose\x20field\x20rules\x20and\x20schemas\x20you\x20need.\x20Omit\x20on\x20the\x20first\x20call\x20to\x20get\x20the\x20catalog\x20directory\x20—\x20every\x20component\x20name\x20with\x20one\x20line\x20on\x20what\x20it\x20is\x20for\x20—\x20then\x20call\x20again\x20with\x20the\x20components\x20this\x20UI\x20actually\x20uses.','text','functionNames','message','145144XNIrFr','Use\x20this\x20only\x20as\x20workflow\x20step\x202,\x20after\x20fetching\x20component\x20schemas\x20with\x20','33598AQpgRD','624GvMFfd','passthrough','-\x20The\x20first\x20message\x20must\x20be\x20createSurface.','95283sMHegY','enum','describe','full','Do\x20not\x20pass\x20a\x20JSON\x20string\x20and\x20do\x20not\x20use\x20a\x20ui_json\x20field.','\x20A2UI\x20UI\x20message(s).','Get\x20A2UI\x20Catalog','literal','optional'];_0x38a2=function(){return _0x565308;};return _0x38a2();}import{z}from'zod';import{createUISendNormalizer,createUIToolCatalog,CATALOG_RESOURCE_URI,createUICatalogResourcePayload,GET_UI_CATALOG_TOOL_NAME,UI_TOOL_NAME,UI_TOOL_WORKFLOW_ORDER,getUICatalog,UI_TOOL_WORKFLOW,normalizeUISendToolArguments}from'@agentic-ui-experience/ui-core/tool-mode';const sendUIOutputSchema={'uiJson':z[_0x20fee2(0x1f9)](),'uiMessages':z['array'](z['unknown']())},getCatalogOutputSchema={'catalog':z['object']({'id':z['string'](),'resourceUri':z['string'](),'instructionMode':z[_0x20fee2(0x216)](['compact',_0x20fee2(0x218)]),'componentPurposes':z[_0x20fee2(0x1e4)](z['string'](),z['string']()),'descriptor':z[_0x20fee2(0x203)](),'instructions':z[_0x20fee2(0x1f9)]()})},componentSchema=z[_0x20fee2(0x1e4)](z['string'](),z['unknown']()),createSurfaceMessageSchema=z[_0x20fee2(0x200)]({'version':z['literal']('v0.9'),'createSurface':z[_0x20fee2(0x200)]({'surfaceId':z['string'](),'catalogId':z['string']()})['passthrough']()})[_0x20fee2(0x213)](),updateComponentsMessageSchema=z[_0x20fee2(0x200)]({'version':z[_0x20fee2(0x1e2)]('v0.9'),'updateComponents':z['object']({'surfaceId':z['string'](),'components':z['array'](componentSchema)})[_0x20fee2(0x213)]()})[_0x20fee2(0x213)](),updateDataModelMessageSchema=z['object']({'version':z[_0x20fee2(0x1e2)](_0x20fee2(0x204)),'updateDataModel':z['object']({'surfaceId':z['string'](),'path':z[_0x20fee2(0x1f9)]()[_0x20fee2(0x1e3)](),'value':z['unknown']()['optional']()})['passthrough']()})['passthrough'](),deleteSurfaceMessageSchema=z[_0x20fee2(0x200)]({'version':z[_0x20fee2(0x1e2)](_0x20fee2(0x204)),'deleteSurface':z['object']({'surfaceId':z['string']()})[_0x20fee2(0x213)]()})['passthrough']();function _0x5886(_0x291a97,_0x1f1940){_0x291a97=_0x291a97-0x1e0;const _0x38a22f=_0x38a2();let _0x588633=_0x38a22f[_0x291a97];return _0x588633;}function createSendUIInputSchema(){const _0x3f17f9=_0x20fee2;return{'surfaceId':z[_0x3f17f9(0x1f9)]()['optional']()[_0x3f17f9(0x217)](_0x3f17f9(0x1e7)),'messages':z['array'](z[_0x3f17f9(0x206)]([createSurfaceMessageSchema,updateComponentsMessageSchema,updateDataModelMessageSchema,deleteSurfaceMessageSchema]))[_0x3f17f9(0x217)]([_0x3f17f9(0x1e9),_0x3f17f9(0x210)+GET_UI_CATALOG_TOOL_NAME+'.','Build\x20component\x20objects\x20from\x20the\x20schema\x20returned\x20by\x20'+GET_UI_CATALOG_TOOL_NAME+';\x20do\x20not\x20guess\x20component\x20fields\x20from\x20this\x20tool\x20schema.',_0x3f17f9(0x219),'Every\x20entry\x20contains\x20`version`\x20and\x20exactly\x20one\x20of\x20`createSurface`/`updateComponents`/`updateDataModel`/`deleteSurface`.',_0x3f17f9(0x1ea)+GET_UI_CATALOG_TOOL_NAME+'\x20at\x20`createSurface.catalogId`.','Component\x20objects\x20belong\x20inside\x20a\x20later\x20`updateComponents.components`\x20array.'][_0x3f17f9(0x1ee)]('\x20'))};}function createGetCatalogInputSchema(){const _0x1bc8f7=_0x20fee2;return{'componentNames':z[_0x1bc8f7(0x209)](z[_0x1bc8f7(0x1f9)]())['min'](0x1)[_0x1bc8f7(0x1e3)]()['describe'](_0x1bc8f7(0x20b)),'functionNames':z[_0x1bc8f7(0x209)](z[_0x1bc8f7(0x1f9)]())['min'](0x1)['optional']()[_0x1bc8f7(0x217)]('Optional\x20catalog\x20function\x20names\x20whose\x20full\x20schemas\x20you\x20need\x20(e.g.\x20formatDate,\x20formatNumber).\x20The\x20returned\x20instructions\x20always\x20list\x20every\x20function\x20name\x20with\x20its\x20arguments,\x20so\x20request\x20schemas\x20only\x20for\x20the\x20functions\x20this\x20UI\x20actually\x20calls.\x20Omit\x20when\x20the\x20UI\x20calls\x20no\x20functions.'),'instructionMode':z[_0x1bc8f7(0x216)]([_0x1bc8f7(0x1fb),'full'])['optional']()['describe']('Optional\x20instruction\x20detail\x20level\x20for\x20the\x20returned\x20catalog\x20instructions.\x20Defaults\x20to\x20the\x20MCP\x20server\x20catalogInstructionMode.\x20Use\x20compact\x20for\x20a\x20concise\x20field\x20cheat\x20sheet;\x20use\x20full\x20when\x20the\x20model\x20needs\x20the\x20authoritative\x20JSON\x20schema\x20in\x20the\x20instructions.')};}function createGenericToolDescription(_0x10e033){const _0x753ee9=_0x20fee2;return[_0x753ee9(0x205),UI_TOOL_WORKFLOW,'Do\x20not\x20call\x20this\x20tool\x20before\x20'+GET_UI_CATALOG_TOOL_NAME+'\x20in\x20the\x20same\x20task.\x20This\x20tool\x20validates\x20and\x20returns\x20A2UI\x20messages;\x20it\x20is\x20not\x20the\x20source\x20of\x20component\x20schemas.',_0x753ee9(0x20a)+_0x10e033[_0x753ee9(0x1eb)]['id']+'.',_0x753ee9(0x1f1),'-\x20Every\x20message\x20must\x20include\x20\x22version\x22:\x20\x22v0.9\x22.',_0x753ee9(0x214),'-\x20createSurface.surfaceId\x20must\x20match\x20the\x20top-level\x20surfaceId\x20when\x20supplied.',_0x753ee9(0x1ec)+_0x10e033['descriptor']['id']+'\x22.',_0x753ee9(0x201),'-\x20Component\x20objects\x20belong\x20only\x20inside\x20updateComponents.components\x20and\x20must\x20conform\x20to\x20the\x20schemas\x20returned\x20by\x20get_ui_catalog.',_0x753ee9(0x1f4)][_0x753ee9(0x1ee)]('\x0a\x0a');}function createUIMCPNormalize(_0x26991c={}){const _0x27f738=_0x20fee2;return createUISendNormalizer({'mode':_0x26991c['mode'],'surfaceId':_0x26991c[_0x27f738(0x1f7)],'catalog':_0x26991c[_0x27f738(0x1fa)]});}const defaultNormalize=createUIMCPNormalize();function toToolError(_0x1049f2){const _0x178bb5=_0x20fee2;return{'isError':!![],'content':[{'type':_0x178bb5(0x20c),'text':_0x1049f2}]};}function toToolResult(_0x1002ef){const _0x2db487=_0x20fee2;return{'content':[{'type':'text','text':'Accepted\x20'+_0x1002ef[_0x2db487(0x1f8)]['length']+_0x2db487(0x1e0)}],'structuredContent':_0x1002ef};}function toCatalogToolResult(_0x113475){const _0x39ca59=_0x20fee2;return{'content':[{'type':_0x39ca59(0x20c),'text':JSON[_0x39ca59(0x1f3)](_0x113475)}],'structuredContent':_0x113475};}async function createUIToolCallResult(_0x61c3a3,_0x21f5d4=defaultNormalize){const _0x4bba3e=_0x20fee2;try{const _0x3083fe=await _0x21f5d4(_0x61c3a3);return toToolResult(normalizeUISendToolArguments(_0x61c3a3,()=>_0x3083fe));}catch(_0x5cfd01){const _0xe516a2=_0x5cfd01 instanceof Error?_0x5cfd01[_0x4bba3e(0x20e)]:String(_0x5cfd01);return toToolError(_0xe516a2);}}function toMCPResourceResult(_0x255bce){return _0x255bce;}function registerUICatalogResources(_0x216b8d,_0x360d28){const _0x483fb6=_0x20fee2,_0x539e1a=_0x216b8d['registerResource']('a2ui-catalog',CATALOG_RESOURCE_URI,{'title':'A2UI\x20Catalog\x20'+_0x360d28['descriptor']['id'],'description':'A2UI\x20catalog\x20instructions\x20and\x20component\x20schema.','mimeType':_0x483fb6(0x208)},_0x142ae8=>toMCPResourceResult(createUICatalogResourcePayload(_0x360d28,_0x142ae8[_0x483fb6(0x1fe)])));return{'catalog':_0x539e1a};}function registerUICatalogTools(_0x1199dd,_0xd72927){const _0x1c8288=_0x20fee2,_0x1f844e=_0x1199dd['registerTool'](GET_UI_CATALOG_TOOL_NAME,{'title':_0x1c8288(0x1e1),'description':['Step\x201\x20of\x20the\x20A2UI\x20MCP\x20workflow.\x20Call\x20this\x20before\x20'+UI_TOOL_NAME+'.',UI_TOOL_WORKFLOW_ORDER,'With\x20no\x20componentNames\x20it\x20returns\x20the\x20catalog\x20directory:\x20the\x20catalog\x20id\x20and\x20every\x20component\x20name\x20with\x20one\x20line\x20saying\x20what\x20it\x20is\x20for.\x20With\x20componentNames\x20it\x20returns\x20A2UI\x20message\x20rules,\x20component\x20field\x20rules,\x20custom\x20component\x20schemas,\x20style\x20guide,\x20and\x20examples\x20for\x20those\x20components.',_0x1c8288(0x1f2),'Use\x20instructionMode\x20\x22full\x22\x20for\x20forms,\x20unfamiliar\x20components,\x20validation\x20failures,\x20or\x20when\x20exact\x20required\x20fields\x20are\x20needed.']['join']('\x0a\x0a'),'inputSchema':createGetCatalogInputSchema(),'outputSchema':getCatalogOutputSchema,'annotations':{'readOnlyHint':!![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':![]}},async _0x2a1720=>{const _0x2f9df2=_0x1c8288;try{return toCatalogToolResult(getUICatalog(_0xd72927,{'componentNames':_0x2a1720[_0x2f9df2(0x1e8)],'functionNames':_0x2a1720[_0x2f9df2(0x20d)],'instructionMode':_0x2a1720['instructionMode']}));}catch(_0x6397c6){const _0x4f1934=_0x6397c6 instanceof Error?_0x6397c6['message']:String(_0x6397c6);return toToolError(_0x4f1934);}});return{'get':_0x1f844e};}function registerGenericUITool(_0x47912a,_0x20bab8,_0x5a8f99={}){const _0x3e93ba=_0x20fee2,_0x380e02=_0x5a8f99['normalize']??createUISendNormalizer({'catalog':_0x20bab8});return _0x47912a[_0x3e93ba(0x202)](UI_TOOL_NAME,{'title':_0x5a8f99['title'],'description':createGenericToolDescription(_0x20bab8),'inputSchema':createSendUIInputSchema(),'outputSchema':sendUIOutputSchema,'annotations':{'readOnlyHint':![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':![],..._0x5a8f99['annotations']}},async _0x36cd32=>createUIToolCallResult(_0x36cd32,_0x380e02));}function createUIMCPServer(_0x21dc6={}){const _0x8b0db2=_0x20fee2,_0x682d75=createUIToolCatalog(_0x21dc6[_0x8b0db2(0x1fa)],_0x21dc6[_0x8b0db2(0x1f6)]),_0x12a32f=_0x21dc6['normalize']??createUISendNormalizer({'catalog':_0x682d75}),_0x2ed1e4=new McpServer({'name':_0x21dc6[_0x8b0db2(0x1fd)]?.['name']??_0x8b0db2(0x1e6),'version':_0x21dc6['server']?.[_0x8b0db2(0x1fc)]??'0.0.0'});return registerUICatalogResources(_0x2ed1e4,_0x682d75),registerUICatalogTools(_0x2ed1e4,_0x682d75),registerGenericUITool(_0x2ed1e4,_0x682d75,{..._0x21dc6,'normalize':_0x12a32f}),_0x2ed1e4;}export{_0x5312a8 as McpServer,createUIMCPNormalize,createUIMCPServer,createUIToolCallResult,registerGenericUITool,registerUICatalogResources,registerUICatalogTools};
1
+ const _0x2b5726=_0x2831;(function(_0x15e93b,_0x29aaeb){const _0x1d429e=_0x2831,_0x41a6ee=_0x15e93b();while(!![]){try{const _0x411598=-parseInt(_0x1d429e(0x83))/0x1+-parseInt(_0x1d429e(0xa0))/0x2+-parseInt(_0x1d429e(0xad))/0x3*(-parseInt(_0x1d429e(0x71))/0x4)+parseInt(_0x1d429e(0x91))/0x5*(-parseInt(_0x1d429e(0x93))/0x6)+parseInt(_0x1d429e(0x92))/0x7+-parseInt(_0x1d429e(0x8e))/0x8*(-parseInt(_0x1d429e(0x99))/0x9)+parseInt(_0x1d429e(0x80))/0xa;if(_0x411598===_0x29aaeb)break;else _0x41a6ee['push'](_0x41a6ee['shift']());}catch(_0x328bd4){_0x41a6ee['push'](_0x41a6ee['shift']());}}}(_0x3d32,0xb67e3));import{McpServer}from'@modelcontextprotocol/sdk/server/mcp.js';import{McpServer as _0x35f72c}from'@modelcontextprotocol/sdk/server/mcp.js';import{z}from'zod';import{A2UI_SUPPORTED_PROTOCOL_VERSIONS,A2UI_DEFAULT_PROTOCOL_VERSION,A2UI_MESSAGE_MEDIA_TYPE}from'@agentic-ui-experience/ui-core';import{createUISendNormalizer,createUIToolCatalog,CATALOG_RESOURCE_URI,createUICatalogResourcePayload,GET_UI_CATALOG_TOOL_NAME,UI_TOOL_NAME,UI_TOOL_WORKFLOW_ORDER,getUICatalog,createUISendToolSpec,UI_TOOL_WORKFLOW}from'@agentic-ui-experience/ui-core/tool-mode';function _0x3d32(){const _0x172227=['lazy','number','set','directory','normalize','registerResource','unknown','string','array','optional','discovery','componentNames','The\x20complete\x20A2UI\x20','20578660jasrOi','title','enum','1193434wrqvlb','every','@agentic-ui-experience/ui-mcp','getPrototypeOf','Unsupported\x20schemaDelivery\x20\x22','stringify','inline','catalog','delete','href','prototype','16VPyFdF','length','-\x20The\x20first\x20message\x20must\x20be\x20createSurface.','1185VjHaUq','7667058qWDwDZ','36000pmqiZB','Client\x20A2UI\x20capabilities\x20are\x20malformed:\x20clientCapabilities[\x22','describe','Use\x20this\x20only\x20as\x20workflow\x20step\x202,\x20after\x20fetching\x20component\x20schemas\x20with\x20','registerTool','functionNames','3723633SbhWkM','annotations','\x20at\x20`createSurface.catalogId`.','join','object','literal','Build\x20component\x20objects\x20from\x20the\x20schema\x20returned\x20by\x20','2888002kuqhjm','union','Generated\x20an\x20interactive\x20A2UI\x20interface.','\x22\x20(','supportedCatalogIds','isFinite','message','\x20in\x20the\x20same\x20task.\x20This\x20tool\x20validates\x20and\x20returns\x20A2UI\x20messages;\x20it\x20is\x20not\x20the\x20source\x20of\x20component\x20schemas.','a2ui-catalog','add','-\x20createSurface.catalogId\x20must\x20be\x20\x22','discriminatedUnion','With\x20componentNames\x20it\x20returns\x20only\x20the\x20selected\x20generation\x20contract:\x20A2UI\x20guidance\x20in\x20catalog.instructions\x20and\x20machine-readable\x20component/function\x20definitions\x20in\x20catalog.definitions.\x20The\x20directory\x20is\x20omitted\x20from\x20this\x20selected\x20response.','6HYLjPw','record','Catalog\x20id:\x20','keys','get','isArray','catchall','uiJson','Get\x20A2UI\x20Catalog','uiMessages','has','A2UI\x20catalog\x20instructions\x20and\x20component\x20schema.','kind','ownKeys','-\x20Later\x20updateComponents/updateDataModel/deleteSurface\x20messages\x20must\x20target\x20the\x20same\x20surface.','text','strict','descriptor','a2ui','surfaceId','mode','1652584RbhCaF','Do\x20not\x20call\x20this\x20tool\x20before\x20'];_0x3d32=function(){return _0x172227;};return _0x3d32();}import{A2UI_MCP_CAPABILITY_FAMILY,A2UI_MCP_CAPABILITY_EXTENSION_ID}from'./client.js';const jsonValueSchema=z[_0x2b5726(0x73)](()=>z[_0x2b5726(0xa1)]([z['null'](),z['boolean'](),z['number'](),z['string'](),z['array'](jsonValueSchema),z[_0x2b5726(0xae)](z[_0x2b5726(0x7a)](),jsonValueSchema)])),jsonObjectSchema=z['record'](z[_0x2b5726(0x7a)](),jsonValueSchema),catalogDescriptionBaseSchema={'id':z['string'](),'resourceUri':z[_0x2b5726(0x7a)](),'instructions':z[_0x2b5726(0x7a)]()},catalogBasicDefinitionsSchema=z['object']({'format':z['literal']('json-schema'),'schema':jsonObjectSchema}),catalogDefinitionsSchema=z[_0x2b5726(0x9d)]({'componentNames':z[_0x2b5726(0x7b)](z['string']()),'functionNames':z[_0x2b5726(0x7b)](z[_0x2b5726(0x7a)]()),'basicComponents':catalogBasicDefinitionsSchema[_0x2b5726(0x7c)](),'customComponents':z[_0x2b5726(0xae)](z[_0x2b5726(0x7a)](),z['union']([z['boolean'](),jsonObjectSchema])),'functions':z[_0x2b5726(0xae)](z['string'](),jsonObjectSchema),'$defs':jsonObjectSchema}),getCatalogOutputSchema={'catalog':z[_0x2b5726(0xab)](_0x2b5726(0xb9),[z[_0x2b5726(0x9d)]({...catalogDescriptionBaseSchema,'kind':z[_0x2b5726(0x9e)](_0x2b5726(0x76)),'componentPurposes':z[_0x2b5726(0xae)](z[_0x2b5726(0x7a)](),z[_0x2b5726(0x7a)]()),'definitions':catalogDefinitionsSchema['optional']()}),z[_0x2b5726(0x9d)]({...catalogDescriptionBaseSchema,'kind':z['literal']('selection'),'definitions':catalogDefinitionsSchema})])},protocolVersionSchema=z[_0x2b5726(0x82)](A2UI_SUPPORTED_PROTOCOL_VERSIONS),componentSchema=jsonObjectSchema,createSurfaceMessageSchema=z[_0x2b5726(0x9d)]({'version':protocolVersionSchema,'createSurface':z['object']({'surfaceId':z['string'](),'catalogId':z[_0x2b5726(0x7a)]()})[_0x2b5726(0xb3)](jsonValueSchema)})['catchall'](jsonValueSchema),updateComponentsMessageSchema=z['object']({'version':protocolVersionSchema,'updateComponents':z[_0x2b5726(0x9d)]({'surfaceId':z[_0x2b5726(0x7a)](),'components':z['array'](componentSchema)})[_0x2b5726(0xb3)](jsonValueSchema)})[_0x2b5726(0xb3)](jsonValueSchema),updateDataModelMessageSchema=z['object']({'version':protocolVersionSchema,'updateDataModel':z['object']({'surfaceId':z[_0x2b5726(0x7a)](),'path':z['string']()['optional'](),'value':jsonValueSchema['optional']()})['catchall'](jsonValueSchema)})[_0x2b5726(0xb3)](jsonValueSchema),deleteSurfaceMessageSchema=z['object']({'version':protocolVersionSchema,'deleteSurface':z['object']({'surfaceId':z[_0x2b5726(0x7a)]()})['catchall'](jsonValueSchema)})['catchall'](jsonValueSchema);function createSendUIInputSchema(_0x62de57=A2UI_DEFAULT_PROTOCOL_VERSION){const _0x7edb8e=_0x2b5726;return{'surfaceId':z['string']()['optional']()[_0x7edb8e(0x95)]('Optional\x20expected\x20surface\x20id\x20for\x20this\x20UI\x20call.\x20When\x20supplied,\x20`messages[0].createSurface.surfaceId`\x20must\x20match\x20it.'),'messages':z[_0x7edb8e(0x7b)](z[_0x7edb8e(0xa1)]([createSurfaceMessageSchema,updateComponentsMessageSchema,updateDataModelMessageSchema,deleteSurfaceMessageSchema]))['describe']([_0x7edb8e(0x7f)+_0x62de57+'\x20UI\x20message\x20array.','Every\x20message\x20you\x20generate\x20must\x20use\x20\x22version\x22:\x20\x22'+_0x62de57+'\x22;\x20no\x20other\x20wire\x20version\x20is\x20accepted.',_0x7edb8e(0x96)+GET_UI_CATALOG_TOOL_NAME+'.',_0x7edb8e(0x9f)+GET_UI_CATALOG_TOOL_NAME+';\x20do\x20not\x20guess\x20component\x20fields\x20from\x20this\x20tool\x20schema.','Do\x20not\x20pass\x20a\x20JSON\x20string\x20and\x20do\x20not\x20use\x20a\x20ui_json\x20field.','Every\x20entry\x20contains\x20`version`\x20and\x20exactly\x20one\x20of\x20`createSurface`/`updateComponents`/`updateDataModel`/`deleteSurface`.','The\x20first\x20entry\x20must\x20be\x20`createSurface`,\x20carrying\x20the\x20catalog\x20id\x20reported\x20by\x20'+GET_UI_CATALOG_TOOL_NAME+_0x7edb8e(0x9b),'Component\x20objects\x20belong\x20inside\x20a\x20later\x20`updateComponents.components`\x20array.'][_0x7edb8e(0x9c)]('\x20'))};}function createGetCatalogInputSchema(){const _0x3b9d6d=_0x2b5726;return{'componentNames':z['array'](z['string']())['min'](0x1)['optional']()['describe']('Component\x20names\x20whose\x20field\x20rules\x20and\x20schemas\x20you\x20need.\x20Omit\x20on\x20the\x20first\x20call\x20to\x20get\x20the\x20catalog\x20directory\x20—\x20every\x20component\x20name\x20with\x20one\x20line\x20on\x20what\x20it\x20is\x20for\x20—\x20then\x20call\x20again\x20with\x20the\x20components\x20this\x20UI\x20actually\x20uses.'),'functionNames':z['array'](z[_0x3b9d6d(0x7a)]())['min'](0x1)['optional']()[_0x3b9d6d(0x95)]('Optional\x20catalog\x20function\x20names\x20whose\x20full\x20schemas\x20you\x20need\x20(e.g.\x20formatDate,\x20formatNumber).\x20The\x20directory\x20instructions\x20list\x20available\x20functions\x20by\x20name\x20and\x20arguments;\x20requested\x20schemas\x20are\x20returned\x20in\x20catalog.definitions.functions.\x20Omit\x20when\x20the\x20UI\x20calls\x20no\x20functions.')};}function createGenericToolDescription(_0x10bf0b){const _0x1352e6=_0x2b5726,_0x3e1116=_0x10bf0b['protocolVersion']??A2UI_DEFAULT_PROTOCOL_VERSION;return['Final\x20step:\x20render\x20UI\x20on\x20the\x20client\x20by\x20submitting\x20structured\x20A2UI\x20messages.',UI_TOOL_WORKFLOW,_0x1352e6(0x72)+GET_UI_CATALOG_TOOL_NAME+_0x1352e6(0xa7),_0x1352e6(0xaf)+_0x10bf0b['descriptor']['id']+'.','Message\x20list\x20rules:','-\x20Every\x20message\x20you\x20generate\x20must\x20include\x20\x22version\x22:\x20\x22'+_0x3e1116+'\x22.',_0x1352e6(0x90),'-\x20createSurface.surfaceId\x20must\x20match\x20the\x20top-level\x20surfaceId\x20when\x20supplied.',_0x1352e6(0xaa)+_0x10bf0b['descriptor']['id']+'\x22.',_0x1352e6(0xbb),'-\x20Component\x20objects\x20belong\x20only\x20inside\x20updateComponents.components\x20and\x20must\x20conform\x20to\x20the\x20schemas\x20returned\x20by\x20get_ui_catalog.','Do\x20not\x20send\x20`ui_json`;\x20do\x20not\x20serialize\x20the\x20messages\x20into\x20a\x20JSON\x20string.'][_0x1352e6(0x9c)]('\x0a\x0a');}function createUIMCPNormalize(_0x25a61a={}){const _0x415197=_0x2b5726;return createUISendNormalizer({'mode':_0x25a61a[_0x415197(0x70)],'surfaceId':_0x25a61a['surfaceId'],'catalog':_0x25a61a[_0x415197(0x8a)]});}const defaultNormalize=createUIMCPNormalize(),carrierValidators=new WeakMap();function getCarrierValidator(_0x3750cb){const _0x52a231=_0x2b5726;if(_0x3750cb===void 0x0)return defaultNormalize;const _0x535d1b=carrierValidators[_0x52a231(0xb1)](_0x3750cb);if(_0x535d1b)return _0x535d1b;const _0x5a6295=createUIMCPNormalize({'mode':_0x52a231(0xbd),'catalog':_0x3750cb});return carrierValidators[_0x52a231(0x75)](_0x3750cb,_0x5a6295),_0x5a6295;}function isJsonObject(_0x436b96){const _0x386c74=_0x2b5726;return typeof _0x436b96===_0x386c74(0x9d)&&_0x436b96!==null&&!Array['isArray'](_0x436b96);}function isPlainJsonObject(_0x4718a5){const _0x20e08b=_0x2b5726;if(!isJsonObject(_0x4718a5))return![];const _0xe79168=Object[_0x20e08b(0x86)](_0x4718a5);return _0xe79168===Object['prototype']||_0xe79168===null;}function hasOwn(_0x5927da,_0x302154){const _0x40c86c=_0x2b5726;return Object[_0x40c86c(0x8d)]['hasOwnProperty']['call'](_0x5927da,_0x302154);}function jsonValuesEqual(_0x576185,_0x4bb62b,_0x2a19f2=new WeakSet(),_0x1d7d26=new WeakSet()){const _0x3bc203=_0x2b5726;if(_0x576185===null||_0x4bb62b===null)return _0x576185===_0x4bb62b;if(typeof _0x576185!==typeof _0x4bb62b)return![];if(typeof _0x576185===_0x3bc203(0x7a)||typeof _0x576185==='boolean')return _0x576185===_0x4bb62b;if(typeof _0x576185===_0x3bc203(0x74))return Number[_0x3bc203(0xa5)](_0x576185)&&Number['isFinite'](_0x4bb62b)&&_0x576185===_0x4bb62b;if(typeof _0x576185!==_0x3bc203(0x9d)||typeof _0x4bb62b!==_0x3bc203(0x9d))return![];if(_0x2a19f2[_0x3bc203(0xb7)](_0x576185)||_0x1d7d26[_0x3bc203(0xb7)](_0x4bb62b))return![];_0x2a19f2['add'](_0x576185),_0x1d7d26[_0x3bc203(0xa9)](_0x4bb62b);try{if(Array[_0x3bc203(0xb2)](_0x576185)||Array[_0x3bc203(0xb2)](_0x4bb62b)){if(!Array[_0x3bc203(0xb2)](_0x576185)||!Array['isArray'](_0x4bb62b))return![];if(_0x576185['length']!==_0x4bb62b[_0x3bc203(0x8f)])return![];if(Reflect['ownKeys'](_0x576185)[_0x3bc203(0x8f)]!==_0x576185[_0x3bc203(0x8f)]+0x1)return![];if(Reflect['ownKeys'](_0x4bb62b)[_0x3bc203(0x8f)]!==_0x4bb62b[_0x3bc203(0x8f)]+0x1)return![];for(let _0x5a08bd=0x0;_0x5a08bd<_0x576185['length'];_0x5a08bd+=0x1){if(!hasOwn(_0x576185,String(_0x5a08bd)))return![];if(!hasOwn(_0x4bb62b,String(_0x5a08bd)))return![];if(!jsonValuesEqual(_0x576185[_0x5a08bd],_0x4bb62b[_0x5a08bd],_0x2a19f2,_0x1d7d26))return![];}return!![];}if(!isPlainJsonObject(_0x576185)||!isPlainJsonObject(_0x4bb62b))return![];const _0x5adc9b=Object[_0x3bc203(0xb0)](_0x576185),_0x30db77=Object['keys'](_0x4bb62b);if(Reflect[_0x3bc203(0xba)](_0x576185)[_0x3bc203(0x8f)]!==_0x5adc9b[_0x3bc203(0x8f)])return![];if(Reflect[_0x3bc203(0xba)](_0x4bb62b)['length']!==_0x30db77[_0x3bc203(0x8f)])return![];if(_0x5adc9b['length']!==_0x30db77['length'])return![];return _0x5adc9b['every'](_0x39ee6=>hasOwn(_0x4bb62b,_0x39ee6)&&jsonValuesEqual(_0x576185[_0x39ee6],_0x4bb62b[_0x39ee6],_0x2a19f2,_0x1d7d26));}finally{_0x2a19f2[_0x3bc203(0x8b)](_0x576185),_0x1d7d26[_0x3bc203(0x8b)](_0x4bb62b);}}function getNormalizedSurfaceId(_0x460b23,_0x57ad37,_0x47e419){const _0x708937=_0x2b5726;if(typeof _0x460b23['uiJson']!=='string'||!Array[_0x708937(0xb2)](_0x460b23['uiMessages']))throw new Error('UI\x20normalizer\x20must\x20return\x20uiJson\x20and\x20uiMessages.');let _0x107106;try{_0x107106=JSON['parse'](_0x460b23[_0x708937(0xb4)]);}catch{throw new Error('UI\x20normalizer\x20uiJson\x20must\x20contain\x20valid\x20JSON.');}if(!jsonValuesEqual(_0x107106,_0x460b23[_0x708937(0xb6)]))throw new Error('UI\x20normalizer\x20uiJson\x20and\x20uiMessages\x20must\x20represent\x20the\x20same\x20JSON\x20value.');if(!Array['isArray'](_0x107106)||!isJsonObject(_0x107106[0x0]))throw new Error('UI\x20normalizer\x20result\x20must\x20begin\x20with\x20createSurface.');const _0x231b20=_0x107106[0x0]['createSurface'];if(!isJsonObject(_0x231b20)||typeof _0x231b20['surfaceId']!==_0x708937(0x7a))throw new Error('UI\x20normalizer\x20result\x20must\x20begin\x20with\x20createSurface.');return getCarrierValidator(_0x47e419['catalog'])({'messages':_0x107106,..._0x57ad37===void 0x0?{}:{'surfaceId':_0x57ad37}}),_0x231b20['surfaceId'];}function getA2UIClientCapability(_0x92b114,_0x3c5e27){const _0x4f4772=_0x2b5726;if(isJsonObject(_0x3c5e27)&&hasOwn(_0x3c5e27,_0x4f4772(0x6e)))return _0x3c5e27['a2ui'];const _0x3c70dc=_0x92b114['server']['getClientCapabilities']();if(!isJsonObject(_0x3c70dc))return void 0x0;if(hasOwn(_0x3c70dc,_0x4f4772(0x6e)))return _0x3c70dc['a2ui'];const _0x51014e=_0x3c70dc['extensions'];return isJsonObject(_0x51014e)&&hasOwn(_0x51014e,A2UI_MCP_CAPABILITY_EXTENSION_ID)?_0x51014e[A2UI_MCP_CAPABILITY_EXTENSION_ID]:void 0x0;}function validateA2UIClientCapability(_0x293f7a,_0x5e8e44){const _0x44b927=_0x2b5726;if(!isJsonObject(_0x293f7a))return'Client\x20must\x20declare\x20A2UI\x20'+A2UI_MCP_CAPABILITY_FAMILY+'\x20capability-family\x20support\x20for\x20Catalog\x20\x22'+_0x5e8e44+'\x22.';const _0x403e78=_0x293f7a['clientCapabilities'];if(!isJsonObject(_0x403e78))return'Client\x20A2UI\x20capabilities\x20are\x20malformed:\x20clientCapabilities\x20is\x20required.';const _0x330a5f=_0x403e78[A2UI_MCP_CAPABILITY_FAMILY];if(!isJsonObject(_0x330a5f)||!Array['isArray'](_0x330a5f['supportedCatalogIds']))return _0x44b927(0x94)+A2UI_MCP_CAPABILITY_FAMILY+'\x22].supportedCatalogIds\x20must\x20be\x20an\x20array.';if(!_0x330a5f['supportedCatalogIds'][_0x44b927(0x84)](_0x38c2c6=>typeof _0x38c2c6==='string'))return'Client\x20A2UI\x20capabilities\x20are\x20malformed:\x20supportedCatalogIds\x20must\x20contain\x20only\x20strings.';if(!_0x330a5f[_0x44b927(0xa4)]['includes'](_0x5e8e44))return'Client\x20does\x20not\x20support\x20required\x20A2UI\x20Catalog\x20\x22'+_0x5e8e44+_0x44b927(0xa3)+A2UI_MCP_CAPABILITY_FAMILY+'\x20capability\x20family).';return void 0x0;}function toToolError(_0x1e048b){return{'isError':!![],'content':[{'type':'text','text':_0x1e048b}]};}function toToolResult(_0x49b382,_0x5535b3,_0x22bce0){const _0x7c0fab=_0x2b5726,_0x53c1a1=getNormalizedSurfaceId(_0x49b382,_0x5535b3,_0x22bce0),_0x370927={'type':'resource','resource':{'uri':'a2ui://surface/'+encodeURIComponent(_0x53c1a1),'mimeType':A2UI_MESSAGE_MEDIA_TYPE,'text':_0x49b382['uiJson']}};return{'content':[{'type':_0x7c0fab(0xbc),'text':_0x7c0fab(0xa2)},_0x370927]};}function toCatalogToolResult(_0xf91d1b){const _0x1dbded=_0x2b5726;return{'content':[{'type':_0x1dbded(0xbc),'text':JSON[_0x1dbded(0x88)](_0xf91d1b)}],'structuredContent':_0xf91d1b};}async function createUIToolCallResult(_0x1c93a5,_0x2a9805=defaultNormalize,_0x2eaaa2={}){const _0x33d291=_0x2b5726;try{const _0x440d00=_0x1c93a5[_0x33d291(0x6f)],_0x1e3db7=await _0x2a9805(_0x1c93a5);return toToolResult(_0x1e3db7,_0x440d00,_0x2eaaa2);}catch(_0x556309){const _0x5c8b23=_0x556309 instanceof Error?_0x556309['message']:String(_0x556309);return toToolError(_0x5c8b23);}}function toMCPResourceResult(_0x22875b){return _0x22875b;}function registerUICatalogResources(_0x254f66,_0x44a8db){const _0xe4990e=_0x2b5726,_0x2f843c=_0x254f66[_0xe4990e(0x78)](_0xe4990e(0xa8),CATALOG_RESOURCE_URI,{'title':'A2UI\x20Catalog\x20'+_0x44a8db['descriptor']['id'],'description':_0xe4990e(0xb8),'mimeType':'application/json'},_0x464bf2=>toMCPResourceResult(createUICatalogResourcePayload(_0x44a8db,_0x464bf2[_0xe4990e(0x8c)])));return{'catalog':_0x2f843c};}function registerUICatalogTools(_0xc828a,_0x200e67){const _0x561d46=_0x2b5726,_0x54a9cf=_0xc828a['registerTool'](GET_UI_CATALOG_TOOL_NAME,{'title':_0x561d46(0xb5),'description':['Step\x201\x20of\x20the\x20A2UI\x20MCP\x20workflow.\x20Call\x20this\x20before\x20'+UI_TOOL_NAME+'.',UI_TOOL_WORKFLOW_ORDER,'With\x20no\x20componentNames\x20it\x20returns\x20the\x20catalog\x20directory:\x20the\x20catalog\x20id\x20and\x20every\x20component\x20name\x20with\x20one\x20line\x20saying\x20what\x20it\x20is\x20for.\x20Choose\x20all\x20components\x20the\x20UI\x20needs,\x20then\x20call\x20again\x20with\x20those\x20componentNames.',_0x561d46(0xac),'Basic\x20component\x20and\x20requested\x20function\x20definitions\x20are\x20JSON\x20Schemas\x20whose\x20references\x20resolve\x20from\x20the\x20whole\x20catalog.definitions\x20object,\x20including\x20its\x20shared\x20$defs.\x20Custom\x20component\x20schemas\x20retain\x20their\x20own\x20document\x20scope.']['join']('\x0a\x0a'),'inputSchema':createGetCatalogInputSchema(),'outputSchema':getCatalogOutputSchema,'annotations':{'readOnlyHint':!![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':![]}},async _0x522544=>{const _0x1ac83a=_0x561d46;try{return toCatalogToolResult(getUICatalog(_0x200e67,{'componentNames':_0x522544[_0x1ac83a(0x7e)],'functionNames':_0x522544[_0x1ac83a(0x98)]}));}catch(_0x1acf0d){const _0x7c2f1=_0x1acf0d instanceof Error?_0x1acf0d[_0x1ac83a(0xa6)]:String(_0x1acf0d);return toToolError(_0x7c2f1);}});return{'get':_0x54a9cf};}function resolveSchemaDelivery(_0xc65fd5='discovery'){const _0x525ee5=_0x2b5726;if(_0xc65fd5==='discovery'||_0xc65fd5===_0x525ee5(0x89))return _0xc65fd5;throw new Error(_0x525ee5(0x87)+String(_0xc65fd5)+'\x22.\x20Expected\x20\x22discovery\x22\x20or\x20\x22inline\x22.');}function registerGenericUITool(_0x334a18,_0x33a169,_0x2bb0bd={}){const _0x3c4b94=_0x2b5726,_0x24d76c=resolveSchemaDelivery(_0x2bb0bd['schemaDelivery']),_0x1cf148=_0x24d76c==='inline'?createUISendToolSpec(_0x33a169):void 0x0,_0x4e029a=_0x2bb0bd[_0x3c4b94(0x77)]??createUISendNormalizer({'catalog':_0x33a169}),_0xe8c95=_0x1cf148?z[_0x3c4b94(0x9d)]({'surfaceId':z['string']()[_0x3c4b94(0x7c)](),'messages':z[_0x3c4b94(0x79)]()})['meta'](_0x1cf148['parameters']):z['object'](createSendUIInputSchema(_0x33a169['protocolVersion']??A2UI_DEFAULT_PROTOCOL_VERSION));return _0x334a18[_0x3c4b94(0x97)](UI_TOOL_NAME,{'title':_0x2bb0bd[_0x3c4b94(0x81)],'description':_0x1cf148?.['description']??createGenericToolDescription(_0x33a169),'inputSchema':_0xe8c95,'annotations':{'readOnlyHint':![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':![],..._0x2bb0bd[_0x3c4b94(0x9a)]}},async(_0x16b0ca,_0x1623bf)=>{const _0x370fab=_0x3c4b94,_0x4fb2bc=validateA2UIClientCapability(getA2UIClientCapability(_0x334a18,_0x1623bf['_meta']),_0x33a169[_0x370fab(0xbe)]['id']);if(_0x4fb2bc)return toToolError(_0x4fb2bc);return createUIToolCallResult(_0x16b0ca,_0x4e029a,{'catalog':_0x33a169});});}function _0x2831(_0x352309,_0x4ed600){_0x352309=_0x352309-0x6e;const _0x3d323f=_0x3d32();let _0x2831fc=_0x3d323f[_0x352309];return _0x2831fc;}function createUIMCPServer(_0x197c65={}){const _0x3928a7=_0x2b5726,_0x3de60d=resolveSchemaDelivery(_0x197c65['schemaDelivery']),_0xc2b042=createUIToolCatalog(_0x197c65['catalog'],_0x197c65['protocolVersion']),_0x104d53=new McpServer({'name':_0x197c65['server']?.['name']??_0x3928a7(0x85),'version':_0x197c65['server']?.['version']??'0.0.0'});registerUICatalogResources(_0x104d53,_0xc2b042);if(_0x3de60d===_0x3928a7(0x7d))registerUICatalogTools(_0x104d53,_0xc2b042);return registerGenericUITool(_0x104d53,_0xc2b042,{..._0x197c65,'schemaDelivery':_0x3de60d}),_0x104d53;}export{_0x35f72c as McpServer,createUIMCPNormalize,createUIMCPServer,createUIToolCallResult,registerGenericUITool,registerUICatalogResources,registerUICatalogTools};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentic-ui-experience/ui-mcp",
3
- "version": "0.0.1-beta.4",
3
+ "version": "0.0.1-beta.6",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,6 +11,10 @@
11
11
  ".": {
12
12
  "types": "./dist/index.d.ts",
13
13
  "default": "./dist/index.js"
14
+ },
15
+ "./client": {
16
+ "types": "./dist/client.d.ts",
17
+ "default": "./dist/client.js"
14
18
  }
15
19
  },
16
20
  "files": [
@@ -18,12 +22,12 @@
18
22
  ],
19
23
  "publishConfig": {
20
24
  "access": "public",
21
- "tag": "beta"
25
+ "tag": "latest"
22
26
  },
23
27
  "dependencies": {
24
28
  "@modelcontextprotocol/sdk": "^1.29.0",
25
29
  "zod": "^4.4.3",
26
- "@agentic-ui-experience/ui-core": "0.0.1-beta.4"
30
+ "@agentic-ui-experience/ui-core": "0.0.1-beta.6"
27
31
  },
28
32
  "devDependencies": {
29
33
  "@types/node": "^24.10.1"