@agentic-ui-experience/ui-mcp 0.0.1-beta.3 → 0.0.1-beta.5

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
@@ -2,31 +2,159 @@
2
2
 
3
3
  Generic MCP server adapter for A2UI.
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 Catalog discovery tools
6
+ and a `send_ui_to_client` MCP tool that returns validated A2UI messages as a
7
+ canonical MCP `EmbeddedResource`. The Host extracts that resource and forwards
8
+ its messages to `@agentic-ui-experience/ui-runtime`.
9
+
10
+ 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).
8
11
 
9
12
  `@agentic-ui-experience/ui-mcp` is an MCP adapter over
10
- `@agentic-ui-experience/ui-core/tool-mode`. Catalog registry, catalog resource
13
+ `@agentic-ui-experience/ui-core/tool-mode`. Catalog configuration, catalog resource
11
14
  payloads, catalog filtering, and `send_ui_to_client` normalization live in
12
15
  `ui-core`; this package only maps those provider-neutral operations onto MCP
13
16
  resources and tools.
14
17
 
15
- The A2UI basic catalog is built in. Scenario-specific catalogs are registered
16
- when the MCP server is created, then discovered through tools or resources.
18
+ Generated tool and Catalog instructions require A2UI `v0.9.1`, and incoming
19
+ messages accept only `v0.9.1`; legacy `v0.9` wire messages are rejected. This
20
+ wire version negotiates through the official A2UI `"v0.9"` capability family;
21
+ the family key is not a second accepted message version. Dynamic A2UI tool
22
+ results use only the canonical `application/a2ui+json` media type; the client
23
+ helper deliberately does not recognize the legacy `application/json+a2ui`
24
+ media type.
25
+
26
+ A server serves exactly one catalog. A2UI fixes a surface's catalog at
27
+ `createSurface` time and never composes two catalogs into one component tree, and
28
+ the upstream agent SDK selects a single catalog before it prompts the model, so
29
+ the catalog is a server configuration rather than a model choice. To serve more
30
+ than one vocabulary, merge them when you define the catalog. Omit `catalog` to
31
+ serve this repository's Basic Catalog compatibility unit. Its ID, Core schema,
32
+ and installed Renderer vocabulary move together; this package does not claim
33
+ that local unit is interchangeable with a newer upstream Catalog that happens
34
+ to have a different identity.
17
35
 
18
36
  ```ts
19
37
  import { createUIMCPServer } from "@agentic-ui-experience/ui-mcp";
20
38
 
21
39
  const server = createUIMCPServer({
22
- catalogs: [weatherPromptDescriptor],
23
- defaultCatalogId: "com.agentic-ui-experience.examples.weather.v1",
40
+ catalog: weatherPromptDescriptor,
24
41
  catalogInstructionMode: "compact"
25
42
  });
26
43
 
27
44
  await server.connect(transport);
28
45
  ```
29
46
 
47
+ ## A2UI over MCP contract
48
+
49
+ A successful `send_ui_to_client` call always returns fallback text followed by
50
+ one canonical A2UI embedded resource:
51
+
52
+ ```ts
53
+ {
54
+ content: [
55
+ {
56
+ type: "text",
57
+ text: "Generated an interactive A2UI interface."
58
+ },
59
+ {
60
+ type: "resource",
61
+ resource: {
62
+ uri: "a2ui://surface/main",
63
+ mimeType: "application/a2ui+json",
64
+ text: "[{\"version\":\"v0.9.1\",...}]"
65
+ }
66
+ }
67
+ ]
68
+ }
69
+ ```
70
+
71
+ The send tool has no output schema and successful calls do not duplicate the
72
+ payload in `structuredContent`. A failed call contains `isError: true` and text
73
+ only, never a resource. The emitted `a2ui://surface/<encoded-surface-id>` URI is
74
+ a stable provider identifier for the embedded payload; it is not a registered
75
+ readable resource and clients must not treat that path shape as a protocol
76
+ requirement.
77
+
78
+ A custom normalizer must return JSON-semantically equivalent `uiJson` and
79
+ `uiMessages` values. The server verifies this invariant, then strictly validates
80
+ the parsed carrier against its configured Catalog and the call's optional
81
+ `surfaceId`, before it uses the original `uiJson` as resource text or derives the
82
+ resource URI. Whitespace and object-key order may differ; malformed, divergent,
83
+ or protocol-invalid representations become tool errors.
84
+
85
+ ### Catalog capability negotiation
86
+
87
+ Before accepting UI, the server requires the client to advertise the exact
88
+ configured Catalog ID at:
89
+
90
+ ```ts
91
+ {
92
+ clientCapabilities: {
93
+ "v0.9": {
94
+ supportedCatalogIds: [catalogId]
95
+ }
96
+ }
97
+ }
98
+ ```
99
+
100
+ Use the browser-safe `@agentic-ui-experience/ui-mcp/client` entry point to build
101
+ the declaration:
102
+
103
+ ```ts
104
+ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
105
+ import {
106
+ createA2UIClientCapabilities
107
+ } from "@agentic-ui-experience/ui-mcp/client";
108
+
109
+ const capabilities = createA2UIClientCapabilities([catalogId]);
110
+ const client = new Client(
111
+ { name: "my-a2ui-host", version: "1.0.0" },
112
+ { capabilities }
113
+ );
114
+ ```
115
+
116
+ The builder includes the official initialize-time `capabilities.a2ui` shape and
117
+ an `extensions["a2ui/client-capabilities"]` mirror for MCP SDK versions that
118
+ strip unknown top-level Client capabilities. A stateful server prefers the
119
+ official field when available and then checks this bridge.
120
+
121
+ A stateless client must repeat the declaration on every UI tool call because no
122
+ initialize state survives between requests:
123
+
124
+ ```ts
125
+ await client.callTool({
126
+ name: "send_ui_to_client",
127
+ arguments: { messages },
128
+ _meta: { a2ui: capabilities.a2ui }
129
+ });
130
+ ```
131
+
132
+ Request-local `_meta.a2ui` takes precedence over initialized state. If it is
133
+ present but malformed or does not list the server's exact Catalog ID, the call
134
+ fails without running normalization.
135
+
136
+ ### Browser-safe result extraction
137
+
138
+ The same client entry point strictly extracts canonical A2UI resources without
139
+ importing MCP server or Node-only code:
140
+
141
+ ```ts
142
+ import {
143
+ extractUIMCPToolResult
144
+ } from "@agentic-ui-experience/ui-mcp/client";
145
+
146
+ const extracted = extractUIMCPToolResult(toolResult);
147
+ if (extracted) {
148
+ runtime.ingest(extracted.uiMessages);
149
+ }
150
+ ```
151
+
152
+ The extractor accepts any valid absolute provider URI, including
153
+ `a2ui://recipe-card` and `a2ui://surface/main`. It validates the embedded JSON,
154
+ protocol messages, and Catalog. Tool errors and malformed or ambiguous canonical
155
+ resources throw; an ordinary non-A2UI result returns `undefined`. It does not
156
+ fall back to old `structuredContent`, legacy MIME, or binary resource blobs.
157
+
30
158
  ## CLI
31
159
 
32
160
  `@agentic-ui-experience/ui-mcp` also ships a small MCP server CLI:
@@ -67,6 +195,8 @@ pnpm --filter @agentic-ui-experience/ui-mcp inspector
67
195
  The HTTP server is stateless: each MCP request gets a fresh MCP server and
68
196
  `StreamableHTTPServerTransport`. This matches the SDK's stateless Streamable
69
197
  HTTP mode and avoids storing session state inside `@agentic-ui-experience/ui-mcp`.
198
+ Consequently every `send_ui_to_client` request must include `_meta.a2ui`; an
199
+ initialize declaration alone cannot authorize a later request on this server.
70
200
 
71
201
  CORS is closed by default. To expose the HTTP endpoint to browser clients, pass
72
202
  one or more explicit origins:
@@ -87,26 +217,26 @@ The local-development wildcard CORS shortcut is:
87
217
  pnpm --filter @agentic-ui-experience/ui-mcp start:http:cors
88
218
  ```
89
219
 
90
- Custom catalogs can be loaded from ESM modules:
220
+ A custom catalog can be loaded from an ESM module:
91
221
 
92
222
  ```bash
93
223
  ax-ui-mcp \
94
224
  --transport http \
95
225
  --catalog ./weather-catalog.js \
96
- --default-catalog-id com.agentic-ui-experience.examples.weather.v1 \
97
226
  --catalog-instruction-mode compact
98
227
  ```
99
228
 
229
+ The CLI generates `v0.9.1` instructions and accepts only
230
+ `--protocol-version v0.9.1`. Passing legacy `v0.9` is an error.
231
+
100
232
  With the package scripts, append extra CLI flags after `--`:
101
233
 
102
234
  ```bash
103
235
  pnpm --filter @agentic-ui-experience/ui-mcp start:http -- \
104
- --catalog ./weather-catalog.js \
105
- --default-catalog-id com.agentic-ui-experience.examples.weather.v1
236
+ --catalog ./weather-catalog.js
106
237
  ```
107
238
 
108
- The catalog module may export a descriptor directly, a `catalog`, a `catalogs`
109
- array, and optionally `defaultCatalogId`:
239
+ The catalog module may export a descriptor directly or as `catalog`:
110
240
 
111
241
  ```ts
112
242
  export const catalog = {
@@ -114,40 +244,71 @@ export const catalog = {
114
244
  baseComponentNames: ["Card", "Text"],
115
245
  customComponents: []
116
246
  };
117
-
118
- export const defaultCatalogId = "example/weather/v1";
119
247
  ```
120
248
 
121
249
  The normal agent flow is:
122
250
 
123
251
  ```ts
124
- // Step 1: discover the server default catalog and available component names.
125
- list_ui_catalogs();
126
-
127
- // Step 2: fetch the catalog instructions and schemas for the components needed
128
- // by this UI. Use instructionMode: "full" when exact fields are needed.
252
+ // Step 1a: discover what the catalog has. With no componentNames the server
253
+ // returns the directory — every component name with one line on what it is for
254
+ // — and no schemas, so discovery costs a listing rather than the catalog.
255
+ get_ui_catalog();
256
+
257
+ // Step 1b: fetch instructions and schemas for the components this UI needs.
258
+ // Use instructionMode: "full" when exact fields are needed.
259
+ // Name a function in functionNames only when the UI actually calls it.
129
260
  get_ui_catalog({
130
- catalogId: "com.agentic-ui-experience.examples.weather.v1",
131
261
  componentNames: ["Card", "Text", "WeatherIcon"],
262
+ functionNames: ["formatDate"],
132
263
  instructionMode: "full"
133
264
  });
134
265
 
135
- // Step 3: submit messages built from the catalog returned by get_ui_catalog.
266
+ // Step 2: submit messages built from the catalog returned by get_ui_catalog.
136
267
  send_ui_to_client({
137
- // Top-level catalogId is an expected-value guard for the MCP server.
138
- // The createSurface message must still repeat the same catalogId.
139
- catalogId: "com.agentic-ui-experience.examples.weather.v1",
140
268
  surfaceId: "main",
141
269
  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" }] } }
270
+ { version: "v0.9.1", createSurface: { surfaceId: "main", catalogId: "com.agentic-ui-experience.examples.weather.v1" } },
271
+ { version: "v0.9.1", updateComponents: { surfaceId: "main", components: [{ id: "root", component: "Text", text: "Current weather" }] } }
144
272
  ]
145
273
  });
146
274
  ```
147
275
 
148
- Omit `componentNames` to fetch the complete catalog. When supplied, the server
149
- returns only the requested basic component schema and registered custom
150
- component schemas; use `list_ui_catalogs` first to inspect available names.
276
+ The MCP client, not the model-visible arguments above, supplies the negotiated
277
+ A2UI capability through initialize state or request `_meta`.
278
+
279
+ Neither tool takes a `catalogId`. The server pins the catalog, so there is
280
+ nothing for the model to choose; `createSurface.catalogId` is validated against
281
+ the configured catalog. Once the Host forwards these messages to its Runtime, a
282
+ `surfaceId` must be unique among active surfaces: a duplicate active
283
+ `createSurface` is an error, while an ID may be reused after `deleteSurface`.
284
+
285
+ `componentNames` is what narrows the response: supply it and the server returns
286
+ only those basic and custom component schemas.
287
+
288
+ Function schemas are opt-in and are *not* covered by `componentNames`. Components
289
+ never reference functions through `$ref`, so no component selection can narrow
290
+ them — they have to be named. The instructions always list every function with
291
+ its arguments, so an agent can see what exists and then request only the schemas
292
+ it needs via `functionNames`. Omit `functionNames` when the UI calls no
293
+ functions. This works in both instruction modes, and with or without
294
+ `componentNames`: an explicitly requested function schema is returned even in
295
+ `"compact"` (which otherwise emits no schemas at all) and even on a directory
296
+ call.
297
+
298
+ The returned `descriptor` carries component schemas only. The catalog's
299
+ `styleGuide` and `examples` are prose that `instructions` already renders, so
300
+ repeating them in `descriptor` would have doubled every response; the
301
+ `a2ui://catalog` resource still carries the descriptor whole.
302
+
303
+ `get_ui_catalog` returns `componentPurposes` on every call — a
304
+ `componentName -> what it is for` map covering base and custom components
305
+ together, regardless of what the call requested. Component names alone do not say
306
+ when to reach for `Tabs` over `List`, or `Card` over `Column`, and field rules
307
+ only help once the component is already chosen. Keeping the whole directory in
308
+ view also means an agent that under-selected can see what it missed and widen
309
+ with a second call, instead of quietly building something worse out of the
310
+ components it already has. For custom components the prose is the descriptor's
311
+ `description`.
151
312
 
