@agentic-ui-experience/ui-mcp 0.0.1-beta.4 → 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 +144 -9
- package/dist/cli.js +1 -1
- package/dist/client.d.ts +29 -0
- package/dist/client.js +1 -0
- package/dist/index.d.ts +8 -2
- package/dist/index.js +1 -1
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Generic MCP server adapter for A2UI.
|
|
4
4
|
|
|
5
|
-
This package does not render or ingest UI. It exposes
|
|
6
|
-
and a `send_ui_to_client` MCP tool that returns validated A2UI messages
|
|
7
|
-
`
|
|
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`.
|
|
8
9
|
|
|
9
|
-
MCP is one integration path for producing the project's UI Message Contract. The Host app still owns the Transport that forwards the result to the frontend; this package does not choose or operate that Transport. See the [project glossary](../../docs/glossary.md).
|
|
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).
|
|
10
11
|
|
|
11
12
|
`@agentic-ui-experience/ui-mcp` is an MCP adapter over
|
|
12
13
|
`@agentic-ui-experience/ui-core/tool-mode`. Catalog configuration, catalog resource
|
|
@@ -14,12 +15,23 @@ payloads, catalog filtering, and `send_ui_to_client` normalization live in
|
|
|
14
15
|
`ui-core`; this package only maps those provider-neutral operations onto MCP
|
|
15
16
|
resources and tools.
|
|
16
17
|
|
|
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
|
+
|
|
17
26
|
A server serves exactly one catalog. A2UI fixes a surface's catalog at
|
|
18
27
|
`createSurface` time and never composes two catalogs into one component tree, and
|
|
19
28
|
the upstream agent SDK selects a single catalog before it prompts the model, so
|
|
20
29
|
the catalog is a server configuration rather than a model choice. To serve more
|
|
21
30
|
than one vocabulary, merge them when you define the catalog. Omit `catalog` to
|
|
22
|
-
serve
|
|
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.
|
|
23
35
|
|
|
24
36
|
```ts
|
|
25
37
|
import { createUIMCPServer } from "@agentic-ui-experience/ui-mcp";
|
|
@@ -32,6 +44,117 @@ const server = createUIMCPServer({
|
|
|
32
44
|
await server.connect(transport);
|
|
33
45
|
```
|
|
34
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
|
+
|
|
35
158
|
## CLI
|
|
36
159
|
|
|
37
160
|
`@agentic-ui-experience/ui-mcp` also ships a small MCP server CLI:
|
|
@@ -72,6 +195,8 @@ pnpm --filter @agentic-ui-experience/ui-mcp inspector
|
|
|
72
195
|
The HTTP server is stateless: each MCP request gets a fresh MCP server and
|
|
73
196
|
`StreamableHTTPServerTransport`. This matches the SDK's stateless Streamable
|
|
74
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.
|
|
75
200
|
|
|
76
201
|
CORS is closed by default. To expose the HTTP endpoint to browser clients, pass
|
|
77
202
|
one or more explicit origins:
|
|
@@ -101,6 +226,9 @@ ax-ui-mcp \
|
|
|
101
226
|
--catalog-instruction-mode compact
|
|
102
227
|
```
|
|
103
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
|
+
|
|
104
232
|
With the package scripts, append extra CLI flags after `--`:
|
|
105
233
|
|
|
106
234
|
```bash
|
|
@@ -139,15 +267,20 @@ get_ui_catalog({
|
|
|
139
267
|
send_ui_to_client({
|
|
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
|
|
|
276
|
+
The MCP client, not the model-visible arguments above, supplies the negotiated
|
|
277
|
+
A2UI capability through initialize state or request `_meta`.
|
|
278
|
+
|
|
148
279
|
Neither tool takes a `catalogId`. The server pins the catalog, so there is
|
|
149
280
|
nothing for the model to choose; `createSurface.catalogId` is validated against
|
|
150
|
-
the configured catalog.
|
|
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`.
|
|
151
284
|
|
|
152
285
|
`componentNames` is what narrows the response: supply it and the server returns
|
|
153
286
|
only those basic and custom component schemas.
|
|
@@ -191,7 +324,9 @@ schema such as `customComponents` in the tool call.
|
|
|
191
324
|
tool. Agents should call `get_ui_catalog` before using it, then build component
|
|
192
325
|
objects from the returned catalog schema.
|
|
193
326
|
|
|
194
|
-
The catalog is also exposed as an MCP resource
|
|
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
|
|
195
330
|
clients rather than picked from by a model, so this payload carries every
|
|
196
331
|
component and function:
|
|
197
332
|
|
package/dist/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const _0x24bdc9=_0x55a8;function _0x55a8(_0x48c825,_0x5caa02){_0x48c825=_0x48c825-0x19f;const _0x2c4013=_0x2c40();let _0x55a8ad=_0x2c4013[_0x48c825];return _0x55a8ad;}(function(_0x298a60,_0xadd7e3){const _0x3dc739=_0x55a8,_0x2eb83a=_0x298a60();while(!![]){try{const _0x3f1ca2=-parseInt(_0x3dc739(0x1c8))/0x1+parseInt(_0x3dc739(0x1a5))/0x2+parseInt(_0x3dc739(0x1b6))/0x3+-parseInt(_0x3dc739(0x1cc))/0x4+parseInt(_0x3dc739(0x1c4))/0x5+-parseInt(_0x3dc739(0x1b1))/0x6*(-parseInt(_0x3dc739(0x1a2))/0x7)+parseInt(_0x3dc739(0x1d3))/0x8*(-parseInt(_0x3dc739(0x1b9))/0x9);if(_0x3f1ca2===_0xadd7e3)break;else _0x2eb83a['push'](_0x2eb83a['shift']());}catch(_0xc3c2da){_0x2eb83a['push'](_0x2eb83a['shift']());}}}(_0x2c40,0x21699));function _0x2c40(){const _0x2a6b7b=['408AUqXrO','once','stderr','full','message','endpoint','headers','catch','127.0.0.1','1169qDiPqL','string','\x20catalogs.\x20A\x20server\x20serves\x20exactly\x20one;\x20merge\x20them\x20into\x20a\x20single\x20descriptor.','383966vDRogl','catalogInstructionMode','@agentic-ui-experience/ui-mcp\x20listening\x20on\x20http://','\x22\x20exported\x20','values','Access-Control-Allow-Headers','Content-Type,\x20Accept,\x20Authorization,\x20MCP-Protocol-Version,\x20Mcp-Session-Id,\x20Last-Event-ID','GET,POST,DELETE,OPTIONS','catalogs','\x22\x20exported\x20an\x20invalid\x20catalog\x20descriptor.','setHeader','catalog','6942uSijQR','transport','\x22.\x20Expected\x20an\x20integer\x20from\x201\x20to\x2065535.','stdout','2.0','604485iOHyQP','version','write','63081bFhLrf','catalog-instruction-mode','end','compact','OPTIONS','host','SIGTERM','isArray','@agentic-ui-experience/ui-mcp\x0a\x0aUsage:\x0a\x20\x20ax-ui-mcp\x20[options]\x0a\x0aOptions:\x0a\x20\x20--transport\x20<stdio|http>\x20\x20\x20\x20\x20\x20MCP\x20transport\x20to\x20start.\x20Default:\x20stdio\x0a\x20\x20--host\x20<host>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20HTTP\x20bind\x20host.\x20Default:\x20127.0.0.1\x0a\x20\x20--port\x20<port>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20HTTP\x20bind\x20port.\x20Default:\x203001\x0a\x20\x20--endpoint\x20<path>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20HTTP\x20MCP\x20endpoint.\x20Default:\x20/mcp\x0a\x20\x20--cors-origin\x20<origin>\x20\x20\x20\x20\x20\x20\x20\x20Allow\x20a\x20browser\x20origin.\x20Repeatable.\x20Use\x20\x22*\x22\x20for\x20development.\x0a\x20\x20--catalog\x20<module>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ESM\x20module\x20exporting\x20the\x20CatalogPromptDescriptor\x20to\x20serve.\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Defaults\x20to\x20the\x20A2UI\x20basic\x20catalog.\x0a\x20\x20--catalog-instruction-mode\x20<compact|full>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Default\x20get_ui_catalog\x20instruction\x20detail.\x20Default:\x20compact\x0a\x20\x20--name\x20<name>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20MCP\x20server\x20name.\x20Default:\x20@agentic-ui-experience/ui-mcp\x0a\x20\x20--version\x20<version>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20MCP\x20server\x20version.\x20Default:\x200.0.0\x0a\x20\x20--help\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Show\x20this\x20help.\x0a\x0aA\x20server\x20serves\x20exactly\x20one\x20catalog,\x20matching\x20A2UI\x27s\x20model\x20where\x20a\x20surface\x27s\x0acatalog\x20is\x20fixed\x20at\x20createSurface\x20time.\x20Combine\x20vocabularies\x20when\x20you\x20define\x20the\x0acatalog,\x20not\x20at\x20runtime.\x0a\x0aCatalog\x20modules\x20may\x20export\x20one\x20of:\x0a\x20\x20export\x20default\x20descriptor\x0a\x20\x20export\x20const\x20catalog\x20=\x20descriptor\x0a','Not\x20Found','close','461555HGuHNw','Internal\x20MCP\x20server\x20error','length','help','96028KxRKSn','stdio','Access-Control-Allow-Methods','Catalog\x20module\x20\x22','354656enIJyu','Unsupported\x20transport\x20\x22','serverName','connect','port','3001','Access-Control-Allow-Origin'];_0x2c40=function(){return _0x2a6b7b;};return _0x2c40();}import{createServer}from'node:http';import{resolve}from'node:path';import{pathToFileURL}from'node:url';import{parseArgs}from'node:util';import{StreamableHTTPServerTransport}from'@modelcontextprotocol/sdk/server/streamableHttp.js';import{StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import{createUIMCPServer}from'./index.js';const helpText=_0x24bdc9(0x1c1);function stringValue(_0x218783,_0x3507a9){return typeof _0x218783==='string'&&_0x218783['length']>0x0?_0x218783:_0x3507a9;}function optionalStringValue(_0x185ec6){const _0x52150f=_0x24bdc9;return typeof _0x185ec6==='string'&&_0x185ec6[_0x52150f(0x1c6)]>0x0?_0x185ec6:void 0x0;}function stringArrayValue(_0x4643e7){const _0x249eb2=_0x24bdc9;if(Array[_0x249eb2(0x1c0)](_0x4643e7))return _0x4643e7;if(typeof _0x4643e7==='string'&&_0x4643e7['length']>0x0)return[_0x4643e7];return[];}function parseTransport(_0x587053){const _0x5bfdd7=_0x24bdc9;if(_0x587053===_0x5bfdd7(0x1c9)||_0x587053==='http')return _0x587053;throw new Error(_0x5bfdd7(0x1cd)+_0x587053+'\x22.\x20Expected\x20\x22stdio\x22\x20or\x20\x22http\x22.');}function parseCatalogInstructionMode(_0x300f58){const _0x375090=_0x24bdc9;if(_0x300f58===_0x375090(0x1bc)||_0x300f58===_0x375090(0x1d6))return _0x300f58;throw new Error('Unsupported\x20catalog\x20instruction\x20mode\x20\x22'+_0x300f58+'\x22.\x20Expected\x20\x22compact\x22\x20or\x20\x22full\x22.');}function parsePort(_0x126a95){const _0x11f6de=_0x24bdc9,_0x2c8ad0=Number(_0x126a95);if(!Number['isInteger'](_0x2c8ad0)||_0x2c8ad0<0x1||_0x2c8ad0>0xffff)throw new Error('Invalid\x20--port\x20\x22'+_0x126a95+_0x11f6de(0x1b3));return _0x2c8ad0;}function normalizeEndpoint(_0x1385a3){if(!_0x1385a3['startsWith']('/'))return'/'+_0x1385a3;return _0x1385a3;}function isCatalogDescriptor(_0x5d3a88){const _0x111c92=_0x24bdc9;return!!_0x5d3a88&&typeof _0x5d3a88==='object'&&!Array[_0x111c92(0x1c0)](_0x5d3a88)&&typeof _0x5d3a88['id']===_0x111c92(0x1a3)&&Array['isArray'](_0x5d3a88['baseComponentNames']);}function readCatalogExport(_0x4d8171,_0x8c3f41){const _0x55b9e2=_0x24bdc9,_0x2b0dd0=_0x4d8171[_0x55b9e2(0x1ad)]??_0x4d8171['catalog']??_0x4d8171['default'];if(Array[_0x55b9e2(0x1c0)](_0x2b0dd0)){if(_0x2b0dd0['length']!==0x1)throw new Error(_0x55b9e2(0x1cb)+_0x8c3f41+_0x55b9e2(0x1a8)+_0x2b0dd0['length']+_0x55b9e2(0x1a4));const [_0x6e46b2]=_0x2b0dd0;if(!isCatalogDescriptor(_0x6e46b2))throw new Error('Catalog\x20module\x20\x22'+_0x8c3f41+_0x55b9e2(0x1ae));return _0x6e46b2;}if(_0x2b0dd0===void 0x0)throw new Error('Catalog\x20module\x20\x22'+_0x8c3f41+'\x22\x20did\x20not\x20export\x20a\x20catalog\x20descriptor.');if(!isCatalogDescriptor(_0x2b0dd0))throw new Error('Catalog\x20module\x20\x22'+_0x8c3f41+'\x22\x20exported\x20an\x20invalid\x20catalog\x20descriptor.');return _0x2b0dd0;}async function loadCatalog(_0x150693){if(_0x150693===void 0x0)return void 0x0;const _0x1d045d=await import(pathToFileURL(resolve(_0x150693))['href']);return readCatalogExport(_0x1d045d,_0x150693);}async function parseCliOptions(){const _0x93d339=_0x24bdc9,_0x4c2c1c=parseArgs({'allowPositionals':![],'options':{'transport':{'type':'string'},'host':{'type':_0x93d339(0x1a3)},'port':{'type':'string'},'endpoint':{'type':_0x93d339(0x1a3)},'cors-origin':{'type':_0x93d339(0x1a3),'multiple':!![]},'catalog':{'type':_0x93d339(0x1a3)},'catalog-instruction-mode':{'type':_0x93d339(0x1a3)},'name':{'type':'string'},'version':{'type':_0x93d339(0x1a3)},'help':{'type':'boolean','short':'h'}}});_0x4c2c1c[_0x93d339(0x1a9)][_0x93d339(0x1c7)]&&(process[_0x93d339(0x1b4)]['write'](helpText),process['exit'](0x0));const _0x58d483=await loadCatalog(optionalStringValue(_0x4c2c1c[_0x93d339(0x1a9)][_0x93d339(0x1b0)]));return{'transport':parseTransport(stringValue(_0x4c2c1c[_0x93d339(0x1a9)][_0x93d339(0x1b2)],'stdio')),'host':stringValue(_0x4c2c1c[_0x93d339(0x1a9)][_0x93d339(0x1be)],_0x93d339(0x1a1)),'port':parsePort(stringValue(_0x4c2c1c['values'][_0x93d339(0x1d0)],_0x93d339(0x1d1))),'endpoint':normalizeEndpoint(stringValue(_0x4c2c1c['values'][_0x93d339(0x1d8)],'/mcp')),'corsOrigins':stringArrayValue(_0x4c2c1c['values']['cors-origin']),..._0x58d483?{'catalog':_0x58d483}:{},'catalogInstructionMode':parseCatalogInstructionMode(stringValue(_0x4c2c1c['values'][_0x93d339(0x1ba)],'compact')),...optionalStringValue(_0x4c2c1c[_0x93d339(0x1a9)]['name'])?{'serverName':optionalStringValue(_0x4c2c1c['values']['name'])}:{},...optionalStringValue(_0x4c2c1c[_0x93d339(0x1a9)][_0x93d339(0x1b7)])?{'serverVersion':optionalStringValue(_0x4c2c1c['values']['version'])}:{}};}function createServerOptions(_0x3c8f06){const _0x4a28f0=_0x24bdc9;return{..._0x3c8f06[_0x4a28f0(0x1b0)]?{'catalog':_0x3c8f06['catalog']}:{},..._0x3c8f06[_0x4a28f0(0x1a6)]?{'catalogInstructionMode':_0x3c8f06['catalogInstructionMode']}:{},'server':{..._0x3c8f06[_0x4a28f0(0x1ce)]?{'name':_0x3c8f06[_0x4a28f0(0x1ce)]}:{},..._0x3c8f06['serverVersion']?{'version':_0x3c8f06['serverVersion']}:{}}};}function setCorsHeaders(_0x3d36d9,_0x185c18,_0x1eef8b){const _0x41e191=_0x24bdc9;if(_0x1eef8b['length']===0x0)return;const _0x34b696=_0x3d36d9['headers']['origin'],_0xc5ca1d=_0x1eef8b['includes']('*'),_0x1c5288=_0xc5ca1d?'*':typeof _0x34b696===_0x41e191(0x1a3)&&_0x1eef8b['includes'](_0x34b696)?_0x34b696:void 0x0;if(!_0x1c5288)return;_0x185c18['setHeader'](_0x41e191(0x1d2),_0x1c5288),_0x185c18[_0x41e191(0x1af)]('Vary','Origin'),_0x185c18[_0x41e191(0x1af)](_0x41e191(0x1ca),_0x41e191(0x1ac)),_0x185c18['setHeader'](_0x41e191(0x1aa),_0x41e191(0x1ab)),_0x185c18[_0x41e191(0x1af)]('Access-Control-Expose-Headers','Mcp-Session-Id');}function writeJsonRpcError(_0x31b189,_0x457271,_0x326f20){const _0x41e96e=_0x24bdc9;_0x31b189['statusCode']=_0x457271,_0x31b189['setHeader']('content-type','application/json'),_0x31b189[_0x41e96e(0x1bb)](JSON['stringify']({'jsonrpc':_0x41e96e(0x1b5),'error':{'code':-0x7f5b,'message':_0x326f20},'id':null}));}async function startStdio(_0x4475ae){const _0x3822b4=_0x24bdc9,_0x5439a6=createUIMCPServer(createServerOptions(_0x4475ae));await _0x5439a6[_0x3822b4(0x1cf)](new StdioServerTransport());}async function startHttp(_0x18d99d){const _0x4c5c33=_0x24bdc9,_0xe97338=createServer(async(_0x598754,_0x540c7d)=>{const _0x3536ca=_0x55a8,_0x1622a2=new URL(_0x598754['url']??'/','http://'+(_0x598754[_0x3536ca(0x19f)][_0x3536ca(0x1be)]??'localhost'));if(_0x1622a2['pathname']!==_0x18d99d['endpoint']){_0x540c7d['statusCode']=0x194,_0x540c7d['end'](_0x3536ca(0x1c2));return;}setCorsHeaders(_0x598754,_0x540c7d,_0x18d99d['corsOrigins']);if(_0x598754['method']===_0x3536ca(0x1bd)){_0x540c7d['statusCode']=0xcc,_0x540c7d['end']();return;}const _0x33b330=createUIMCPServer(createServerOptions(_0x18d99d)),_0xe29765=new StreamableHTTPServerTransport({'sessionIdGenerator':void 0x0});try{await _0x33b330[_0x3536ca(0x1cf)](_0xe29765),await _0xe29765['handleRequest'](_0x598754,_0x540c7d),_0x540c7d['on'](_0x3536ca(0x1c3),()=>{const _0x412514=_0x3536ca;void _0xe29765[_0x412514(0x1c3)](),void _0x33b330[_0x412514(0x1c3)]();});}catch(_0x2cf789){console['error']('[@agentic-ui-experience/ui-mcp]\x20request\x20failed',_0x2cf789),!_0x540c7d['headersSent']&&writeJsonRpcError(_0x540c7d,0x1f4,_0x2cf789 instanceof Error?_0x2cf789[_0x3536ca(0x1d7)]:_0x3536ca(0x1c5));}});await new Promise((_0xbe04cc,_0x45f9ff)=>{const _0x3b6f3d=_0x55a8;_0xe97338[_0x3b6f3d(0x1d4)]('error',_0x45f9ff),_0xe97338['listen'](_0x18d99d[_0x3b6f3d(0x1d0)],_0x18d99d[_0x3b6f3d(0x1be)],_0xbe04cc);});const _0x310eed=()=>{const _0x15e190=_0x55a8;_0xe97338[_0x15e190(0x1c3)](()=>process['exit'](0x0));};process[_0x4c5c33(0x1d4)]('SIGINT',_0x310eed),process[_0x4c5c33(0x1d4)](_0x4c5c33(0x1bf),_0x310eed),process[_0x4c5c33(0x1d5)][_0x4c5c33(0x1b8)](_0x4c5c33(0x1a7)+_0x18d99d['host']+':'+_0x18d99d['port']+_0x18d99d[_0x4c5c33(0x1d8)]+'\x0a');}async function main(){const _0x2bb58d=_0x24bdc9,_0x35fa3f=await parseCliOptions();if(_0x35fa3f[_0x2bb58d(0x1b2)]===_0x2bb58d(0x1c9)){await startStdio(_0x35fa3f);return;}await startHttp(_0x35fa3f);}main()[_0x24bdc9(0x1a0)](_0x120fb2=>{const _0x5a2ebb=_0x24bdc9;process[_0x5a2ebb(0x1d5)]['write']((_0x120fb2 instanceof Error?_0x120fb2[_0x5a2ebb(0x1d7)]:String(_0x120fb2))+'\x0a'),process['exit'](0x1);});
|
|
2
|
+
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);});
|
package/dist/client.d.ts
ADDED
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
import { McpServer, type RegisteredResource, type RegisteredTool } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import type { CallToolResult, ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type A2UIProtocolVersion, type CatalogPromptDescriptor } from "@agentic-ui-experience/ui-core";
|
|
4
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;
|
|
@@ -21,10 +21,16 @@ export interface UIMCPNormalizeMessagesOptions {
|
|
|
21
21
|
*/
|
|
22
22
|
catalog?: CatalogPromptDescriptor | UIMCPCatalog;
|
|
23
23
|
}
|
|
24
|
+
export interface CreateUIToolCallResultOptions {
|
|
25
|
+
/** Catalog used to strictly validate the normalized carrier. Defaults to Basic. */
|
|
26
|
+
catalog?: CatalogPromptDescriptor | UIMCPCatalog;
|
|
27
|
+
}
|
|
24
28
|
export interface CreateUIMCPServerOptions {
|
|
25
29
|
/** The single catalog this server serves. Defaults to the A2UI basic catalog. */
|
|
26
30
|
catalog?: CatalogPromptDescriptor;
|
|
27
31
|
catalogInstructionMode?: UIMCPCatalogInstructionMode;
|
|
32
|
+
/** Version requested in generated tool and catalog instructions. Defaults to v0.9.1. */
|
|
33
|
+
protocolVersion?: A2UIProtocolVersion;
|
|
28
34
|
title?: string;
|
|
29
35
|
annotations?: ToolAnnotations;
|
|
30
36
|
normalize?: UIMCPNormalize;
|
|
@@ -38,7 +44,7 @@ export declare function createUIMCPNormalize(options?: UIMCPNormalizeMessagesOpt
|
|
|
38
44
|
* Execute a UI MCP call. This is intentionally pure: it parses and returns the
|
|
39
45
|
* UI payload, but does not mutate any UI runtime.
|
|
40
46
|
*/
|
|
41
|
-
export declare function createUIToolCallResult(args: UIMCPToolArguments, normalize?: UIMCPNormalize): Promise<CallToolResult>;
|
|
47
|
+
export declare function createUIToolCallResult(args: UIMCPToolArguments, normalize?: UIMCPNormalize, options?: CreateUIToolCallResultOptions): Promise<CallToolResult>;
|
|
42
48
|
export declare function registerUICatalogResources(server: McpServer, catalog: UIMCPCatalog): {
|
|
43
49
|
catalog: RegisteredResource;
|
|
44
50
|
};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const _0x20fee2=_0x5886;(function(_0x4b7a5a,_0x1c0539){const _0x5499a6=_0x5886,_0x39daf0=_0x4b7a5a();while(!![]){try{const _0x141434=parseInt(_0x5499a6(0x1ed))/0x1+parseInt(_0x5499a6(0x211))/0x2*(-parseInt(_0x5499a6(0x207))/0x3)+-parseInt(_0x5499a6(0x20f))/0x4*(-parseInt(_0x5499a6(0x1ff))/0x5)+parseInt(_0x5499a6(0x1f0))/0x6+parseInt(_0x5499a6(0x1f5))/0x7+parseInt(_0x5499a6(0x212))/0x8*(parseInt(_0x5499a6(0x215))/0x9)+parseInt(_0x5499a6(0x1ef))/0xa*(-parseInt(_0x5499a6(0x1e5))/0xb);if(_0x141434===_0x1c0539)break;else _0x39daf0['push'](_0x39daf0['shift']());}catch(_0x525c22){_0x39daf0['push'](_0x39daf0['shift']());}}}(_0x38a2,0x663b1));import{McpServer}from'@modelcontextprotocol/sdk/server/mcp.js';import{McpServer as _0x5312a8}from'@modelcontextprotocol/sdk/server/mcp.js';function _0x38a2(){const _0x565308=['record','11bMiJNf','@agentic-ui-experience/ui-mcp','Optional\x20expected\x20surface\x20id\x20for\x20this\x20UI\x20call.\x20When\x20supplied,\x20`messages[0].createSurface.surfaceId`\x20must\x20match\x20it.','componentNames','The\x20complete\x20A2UI\x20v0.9-compatible\x20UI\x20message\x20array.','The\x20first\x20entry\x20must\x20be\x20`createSurface`,\x20carrying\x20the\x20catalog\x20id\x20reported\x20by\x20','descriptor','-\x20createSurface.catalogId\x20must\x20be\x20\x22','769910pTCqrr','join','14523620TVLqzI','1111044fZwyfl','Message\x20list\x20rules:','The\x20directory\x20is\x20returned\x20on\x20every\x20call,\x20so\x20you\x20can\x20widen\x20your\x20selection\x20with\x20a\x20second\x20call\x20if\x20the\x20first\x20one\x20missed\x20something.','stringify','Do\x20not\x20send\x20`ui_json`;\x20do\x20not\x20serialize\x20the\x20messages\x20into\x20a\x20JSON\x20string.','462259ySCnuw','catalogInstructionMode','surfaceId','uiMessages','string','catalog','compact','version','server','href','45ZiivrD','object','-\x20Later\x20updateComponents/updateDataModel/deleteSurface\x20messages\x20must\x20target\x20the\x20same\x20surface.','registerTool','unknown','v0.9','Final\x20step:\x20render\x20UI\x20on\x20the\x20client\x20by\x20submitting\x20structured\x20A2UI\x20messages.','union','54iThIkq','application/json','array','Catalog\x20id:\x20','Component\x20names\x20whose\x20field\x20rules\x20and\x20schemas\x20you\x20need.\x20Omit\x20on\x20the\x20first\x20call\x20to\x20get\x20the\x20catalog\x20directory\x20—\x20every\x20component\x20name\x20with\x20one\x20line\x20on\x20what\x20it\x20is\x20for\x20—\x20then\x20call\x20again\x20with\x20the\x20components\x20this\x20UI\x20actually\x20uses.','text','functionNames','message','145144XNIrFr','Use\x20this\x20only\x20as\x20workflow\x20step\x202,\x20after\x20fetching\x20component\x20schemas\x20with\x20','33598AQpgRD','624GvMFfd','passthrough','-\x20The\x20first\x20message\x20must\x20be\x20createSurface.','95283sMHegY','enum','describe','full','Do\x20not\x20pass\x20a\x20JSON\x20string\x20and\x20do\x20not\x20use\x20a\x20ui_json\x20field.','\x20A2UI\x20UI\x20message(s).','Get\x20A2UI\x20Catalog','literal','optional'];_0x38a2=function(){return _0x565308;};return _0x38a2();}import{z}from'zod';import{createUISendNormalizer,createUIToolCatalog,CATALOG_RESOURCE_URI,createUICatalogResourcePayload,GET_UI_CATALOG_TOOL_NAME,UI_TOOL_NAME,UI_TOOL_WORKFLOW_ORDER,getUICatalog,UI_TOOL_WORKFLOW,normalizeUISendToolArguments}from'@agentic-ui-experience/ui-core/tool-mode';const sendUIOutputSchema={'uiJson':z[_0x20fee2(0x1f9)](),'uiMessages':z['array'](z['unknown']())},getCatalogOutputSchema={'catalog':z['object']({'id':z['string'](),'resourceUri':z['string'](),'instructionMode':z[_0x20fee2(0x216)](['compact',_0x20fee2(0x218)]),'componentPurposes':z[_0x20fee2(0x1e4)](z['string'](),z['string']()),'descriptor':z[_0x20fee2(0x203)](),'instructions':z[_0x20fee2(0x1f9)]()})},componentSchema=z[_0x20fee2(0x1e4)](z['string'](),z['unknown']()),createSurfaceMessageSchema=z[_0x20fee2(0x200)]({'version':z['literal']('v0.9'),'createSurface':z[_0x20fee2(0x200)]({'surfaceId':z['string'](),'catalogId':z['string']()})['passthrough']()})[_0x20fee2(0x213)](),updateComponentsMessageSchema=z[_0x20fee2(0x200)]({'version':z[_0x20fee2(0x1e2)]('v0.9'),'updateComponents':z['object']({'surfaceId':z['string'](),'components':z['array'](componentSchema)})[_0x20fee2(0x213)]()})[_0x20fee2(0x213)](),updateDataModelMessageSchema=z['object']({'version':z[_0x20fee2(0x1e2)](_0x20fee2(0x204)),'updateDataModel':z['object']({'surfaceId':z['string'](),'path':z[_0x20fee2(0x1f9)]()[_0x20fee2(0x1e3)](),'value':z['unknown']()['optional']()})['passthrough']()})['passthrough'](),deleteSurfaceMessageSchema=z[_0x20fee2(0x200)]({'version':z[_0x20fee2(0x1e2)](_0x20fee2(0x204)),'deleteSurface':z['object']({'surfaceId':z['string']()})[_0x20fee2(0x213)]()})['passthrough']();function _0x5886(_0x291a97,_0x1f1940){_0x291a97=_0x291a97-0x1e0;const _0x38a22f=_0x38a2();let _0x588633=_0x38a22f[_0x291a97];return _0x588633;}function createSendUIInputSchema(){const _0x3f17f9=_0x20fee2;return{'surfaceId':z[_0x3f17f9(0x1f9)]()['optional']()[_0x3f17f9(0x217)](_0x3f17f9(0x1e7)),'messages':z['array'](z[_0x3f17f9(0x206)]([createSurfaceMessageSchema,updateComponentsMessageSchema,updateDataModelMessageSchema,deleteSurfaceMessageSchema]))[_0x3f17f9(0x217)]([_0x3f17f9(0x1e9),_0x3f17f9(0x210)+GET_UI_CATALOG_TOOL_NAME+'.','Build\x20component\x20objects\x20from\x20the\x20schema\x20returned\x20by\x20'+GET_UI_CATALOG_TOOL_NAME+';\x20do\x20not\x20guess\x20component\x20fields\x20from\x20this\x20tool\x20schema.',_0x3f17f9(0x219),'Every\x20entry\x20contains\x20`version`\x20and\x20exactly\x20one\x20of\x20`createSurface`/`updateComponents`/`updateDataModel`/`deleteSurface`.',_0x3f17f9(0x1ea)+GET_UI_CATALOG_TOOL_NAME+'\x20at\x20`createSurface.catalogId`.','Component\x20objects\x20belong\x20inside\x20a\x20later\x20`updateComponents.components`\x20array.'][_0x3f17f9(0x1ee)]('\x20'))};}function createGetCatalogInputSchema(){const _0x1bc8f7=_0x20fee2;return{'componentNames':z[_0x1bc8f7(0x209)](z[_0x1bc8f7(0x1f9)]())['min'](0x1)[_0x1bc8f7(0x1e3)]()['describe'](_0x1bc8f7(0x20b)),'functionNames':z[_0x1bc8f7(0x209)](z[_0x1bc8f7(0x1f9)]())['min'](0x1)['optional']()[_0x1bc8f7(0x217)]('Optional\x20catalog\x20function\x20names\x20whose\x20full\x20schemas\x20you\x20need\x20(e.g.\x20formatDate,\x20formatNumber).\x20The\x20returned\x20instructions\x20always\x20list\x20every\x20function\x20name\x20with\x20its\x20arguments,\x20so\x20request\x20schemas\x20only\x20for\x20the\x20functions\x20this\x20UI\x20actually\x20calls.\x20Omit\x20when\x20the\x20UI\x20calls\x20no\x20functions.'),'instructionMode':z[_0x1bc8f7(0x216)]([_0x1bc8f7(0x1fb),'full'])['optional']()['describe']('Optional\x20instruction\x20detail\x20level\x20for\x20the\x20returned\x20catalog\x20instructions.\x20Defaults\x20to\x20the\x20MCP\x20server\x20catalogInstructionMode.\x20Use\x20compact\x20for\x20a\x20concise\x20field\x20cheat\x20sheet;\x20use\x20full\x20when\x20the\x20model\x20needs\x20the\x20authoritative\x20JSON\x20schema\x20in\x20the\x20instructions.')};}function createGenericToolDescription(_0x10e033){const _0x753ee9=_0x20fee2;return[_0x753ee9(0x205),UI_TOOL_WORKFLOW,'Do\x20not\x20call\x20this\x20tool\x20before\x20'+GET_UI_CATALOG_TOOL_NAME+'\x20in\x20the\x20same\x20task.\x20This\x20tool\x20validates\x20and\x20returns\x20A2UI\x20messages;\x20it\x20is\x20not\x20the\x20source\x20of\x20component\x20schemas.',_0x753ee9(0x20a)+_0x10e033[_0x753ee9(0x1eb)]['id']+'.',_0x753ee9(0x1f1),'-\x20Every\x20message\x20must\x20include\x20\x22version\x22:\x20\x22v0.9\x22.',_0x753ee9(0x214),'-\x20createSurface.surfaceId\x20must\x20match\x20the\x20top-level\x20surfaceId\x20when\x20supplied.',_0x753ee9(0x1ec)+_0x10e033['descriptor']['id']+'\x22.',_0x753ee9(0x201),'-\x20Component\x20objects\x20belong\x20only\x20inside\x20updateComponents.components\x20and\x20must\x20conform\x20to\x20the\x20schemas\x20returned\x20by\x20get_ui_catalog.',_0x753ee9(0x1f4)][_0x753ee9(0x1ee)]('\x0a\x0a');}function createUIMCPNormalize(_0x26991c={}){const _0x27f738=_0x20fee2;return createUISendNormalizer({'mode':_0x26991c['mode'],'surfaceId':_0x26991c[_0x27f738(0x1f7)],'catalog':_0x26991c[_0x27f738(0x1fa)]});}const defaultNormalize=createUIMCPNormalize();function toToolError(_0x1049f2){const _0x178bb5=_0x20fee2;return{'isError':!![],'content':[{'type':_0x178bb5(0x20c),'text':_0x1049f2}]};}function toToolResult(_0x1002ef){const _0x2db487=_0x20fee2;return{'content':[{'type':'text','text':'Accepted\x20'+_0x1002ef[_0x2db487(0x1f8)]['length']+_0x2db487(0x1e0)}],'structuredContent':_0x1002ef};}function toCatalogToolResult(_0x113475){const _0x39ca59=_0x20fee2;return{'content':[{'type':_0x39ca59(0x20c),'text':JSON[_0x39ca59(0x1f3)](_0x113475)}],'structuredContent':_0x113475};}async function createUIToolCallResult(_0x61c3a3,_0x21f5d4=defaultNormalize){const _0x4bba3e=_0x20fee2;try{const _0x3083fe=await _0x21f5d4(_0x61c3a3);return toToolResult(normalizeUISendToolArguments(_0x61c3a3,()=>_0x3083fe));}catch(_0x5cfd01){const _0xe516a2=_0x5cfd01 instanceof Error?_0x5cfd01[_0x4bba3e(0x20e)]:String(_0x5cfd01);return toToolError(_0xe516a2);}}function toMCPResourceResult(_0x255bce){return _0x255bce;}function registerUICatalogResources(_0x216b8d,_0x360d28){const _0x483fb6=_0x20fee2,_0x539e1a=_0x216b8d['registerResource']('a2ui-catalog',CATALOG_RESOURCE_URI,{'title':'A2UI\x20Catalog\x20'+_0x360d28['descriptor']['id'],'description':'A2UI\x20catalog\x20instructions\x20and\x20component\x20schema.','mimeType':_0x483fb6(0x208)},_0x142ae8=>toMCPResourceResult(createUICatalogResourcePayload(_0x360d28,_0x142ae8[_0x483fb6(0x1fe)])));return{'catalog':_0x539e1a};}function registerUICatalogTools(_0x1199dd,_0xd72927){const _0x1c8288=_0x20fee2,_0x1f844e=_0x1199dd['registerTool'](GET_UI_CATALOG_TOOL_NAME,{'title':_0x1c8288(0x1e1),'description':['Step\x201\x20of\x20the\x20A2UI\x20MCP\x20workflow.\x20Call\x20this\x20before\x20'+UI_TOOL_NAME+'.',UI_TOOL_WORKFLOW_ORDER,'With\x20no\x20componentNames\x20it\x20returns\x20the\x20catalog\x20directory:\x20the\x20catalog\x20id\x20and\x20every\x20component\x20name\x20with\x20one\x20line\x20saying\x20what\x20it\x20is\x20for.\x20With\x20componentNames\x20it\x20returns\x20A2UI\x20message\x20rules,\x20component\x20field\x20rules,\x20custom\x20component\x20schemas,\x20style\x20guide,\x20and\x20examples\x20for\x20those\x20components.',_0x1c8288(0x1f2),'Use\x20instructionMode\x20\x22full\x22\x20for\x20forms,\x20unfamiliar\x20components,\x20validation\x20failures,\x20or\x20when\x20exact\x20required\x20fields\x20are\x20needed.']['join']('\x0a\x0a'),'inputSchema':createGetCatalogInputSchema(),'outputSchema':getCatalogOutputSchema,'annotations':{'readOnlyHint':!![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':![]}},async _0x2a1720=>{const _0x2f9df2=_0x1c8288;try{return toCatalogToolResult(getUICatalog(_0xd72927,{'componentNames':_0x2a1720[_0x2f9df2(0x1e8)],'functionNames':_0x2a1720[_0x2f9df2(0x20d)],'instructionMode':_0x2a1720['instructionMode']}));}catch(_0x6397c6){const _0x4f1934=_0x6397c6 instanceof Error?_0x6397c6['message']:String(_0x6397c6);return toToolError(_0x4f1934);}});return{'get':_0x1f844e};}function registerGenericUITool(_0x47912a,_0x20bab8,_0x5a8f99={}){const _0x3e93ba=_0x20fee2,_0x380e02=_0x5a8f99['normalize']??createUISendNormalizer({'catalog':_0x20bab8});return _0x47912a[_0x3e93ba(0x202)](UI_TOOL_NAME,{'title':_0x5a8f99['title'],'description':createGenericToolDescription(_0x20bab8),'inputSchema':createSendUIInputSchema(),'outputSchema':sendUIOutputSchema,'annotations':{'readOnlyHint':![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':![],..._0x5a8f99['annotations']}},async _0x36cd32=>createUIToolCallResult(_0x36cd32,_0x380e02));}function createUIMCPServer(_0x21dc6={}){const _0x8b0db2=_0x20fee2,_0x682d75=createUIToolCatalog(_0x21dc6[_0x8b0db2(0x1fa)],_0x21dc6[_0x8b0db2(0x1f6)]),_0x12a32f=_0x21dc6['normalize']??createUISendNormalizer({'catalog':_0x682d75}),_0x2ed1e4=new McpServer({'name':_0x21dc6[_0x8b0db2(0x1fd)]?.['name']??_0x8b0db2(0x1e6),'version':_0x21dc6['server']?.[_0x8b0db2(0x1fc)]??'0.0.0'});return registerUICatalogResources(_0x2ed1e4,_0x682d75),registerUICatalogTools(_0x2ed1e4,_0x682d75),registerGenericUITool(_0x2ed1e4,_0x682d75,{..._0x21dc6,'normalize':_0x12a32f}),_0x2ed1e4;}export{_0x5312a8 as McpServer,createUIMCPNormalize,createUIMCPServer,createUIToolCallResult,registerGenericUITool,registerUICatalogResources,registerUICatalogTools};
|
|
1
|
+
const _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
|
+
"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": [
|
|
@@ -23,7 +27,7 @@
|
|
|
23
27
|
"dependencies": {
|
|
24
28
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
25
29
|
"zod": "^4.4.3",
|
|
26
|
-
"@agentic-ui-experience/ui-core": "0.0.1-beta.
|
|
30
|
+
"@agentic-ui-experience/ui-core": "0.0.1-beta.5"
|
|
27
31
|
},
|
|
28
32
|
"devDependencies": {
|
|
29
33
|
"@types/node": "^24.10.1"
|