@agentic-ui-experience/ui-mcp 0.0.1-beta.5 → 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 +125 -58
- package/dist/cli.js +1 -1
- package/dist/client.js +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.js +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
# @agentic-ui-experience/ui-mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
MCP server adapter for this project's A2UI integration.
|
|
4
4
|
|
|
5
|
-
This package does not render or ingest UI. It exposes
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
its messages
|
|
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`.
|
|
9
10
|
|
|
10
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).
|
|
11
12
|
|
|
@@ -37,14 +38,73 @@ to have a different identity.
|
|
|
37
38
|
import { createUIMCPServer } from "@agentic-ui-experience/ui-mcp";
|
|
38
39
|
|
|
39
40
|
const server = createUIMCPServer({
|
|
40
|
-
catalog: weatherPromptDescriptor
|
|
41
|
-
catalogInstructionMode: "compact"
|
|
41
|
+
catalog: weatherPromptDescriptor
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
await server.connect(transport);
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
##
|
|
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.
|
|
48
108
|
|
|
49
109
|
A successful `send_ui_to_client` call always returns fallback text followed by
|
|
50
110
|
one canonical A2UI embedded resource:
|
|
@@ -82,6 +142,11 @@ the parsed carrier against its configured Catalog and the call's optional
|
|
|
82
142
|
resource URI. Whitespace and object-key order may differ; malformed, divergent,
|
|
83
143
|
or protocol-invalid representations become tool errors.
|
|
84
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
|
+
|
|
85
150
|
### Catalog capability negotiation
|
|
86
151
|
|
|
87
152
|
Before accepting UI, the server requires the client to advertise the exact
|
|
@@ -222,8 +287,7 @@ A custom catalog can be loaded from an ESM module:
|
|
|
222
287
|
```bash
|
|
223
288
|
ax-ui-mcp \
|
|
224
289
|
--transport http \
|
|
225
|
-
--catalog ./weather-catalog.js
|
|
226
|
-
--catalog-instruction-mode compact
|
|
290
|
+
--catalog ./weather-catalog.js
|
|
227
291
|
```
|
|
228
292
|
|
|
229
293
|
The CLI generates `v0.9.1` instructions and accepts only
|
|
@@ -246,21 +310,22 @@ export const catalog = {
|
|
|
246
310
|
};
|
|
247
311
|
```
|
|
248
312
|
|
|
249
|
-
|
|
313
|
+
## Agent workflow
|
|
314
|
+
|
|
315
|
+
The default discovery flow is:
|
|
250
316
|
|
|
251
317
|
```ts
|
|
252
|
-
// Step 1a: discover
|
|
253
|
-
//
|
|
254
|
-
//
|
|
318
|
+
// Step 1a: discover the catalog. With no componentNames, catalog.kind is
|
|
319
|
+
// "directory", componentPurposes is complete, and component definitions
|
|
320
|
+
// are absent.
|
|
255
321
|
get_ui_catalog();
|
|
256
322
|
|
|
257
|
-
// Step 1b:
|
|
258
|
-
//
|
|
259
|
-
//
|
|
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.
|
|
260
326
|
get_ui_catalog({
|
|
261
327
|
componentNames: ["Card", "Text", "WeatherIcon"],
|
|
262
|
-
functionNames: ["formatDate"]
|
|
263
|
-
instructionMode: "full"
|
|
328
|
+
functionNames: ["formatDate"]
|
|
264
329
|
});
|
|
265
330
|
|
|
266
331
|
// Step 2: submit messages built from the catalog returned by get_ui_catalog.
|
|
@@ -282,53 +347,55 @@ the configured catalog. Once the Host forwards these messages to its Runtime, a
|
|
|
282
347
|
`surfaceId` must be unique among active surfaces: a duplicate active
|
|
283
348
|
`createSurface` is an error, while an ID may be reused after `deleteSurface`.
|
|
284
349
|
|
|
285
|
-
`componentNames`
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
`
|
|
295
|
-
`
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
`
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
`
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
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.
|
|
318
383
|
|
|
319
384
|
`send_ui_to_client` accepts structured messages. Do not pass `ui_json`, do not
|
|
320
385
|
serialize the message list into a JSON string, and do not pass static catalog
|
|
321
386
|
schema such as `customComponents` in the tool call.
|
|
322
387
|
|
|
323
|
-
`send_ui_to_client` is the final submission tool, not the
|
|
324
|
-
|
|
325
|
-
|
|
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.
|
|
326
392
|
|
|
327
393
|
The catalog is also exposed as an MCP resource with media type
|
|
328
394
|
`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
|
|
330
|
-
clients rather than
|
|
331
|
-
component and
|
|
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`:
|
|
332
399
|
|
|
333
400
|
```text
|
|
334
401
|
a2ui://catalog
|
package/dist/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
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);});
|
|
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);});
|
package/dist/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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
3
|
import { type A2UIProtocolVersion, type CatalogPromptDescriptor } from "@agentic-ui-experience/ui-core";
|
|
4
|
-
import { type UIGetCatalogArguments, type UIGetCatalogResult, type UISendToolArguments, type UISendToolResult, type UIToolCatalog
|
|
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
|
|
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>;
|
|
@@ -28,7 +28,8 @@ export interface CreateUIToolCallResultOptions {
|
|
|
28
28
|
export interface CreateUIMCPServerOptions {
|
|
29
29
|
/** The single catalog this server serves. Defaults to the A2UI basic catalog. */
|
|
30
30
|
catalog?: CatalogPromptDescriptor;
|
|
31
|
-
|
|
31
|
+
/** How the model receives schemas. Defaults to discovery via get_ui_catalog. */
|
|
32
|
+
schemaDelivery?: UIMCPSchemaDelivery;
|
|
32
33
|
/** Version requested in generated tool and catalog instructions. Defaults to v0.9.1. */
|
|
33
34
|
protocolVersion?: A2UIProtocolVersion;
|
|
34
35
|
title?: string;
|
|
@@ -56,7 +57,7 @@ export declare function registerUICatalogTools(server: McpServer, catalog: UIMCP
|
|
|
56
57
|
* scenario-independent; catalog-specific schema comes from the one catalog it
|
|
57
58
|
* was configured with.
|
|
58
59
|
*/
|
|
59
|
-
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;
|
|
60
61
|
/**
|
|
61
62
|
* Create a generic A2UI MCP server. Transport ownership stays with the caller
|
|
62
63
|
* so this can be used with stdio, SSE, or streamable HTTP.
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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};
|
|
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.
|
|
3
|
+
"version": "0.0.1-beta.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
],
|
|
23
23
|
"publishConfig": {
|
|
24
24
|
"access": "public",
|
|
25
|
-
"tag": "
|
|
25
|
+
"tag": "latest"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
29
29
|
"zod": "^4.4.3",
|
|
30
|
-
"@agentic-ui-experience/ui-core": "0.0.1-beta.
|
|
30
|
+
"@agentic-ui-experience/ui-core": "0.0.1-beta.6"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "^24.10.1"
|