152
313
  `get_ui_catalog` returns compact instructions by default. Pass
153
314
  `instructionMode: "full"` when the agent needs the authoritative JSON schema in
@@ -160,16 +321,15 @@ serialize the message list into a JSON string, and do not pass static catalog
160
321
  schema such as `customComponents` in the tool call.
161
322
 
162
323
  `send_ui_to_client` is the final submission tool, not the schema discovery
163
- tool. Agents should call `list_ui_catalogs` and `get_ui_catalog` before using
164
- it, then build component objects from the returned catalog schema.
165
-
166
- The top-level `catalogId` is not copied into the A2UI payload. Always include
167
- the same value in the first message at `createSurface.catalogId`; the MCP server
168
- validates that the two values match.
324
+ tool. Agents should call `get_ui_catalog` before using it, then build component
325
+ objects from the returned catalog schema.
169
326
 
170
- Catalogs are also exposed as MCP resources:
327
+ The catalog is also exposed as an MCP resource with media type
328
+ `application/json`. This remains JSON catalog metadata, not an A2UI message, so
329
+ the A2UI message media types do not apply. Resources are read by hosts and
330
+ clients rather than picked from by a model, so this payload carries every
331
+ component and function:
171
332
 
172
333
  ```text
173
- a2ui://catalog/basic
174
- a2ui://catalog/{catalogId}
334
+ a2ui://catalog
175
335
  ```
package/dist/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- const _0x448f3b=_0x736e;(function(_0x548320,_0x26b48e){const _0x4dff72=_0x736e,_0x445ba0=_0x548320();while(!![]){try{const _0x1e99a5=parseInt(_0x4dff72(0xa0))/0x1*(-parseInt(_0x4dff72(0xad))/0x2)+-parseInt(_0x4dff72(0xc3))/0x3*(-parseInt(_0x4dff72(0xbe))/0x4)+parseInt(_0x4dff72(0x8b))/0x5+parseInt(_0x4dff72(0x99))/0x6*(parseInt(_0x4dff72(0xb7))/0x7)+parseInt(_0x4dff72(0xc4))/0x8+parseInt(_0x4dff72(0xc2))/0x9+-parseInt(_0x4dff72(0xac))/0xa;if(_0x1e99a5===_0x26b48e)break;else _0x445ba0['push'](_0x445ba0['shift']());}catch(_0x1534a1){_0x445ba0['push'](_0x445ba0['shift']());}}}(_0x4e82,0x5936e));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=_0x448f3b(0xb9);function stringValue(_0x5b2be7,_0xb5511d){const _0xb595f0=_0x448f3b;return typeof _0x5b2be7===_0xb595f0(0x8c)&&_0x5b2be7[_0xb595f0(0x90)]>0x0?_0x5b2be7:_0xb5511d;}function optionalStringValue(_0x401556){const _0x1d295f=_0x448f3b;return typeof _0x401556==='string'&&_0x401556[_0x1d295f(0x90)]>0x0?_0x401556:void 0x0;}function stringArrayValue(_0x359ec1){const _0x11fd29=_0x448f3b;if(Array['isArray'](_0x359ec1))return _0x359ec1;if(typeof _0x359ec1===_0x11fd29(0x8c)&&_0x359ec1[_0x11fd29(0x90)]>0x0)return[_0x359ec1];return[];}function parseTransport(_0x52f906){const _0x38b60c=_0x448f3b;if(_0x52f906==='stdio'||_0x52f906===_0x38b60c(0x9e))return _0x52f906;throw new Error('Unsupported\x20transport\x20\x22'+_0x52f906+_0x38b60c(0xc8));}function _0x4e82(){const _0x367a74=['Internal\x20MCP\x20server\x20error','setHeader','\x22.\x20Expected\x20an\x20integer\x20from\x201\x20to\x2065535.','port','OPTIONS','catalog-instruction-mode','123137ezsUId','Origin','@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\x20a\x20CatalogPromptDescriptor\x20or\x20array.\x20Repeatable.\x0a\x20\x20--default-catalog-id\x20<id>\x20\x20\x20\x20\x20Default\x20catalog\x20id.\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\x0aCatalog\x20modules\x20may\x20export\x20one\x20of:\x0a\x20\x20export\x20default\x20descriptor\x0a\x20\x20export\x20const\x20catalog\x20=\x20descriptor\x0a\x20\x20export\x20const\x20catalogs\x20=\x20[descriptor]\x0a\x20\x20export\x20const\x20defaultCatalogId\x20=\x20\x22...\x22\x0a','statusCode','help','serverVersion','serverName','376CFfCed','catalogs','\x22.\x20Expected\x20\x22compact\x22\x20or\x20\x22full\x22.','catalog','6220197KlMazO','20337ULIvXG','4470600nYmYKs','connect','compact','boolean','\x22.\x20Expected\x20\x22stdio\x22\x20or\x20\x22http\x22.','stdout','stdio','object','SIGTERM','baseComponentNames','method','defaultCatalogId','host','catch','localhost','3082355MSYqgv','string','once','message','Invalid\x20--port\x20\x22','length','Access-Control-Expose-Headers','Unsupported\x20catalog\x20instruction\x20mode\x20\x22','[@agentic-ui-experience/ui-mcp]\x20request\x20failed','origin','endpoint','stringify','headers','\x22\x20exported\x20an\x20invalid\x20catalog\x20descriptor.','222UZJvRt','href','transport','GET,POST,DELETE,OPTIONS','error','http','Content-Type,\x20Accept,\x20Authorization,\x20MCP-Protocol-Version,\x20Mcp-Session-Id,\x20Last-Event-ID','11zyxOWy','content-type','version','end','name','Not\x20Found','default','values','close','3001','includes','headersSent','23531590bxInDb','79262McRtAL','isArray','@agentic-ui-experience/ui-mcp\x20listening\x20on\x20http://','corsOrigins'];_0x4e82=function(){return _0x367a74;};return _0x4e82();}function parseCatalogInstructionMode(_0x47cf15){const _0x29d021=_0x448f3b;if(_0x47cf15==='compact'||_0x47cf15==='full')return _0x47cf15;throw new Error(_0x29d021(0x92)+_0x47cf15+_0x29d021(0xc0));}function parsePort(_0x2b4e8d){const _0x35f978=_0x448f3b,_0x4339a2=Number(_0x2b4e8d);if(!Number['isInteger'](_0x4339a2)||_0x4339a2<0x1||_0x4339a2>0xffff)throw new Error(_0x35f978(0x8f)+_0x2b4e8d+_0x35f978(0xb3));return _0x4339a2;}function _0x736e(_0x4cc1c0,_0x3c5a73){_0x4cc1c0=_0x4cc1c0-0x87;const _0x4e828a=_0x4e82();let _0x736e54=_0x4e828a[_0x4cc1c0];return _0x736e54;}function normalizeEndpoint(_0xc022f2){if(!_0xc022f2['startsWith']('/'))return'/'+_0xc022f2;return _0xc022f2;}function isCatalogDescriptor(_0x415437){const _0x30f057=_0x448f3b;return!!_0x415437&&typeof _0x415437===_0x30f057(0xcb)&&!Array['isArray'](_0x415437)&&typeof _0x415437['id']==='string'&&Array[_0x30f057(0xae)](_0x415437[_0x30f057(0xcd)]);}function readCatalogExports(_0x202a50,_0x12e0de){const _0x40cecf=_0x448f3b,_0x288d57=_0x202a50[_0x40cecf(0xbf)]??_0x202a50[_0x40cecf(0xc1)]??_0x202a50[_0x40cecf(0xa6)],_0x59953f=[];if(Array['isArray'](_0x288d57))for(const _0x1141ce of _0x288d57){if(!isCatalogDescriptor(_0x1141ce))throw new Error('Catalog\x20module\x20\x22'+_0x12e0de+_0x40cecf(0x98));_0x59953f['push'](_0x1141ce);}else{if(_0x288d57!==void 0x0){if(!isCatalogDescriptor(_0x288d57))throw new Error('Catalog\x20module\x20\x22'+_0x12e0de+_0x40cecf(0x98));_0x59953f['push'](_0x288d57);}}if(_0x59953f['length']===0x0)throw new Error('Catalog\x20module\x20\x22'+_0x12e0de+'\x22\x20did\x20not\x20export\x20a\x20catalog\x20descriptor.');const _0x3203af=typeof _0x202a50['defaultCatalogId']==='string'&&_0x202a50[_0x40cecf(0x87)][_0x40cecf(0x90)]>0x0?_0x202a50[_0x40cecf(0x87)]:void 0x0;return{'catalogs':_0x59953f,'defaultCatalogId':_0x3203af};}async function loadCatalogs(_0x3be76f){const _0x440621=_0x448f3b,_0x8d659d=[];let _0x27a098;for(const _0x5886e7 of _0x3be76f){const _0x43610e=await import(pathToFileURL(resolve(_0x5886e7))[_0x440621(0x9a)]),_0x94ccc4=readCatalogExports(_0x43610e,_0x5886e7);_0x8d659d['push'](..._0x94ccc4[_0x440621(0xbf)]),_0x27a098??(_0x27a098=_0x94ccc4[_0x440621(0x87)]);}return{'catalogs':_0x8d659d,'defaultCatalogId':_0x27a098};}async function parseCliOptions(){const _0x45dd94=_0x448f3b,_0x51d7c8=parseArgs({'allowPositionals':![],'options':{'transport':{'type':_0x45dd94(0x8c)},'host':{'type':'string'},'port':{'type':'string'},'endpoint':{'type':_0x45dd94(0x8c)},'cors-origin':{'type':'string','multiple':!![]},'catalog':{'type':_0x45dd94(0x8c),'multiple':!![]},'default-catalog-id':{'type':_0x45dd94(0x8c)},'catalog-instruction-mode':{'type':_0x45dd94(0x8c)},'name':{'type':'string'},'version':{'type':_0x45dd94(0x8c)},'help':{'type':_0x45dd94(0xc7),'short':'h'}}});_0x51d7c8['values'][_0x45dd94(0xbb)]&&(process[_0x45dd94(0xc9)]['write'](helpText),process['exit'](0x0));const _0x56746a=await loadCatalogs(stringArrayValue(_0x51d7c8['values'][_0x45dd94(0xc1)])),_0x2f1021=optionalStringValue(_0x51d7c8[_0x45dd94(0xa7)]['default-catalog-id'])??_0x56746a['defaultCatalogId'];return{'transport':parseTransport(stringValue(_0x51d7c8[_0x45dd94(0xa7)][_0x45dd94(0x9b)],_0x45dd94(0xca))),'host':stringValue(_0x51d7c8[_0x45dd94(0xa7)][_0x45dd94(0x88)],'127.0.0.1'),'port':parsePort(stringValue(_0x51d7c8[_0x45dd94(0xa7)][_0x45dd94(0xb4)],_0x45dd94(0xa9))),'endpoint':normalizeEndpoint(stringValue(_0x51d7c8['values'][_0x45dd94(0x95)],'/mcp')),'corsOrigins':stringArrayValue(_0x51d7c8['values']['cors-origin']),'catalogs':_0x56746a[_0x45dd94(0xbf)],..._0x2f1021?{'defaultCatalogId':_0x2f1021}:{},'catalogInstructionMode':parseCatalogInstructionMode(stringValue(_0x51d7c8[_0x45dd94(0xa7)][_0x45dd94(0xb6)],_0x45dd94(0xc6))),...optionalStringValue(_0x51d7c8[_0x45dd94(0xa7)]['name'])?{'serverName':optionalStringValue(_0x51d7c8['values'][_0x45dd94(0xa4)])}:{},...optionalStringValue(_0x51d7c8[_0x45dd94(0xa7)][_0x45dd94(0xa2)])?{'serverVersion':optionalStringValue(_0x51d7c8['values'][_0x45dd94(0xa2)])}:{}};}function createServerOptions(_0x3b8440){const _0x27ec3d=_0x448f3b;return{'catalogs':_0x3b8440[_0x27ec3d(0xbf)],..._0x3b8440[_0x27ec3d(0x87)]?{'defaultCatalogId':_0x3b8440[_0x27ec3d(0x87)]}:{},..._0x3b8440['catalogInstructionMode']?{'catalogInstructionMode':_0x3b8440['catalogInstructionMode']}:{},'server':{..._0x3b8440[_0x27ec3d(0xbd)]?{'name':_0x3b8440[_0x27ec3d(0xbd)]}:{},..._0x3b8440['serverVersion']?{'version':_0x3b8440[_0x27ec3d(0xbc)]}:{}}};}function setCorsHeaders(_0x1e0bf0,_0x2a3758,_0x3130f0){const _0xf341a6=_0x448f3b;if(_0x3130f0['length']===0x0)return;const _0x413ba2=_0x1e0bf0[_0xf341a6(0x97)][_0xf341a6(0x94)],_0x190c62=_0x3130f0[_0xf341a6(0xaa)]('*'),_0x545482=_0x190c62?'*':typeof _0x413ba2===_0xf341a6(0x8c)&&_0x3130f0[_0xf341a6(0xaa)](_0x413ba2)?_0x413ba2:void 0x0;if(!_0x545482)return;_0x2a3758[_0xf341a6(0xb2)]('Access-Control-Allow-Origin',_0x545482),_0x2a3758['setHeader']('Vary',_0xf341a6(0xb8)),_0x2a3758['setHeader']('Access-Control-Allow-Methods',_0xf341a6(0x9c)),_0x2a3758['setHeader']('Access-Control-Allow-Headers',_0xf341a6(0x9f)),_0x2a3758[_0xf341a6(0xb2)](_0xf341a6(0x91),'Mcp-Session-Id');}function writeJsonRpcError(_0x12b71e,_0x142f0b,_0x259cc9){const _0x486c96=_0x448f3b;_0x12b71e[_0x486c96(0xba)]=_0x142f0b,_0x12b71e['setHeader'](_0x486c96(0xa1),'application/json'),_0x12b71e[_0x486c96(0xa3)](JSON[_0x486c96(0x96)]({'jsonrpc':'2.0','error':{'code':-0x7f5b,'message':_0x259cc9},'id':null}));}async function startStdio(_0x5b9c84){const _0x29282f=createUIMCPServer(createServerOptions(_0x5b9c84));await _0x29282f['connect'](new StdioServerTransport());}async function startHttp(_0x31b19d){const _0x2836bc=_0x448f3b,_0x4c809e=createServer(async(_0x445358,_0x2e53ca)=>{const _0x563c18=_0x736e,_0x56e8cc=new URL(_0x445358['url']??'/','http://'+(_0x445358['headers']['host']??_0x563c18(0x8a)));if(_0x56e8cc['pathname']!==_0x31b19d['endpoint']){_0x2e53ca['statusCode']=0x194,_0x2e53ca[_0x563c18(0xa3)](_0x563c18(0xa5));return;}setCorsHeaders(_0x445358,_0x2e53ca,_0x31b19d[_0x563c18(0xb0)]);if(_0x445358[_0x563c18(0xce)]===_0x563c18(0xb5)){_0x2e53ca[_0x563c18(0xba)]=0xcc,_0x2e53ca[_0x563c18(0xa3)]();return;}const _0x23c0a0=createUIMCPServer(createServerOptions(_0x31b19d)),_0x1b7c27=new StreamableHTTPServerTransport({'sessionIdGenerator':void 0x0});try{await _0x23c0a0[_0x563c18(0xc5)](_0x1b7c27),await _0x1b7c27['handleRequest'](_0x445358,_0x2e53ca),_0x2e53ca['on'](_0x563c18(0xa8),()=>{const _0x5a3840=_0x563c18;void _0x1b7c27[_0x5a3840(0xa8)](),void _0x23c0a0[_0x5a3840(0xa8)]();});}catch(_0x3560ef){console['error'](_0x563c18(0x93),_0x3560ef),!_0x2e53ca[_0x563c18(0xab)]&&writeJsonRpcError(_0x2e53ca,0x1f4,_0x3560ef instanceof Error?_0x3560ef['message']:_0x563c18(0xb1));}});await new Promise((_0x3ddd32,_0x38fd01)=>{const _0x4b86ea=_0x736e;_0x4c809e[_0x4b86ea(0x8d)](_0x4b86ea(0x9d),_0x38fd01),_0x4c809e['listen'](_0x31b19d[_0x4b86ea(0xb4)],_0x31b19d[_0x4b86ea(0x88)],_0x3ddd32);});const _0x546283=()=>{const _0x2cfaac=_0x736e;_0x4c809e[_0x2cfaac(0xa8)](()=>process['exit'](0x0));};process[_0x2836bc(0x8d)]('SIGINT',_0x546283),process['once'](_0x2836bc(0xcc),_0x546283),process['stderr']['write'](_0x2836bc(0xaf)+_0x31b19d['host']+':'+_0x31b19d[_0x2836bc(0xb4)]+_0x31b19d['endpoint']+'\x0a');}async function main(){const _0x2f0a43=_0x448f3b,_0x5939ca=await parseCliOptions();if(_0x5939ca[_0x2f0a43(0x9b)]===_0x2f0a43(0xca)){await startStdio(_0x5939ca);return;}await startHttp(_0x5939ca);}main()[_0x448f3b(0x89)](_0x206766=>{const _0x51393c=_0x448f3b;process['stderr']['write']((_0x206766 instanceof Error?_0x206766[_0x51393c(0x8e)]:String(_0x206766))+'\x0a'),process['exit'](0x1);});
2
+ const _0x4b7a93=_0xff34;(function(_0x2e2497,_0x12a447){const _0x1d08f8=_0xff34,_0x3ae03d=_0x2e2497();while(!![]){try{const _0x340c69=parseInt(_0x1d08f8(0x1a6))/0x1+parseInt(_0x1d08f8(0x1b9))/0x2+-parseInt(_0x1d08f8(0x1c8))/0x3+-parseInt(_0x1d08f8(0x1d2))/0x4+parseInt(_0x1d08f8(0x1d7))/0x5*(parseInt(_0x1d08f8(0x1cb))/0x6)+-parseInt(_0x1d08f8(0x1b8))/0x7*(-parseInt(_0x1d08f8(0x1d3))/0x8)+-parseInt(_0x1d08f8(0x1e0))/0x9;if(_0x340c69===_0x12a447)break;else _0x3ae03d['push'](_0x3ae03d['shift']());}catch(_0x3943d8){_0x3ae03d['push'](_0x3ae03d['shift']());}}}(_0x5e89,0x84505));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';import{StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import{createUIMCPServer}from'./index.js';const helpText=_0x4b7a93(0x1b0);function stringValue(_0x5de918,_0x1628c8){const _0x2a8120=_0x4b7a93;return typeof _0x5de918==='string'&&_0x5de918[_0x2a8120(0x1aa)]>0x0?_0x5de918:_0x1628c8;}function _0x5e89(){const _0x3b1840=['Access-Control-Allow-Origin','@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--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','name','serverVersion','pathname','default','setHeader','baseComponentNames','SIGINT','5477346pmZpZS','889036wwUPfW','http','SIGTERM','write','values','statusCode','headersSent','2.0','protocolVersion','endpoint','GET,POST,DELETE,OPTIONS','Unsupported\x20transport\x20\x22','stdio','OPTIONS','stderr','2937141GtrzLS','stdout','isArray','378kiQqaU','Catalog\x20module\x20\x22','message','Access-Control-Allow-Headers','localhost','Origin','\x20or\x20','2953920PYIbXn','8PCCdKU','stringify','end','Mcp-Session-Id','51090gTGnQq','3001','help','headers','\x22\x20exported\x20','href','string','close','host','1644849gIfQZQ','serverName','\x22\x20exported\x20an\x20invalid\x20catalog\x20descriptor.','origin','connect','boolean','error','571515JDcqon','catalogInstructionMode','protocol-version','map','length','\x22.\x20Expected\x20','corsOrigins','Access-Control-Allow-Methods','listen'];_0x5e89=function(){return _0x3b1840;};return _0x5e89();}function optionalStringValue(_0x546d77){const _0x4c2e07=_0x4b7a93;return typeof _0x546d77==='string'&&_0x546d77[_0x4c2e07(0x1aa)]>0x0?_0x546d77:void 0x0;}function stringArrayValue(_0x54e7be){const _0x41fa44=_0x4b7a93;if(Array[_0x41fa44(0x1ca)](_0x54e7be))return _0x54e7be;if(typeof _0x54e7be==='string'&&_0x54e7be['length']>0x0)return[_0x54e7be];return[];}function parseTransport(_0x455d06){const _0x279517=_0x4b7a93;if(_0x455d06==='stdio'||_0x455d06===_0x279517(0x1ba))return _0x455d06;throw new Error(_0x279517(0x1c4)+_0x455d06+'\x22.\x20Expected\x20\x22stdio\x22\x20or\x20\x22http\x22.');}function parseCatalogInstructionMode(_0x470c49){if(_0x470c49==='compact'||_0x470c49==='full')return _0x470c49;throw new Error('Unsupported\x20catalog\x20instruction\x20mode\x20\x22'+_0x470c49+'\x22.\x20Expected\x20\x22compact\x22\x20or\x20\x22full\x22.');}function parseProtocolVersion(_0x36d24d){const _0x100f16=_0x4b7a93;if(A2UI_SUPPORTED_PROTOCOL_VERSIONS['some'](_0x3c571a=>_0x3c571a===_0x36d24d))return _0x36d24d;throw new Error('Unsupported\x20protocol\x20version\x20\x22'+_0x36d24d+_0x100f16(0x1ab)+A2UI_SUPPORTED_PROTOCOL_VERSIONS[_0x100f16(0x1a9)](_0x43652d=>'\x22'+_0x43652d+'\x22')['join'](_0x100f16(0x1d1))+'.');}function parsePort(_0x3539ea){const _0x34d721=Number(_0x3539ea);if(!Number['isInteger'](_0x34d721)||_0x34d721<0x1||_0x34d721>0xffff)throw new Error('Invalid\x20--port\x20\x22'+_0x3539ea+'\x22.\x20Expected\x20an\x20integer\x20from\x201\x20to\x2065535.');return _0x34d721;}function normalizeEndpoint(_0x18733e){if(!_0x18733e['startsWith']('/'))return'/'+_0x18733e;return _0x18733e;}function isCatalogDescriptor(_0x43f63d){const _0x530a41=_0x4b7a93;return!!_0x43f63d&&typeof _0x43f63d==='object'&&!Array[_0x530a41(0x1ca)](_0x43f63d)&&typeof _0x43f63d['id']==='string'&&Array['isArray'](_0x43f63d[_0x530a41(0x1b6)]);}function readCatalogExport(_0x3626b2,_0x12367f){const _0x402f36=_0x4b7a93,_0x168334=_0x3626b2['catalogs']??_0x3626b2['catalog']??_0x3626b2[_0x402f36(0x1b4)];if(Array[_0x402f36(0x1ca)](_0x168334)){if(_0x168334[_0x402f36(0x1aa)]!==0x1)throw new Error(_0x402f36(0x1cc)+_0x12367f+_0x402f36(0x1db)+_0x168334['length']+'\x20catalogs.\x20A\x20server\x20serves\x20exactly\x20one;\x20merge\x20them\x20into\x20a\x20single\x20descriptor.');const [_0x5c8c76]=_0x168334;if(!isCatalogDescriptor(_0x5c8c76))throw new Error('Catalog\x20module\x20\x22'+_0x12367f+'\x22\x20exported\x20an\x20invalid\x20catalog\x20descriptor.');return _0x5c8c76;}if(_0x168334===void 0x0)throw new Error('Catalog\x20module\x20\x22'+_0x12367f+'\x22\x20did\x20not\x20export\x20a\x20catalog\x20descriptor.');if(!isCatalogDescriptor(_0x168334))throw new Error('Catalog\x20module\x20\x22'+_0x12367f+_0x402f36(0x1e2));return _0x168334;}async function loadCatalog(_0x201606){const _0x1589c5=_0x4b7a93;if(_0x201606===void 0x0)return void 0x0;const _0x46ed8f=await import(pathToFileURL(resolve(_0x201606))[_0x1589c5(0x1dc)]);return readCatalogExport(_0x46ed8f,_0x201606);}async function parseCliOptions(){const _0x297d5e=_0x4b7a93,_0x13d9ad=parseArgs({'allowPositionals':![],'options':{'transport':{'type':_0x297d5e(0x1dd)},'host':{'type':_0x297d5e(0x1dd)},'port':{'type':_0x297d5e(0x1dd)},'endpoint':{'type':_0x297d5e(0x1dd)},'cors-origin':{'type':_0x297d5e(0x1dd),'multiple':!![]},'catalog':{'type':_0x297d5e(0x1dd)},'catalog-instruction-mode':{'type':'string'},'protocol-version':{'type':_0x297d5e(0x1dd)},'name':{'type':'string'},'version':{'type':_0x297d5e(0x1dd)},'help':{'type':_0x297d5e(0x1a4),'short':'h'}}});_0x13d9ad['values'][_0x297d5e(0x1d9)]&&(process[_0x297d5e(0x1c9)][_0x297d5e(0x1bc)](helpText),process['exit'](0x0));const _0x100b67=await loadCatalog(optionalStringValue(_0x13d9ad[_0x297d5e(0x1bd)]['catalog'])),_0x55099a=optionalStringValue(_0x13d9ad[_0x297d5e(0x1bd)][_0x297d5e(0x1a8)]);return{'transport':parseTransport(stringValue(_0x13d9ad[_0x297d5e(0x1bd)]['transport'],'stdio')),'host':stringValue(_0x13d9ad['values'][_0x297d5e(0x1df)],'127.0.0.1'),'port':parsePort(stringValue(_0x13d9ad['values']['port'],_0x297d5e(0x1d8))),'endpoint':normalizeEndpoint(stringValue(_0x13d9ad['values'][_0x297d5e(0x1c2)],'/mcp')),'corsOrigins':stringArrayValue(_0x13d9ad['values']['cors-origin']),..._0x100b67?{'catalog':_0x100b67}:{},'catalogInstructionMode':parseCatalogInstructionMode(stringValue(_0x13d9ad['values']['catalog-instruction-mode'],'compact')),..._0x55099a?{'protocolVersion':parseProtocolVersion(_0x55099a)}:{},...optionalStringValue(_0x13d9ad[_0x297d5e(0x1bd)][_0x297d5e(0x1b1)])?{'serverName':optionalStringValue(_0x13d9ad[_0x297d5e(0x1bd)][_0x297d5e(0x1b1)])}:{},...optionalStringValue(_0x13d9ad['values']['version'])?{'serverVersion':optionalStringValue(_0x13d9ad[_0x297d5e(0x1bd)]['version'])}:{}};}function createServerOptions(_0x2d1b13){const _0x5f0665=_0x4b7a93;return{..._0x2d1b13['catalog']?{'catalog':_0x2d1b13['catalog']}:{},..._0x2d1b13[_0x5f0665(0x1a7)]?{'catalogInstructionMode':_0x2d1b13[_0x5f0665(0x1a7)]}:{},..._0x2d1b13[_0x5f0665(0x1c1)]?{'protocolVersion':_0x2d1b13[_0x5f0665(0x1c1)]}:{},'server':{..._0x2d1b13[_0x5f0665(0x1e1)]?{'name':_0x2d1b13['serverName']}:{},..._0x2d1b13[_0x5f0665(0x1b2)]?{'version':_0x2d1b13['serverVersion']}:{}}};}function setCorsHeaders(_0x4319eb,_0x1888bd,_0xf926a8){const _0x1124bf=_0x4b7a93;if(_0xf926a8[_0x1124bf(0x1aa)]===0x0)return;const _0x8f8d4a=_0x4319eb[_0x1124bf(0x1da)][_0x1124bf(0x1e3)],_0xe5b43e=_0xf926a8['includes']('*'),_0x33130b=_0xe5b43e?'*':typeof _0x8f8d4a==='string'&&_0xf926a8['includes'](_0x8f8d4a)?_0x8f8d4a:void 0x0;if(!_0x33130b)return;_0x1888bd['setHeader'](_0x1124bf(0x1af),_0x33130b),_0x1888bd[_0x1124bf(0x1b5)]('Vary',_0x1124bf(0x1d0)),_0x1888bd[_0x1124bf(0x1b5)](_0x1124bf(0x1ad),_0x1124bf(0x1c3)),_0x1888bd['setHeader'](_0x1124bf(0x1ce),'Content-Type,\x20Accept,\x20Authorization,\x20MCP-Protocol-Version,\x20Mcp-Session-Id,\x20Last-Event-ID'),_0x1888bd[_0x1124bf(0x1b5)]('Access-Control-Expose-Headers',_0x1124bf(0x1d6));}function _0xff34(_0x2d7dda,_0x1988a1){_0x2d7dda=_0x2d7dda-0x1a4;const _0x5e89d1=_0x5e89();let _0xff3486=_0x5e89d1[_0x2d7dda];return _0xff3486;}function writeJsonRpcError(_0x51e12c,_0x2971a1,_0x673d3d){const _0x33ae5e=_0x4b7a93;_0x51e12c['statusCode']=_0x2971a1,_0x51e12c[_0x33ae5e(0x1b5)]('content-type','application/json'),_0x51e12c['end'](JSON[_0x33ae5e(0x1d4)]({'jsonrpc':_0x33ae5e(0x1c0),'error':{'code':-0x7f5b,'message':_0x673d3d},'id':null}));}async function startStdio(_0x4d1d1c){const _0x38ce3d=createUIMCPServer(createServerOptions(_0x4d1d1c));await _0x38ce3d['connect'](new StdioServerTransport());}async function startHttp(_0x37f7fe){const _0x4f672c=_0x4b7a93,_0x1228d7=createServer(async(_0x494a84,_0x4727d4)=>{const _0x40f1a2=_0xff34,_0x42d77e=new URL(_0x494a84['url']??'/','http://'+(_0x494a84[_0x40f1a2(0x1da)][_0x40f1a2(0x1df)]??_0x40f1a2(0x1cf)));if(_0x42d77e[_0x40f1a2(0x1b3)]!==_0x37f7fe[_0x40f1a2(0x1c2)]){_0x4727d4[_0x40f1a2(0x1be)]=0x194,_0x4727d4['end']('Not\x20Found');return;}setCorsHeaders(_0x494a84,_0x4727d4,_0x37f7fe[_0x40f1a2(0x1ac)]);if(_0x494a84['method']===_0x40f1a2(0x1c6)){_0x4727d4[_0x40f1a2(0x1be)]=0xcc,_0x4727d4[_0x40f1a2(0x1d5)]();return;}const _0x74311e=createUIMCPServer(createServerOptions(_0x37f7fe)),_0x2d62fa=new StreamableHTTPServerTransport({'sessionIdGenerator':void 0x0});try{await _0x74311e[_0x40f1a2(0x1e4)](_0x2d62fa),await _0x2d62fa['handleRequest'](_0x494a84,_0x4727d4),_0x4727d4['on'](_0x40f1a2(0x1de),()=>{const _0x2760b3=_0x40f1a2;void _0x2d62fa['close'](),void _0x74311e[_0x2760b3(0x1de)]();});}catch(_0xba0a18){console['error']('[@agentic-ui-experience/ui-mcp]\x20request\x20failed',_0xba0a18),!_0x4727d4[_0x40f1a2(0x1bf)]&&writeJsonRpcError(_0x4727d4,0x1f4,_0xba0a18 instanceof Error?_0xba0a18[_0x40f1a2(0x1cd)]:'Internal\x20MCP\x20server\x20error');}});await new Promise((_0x293e62,_0x354c1a)=>{const _0x2a8948=_0xff34;_0x1228d7['once'](_0x2a8948(0x1a5),_0x354c1a),_0x1228d7[_0x2a8948(0x1ae)](_0x37f7fe['port'],_0x37f7fe[_0x2a8948(0x1df)],_0x293e62);});const _0x25c8bf=()=>{_0x1228d7['close'](()=>process['exit'](0x0));};process['once'](_0x4f672c(0x1b7),_0x25c8bf),process['once'](_0x4f672c(0x1bb),_0x25c8bf),process['stderr']['write']('@agentic-ui-experience/ui-mcp\x20listening\x20on\x20http://'+_0x37f7fe['host']+':'+_0x37f7fe['port']+_0x37f7fe['endpoint']+'\x0a');}async function main(){const _0x251bf0=_0x4b7a93,_0x19a980=await parseCliOptions();if(_0x19a980['transport']===_0x251bf0(0x1c5)){await startStdio(_0x19a980);return;}await startHttp(_0x19a980);}main()['catch'](_0x53def5=>{const _0x55dc6f=_0x4b7a93;process[_0x55dc6f(0x1c7)][_0x55dc6f(0x1bc)]((_0x53def5 instanceof Error?_0x53def5[_0x55dc6f(0x1cd)]:String(_0x53def5))+'\x0a'),process['exit'](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
+ const _0x5a8963=_0x8857;(function(_0x2b4be2,_0x3d56eb){const _0x8221aa=_0x8857,_0x10433e=_0x2b4be2();while(!![]){try{const _0x56eda9=parseInt(_0x8221aa(0x175))/0x1*(-parseInt(_0x8221aa(0x173))/0x2)+parseInt(_0x8221aa(0x17f))/0x3+-parseInt(_0x8221aa(0x172))/0x4*(-parseInt(_0x8221aa(0x177))/0x5)+-parseInt(_0x8221aa(0x178))/0x6*(parseInt(_0x8221aa(0x161))/0x7)+parseInt(_0x8221aa(0x171))/0x8*(parseInt(_0x8221aa(0x174))/0x9)+parseInt(_0x8221aa(0x15e))/0xa*(parseInt(_0x8221aa(0x17c))/0xb)+-parseInt(_0x8221aa(0x165))/0xc;if(_0x56eda9===_0x3d56eb)break;else _0x10433e['push'](_0x10433e['shift']());}catch(_0x3476ec){_0x10433e['push'](_0x10433e['shift']());}}}(_0x5340,0x4f150));import{A2UI_MESSAGE_MEDIA_TYPE}from'@agentic-ui-experience/ui-core';import{createUISendNormalizer}from'@agentic-ui-experience/ui-core/tool-mode';function _0x5340(){const _0x5db93a=['MCP\x20tool\x20reported\x20an\x20error.','type','A2UI\x20client\x20capability\x20Catalog\x20IDs\x20must\x20be\x20non-empty\x20strings.','join','A2UI\x20embedded\x20resource\x20text\x20must\x20contain\x20valid\x20JSON.','filter','protocol','includes','2406568vcgady','10884XHiSwf','544982dRvjmn','9sqXTDR','1OMuYVc','trim','515yqZgYO','54dzGHTU','A2UI\x20embedded\x20resource\x20must\x20contain\x20text\x20content.','length','parse','775819UBlTvT','text','object','1297713xdRrDO','isArray','resource','40yuiayn','mimeType','MCP\x20tool\x20result\x20contains\x20multiple\x20A2UI\x20embedded\x20resources.','266861oLNkNA','content','a2ui/client-capabilities','string','4275036DidVYt','A2UI\x20client\x20capabilities\x20require\x20at\x20least\x20one\x20Catalog\x20ID.','uri','map'];_0x5340=function(){return _0x5db93a;};return _0x5340();}function _0x8857(_0x16d82a,_0x3043c2){_0x16d82a=_0x16d82a-0x15c;const _0x534028=_0x5340();let _0x88572e=_0x534028[_0x16d82a];return _0x88572e;}const A2UI_MCP_CAPABILITY_FAMILY='v0.9',A2UI_MCP_CAPABILITY_EXTENSION_ID=_0x5a8963(0x163);function isJsonObject(_0x338fb2){const _0x317741=_0x5a8963;return typeof _0x338fb2===_0x317741(0x17e)&&_0x338fb2!==null&&!Array[_0x317741(0x15c)](_0x338fb2);}function textErrorMessage(_0xc0eed3){const _0x1235b2=_0x5a8963;if(!Array[_0x1235b2(0x15c)](_0xc0eed3['content']))return'MCP\x20tool\x20reported\x20an\x20error.';const _0x2ef366=_0xc0eed3['content'][_0x1235b2(0x16e)](isJsonObject)[_0x1235b2(0x16e)](_0x244d18=>_0x244d18['type']===_0x1235b2(0x17d)&&typeof _0x244d18[_0x1235b2(0x17d)]==='string')[_0x1235b2(0x168)](_0x5b770c=>_0x5b770c[_0x1235b2(0x17d)])[_0x1235b2(0x16e)](_0x1e16f8=>_0x1e16f8['length']>0x0);return _0x2ef366[_0x1235b2(0x16c)]('\x0a')||_0x1235b2(0x169);}function isAbsoluteUri(_0xb40b7a){const _0x568a1b=_0x5a8963;try{return new URL(_0xb40b7a)[_0x568a1b(0x16f)]['length']>0x1;}catch{return![];}}function createA2UIClientCapabilities(_0x40ab0a){const _0x5cb906=_0x5a8963;if(!Array[_0x5cb906(0x15c)](_0x40ab0a)||_0x40ab0a['length']===0x0)throw new Error(_0x5cb906(0x166));const _0x4d2c36=[];for(const _0x25b108 of _0x40ab0a){if(typeof _0x25b108!=='string'||_0x25b108[_0x5cb906(0x176)]()['length']===0x0)throw new Error(_0x5cb906(0x16b));if(!_0x4d2c36[_0x5cb906(0x170)](_0x25b108))_0x4d2c36['push'](_0x25b108);}const _0x44aead={'clientCapabilities':{[A2UI_MCP_CAPABILITY_FAMILY]:{'supportedCatalogIds':_0x4d2c36}}};return{'a2ui':_0x44aead,'extensions':{[A2UI_MCP_CAPABILITY_EXTENSION_ID]:_0x44aead}};}function extractUIMCPToolResult(_0x4df44f,_0x1ad566={}){const _0x447979=_0x5a8963;if(!isJsonObject(_0x4df44f))return void 0x0;if(_0x4df44f['isError']===!![])throw new Error(textErrorMessage(_0x4df44f));if(!Array[_0x447979(0x15c)](_0x4df44f[_0x447979(0x162)]))return void 0x0;const _0x357c56=_0x4df44f[_0x447979(0x162)][_0x447979(0x16e)](_0x2faf63=>{const _0x1ff66e=_0x447979;if(!isJsonObject(_0x2faf63)||_0x2faf63[_0x1ff66e(0x16a)]!=='resource')return![];if(!isJsonObject(_0x2faf63['resource']))return![];return _0x2faf63[_0x1ff66e(0x15d)][_0x1ff66e(0x15f)]===A2UI_MESSAGE_MEDIA_TYPE;});if(_0x357c56['length']===0x0)return void 0x0;if(_0x357c56[_0x447979(0x17a)]>0x1)throw new Error(_0x447979(0x160));const _0x5ce76c=_0x357c56[0x0][_0x447979(0x15d)];if(!isJsonObject(_0x5ce76c))throw new Error('A2UI\x20embedded\x20resource\x20is\x20malformed.');if(typeof _0x5ce76c['uri']!=='string'||!isAbsoluteUri(_0x5ce76c[_0x447979(0x167)]))throw new Error('A2UI\x20embedded\x20resource\x20must\x20contain\x20a\x20valid\x20absolute\x20URI.');if(typeof _0x5ce76c[_0x447979(0x17d)]!==_0x447979(0x164))throw new Error(_0x447979(0x179));let _0x19ea78;try{_0x19ea78=JSON[_0x447979(0x17b)](_0x5ce76c['text']);}catch{throw new Error(_0x447979(0x16d));}const _0x11bf6f=createUISendNormalizer({'mode':'strict','catalog':_0x1ad566['catalog']})({'messages':_0x19ea78});return{..._0x11bf6f,'resourceUri':_0x5ce76c['uri'],'mimeType':A2UI_MESSAGE_MEDIA_TYPE};}export{A2UI_MCP_CAPABILITY_EXTENSION_ID,A2UI_MCP_CAPABILITY_FAMILY,createA2UIClientCapabilities,extractUIMCPToolResult};
package/dist/index.d.ts CHANGED
@@ -1,28 +1,36 @@
1
- import { McpServer, ResourceTemplate, type RegisteredResource, type RegisteredResourceTemplate, type RegisteredTool } from "@modelcontextprotocol/sdk/server/mcp.js";
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 UIListCatalogsResult, type UISendToolArguments, type UISendToolResult, type UIToolCatalogInstructionMode, type UIToolCatalogRegistry } 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, type UIToolCatalogInstructionMode } from "@agentic-ui-experience/ui-core/tool-mode";
5
5
  export type UIMCPToolResult = UISendToolResult & Record<string, unknown>;
6
6
  export type UIMCPToolArguments = UISendToolArguments;
7
7
  export type UIMCPCatalogInstructionMode = UIToolCatalogInstructionMode;
8
- export type UIMCPCatalogSummary = UIListCatalogsResult["catalogs"][number];
9
8
  export type UIMCPCatalogDescription = UIGetCatalogResult["catalog"];
10
- export type UIMCPListCatalogsResult = UIListCatalogsResult & Record<string, unknown>;
11
9
  export type UIMCPGetCatalogArguments = UIGetCatalogArguments;
12
10
  export type UIMCPGetCatalogResult = UIGetCatalogResult & Record<string, unknown>;
13
11
  export type UIMCPNormalize = (args: UIMCPToolArguments) => UIMCPToolResult | Promise<UIMCPToolResult>;
14
12
  export type UIMCPSyncNormalize = (args: UIMCPToolArguments) => UIMCPToolResult;
15
- export type UIMCPCatalogRegistry = UIToolCatalogRegistry;
13
+ export type UIMCPCatalog = UIToolCatalog;
16
14
  export interface UIMCPNormalizeMessagesOptions {
17
15
  mode?: "strict" | "repair";
18
16
  surfaceId?: string;
19
- defaultCatalogId?: string;
20
- catalogs?: readonly CatalogPromptDescriptor[];
17
+ /**
18
+ * The catalog to validate against. Accepts the configured `UIMCPCatalog` as
19
+ * well as a bare descriptor, so a caller holding the value this server was
20
+ * built from does not have to unwrap it.
21
+ */
22
+ catalog?: CatalogPromptDescriptor | UIMCPCatalog;
23
+ }
24
+ export interface CreateUIToolCallResultOptions {
25
+ /** Catalog used to strictly validate the normalized carrier. Defaults to Basic. */
26
+ catalog?: CatalogPromptDescriptor | UIMCPCatalog;
21
27
  }
22
28
  export interface CreateUIMCPServerOptions {
23
- catalogs?: readonly CatalogPromptDescriptor[];
24
- defaultCatalogId?: string;
29
+ /** The single catalog this server serves. Defaults to the A2UI basic catalog. */
30
+ catalog?: CatalogPromptDescriptor;
25
31
  catalogInstructionMode?: UIMCPCatalogInstructionMode;
32
+ /** Version requested in generated tool and catalog instructions. Defaults to v0.9.1. */
33
+ protocolVersion?: A2UIProtocolVersion;
26
34
  title?: string;
27
35
  annotations?: ToolAnnotations;
28
36
  normalize?: UIMCPNormalize;
@@ -36,25 +44,23 @@ export declare function createUIMCPNormalize(options?: UIMCPNormalizeMessagesOpt
36
44
  * Execute a UI MCP call. This is intentionally pure: it parses and returns the
37
45
  * UI payload, but does not mutate any UI runtime.
38
46
  */
39
- export declare function createUIToolCallResult(args: UIMCPToolArguments, normalize?: UIMCPNormalize): Promise<CallToolResult>;
40
- export declare function registerUICatalogResources(server: McpServer, registry: UIMCPCatalogRegistry): {
41
- basic: RegisteredResource;
42
- catalogs: RegisteredResource[];
43
- template: RegisteredResourceTemplate;
47
+ export declare function createUIToolCallResult(args: UIMCPToolArguments, normalize?: UIMCPNormalize, options?: CreateUIToolCallResultOptions): Promise<CallToolResult>;
48
+ export declare function registerUICatalogResources(server: McpServer, catalog: UIMCPCatalog): {
49
+ catalog: RegisteredResource;
44
50
  };
45
- export declare function registerUICatalogTools(server: McpServer, registry: UIMCPCatalogRegistry): {
46
- list: RegisteredTool;
51
+ export declare function registerUICatalogTools(server: McpServer, catalog: UIMCPCatalog): {
47
52
  get: RegisteredTool;
48
53
  };
49
54
  /**
50
55
  * Register the generic deployable A2UI MCP tool. The server is
51
- * scenario-independent; catalog-specific schema comes from the registry.
56
+ * scenario-independent; catalog-specific schema comes from the one catalog it
57
+ * was configured with.
52
58
  */
53
- export declare function registerGenericUITool(server: McpServer, registry: UIMCPCatalogRegistry, options?: Pick<CreateUIMCPServerOptions, "title" | "annotations" | "normalize">): RegisteredTool;
59
+ export declare function registerGenericUITool(server: McpServer, catalog: UIMCPCatalog, options?: Pick<CreateUIMCPServerOptions, "title" | "annotations" | "normalize">): RegisteredTool;
54
60
  /**
55
61
  * Create a generic A2UI MCP server. Transport ownership stays with the caller
56
62
  * so this can be used with stdio, SSE, or streamable HTTP.
57
63
  */
58
64
  export declare function createUIMCPServer(options?: CreateUIMCPServerOptions): McpServer;
59
- export { McpServer, ResourceTemplate };
65
+ export { McpServer };
60
66
  export type { CallToolResult, ToolAnnotations, CatalogPromptDescriptor };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- const _0x32dd7e=_0x1500;(function(_0x59384c,_0x5dab4b){const _0x35a13b=_0x1500,_0x5b9344=_0x59384c();while(!![]){try{const _0x3aaddf=parseInt(_0x35a13b(0x175))/0x1+parseInt(_0x35a13b(0x161))/0x2+-parseInt(_0x35a13b(0x16c))/0x3*(-parseInt(_0x35a13b(0x166))/0x4)+-parseInt(_0x35a13b(0x155))/0x5*(parseInt(_0x35a13b(0x151))/0x6)+-parseInt(_0x35a13b(0x185))/0x7*(-parseInt(_0x35a13b(0x186))/0x8)+parseInt(_0x35a13b(0x168))/0x9*(-parseInt(_0x35a13b(0x148))/0xa)+-parseInt(_0x35a13b(0x14b))/0xb*(parseInt(_0x35a13b(0x158))/0xc);if(_0x3aaddf===_0x5dab4b)break;else _0x5b9344['push'](_0x5b9344['shift']());}catch(_0x29406d){_0x5b9344['push'](_0x5b9344['shift']());}}}(_0x43ac,0x7dbe7));import{McpServer,ResourceTemplate}from'@modelcontextprotocol/sdk/server/mcp.js';import{McpServer as _0x13fec9,ResourceTemplate as _0x32ec85}from'@modelcontextprotocol/sdk/server/mcp.js';import{z}from'zod/v4';import{createUISendNormalizer,createUICatalogRegistry,BASIC_CATALOG_RESOURCE_URI,catalogIdFromResourceVariable,catalogResourceUri,CATALOG_RESOURCE_URI_TEMPLATE,LIST_UI_CATALOGS_TOOL_NAME,UI_TOOL_WORKFLOW,listUICatalogs,GET_UI_CATALOG_TOOL_NAME,getUICatalog,UI_TOOL_NAME,createUICatalogResourcePayload,normalizeUISendToolArguments}from'@agentic-ui-experience/ui-core/tool-mode';const sendUIOutputSchema={'uiJson':z['string'](),'uiMessages':z['array'](z[_0x32dd7e(0x176)]())},listCatalogsOutputSchema={'catalogs':z['array'](z['object']({'id':z['string'](),'resourceUri':z[_0x32dd7e(0x146)](),'isDefault':z['boolean'](),'baseCatalogId':z['string'](),'baseComponentNames':z[_0x32dd7e(0x157)](z[_0x32dd7e(0x146)]()),'customComponents':z['array'](z['string']())}))},getCatalogOutputSchema={'catalog':z['object']({'id':z['string'](),'resourceUri':z['string'](),'isDefault':z['boolean'](),'baseCatalogId':z['string'](),'instructionMode':z['enum'](['compact','full']),'descriptor':z[_0x32dd7e(0x176)](),'instructions':z[_0x32dd7e(0x146)](),'catalogPrompt':z['string'](),'basicCatalogSchema':z['unknown']()[_0x32dd7e(0x17b)]()})},componentSchema=z[_0x32dd7e(0x165)](z['string'](),z[_0x32dd7e(0x176)]()),createSurfaceMessageSchema=z[_0x32dd7e(0x14a)]({'version':z[_0x32dd7e(0x16e)]('v0.9'),'createSurface':z['object']({'surfaceId':z['string'](),'catalogId':z['string']()})[_0x32dd7e(0x15c)]()})['passthrough'](),updateComponentsMessageSchema=z['object']({'version':z['literal'](_0x32dd7e(0x18b)),'updateComponents':z[_0x32dd7e(0x14a)]({'surfaceId':z[_0x32dd7e(0x146)](),'components':z['array'](componentSchema)})['passthrough']()})['passthrough'](),updateDataModelMessageSchema=z[_0x32dd7e(0x14a)]({'version':z[_0x32dd7e(0x16e)](_0x32dd7e(0x18b)),'updateDataModel':z['object']({'surfaceId':z[_0x32dd7e(0x146)](),'path':z['string']()['optional'](),'value':z[_0x32dd7e(0x176)]()['optional']()})[_0x32dd7e(0x15c)]()})['passthrough'](),deleteSurfaceMessageSchema=z[_0x32dd7e(0x14a)]({'version':z['literal']('v0.9'),'deleteSurface':z[_0x32dd7e(0x14a)]({'surfaceId':z[_0x32dd7e(0x146)]()})[_0x32dd7e(0x15c)]()})[_0x32dd7e(0x15c)]();function createSendUIInputSchema(){const _0xf23b15=_0x32dd7e;return{'catalogId':z['string']()['optional']()['describe']('Optional\x20expected\x20catalog\x20id\x20for\x20this\x20UI\x20call.\x20This\x20is\x20a\x20validator\x20only:\x20still\x20include\x20the\x20same\x20value\x20in\x20`messages[0].createSurface.catalogId`.\x20Defaults\x20to\x20the\x20MCP\x20server\x20default\x20catalog\x20id,\x20then\x20the\x20A2UI\x20basic\x20catalog\x20id.'),'surfaceId':z['string']()['optional']()['describe']('Optional\x20expected\x20surface\x20id\x20for\x20this\x20UI\x20call.\x20When\x20supplied,\x20`messages[0].createSurface.surfaceId`\x20must\x20match\x20it.'),'messages':z[_0xf23b15(0x157)](z['union']([createSurfaceMessageSchema,updateComponentsMessageSchema,updateDataModelMessageSchema,deleteSurfaceMessageSchema]))[_0xf23b15(0x180)](['The\x20complete\x20A2UI\x20v0.9-compatible\x20UI\x20message\x20array.',_0xf23b15(0x15b)+LIST_UI_CATALOGS_TOOL_NAME+'\x20and\x20'+GET_UI_CATALOG_TOOL_NAME+'.',_0xf23b15(0x18d)+GET_UI_CATALOG_TOOL_NAME+_0xf23b15(0x184),_0xf23b15(0x159),_0xf23b15(0x178),'The\x20first\x20entry\x20must\x20be\x20`createSurface`\x20with\x20both\x20`surfaceId`\x20and\x20`catalogId`\x20inside\x20`createSurface`.','If\x20the\x20tool\x20call\x20includes\x20top-level\x20`catalogId`,\x20`messages[0].createSurface.catalogId`\x20must\x20repeat\x20the\x20same\x20value.',_0xf23b15(0x17c)]['join']('\x20'))};}function createGetCatalogInputSchema(){const _0x190f77=_0x32dd7e;return{'catalogId':z[_0x190f77(0x146)]()['optional']()[_0x190f77(0x180)](_0x190f77(0x167)),'componentNames':z['array'](z[_0x190f77(0x146)]())[_0x190f77(0x189)](0x1)['optional']()[_0x190f77(0x180)](_0x190f77(0x174)),'instructionMode':z['enum']([_0x190f77(0x182),_0x190f77(0x147)])['optional']()[_0x190f77(0x180)]('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(_0x4e1f32){const _0x54a9ad=_0x32dd7e,_0x2a37d0=listUICatalogs(_0x4e1f32)[_0x54a9ad(0x172)];return[_0x54a9ad(0x17f),UI_TOOL_WORKFLOW,_0x54a9ad(0x17e),_0x54a9ad(0x173)+_0x4e1f32['defaultCatalogId']+'.','Registered\x20catalogs:\x20'+_0x2a37d0[_0x54a9ad(0x152)](_0x358de5=>_0x358de5['id'])[_0x54a9ad(0x14c)](',\x20')+'.','Message\x20list\x20rules:',_0x54a9ad(0x188),'-\x20The\x20first\x20message\x20must\x20be\x20createSurface.',_0x54a9ad(0x16d),_0x54a9ad(0x17a),'-\x20Later\x20updateComponents/updateDataModel/deleteSurface\x20messages\x20must\x20target\x20the\x20same\x20surface.','-\x20Component\x20objects\x20belong\x20only\x20inside\x20updateComponents.components\x20and\x20must\x20conform\x20to\x20the\x20schemas\x20returned\x20by\x20get_ui_catalog.',_0x54a9ad(0x16a),_0x54a9ad(0x16b)]['join']('\x0a\x0a');}function createUIMCPNormalize(_0x1ef7e9={}){const _0x4fb648=_0x32dd7e;return createUISendNormalizer({'mode':_0x1ef7e9[_0x4fb648(0x15a)],'surfaceId':_0x1ef7e9[_0x4fb648(0x183)],'defaultCatalogId':_0x1ef7e9[_0x4fb648(0x169)],'catalogs':_0x1ef7e9[_0x4fb648(0x172)]});}const defaultNormalize=createUIMCPNormalize();function _0x43ac(){const _0x221c58=['a2ui-basic-catalog','values','1317786LhWmrM','map','Accepted\x20','keys','10KPOyvR','catalogId','array','338028kHPfyK','Do\x20not\x20pass\x20a\x20JSON\x20string\x20and\x20do\x20not\x20use\x20a\x20ui_json\x20field.','mode','Use\x20this\x20only\x20as\x20workflow\x20step\x203,\x20after\x20inspecting\x20catalog\x20metadata\x20with\x20','passthrough','componentNames','text','List\x20A2UI\x20Catalogs','application/json','1130792JzxVix','name','href','basic','record','412NvjEeo','Optional\x20catalog\x20id.\x20Defaults\x20to\x20the\x20MCP\x20server\x20default\x20catalog\x20id,\x20then\x20the\x20A2UI\x20basic\x20catalog\x20id.','542421HGLuLr','defaultCatalogId','Do\x20not\x20send\x20`ui_json`;\x20do\x20not\x20serialize\x20the\x20messages\x20into\x20a\x20JSON\x20string.','Top-level\x20`catalogId`\x20is\x20only\x20an\x20expected-value\x20guard;\x20it\x20does\x20not\x20populate\x20the\x20A2UI\x20message.\x20The\x20first\x20message\x20must\x20repeat\x20the\x20catalog\x20id\x20at\x20`messages[0].createSurface.catalogId`.','10215xzfpUz','-\x20createSurface.surfaceId\x20must\x20match\x20the\x20top-level\x20surfaceId\x20when\x20supplied.','literal','instructionMode','server','Step\x201\x20of\x20the\x20A2UI\x20MCP\x20workflow.\x20Call\x20this\x20before\x20get_ui_catalog\x20or\x20send_ui_to_client.','catalogs','Default\x20catalog\x20id:\x20','Optional\x20component\x20names\x20to\x20fetch.\x20Use\x20list_ui_catalogs\x20first,\x20then\x20pass\x20only\x20the\x20basic\x20or\x20custom\x20components\x20needed\x20for\x20this\x20UI\x20response.\x20Omit\x20to\x20fetch\x20the\x20complete\x20catalog.','896050bGZwkj','unknown','annotations','Every\x20entry\x20contains\x20`version`\x20and\x20exactly\x20one\x20of\x20`createSurface`/`updateComponents`/`updateDataModel`/`deleteSurface`.','normalize','-\x20createSurface.catalogId\x20must\x20be\x20present\x20and\x20must\x20match\x20the\x20top-level\x20catalogId\x20when\x20supplied;\x20otherwise\x20it\x20must\x20match\x20the\x20registered\x20default\x20catalog\x20id.','optional','Component\x20objects\x20belong\x20inside\x20a\x20later\x20`updateComponents.components`\x20array.','toLowerCase','Do\x20not\x20call\x20this\x20tool\x20before\x20using\x20the\x20catalog\x20discovery\x20tools\x20in\x20the\x20same\x20task.\x20This\x20tool\x20validates\x20and\x20returns\x20A2UI\x20messages;\x20it\x20is\x20not\x20the\x20source\x20of\x20component\x20schemas.','Final\x20step:\x20render\x20UI\x20on\x20the\x20client\x20by\x20submitting\x20structured\x20A2UI\x20messages.','describe','Registered\x20A2UI\x20catalog\x20instructions\x20and\x20custom\x20component\x20schema.','compact','surfaceId',';\x20do\x20not\x20guess\x20component\x20fields\x20from\x20this\x20tool\x20schema.','63ibpwgD','521448mPRtxc','message','-\x20Every\x20message\x20must\x20include\x20\x22version\x22:\x20\x22v0.9\x22.','min','Returns\x20LLM-facing\x20A2UI\x20message\x20rules,\x20basic\x20catalog\x20schema,\x20custom\x20component\x20schemas,\x20style\x20guide,\x20and\x20examples\x20for\x20a\x20registered\x20catalog.','v0.9','Pass\x20only\x20the\x20componentNames\x20needed\x20for\x20the\x20current\x20UI\x20response.\x20Omit\x20componentNames\x20only\x20when\x20the\x20complete\x20catalog\x20is\x20needed.','Build\x20component\x20objects\x20from\x20the\x20schema\x20returned\x20by\x20','string','full','20FaRran','\x20A2UI\x20UI\x20message(s).','object','517ublcJn','join','@agentic-ui-experience/ui-mcp','A2UI\x20Catalog'];_0x43ac=function(){return _0x221c58;};return _0x43ac();}function toToolError(_0x40a984){return{'isError':!![],'content':[{'type':'text','text':_0x40a984}]};}function toToolResult(_0x5a23d5){const _0xbc1cd3=_0x32dd7e;return{'content':[{'type':'text','text':_0xbc1cd3(0x153)+_0x5a23d5['uiMessages']['length']+_0xbc1cd3(0x149)}],'structuredContent':_0x5a23d5};}function toCatalogToolResult(_0x4686fd){const _0x3774e9=_0x32dd7e;return{'content':[{'type':_0x3774e9(0x15e),'text':JSON['stringify'](_0x4686fd)}],'structuredContent':_0x4686fd};}async function createUIToolCallResult(_0x2420e7,_0x43c141=defaultNormalize){try{const _0x3fdb0c=await _0x43c141(_0x2420e7);return toToolResult(normalizeUISendToolArguments(_0x2420e7,()=>_0x3fdb0c));}catch(_0x52e480){const _0x3aabbd=_0x52e480 instanceof Error?_0x52e480['message']:String(_0x52e480);return toToolError(_0x3aabbd);}}function toMCPResourceResult(_0x12293d){return _0x12293d;}function createCatalogResourceResult(_0x3f6b5a,_0x1930ac,_0x62f94b){return toMCPResourceResult(createUICatalogResourcePayload(_0x3f6b5a,_0x1930ac,_0x62f94b));}function registerUICatalogResources(_0x365009,_0x33fda2){const _0x35b1b2=_0x32dd7e,_0x6b7c49=_0x365009['registerResource'](_0x35b1b2(0x14f),BASIC_CATALOG_RESOURCE_URI,{'title':'A2UI\x20Basic\x20Catalog','description':'Built-in\x20A2UI\x20basic\x20catalog\x20instructions\x20and\x20component\x20schema.','mimeType':'application/json'},_0x4193dd=>createCatalogResourceResult(_0x33fda2,catalogIdFromResourceVariable(_0x35b1b2(0x164)),_0x4193dd[_0x35b1b2(0x163)])),_0x52fa9b=[..._0x33fda2[_0x35b1b2(0x172)][_0x35b1b2(0x150)]()]['filter'](_0x20b2b0=>catalogResourceUri(_0x20b2b0['id'])!==BASIC_CATALOG_RESOURCE_URI)['map'](_0x463735=>_0x365009['registerResource']('a2ui-catalog-'+_0x463735['id'],catalogResourceUri(_0x463735['id']),{'title':'A2UI\x20Catalog\x20'+_0x463735['id'],'description':_0x35b1b2(0x181),'mimeType':_0x35b1b2(0x160)},_0x3b0684=>createCatalogResourceResult(_0x33fda2,_0x463735['id'],_0x3b0684['href']))),_0x11f624=_0x365009['registerResource']('a2ui-catalog',new ResourceTemplate(CATALOG_RESOURCE_URI_TEMPLATE,{'list':()=>({'resources':[..._0x33fda2['catalogs']['values']()]['map'](_0x2ea7dc=>({'uri':catalogResourceUri(_0x2ea7dc['id']),'name':_0x2ea7dc['id'],'title':_0x2ea7dc['id'],'mimeType':'application/json'}))}),'complete':{'catalogId':_0x454ef7=>{const _0x2898d7=_0x35b1b2,_0x26038c=_0x454ef7['toLowerCase']();return[..._0x33fda2[_0x2898d7(0x172)][_0x2898d7(0x154)]()][_0x2898d7(0x152)](_0x368466=>catalogResourceUri(_0x368466)===BASIC_CATALOG_RESOURCE_URI?'basic':encodeURIComponent(_0x368466))['filter'](_0x2085a=>_0x2085a[_0x2898d7(0x17d)]()['startsWith'](_0x26038c));}}}),{'title':_0x35b1b2(0x14e),'description':_0x35b1b2(0x181),'mimeType':_0x35b1b2(0x160)},(_0x27846a,_0x35afcf)=>createCatalogResourceResult(_0x33fda2,catalogIdFromResourceVariable(String(_0x35afcf[_0x35b1b2(0x156)])),_0x27846a[_0x35b1b2(0x163)]));return{'basic':_0x6b7c49,'catalogs':_0x52fa9b,'template':_0x11f624};}function _0x1500(_0xaa13d6,_0x1c406c){_0xaa13d6=_0xaa13d6-0x146;const _0x43ac42=_0x43ac();let _0x15002b=_0x43ac42[_0xaa13d6];return _0x15002b;}function registerUICatalogTools(_0x1816ec,_0x4f586c){const _0x4a8692=_0x32dd7e,_0x1ae6a8=_0x1816ec['registerTool'](LIST_UI_CATALOGS_TOOL_NAME,{'title':_0x4a8692(0x15f),'description':[_0x4a8692(0x171),UI_TOOL_WORKFLOW,'Returns\x20registered\x20catalog\x20ids,\x20the\x20default\x20catalog,\x20base\x20component\x20names,\x20and\x20custom\x20component\x20names.\x20Use\x20the\x20returned\x20component\x20names\x20to\x20choose\x20the\x20componentNames\x20for\x20get_ui_catalog.']['join']('\x0a\x0a'),'outputSchema':listCatalogsOutputSchema,'annotations':{'readOnlyHint':!![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':![]}},async()=>toCatalogToolResult(listUICatalogs(_0x4f586c))),_0x133979=_0x1816ec['registerTool'](GET_UI_CATALOG_TOOL_NAME,{'title':'Get\x20A2UI\x20Catalog','description':['Step\x202\x20of\x20the\x20A2UI\x20MCP\x20workflow.\x20Call\x20this\x20after\x20list_ui_catalogs\x20and\x20before\x20send_ui_to_client.',UI_TOOL_WORKFLOW,_0x4a8692(0x18a),_0x4a8692(0x18c),'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 _0x49dd48=>{const _0x59624a=_0x4a8692;try{return toCatalogToolResult(getUICatalog(_0x4f586c,{'catalogId':_0x49dd48[_0x59624a(0x156)],'componentNames':_0x49dd48[_0x59624a(0x15d)],'instructionMode':_0x49dd48[_0x59624a(0x16f)]}));}catch(_0x3f6d05){const _0xc1f529=_0x3f6d05 instanceof Error?_0x3f6d05[_0x59624a(0x187)]:String(_0x3f6d05);return toToolError(_0xc1f529);}});return{'list':_0x1ae6a8,'get':_0x133979};}function registerGenericUITool(_0x17b9ee,_0x7a0d21,_0x26b2e9={}){const _0x181bf3=_0x32dd7e,_0x2c5cda=_0x26b2e9[_0x181bf3(0x179)]??createUISendNormalizer({'registry':_0x7a0d21});return _0x17b9ee['registerTool'](UI_TOOL_NAME,{'title':_0x26b2e9['title'],'description':createGenericToolDescription(_0x7a0d21),'inputSchema':createSendUIInputSchema(),'outputSchema':sendUIOutputSchema,'annotations':{'readOnlyHint':![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':![],..._0x26b2e9[_0x181bf3(0x177)]}},async _0x1d11e6=>createUIToolCallResult(_0x1d11e6,_0x2c5cda));}function createUIMCPServer(_0x50e42c={}){const _0x7243d1=_0x32dd7e,_0x2abdf4=createUICatalogRegistry(_0x50e42c['catalogs'],_0x50e42c[_0x7243d1(0x169)],_0x50e42c['catalogInstructionMode']),_0x4df67c=_0x50e42c[_0x7243d1(0x179)]??createUIMCPNormalize({'catalogs':_0x50e42c[_0x7243d1(0x172)],'defaultCatalogId':_0x50e42c[_0x7243d1(0x169)]}),_0x455eb0=new McpServer({'name':_0x50e42c['server']?.[_0x7243d1(0x162)]??_0x7243d1(0x14d),'version':_0x50e42c[_0x7243d1(0x170)]?.['version']??'0.0.0'});return registerUICatalogResources(_0x455eb0,_0x2abdf4),registerUICatalogTools(_0x455eb0,_0x2abdf4),registerGenericUITool(_0x455eb0,_0x2abdf4,{..._0x50e42c,'normalize':_0x4df67c}),_0x455eb0;}export{_0x13fec9 as McpServer,_0x32ec85 as ResourceTemplate,createUIMCPNormalize,createUIMCPServer,createUIToolCallResult,registerGenericUITool,registerUICatalogResources,registerUICatalogTools};
1
+ const _0x545829=_0x1961;(function(_0x540161,_0x35fc40){const _0x3615d1=_0x1961,_0x5b0c82=_0x540161();while(!![]){try{const _0x212587=-parseInt(_0x3615d1(0x167))/0x1+-parseInt(_0x3615d1(0x15e))/0x2*(-parseInt(_0x3615d1(0x174))/0x3)+parseInt(_0x3615d1(0x177))/0x4+-parseInt(_0x3615d1(0x143))/0x5+parseInt(_0x3615d1(0x134))/0x6+parseInt(_0x3615d1(0x141))/0x7+-parseInt(_0x3615d1(0x170))/0x8;if(_0x212587===_0x35fc40)break;else _0x5b0c82['push'](_0x5b0c82['shift']());}catch(_0x5a5360){_0x5b0c82['push'](_0x5b0c82['shift']());}}}(_0xc495,0xf1092));import{McpServer}from'@modelcontextprotocol/sdk/server/mcp.js';import{McpServer as _0x2e9201}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,UI_TOOL_WORKFLOW}from'@agentic-ui-experience/ui-core/tool-mode';function _0xc495(){const _0xd607f0=['full','ownKeys','Final\x20step:\x20render\x20UI\x20on\x20the\x20client\x20by\x20submitting\x20structured\x20A2UI\x20messages.','catchall','-\x20Every\x20message\x20you\x20generate\x20must\x20include\x20\x22version\x22:\x20\x22','getClientCapabilities','UI\x20normalizer\x20result\x20must\x20begin\x20with\x20createSurface.','The\x20directory\x20is\x20returned\x20on\x20every\x20call,\x20so\x20you\x20can\x20widen\x20your\x20selection\x20with\x20a\x20second\x20call\x20if\x20the\x20first\x20one\x20missed\x20something.','uiMessages','add','Client\x20does\x20not\x20support\x20required\x20A2UI\x20Catalog\x20\x22','describe',';\x20do\x20not\x20guess\x20component\x20fields\x20from\x20this\x20tool\x20schema.','array','getPrototypeOf','2447794GgpZkl','UI\x20normalizer\x20uiJson\x20and\x20uiMessages\x20must\x20represent\x20the\x20same\x20JSON\x20value.','The\x20first\x20entry\x20must\x20be\x20`createSurface`,\x20carrying\x20the\x20catalog\x20id\x20reported\x20by\x20','supportedCatalogIds','normalize','extensions','UI\x20normalizer\x20uiJson\x20must\x20contain\x20valid\x20JSON.','server','protocolVersion','1861813SbphSl','Get\x20A2UI\x20Catalog','The\x20complete\x20A2UI\x20','object','delete','\x20capability\x20family).','a2ui-catalog','prototype','clientCapabilities','17498488XmShZI','annotations','message','number','3ponrtm','strict','null','7353692yDKcRw','uiJson','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.','union','A2UI\x20Catalog\x20','\x20UI\x20message\x20array.','lazy','string','createSurface','registerTool','-\x20Component\x20objects\x20belong\x20only\x20inside\x20updateComponents.components\x20and\x20must\x20conform\x20to\x20the\x20schemas\x20returned\x20by\x20get_ui_catalog.','title','_meta','9982542TpBAYZ','Do\x20not\x20send\x20`ui_json`;\x20do\x20not\x20serialize\x20the\x20messages\x20into\x20a\x20JSON\x20string.','descriptor','isArray','optional','Client\x20must\x20declare\x20A2UI\x20','instructionMode','Generated\x20an\x20interactive\x20A2UI\x20interface.','length','Step\x201\x20of\x20the\x20A2UI\x20MCP\x20workflow.\x20Call\x20this\x20before\x20','A2UI\x20catalog\x20instructions\x20and\x20component\x20schema.','Optional\x20expected\x20surface\x20id\x20for\x20this\x20UI\x20call.\x20When\x20supplied,\x20`messages[0].createSurface.surfaceId`\x20must\x20match\x20it.','isFinite','6044017HhVXMe','-\x20createSurface.surfaceId\x20must\x20match\x20the\x20top-level\x20surfaceId\x20when\x20supplied.','2765510FkPOga','resource','@agentic-ui-experience/ui-mcp','has','Client\x20A2UI\x20capabilities\x20are\x20malformed:\x20clientCapabilities[\x22','boolean','compact','surfaceId','keys','mode','0.0.0','Component\x20objects\x20belong\x20inside\x20a\x20later\x20`updateComponents.components`\x20array.'];_0xc495=function(){return _0xd607f0;};return _0xc495();}import{A2UI_MCP_CAPABILITY_FAMILY,A2UI_MCP_CAPABILITY_EXTENSION_ID}from'./client.js';const jsonValueSchema=z[_0x545829(0x12d)](()=>z[_0x545829(0x17a)]([z[_0x545829(0x176)](),z[_0x545829(0x148)](),z[_0x545829(0x173)](),z['string'](),z['array'](jsonValueSchema),z['record'](z['string'](),jsonValueSchema)])),jsonObjectSchema=z['record'](z['string'](),jsonValueSchema),getCatalogOutputSchema={'catalog':z[_0x545829(0x16a)]({'id':z[_0x545829(0x12e)](),'resourceUri':z[_0x545829(0x12e)](),'instructionMode':z['enum']([_0x545829(0x149),_0x545829(0x14f)]),'componentPurposes':z['record'](z['string'](),z['string']()),'descriptor':jsonObjectSchema,'instructions':z[_0x545829(0x12e)]()})},protocolVersionSchema=z['enum'](A2UI_SUPPORTED_PROTOCOL_VERSIONS),componentSchema=jsonObjectSchema,createSurfaceMessageSchema=z['object']({'version':protocolVersionSchema,'createSurface':z[_0x545829(0x16a)]({'surfaceId':z[_0x545829(0x12e)](),'catalogId':z['string']()})[_0x545829(0x152)](jsonValueSchema)})['catchall'](jsonValueSchema),updateComponentsMessageSchema=z[_0x545829(0x16a)]({'version':protocolVersionSchema,'updateComponents':z['object']({'surfaceId':z[_0x545829(0x12e)](),'components':z[_0x545829(0x15c)](componentSchema)})[_0x545829(0x152)](jsonValueSchema)})[_0x545829(0x152)](jsonValueSchema),updateDataModelMessageSchema=z[_0x545829(0x16a)]({'version':protocolVersionSchema,'updateDataModel':z['object']({'surfaceId':z['string'](),'path':z['string']()[_0x545829(0x138)](),'value':jsonValueSchema['optional']()})[_0x545829(0x152)](jsonValueSchema)})['catchall'](jsonValueSchema),deleteSurfaceMessageSchema=z[_0x545829(0x16a)]({'version':protocolVersionSchema,'deleteSurface':z[_0x545829(0x16a)]({'surfaceId':z['string']()})['catchall'](jsonValueSchema)})[_0x545829(0x152)](jsonValueSchema);function createSendUIInputSchema(_0x44612e=A2UI_DEFAULT_PROTOCOL_VERSION){const _0x5576bb=_0x545829;return{'surfaceId':z[_0x5576bb(0x12e)]()['optional']()[_0x5576bb(0x15a)](_0x5576bb(0x13f)),'messages':z[_0x5576bb(0x15c)](z['union']([createSurfaceMessageSchema,updateComponentsMessageSchema,updateDataModelMessageSchema,deleteSurfaceMessageSchema]))[_0x5576bb(0x15a)]([_0x5576bb(0x169)+_0x44612e+_0x5576bb(0x12c),'Every\x20message\x20you\x20generate\x20must\x20use\x20\x22version\x22:\x20\x22'+_0x44612e+'\x22;\x20no\x20other\x20wire\x20version\x20is\x20accepted.','Use\x20this\x20only\x20as\x20workflow\x20step\x202,\x20after\x20fetching\x20component\x20schemas\x20with\x20'+GET_UI_CATALOG_TOOL_NAME+'.','Build\x20component\x20objects\x20from\x20the\x20schema\x20returned\x20by\x20'+GET_UI_CATALOG_TOOL_NAME+_0x5576bb(0x15b),'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`.',_0x5576bb(0x160)+GET_UI_CATALOG_TOOL_NAME+'\x20at\x20`createSurface.catalogId`.',_0x5576bb(0x14e)]['join']('\x20'))};}function createGetCatalogInputSchema(){const _0x20bdfd=_0x545829;return{'componentNames':z['array'](z[_0x20bdfd(0x12e)]())['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['string']())['min'](0x1)[_0x20bdfd(0x138)]()['describe']('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['enum']([_0x20bdfd(0x149),_0x20bdfd(0x14f)])[_0x20bdfd(0x138)]()['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(_0x41a399){const _0x37620f=_0x545829,_0x6714e7=_0x41a399['protocolVersion']??A2UI_DEFAULT_PROTOCOL_VERSION;return[_0x37620f(0x151),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.','Catalog\x20id:\x20'+_0x41a399[_0x37620f(0x136)]['id']+'.','Message\x20list\x20rules:',_0x37620f(0x153)+_0x6714e7+'\x22.','-\x20The\x20first\x20message\x20must\x20be\x20createSurface.',_0x37620f(0x142),'-\x20createSurface.catalogId\x20must\x20be\x20\x22'+_0x41a399[_0x37620f(0x136)]['id']+'\x22.','-\x20Later\x20updateComponents/updateDataModel/deleteSurface\x20messages\x20must\x20target\x20the\x20same\x20surface.',_0x37620f(0x131),_0x37620f(0x135)]['join']('\x0a\x0a');}function createUIMCPNormalize(_0x509566={}){const _0x3e3664=_0x545829;return createUISendNormalizer({'mode':_0x509566[_0x3e3664(0x14c)],'surfaceId':_0x509566['surfaceId'],'catalog':_0x509566['catalog']});}const defaultNormalize=createUIMCPNormalize(),carrierValidators=new WeakMap();function getCarrierValidator(_0x4c50b5){const _0xdadf89=_0x545829;if(_0x4c50b5===void 0x0)return defaultNormalize;const _0x363196=carrierValidators['get'](_0x4c50b5);if(_0x363196)return _0x363196;const _0x463915=createUIMCPNormalize({'mode':_0xdadf89(0x175),'catalog':_0x4c50b5});return carrierValidators['set'](_0x4c50b5,_0x463915),_0x463915;}function isJsonObject(_0x27a9fe){return typeof _0x27a9fe==='object'&&_0x27a9fe!==null&&!Array['isArray'](_0x27a9fe);}function _0x1961(_0x408938,_0x7e961e){_0x408938=_0x408938-0x12b;const _0xc4955=_0xc495();let _0x196138=_0xc4955[_0x408938];return _0x196138;}function isPlainJsonObject(_0x52cd7a){const _0x390870=_0x545829;if(!isJsonObject(_0x52cd7a))return![];const _0xbb6943=Object[_0x390870(0x15d)](_0x52cd7a);return _0xbb6943===Object[_0x390870(0x16e)]||_0xbb6943===null;}function hasOwn(_0x1e05e0,_0x2bb8d0){const _0xd901e=_0x545829;return Object[_0xd901e(0x16e)]['hasOwnProperty']['call'](_0x1e05e0,_0x2bb8d0);}function jsonValuesEqual(_0x42e322,_0x55c55d,_0x14e966=new WeakSet(),_0x324373=new WeakSet()){const _0x490a8e=_0x545829;if(_0x42e322===null||_0x55c55d===null)return _0x42e322===_0x55c55d;if(typeof _0x42e322!==typeof _0x55c55d)return![];if(typeof _0x42e322===_0x490a8e(0x12e)||typeof _0x42e322===_0x490a8e(0x148))return _0x42e322===_0x55c55d;if(typeof _0x42e322==='number')return Number[_0x490a8e(0x140)](_0x42e322)&&Number[_0x490a8e(0x140)](_0x55c55d)&&_0x42e322===_0x55c55d;if(typeof _0x42e322!==_0x490a8e(0x16a)||typeof _0x55c55d!=='object')return![];if(_0x14e966[_0x490a8e(0x146)](_0x42e322)||_0x324373['has'](_0x55c55d))return![];_0x14e966[_0x490a8e(0x158)](_0x42e322),_0x324373['add'](_0x55c55d);try{if(Array[_0x490a8e(0x137)](_0x42e322)||Array[_0x490a8e(0x137)](_0x55c55d)){if(!Array[_0x490a8e(0x137)](_0x42e322)||!Array[_0x490a8e(0x137)](_0x55c55d))return![];if(_0x42e322[_0x490a8e(0x13c)]!==_0x55c55d['length'])return![];if(Reflect['ownKeys'](_0x42e322)['length']!==_0x42e322[_0x490a8e(0x13c)]+0x1)return![];if(Reflect[_0x490a8e(0x150)](_0x55c55d)[_0x490a8e(0x13c)]!==_0x55c55d[_0x490a8e(0x13c)]+0x1)return![];for(let _0x235660=0x0;_0x235660<_0x42e322[_0x490a8e(0x13c)];_0x235660+=0x1){if(!hasOwn(_0x42e322,String(_0x235660)))return![];if(!hasOwn(_0x55c55d,String(_0x235660)))return![];if(!jsonValuesEqual(_0x42e322[_0x235660],_0x55c55d[_0x235660],_0x14e966,_0x324373))return![];}return!![];}if(!isPlainJsonObject(_0x42e322)||!isPlainJsonObject(_0x55c55d))return![];const _0x3d339e=Object[_0x490a8e(0x14b)](_0x42e322),_0x14ea9b=Object['keys'](_0x55c55d);if(Reflect[_0x490a8e(0x150)](_0x42e322)[_0x490a8e(0x13c)]!==_0x3d339e['length'])return![];if(Reflect[_0x490a8e(0x150)](_0x55c55d)['length']!==_0x14ea9b['length'])return![];if(_0x3d339e['length']!==_0x14ea9b['length'])return![];return _0x3d339e['every'](_0x38a25e=>hasOwn(_0x55c55d,_0x38a25e)&&jsonValuesEqual(_0x42e322[_0x38a25e],_0x55c55d[_0x38a25e],_0x14e966,_0x324373));}finally{_0x14e966[_0x490a8e(0x16b)](_0x42e322),_0x324373['delete'](_0x55c55d);}}function getNormalizedSurfaceId(_0x117b50,_0x29b1fb,_0x5d382e){const _0x205d69=_0x545829;if(typeof _0x117b50[_0x205d69(0x178)]!==_0x205d69(0x12e)||!Array['isArray'](_0x117b50[_0x205d69(0x157)]))throw new Error('UI\x20normalizer\x20must\x20return\x20uiJson\x20and\x20uiMessages.');let _0x1002b9;try{_0x1002b9=JSON['parse'](_0x117b50[_0x205d69(0x178)]);}catch{throw new Error(_0x205d69(0x164));}if(!jsonValuesEqual(_0x1002b9,_0x117b50[_0x205d69(0x157)]))throw new Error(_0x205d69(0x15f));if(!Array[_0x205d69(0x137)](_0x1002b9)||!isJsonObject(_0x1002b9[0x0]))throw new Error(_0x205d69(0x155));const _0x24846d=_0x1002b9[0x0][_0x205d69(0x12f)];if(!isJsonObject(_0x24846d)||typeof _0x24846d['surfaceId']!==_0x205d69(0x12e))throw new Error(_0x205d69(0x155));return getCarrierValidator(_0x5d382e['catalog'])({'messages':_0x1002b9,..._0x29b1fb===void 0x0?{}:{'surfaceId':_0x29b1fb}}),_0x24846d['surfaceId'];}function getA2UIClientCapability(_0x5898f4,_0x5d41b9){const _0x1469f8=_0x545829;if(isJsonObject(_0x5d41b9)&&hasOwn(_0x5d41b9,'a2ui'))return _0x5d41b9['a2ui'];const _0x89ead=_0x5898f4['server'][_0x1469f8(0x154)]();if(!isJsonObject(_0x89ead))return void 0x0;if(hasOwn(_0x89ead,'a2ui'))return _0x89ead['a2ui'];const _0x5bf691=_0x89ead[_0x1469f8(0x163)];return isJsonObject(_0x5bf691)&&hasOwn(_0x5bf691,A2UI_MCP_CAPABILITY_EXTENSION_ID)?_0x5bf691[A2UI_MCP_CAPABILITY_EXTENSION_ID]:void 0x0;}function validateA2UIClientCapability(_0xf85e9f,_0x342cd6){const _0x437800=_0x545829;if(!isJsonObject(_0xf85e9f))return _0x437800(0x139)+A2UI_MCP_CAPABILITY_FAMILY+'\x20capability-family\x20support\x20for\x20Catalog\x20\x22'+_0x342cd6+'\x22.';const _0x1548b7=_0xf85e9f[_0x437800(0x16f)];if(!isJsonObject(_0x1548b7))return'Client\x20A2UI\x20capabilities\x20are\x20malformed:\x20clientCapabilities\x20is\x20required.';const _0x5d816e=_0x1548b7[A2UI_MCP_CAPABILITY_FAMILY];if(!isJsonObject(_0x5d816e)||!Array['isArray'](_0x5d816e[_0x437800(0x161)]))return _0x437800(0x147)+A2UI_MCP_CAPABILITY_FAMILY+'\x22].supportedCatalogIds\x20must\x20be\x20an\x20array.';if(!_0x5d816e[_0x437800(0x161)]['every'](_0x380faf=>typeof _0x380faf===_0x437800(0x12e)))return'Client\x20A2UI\x20capabilities\x20are\x20malformed:\x20supportedCatalogIds\x20must\x20contain\x20only\x20strings.';if(!_0x5d816e[_0x437800(0x161)]['includes'](_0x342cd6))return _0x437800(0x159)+_0x342cd6+'\x22\x20('+A2UI_MCP_CAPABILITY_FAMILY+_0x437800(0x16c);return void 0x0;}function toToolError(_0x4fa423){return{'isError':!![],'content':[{'type':'text','text':_0x4fa423}]};}function toToolResult(_0x1d022f,_0x5f212e,_0xf48210){const _0x4c166e=_0x545829,_0x4459ea=getNormalizedSurfaceId(_0x1d022f,_0x5f212e,_0xf48210),_0xe24e04={'type':_0x4c166e(0x144),'resource':{'uri':'a2ui://surface/'+encodeURIComponent(_0x4459ea),'mimeType':A2UI_MESSAGE_MEDIA_TYPE,'text':_0x1d022f['uiJson']}};return{'content':[{'type':'text','text':_0x4c166e(0x13b)},_0xe24e04]};}function toCatalogToolResult(_0x44874e){return{'content':[{'type':'text','text':JSON['stringify'](_0x44874e)}],'structuredContent':_0x44874e};}async function createUIToolCallResult(_0x2b48db,_0x584766=defaultNormalize,_0x3e8ceb={}){const _0x12c027=_0x545829;try{const _0x3b4fe0=_0x2b48db[_0x12c027(0x14a)],_0x1643de=await _0x584766(_0x2b48db);return toToolResult(_0x1643de,_0x3b4fe0,_0x3e8ceb);}catch(_0x369a0b){const _0x55012b=_0x369a0b instanceof Error?_0x369a0b[_0x12c027(0x172)]:String(_0x369a0b);return toToolError(_0x55012b);}}function toMCPResourceResult(_0x473a15){return _0x473a15;}function registerUICatalogResources(_0x529731,_0x558e79){const _0x56fc0f=_0x545829,_0x2e5a63=_0x529731['registerResource'](_0x56fc0f(0x16d),CATALOG_RESOURCE_URI,{'title':_0x56fc0f(0x12b)+_0x558e79[_0x56fc0f(0x136)]['id'],'description':_0x56fc0f(0x13e),'mimeType':'application/json'},_0x32f3c0=>toMCPResourceResult(createUICatalogResourcePayload(_0x558e79,_0x32f3c0['href'])));return{'catalog':_0x2e5a63};}function registerUICatalogTools(_0x57e2b3,_0x2f8871){const _0x2c98af=_0x545829,_0x2da76b=_0x57e2b3[_0x2c98af(0x130)](GET_UI_CATALOG_TOOL_NAME,{'title':_0x2c98af(0x168),'description':[_0x2c98af(0x13d)+UI_TOOL_NAME+'.',UI_TOOL_WORKFLOW_ORDER,_0x2c98af(0x179),_0x2c98af(0x156),'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 _0x5683dc=>{const _0x39ae69=_0x2c98af;try{return toCatalogToolResult(getUICatalog(_0x2f8871,{'componentNames':_0x5683dc['componentNames'],'functionNames':_0x5683dc['functionNames'],'instructionMode':_0x5683dc[_0x39ae69(0x13a)]}));}catch(_0x1af9e9){const _0x50d8a6=_0x1af9e9 instanceof Error?_0x1af9e9[_0x39ae69(0x172)]:String(_0x1af9e9);return toToolError(_0x50d8a6);}});return{'get':_0x2da76b};}function registerGenericUITool(_0x398ba6,_0x1a1c6d,_0x34a689={}){const _0x1d1b57=_0x545829,_0x54c39b=_0x34a689['normalize']??createUISendNormalizer({'catalog':_0x1a1c6d});return _0x398ba6[_0x1d1b57(0x130)](UI_TOOL_NAME,{'title':_0x34a689[_0x1d1b57(0x132)],'description':createGenericToolDescription(_0x1a1c6d),'inputSchema':createSendUIInputSchema(_0x1a1c6d[_0x1d1b57(0x166)]??A2UI_DEFAULT_PROTOCOL_VERSION),'annotations':{'readOnlyHint':![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':![],..._0x34a689[_0x1d1b57(0x171)]}},async(_0x1bb7be,_0xca82d3)=>{const _0xb3cfe4=_0x1d1b57,_0x31d967=validateA2UIClientCapability(getA2UIClientCapability(_0x398ba6,_0xca82d3[_0xb3cfe4(0x133)]),_0x1a1c6d['descriptor']['id']);if(_0x31d967)return toToolError(_0x31d967);return createUIToolCallResult(_0x1bb7be,_0x54c39b,{'catalog':_0x1a1c6d});});}function createUIMCPServer(_0x42b1ec={}){const _0x45c238=_0x545829,_0x4f73c6=createUIToolCatalog(_0x42b1ec['catalog'],_0x42b1ec['catalogInstructionMode'],_0x42b1ec['protocolVersion']),_0x375747=_0x42b1ec[_0x45c238(0x162)]??createUISendNormalizer({'catalog':_0x4f73c6}),_0x595873=new McpServer({'name':_0x42b1ec[_0x45c238(0x165)]?.['name']??_0x45c238(0x145),'version':_0x42b1ec['server']?.['version']??_0x45c238(0x14d)});return registerUICatalogResources(_0x595873,_0x4f73c6),registerUICatalogTools(_0x595873,_0x4f73c6),registerGenericUITool(_0x595873,_0x4f73c6,{..._0x42b1ec,'normalize':_0x375747}),_0x595873;}export{_0x2e9201 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.3",
3
+ "version": "0.0.1-beta.5",
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": [
@@ -22,8 +26,8 @@
22
26
  },
23
27
  "dependencies": {
24
28
  "@modelcontextprotocol/sdk": "^1.29.0",
25
- "zod": "^3.25.76",
26
- "@agentic-ui-experience/ui-core": "0.0.1-beta.3"
29
+ "zod": "^4.4.3",
30
+ "@agentic-ui-experience/ui-core": "0.0.1-beta.5"
27
31
  },
28
32
  "devDependencies": {
29
33
  "@types/node": "^24.10.1"