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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,21 +6,26 @@ This package does not render or ingest UI. It exposes catalog discovery tools
6
6
  and a `send_ui_to_client` MCP tool that returns validated A2UI messages in
7
7
  `structuredContent`, so the host can forward them to `@agentic-ui-experience/ui-runtime`.
8
8
 
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
+
9
11
  `@agentic-ui-experience/ui-mcp` is an MCP adapter over
10
- `@agentic-ui-experience/ui-core/tool-mode`. Catalog registry, catalog resource
12
+ `@agentic-ui-experience/ui-core/tool-mode`. Catalog configuration, catalog resource
11
13
  payloads, catalog filtering, and `send_ui_to_client` normalization live in
12
14
  `ui-core`; this package only maps those provider-neutral operations onto MCP
13
15
  resources and tools.
14
16
 
15
- The A2UI basic catalog is built in. Scenario-specific catalogs are registered
16
- when the MCP server is created, then discovered through tools or resources.
17
+ A server serves exactly one catalog. A2UI fixes a surface's catalog at
18
+ `createSurface` time and never composes two catalogs into one component tree, and
19
+ the upstream agent SDK selects a single catalog before it prompts the model, so
20
+ the catalog is a server configuration rather than a model choice. To serve more
21
+ than one vocabulary, merge them when you define the catalog. Omit `catalog` to
22
+ serve the A2UI basic catalog.
17
23
 
18
24
  ```ts
19
25
  import { createUIMCPServer } from "@agentic-ui-experience/ui-mcp";
20
26
 
21
27
  const server = createUIMCPServer({
22
- catalogs: [weatherPromptDescriptor],
23
- defaultCatalogId: "com.agentic-ui-experience.examples.weather.v1",
28
+ catalog: weatherPromptDescriptor,
24
29
  catalogInstructionMode: "compact"
25
30
  });
26
31
 
@@ -87,13 +92,12 @@ The local-development wildcard CORS shortcut is:
87
92
  pnpm --filter @agentic-ui-experience/ui-mcp start:http:cors
88
93
  ```
89
94
 
90
- Custom catalogs can be loaded from ESM modules:
95
+ A custom catalog can be loaded from an ESM module:
91
96
 
92
97
  ```bash
93
98
  ax-ui-mcp \
94
99
  --transport http \
95
100
  --catalog ./weather-catalog.js \
96
- --default-catalog-id com.agentic-ui-experience.examples.weather.v1 \
97
101
  --catalog-instruction-mode compact
98
102
  ```
99
103
 
@@ -101,12 +105,10 @@ With the package scripts, append extra CLI flags after `--`:
101
105
 
102
106
  ```bash
103
107
  pnpm --filter @agentic-ui-experience/ui-mcp start:http -- \
104
- --catalog ./weather-catalog.js \
105
- --default-catalog-id com.agentic-ui-experience.examples.weather.v1
108
+ --catalog ./weather-catalog.js
106
109
  ```
107
110
 
108
- The catalog module may export a descriptor directly, a `catalog`, a `catalogs`
109
- array, and optionally `defaultCatalogId`:
111
+ The catalog module may export a descriptor directly or as `catalog`:
110
112
 
111
113
  ```ts
112
114
  export const catalog = {
@@ -114,29 +116,27 @@ export const catalog = {
114
116
  baseComponentNames: ["Card", "Text"],
115
117
  customComponents: []
116
118
  };
117
-
118
- export const defaultCatalogId = "example/weather/v1";
119
119
  ```
120
120
 
121
121
  The normal agent flow is:
122
122
 
123
123
  ```ts
124
- // Step 1: discover the server default catalog and available component names.
125
- list_ui_catalogs();
126
-
127
- // Step 2: fetch the catalog instructions and schemas for the components needed
128
- // by this UI. Use instructionMode: "full" when exact fields are needed.
124
+ // Step 1a: discover what the catalog has. With no componentNames the server
125
+ // returns the directory — every component name with one line on what it is for
126
+ // — and no schemas, so discovery costs a listing rather than the catalog.
127
+ get_ui_catalog();
128
+
129
+ // Step 1b: fetch instructions and schemas for the components this UI needs.
130
+ // Use instructionMode: "full" when exact fields are needed.
131
+ // Name a function in functionNames only when the UI actually calls it.
129
132
  get_ui_catalog({
130
- catalogId: "com.agentic-ui-experience.examples.weather.v1",
131
133
  componentNames: ["Card", "Text", "WeatherIcon"],
134
+ functionNames: ["formatDate"],
132
135
  instructionMode: "full"
133
136
  });
134
137
 
135
- // Step 3: submit messages built from the catalog returned by get_ui_catalog.
138
+ // Step 2: submit messages built from the catalog returned by get_ui_catalog.
136
139
  send_ui_to_client({
137
- // Top-level catalogId is an expected-value guard for the MCP server.
138
- // The createSurface message must still repeat the same catalogId.
139
- catalogId: "com.agentic-ui-experience.examples.weather.v1",
140
140
  surfaceId: "main",
141
141
  messages: [
142
142
  { version: "v0.9", createSurface: { surfaceId: "main", catalogId: "com.agentic-ui-experience.examples.weather.v1" } },
@@ -145,9 +145,37 @@ send_ui_to_client({
145
145
  });
146
146
  ```
147
147
 
148
- Omit `componentNames` to fetch the complete catalog. When supplied, the server
149
- returns only the requested basic component schema and registered custom
150
- component schemas; use `list_ui_catalogs` first to inspect available names.
148
+ Neither tool takes a `catalogId`. The server pins the catalog, so there is
149
+ nothing for the model to choose; `createSurface.catalogId` is validated against
150
+ the configured catalog.
151
+
152
+ `componentNames` is what narrows the response: supply it and the server returns
153
+ only those basic and custom component schemas.
154
+
155
+ Function schemas are opt-in and are *not* covered by `componentNames`. Components
156
+ never reference functions through `$ref`, so no component selection can narrow
157
+ them — they have to be named. The instructions always list every function with
158
+ its arguments, so an agent can see what exists and then request only the schemas
159
+ it needs via `functionNames`. Omit `functionNames` when the UI calls no
160
+ functions. This works in both instruction modes, and with or without
161
+ `componentNames`: an explicitly requested function schema is returned even in
162
+ `"compact"` (which otherwise emits no schemas at all) and even on a directory
163
+ call.
164
+
165
+ The returned `descriptor` carries component schemas only. The catalog's
166
+ `styleGuide` and `examples` are prose that `instructions` already renders, so
167
+ repeating them in `descriptor` would have doubled every response; the
168
+ `a2ui://catalog` resource still carries the descriptor whole.
169
+
170
+ `get_ui_catalog` returns `componentPurposes` on every call — a
171
+ `componentName -> what it is for` map covering base and custom components
172
+ together, regardless of what the call requested. Component names alone do not say
173
+ when to reach for `Tabs` over `List`, or `Card` over `Column`, and field rules
174
+ only help once the component is already chosen. Keeping the whole directory in
175
+ view also means an agent that under-selected can see what it missed and widen
176
+ with a second call, instead of quietly building something worse out of the
177
+ components it already has. For custom components the prose is the descriptor's
178
+ `description`.
151
179
 
152
180
  `get_ui_catalog` returns compact instructions by default. Pass
153
181
  `instructionMode: "full"` when the agent needs the authoritative JSON schema in
@@ -160,16 +188,13 @@ serialize the message list into a JSON string, and do not pass static catalog
160
188
  schema such as `customComponents` in the tool call.
161
189
 
162
190
  `send_ui_to_client` is the final submission tool, not the schema discovery
163
- tool. Agents should call `list_ui_catalogs` and `get_ui_catalog` before using
164
- it, then build component objects from the returned catalog schema.
165
-
166
- The top-level `catalogId` is not copied into the A2UI payload. Always include
167
- the same value in the first message at `createSurface.catalogId`; the MCP server
168
- validates that the two values match.
191
+ tool. Agents should call `get_ui_catalog` before using it, then build component
192
+ objects from the returned catalog schema.
169
193
 
170
- Catalogs are also exposed as MCP resources:
194
+ The catalog is also exposed as an MCP resource. Resources are read by hosts and
195
+ clients rather than picked from by a model, so this payload carries every
196
+ component and function:
171
197
 
172
198
  ```text
173
- a2ui://catalog/basic
174
- a2ui://catalog/{catalogId}
199
+ a2ui://catalog
175
200
  ```
package/dist/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- const _0x31d86c=_0x320f;(function(_0x30e064,_0x478da1){const _0x3d4659=_0x320f,_0x5414b8=_0x30e064();while(!![]){try{const _0x19b178=-parseInt(_0x3d4659(0x148))/0x1+parseInt(_0x3d4659(0x147))/0x2+parseInt(_0x3d4659(0x137))/0x3*(-parseInt(_0x3d4659(0x16a))/0x4)+-parseInt(_0x3d4659(0x150))/0x5*(-parseInt(_0x3d4659(0x13f))/0x6)+parseInt(_0x3d4659(0x16f))/0x7*(parseInt(_0x3d4659(0x163))/0x8)+parseInt(_0x3d4659(0x161))/0x9+-parseInt(_0x3d4659(0x139))/0xa;if(_0x19b178===_0x478da1)break;else _0x5414b8['push'](_0x5414b8['shift']());}catch(_0x5a58ab){_0x5414b8['push'](_0x5414b8['shift']());}}}(_0x370b,0x4c96b));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=_0x31d86c(0x171);function stringValue(_0x4b1b28,_0x63a6c3){const _0x52d2ac=_0x31d86c;return typeof _0x4b1b28==='string'&&_0x4b1b28[_0x52d2ac(0x170)]>0x0?_0x4b1b28:_0x63a6c3;}function optionalStringValue(_0x539a86){return typeof _0x539a86==='string'&&_0x539a86['length']>0x0?_0x539a86:void 0x0;}function stringArrayValue(_0x30c485){const _0x44301a=_0x31d86c;if(Array[_0x44301a(0x167)](_0x30c485))return _0x30c485;if(typeof _0x30c485==='string'&&_0x30c485['length']>0x0)return[_0x30c485];return[];}function _0x370b(){const _0x2a8940=['stringify','7yRlHAo','length','@agentic-ui-experience/ui-mcp\x0a\x0aUsage:\x0a\x20\x20ax-ui-mcp\x20[options]\x0a\x0aOptions:\x0a\x20\x20--transport\x20<stdio|http>\x20\x20\x20\x20\x20\x20MCP\x20transport\x20to\x20start.\x20Default:\x20stdio\x0a\x20\x20--host\x20<host>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20HTTP\x20bind\x20host.\x20Default:\x20127.0.0.1\x0a\x20\x20--port\x20<port>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20HTTP\x20bind\x20port.\x20Default:\x203001\x0a\x20\x20--endpoint\x20<path>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20HTTP\x20MCP\x20endpoint.\x20Default:\x20/mcp\x0a\x20\x20--cors-origin\x20<origin>\x20\x20\x20\x20\x20\x20\x20\x20Allow\x20a\x20browser\x20origin.\x20Repeatable.\x20Use\x20\x22*\x22\x20for\x20development.\x0a\x20\x20--catalog\x20<module>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ESM\x20module\x20exporting\x20a\x20CatalogPromptDescriptor\x20or\x20array.\x20Repeatable.\x0a\x20\x20--default-catalog-id\x20<id>\x20\x20\x20\x20\x20Default\x20catalog\x20id.\x0a\x20\x20--catalog-instruction-mode\x20<compact|full>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Default\x20get_ui_catalog\x20instruction\x20detail.\x20Default:\x20compact\x0a\x20\x20--name\x20<name>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20MCP\x20server\x20name.\x20Default:\x20@agentic-ui-experience/ui-mcp\x0a\x20\x20--version\x20<version>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20MCP\x20server\x20version.\x20Default:\x200.0.0\x0a\x20\x20--help\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Show\x20this\x20help.\x0a\x0aCatalog\x20modules\x20may\x20export\x20one\x20of:\x0a\x20\x20export\x20default\x20descriptor\x0a\x20\x20export\x20const\x20catalog\x20=\x20descriptor\x0a\x20\x20export\x20const\x20catalogs\x20=\x20[descriptor]\x0a\x20\x20export\x20const\x20defaultCatalogId\x20=\x20\x22...\x22\x0a','serverVersion','push','once','stderr','3GfKUNO','serverName','10559010mOUjBR','headers','includes','stdio','Access-Control-Expose-Headers','error','89508GHXthM','2.0','setHeader','url','content-type','@agentic-ui-experience/ui-mcp\x20listening\x20on\x20http://','startsWith','SIGINT','1229852hOjORW','174013hhITQX','headersSent','Catalog\x20module\x20\x22','baseComponentNames','catalogInstructionMode','message','pathname','Origin','175tlZnkQ','http://','values','full','write','GET,POST,DELETE,OPTIONS','host','Unsupported\x20catalog\x20instruction\x20mode\x20\x22','statusCode','end','transport','default-catalog-id','catch','help','string','\x22\x20exported\x20an\x20invalid\x20catalog\x20descriptor.','default','4499667IAutnk','version','3942168krPtLz','port','endpoint','exit','isArray','\x22.\x20Expected\x20an\x20integer\x20from\x201\x20to\x2065535.','/mcp','2344676Nswlkw','handleRequest','defaultCatalogId','catalogs'];_0x370b=function(){return _0x2a8940;};return _0x370b();}function parseTransport(_0x2f52f5){const _0x31f8ef=_0x31d86c;if(_0x2f52f5===_0x31f8ef(0x13c)||_0x2f52f5==='http')return _0x2f52f5;throw new Error('Unsupported\x20transport\x20\x22'+_0x2f52f5+'\x22.\x20Expected\x20\x22stdio\x22\x20or\x20\x22http\x22.');}function _0x320f(_0x4055fa,_0x330141){_0x4055fa=_0x4055fa-0x134;const _0x370b41=_0x370b();let _0x320f98=_0x370b41[_0x4055fa];return _0x320f98;}function parseCatalogInstructionMode(_0x50f335){const _0x1eba0f=_0x31d86c;if(_0x50f335==='compact'||_0x50f335===_0x1eba0f(0x153))return _0x50f335;throw new Error(_0x1eba0f(0x157)+_0x50f335+'\x22.\x20Expected\x20\x22compact\x22\x20or\x20\x22full\x22.');}function parsePort(_0x5e7857){const _0x296c39=_0x31d86c,_0x29a6b0=Number(_0x5e7857);if(!Number['isInteger'](_0x29a6b0)||_0x29a6b0<0x1||_0x29a6b0>0xffff)throw new Error('Invalid\x20--port\x20\x22'+_0x5e7857+_0x296c39(0x168));return _0x29a6b0;}function normalizeEndpoint(_0x35fe11){const _0x3755b8=_0x31d86c;if(!_0x35fe11[_0x3755b8(0x145)]('/'))return'/'+_0x35fe11;return _0x35fe11;}function isCatalogDescriptor(_0x12b55b){const _0x23f50a=_0x31d86c;return!!_0x12b55b&&typeof _0x12b55b==='object'&&!Array['isArray'](_0x12b55b)&&typeof _0x12b55b['id']==='string'&&Array['isArray'](_0x12b55b[_0x23f50a(0x14b)]);}function readCatalogExports(_0x25e634,_0x5833c2){const _0x156eee=_0x31d86c,_0x12e5d7=_0x25e634[_0x156eee(0x16d)]??_0x25e634['catalog']??_0x25e634[_0x156eee(0x160)],_0x1c9eb0=[];if(Array['isArray'](_0x12e5d7))for(const _0x41975b of _0x12e5d7){if(!isCatalogDescriptor(_0x41975b))throw new Error(_0x156eee(0x14a)+_0x5833c2+'\x22\x20exported\x20an\x20invalid\x20catalog\x20descriptor.');_0x1c9eb0['push'](_0x41975b);}else{if(_0x12e5d7!==void 0x0){if(!isCatalogDescriptor(_0x12e5d7))throw new Error('Catalog\x20module\x20\x22'+_0x5833c2+_0x156eee(0x15f));_0x1c9eb0[_0x156eee(0x134)](_0x12e5d7);}}if(_0x1c9eb0['length']===0x0)throw new Error(_0x156eee(0x14a)+_0x5833c2+'\x22\x20did\x20not\x20export\x20a\x20catalog\x20descriptor.');const _0x35c276=typeof _0x25e634['defaultCatalogId']==='string'&&_0x25e634[_0x156eee(0x16c)]['length']>0x0?_0x25e634[_0x156eee(0x16c)]:void 0x0;return{'catalogs':_0x1c9eb0,'defaultCatalogId':_0x35c276};}async function loadCatalogs(_0x46508c){const _0x11079c=_0x31d86c,_0x1870e6=[];let _0x372187;for(const _0x204cd1 of _0x46508c){const _0x4400e4=await import(pathToFileURL(resolve(_0x204cd1))['href']),_0x520a65=readCatalogExports(_0x4400e4,_0x204cd1);_0x1870e6[_0x11079c(0x134)](..._0x520a65[_0x11079c(0x16d)]),_0x372187??(_0x372187=_0x520a65[_0x11079c(0x16c)]);}return{'catalogs':_0x1870e6,'defaultCatalogId':_0x372187};}async function parseCliOptions(){const _0xe7b992=_0x31d86c,_0x777c43=parseArgs({'allowPositionals':![],'options':{'transport':{'type':_0xe7b992(0x15e)},'host':{'type':_0xe7b992(0x15e)},'port':{'type':_0xe7b992(0x15e)},'endpoint':{'type':_0xe7b992(0x15e)},'cors-origin':{'type':'string','multiple':!![]},'catalog':{'type':'string','multiple':!![]},'default-catalog-id':{'type':'string'},'catalog-instruction-mode':{'type':_0xe7b992(0x15e)},'name':{'type':_0xe7b992(0x15e)},'version':{'type':'string'},'help':{'type':'boolean','short':'h'}}});_0x777c43['values'][_0xe7b992(0x15d)]&&(process['stdout']['write'](helpText),process[_0xe7b992(0x166)](0x0));const _0x432da2=await loadCatalogs(stringArrayValue(_0x777c43[_0xe7b992(0x152)]['catalog'])),_0x2cefc2=optionalStringValue(_0x777c43['values'][_0xe7b992(0x15b)])??_0x432da2[_0xe7b992(0x16c)];return{'transport':parseTransport(stringValue(_0x777c43['values'][_0xe7b992(0x15a)],_0xe7b992(0x13c))),'host':stringValue(_0x777c43['values'][_0xe7b992(0x156)],'127.0.0.1'),'port':parsePort(stringValue(_0x777c43[_0xe7b992(0x152)]['port'],'3001')),'endpoint':normalizeEndpoint(stringValue(_0x777c43['values'][_0xe7b992(0x165)],_0xe7b992(0x169))),'corsOrigins':stringArrayValue(_0x777c43[_0xe7b992(0x152)]['cors-origin']),'catalogs':_0x432da2['catalogs'],..._0x2cefc2?{'defaultCatalogId':_0x2cefc2}:{},'catalogInstructionMode':parseCatalogInstructionMode(stringValue(_0x777c43[_0xe7b992(0x152)]['catalog-instruction-mode'],'compact')),...optionalStringValue(_0x777c43[_0xe7b992(0x152)]['name'])?{'serverName':optionalStringValue(_0x777c43[_0xe7b992(0x152)]['name'])}:{},...optionalStringValue(_0x777c43['values']['version'])?{'serverVersion':optionalStringValue(_0x777c43['values'][_0xe7b992(0x162)])}:{}};}function createServerOptions(_0x44dd95){const _0x5656db=_0x31d86c;return{'catalogs':_0x44dd95['catalogs'],..._0x44dd95['defaultCatalogId']?{'defaultCatalogId':_0x44dd95['defaultCatalogId']}:{},..._0x44dd95[_0x5656db(0x14c)]?{'catalogInstructionMode':_0x44dd95[_0x5656db(0x14c)]}:{},'server':{..._0x44dd95[_0x5656db(0x138)]?{'name':_0x44dd95[_0x5656db(0x138)]}:{},..._0x44dd95[_0x5656db(0x172)]?{'version':_0x44dd95[_0x5656db(0x172)]}:{}}};}function setCorsHeaders(_0x4c5bb7,_0x2975fe,_0x1d05a8){const _0x3cd35d=_0x31d86c;if(_0x1d05a8[_0x3cd35d(0x170)]===0x0)return;const _0x26de21=_0x4c5bb7[_0x3cd35d(0x13a)]['origin'],_0x367bd5=_0x1d05a8[_0x3cd35d(0x13b)]('*'),_0x10b1c0=_0x367bd5?'*':typeof _0x26de21==='string'&&_0x1d05a8['includes'](_0x26de21)?_0x26de21:void 0x0;if(!_0x10b1c0)return;_0x2975fe['setHeader']('Access-Control-Allow-Origin',_0x10b1c0),_0x2975fe[_0x3cd35d(0x141)]('Vary',_0x3cd35d(0x14f)),_0x2975fe[_0x3cd35d(0x141)]('Access-Control-Allow-Methods',_0x3cd35d(0x155)),_0x2975fe[_0x3cd35d(0x141)]('Access-Control-Allow-Headers','Content-Type,\x20Accept,\x20Authorization,\x20MCP-Protocol-Version,\x20Mcp-Session-Id,\x20Last-Event-ID'),_0x2975fe[_0x3cd35d(0x141)](_0x3cd35d(0x13d),'Mcp-Session-Id');}function writeJsonRpcError(_0x497641,_0x33622d,_0x29168f){const _0x57da98=_0x31d86c;_0x497641[_0x57da98(0x158)]=_0x33622d,_0x497641['setHeader'](_0x57da98(0x143),'application/json'),_0x497641['end'](JSON[_0x57da98(0x16e)]({'jsonrpc':_0x57da98(0x140),'error':{'code':-0x7f5b,'message':_0x29168f},'id':null}));}async function startStdio(_0x39d58d){const _0x1897d0=createUIMCPServer(createServerOptions(_0x39d58d));await _0x1897d0['connect'](new StdioServerTransport());}async function startHttp(_0x157e7b){const _0x5bc298=_0x31d86c,_0x3619d6=createServer(async(_0x2132f2,_0xbaf134)=>{const _0x4217b9=_0x320f,_0x39b669=new URL(_0x2132f2[_0x4217b9(0x142)]??'/',_0x4217b9(0x151)+(_0x2132f2['headers'][_0x4217b9(0x156)]??'localhost'));if(_0x39b669[_0x4217b9(0x14e)]!==_0x157e7b[_0x4217b9(0x165)]){_0xbaf134[_0x4217b9(0x158)]=0x194,_0xbaf134['end']('Not\x20Found');return;}setCorsHeaders(_0x2132f2,_0xbaf134,_0x157e7b['corsOrigins']);if(_0x2132f2['method']==='OPTIONS'){_0xbaf134['statusCode']=0xcc,_0xbaf134[_0x4217b9(0x159)]();return;}const _0x59428d=createUIMCPServer(createServerOptions(_0x157e7b)),_0x2ea11c=new StreamableHTTPServerTransport({'sessionIdGenerator':void 0x0});try{await _0x59428d['connect'](_0x2ea11c),await _0x2ea11c[_0x4217b9(0x16b)](_0x2132f2,_0xbaf134),_0xbaf134['on']('close',()=>{void _0x2ea11c['close'](),void _0x59428d['close']();});}catch(_0x3c3463){console[_0x4217b9(0x13e)]('[@agentic-ui-experience/ui-mcp]\x20request\x20failed',_0x3c3463),!_0xbaf134[_0x4217b9(0x149)]&&writeJsonRpcError(_0xbaf134,0x1f4,_0x3c3463 instanceof Error?_0x3c3463['message']:'Internal\x20MCP\x20server\x20error');}});await new Promise((_0x10ffa5,_0x4d8f7e)=>{const _0x20c50c=_0x320f;_0x3619d6['once']('error',_0x4d8f7e),_0x3619d6['listen'](_0x157e7b[_0x20c50c(0x164)],_0x157e7b['host'],_0x10ffa5);});const _0x26c7e3=()=>{const _0x143f36=_0x320f;_0x3619d6['close'](()=>process[_0x143f36(0x166)](0x0));};process[_0x5bc298(0x135)](_0x5bc298(0x146),_0x26c7e3),process['once']('SIGTERM',_0x26c7e3),process[_0x5bc298(0x136)][_0x5bc298(0x154)](_0x5bc298(0x144)+_0x157e7b['host']+':'+_0x157e7b['port']+_0x157e7b[_0x5bc298(0x165)]+'\x0a');}async function main(){const _0x5aec4e=_0x31d86c,_0x201cf2=await parseCliOptions();if(_0x201cf2['transport']===_0x5aec4e(0x13c)){await startStdio(_0x201cf2);return;}await startHttp(_0x201cf2);}main()[_0x31d86c(0x15c)](_0xc36129=>{const _0x235124=_0x31d86c;process['stderr'][_0x235124(0x154)]((_0xc36129 instanceof Error?_0xc36129[_0x235124(0x14d)]:String(_0xc36129))+'\x0a'),process[_0x235124(0x166)](0x1);});
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);});
package/dist/index.d.ts CHANGED
@@ -1,27 +1,29 @@
1
- import { McpServer, ResourceTemplate, type RegisteredResource, type RegisteredResourceTemplate, type RegisteredTool } from "@modelcontextprotocol/sdk/server/mcp.js";
1
+ import { McpServer, type RegisteredResource, type RegisteredTool } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  import type { CallToolResult, ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
3
3
  import type { CatalogPromptDescriptor } from "@agentic-ui-experience/ui-core";
4
- import { type UIGetCatalogArguments, type UIGetCatalogResult, type UIListCatalogsResult, type UISendToolArguments, type UISendToolResult, type UIToolCatalogInstructionMode, type UIToolCatalogRegistry } from "@agentic-ui-experience/ui-core/tool-mode";
4
+ import { type UIGetCatalogArguments, type UIGetCatalogResult, type UISendToolArguments, type UISendToolResult, type UIToolCatalog, type UIToolCatalogInstructionMode } from "@agentic-ui-experience/ui-core/tool-mode";
5
5
  export type UIMCPToolResult = UISendToolResult & Record<string, unknown>;
6
6
  export type UIMCPToolArguments = UISendToolArguments;
7
7
  export type UIMCPCatalogInstructionMode = UIToolCatalogInstructionMode;
8
- export type UIMCPCatalogSummary = UIListCatalogsResult["catalogs"][number];
9
8
  export type UIMCPCatalogDescription = UIGetCatalogResult["catalog"];
10
- export type UIMCPListCatalogsResult = UIListCatalogsResult & Record<string, unknown>;
11
9
  export type UIMCPGetCatalogArguments = UIGetCatalogArguments;
12
10
  export type UIMCPGetCatalogResult = UIGetCatalogResult & Record<string, unknown>;
13
11
  export type UIMCPNormalize = (args: UIMCPToolArguments) => UIMCPToolResult | Promise<UIMCPToolResult>;
14
12
  export type UIMCPSyncNormalize = (args: UIMCPToolArguments) => UIMCPToolResult;
15
- export type UIMCPCatalogRegistry = UIToolCatalogRegistry;
13
+ export type UIMCPCatalog = UIToolCatalog;
16
14
  export interface UIMCPNormalizeMessagesOptions {
17
15
  mode?: "strict" | "repair";
18
16
  surfaceId?: string;
19
- defaultCatalogId?: string;
20
- catalogs?: readonly CatalogPromptDescriptor[];
17
+ /**
18
+ * The catalog to validate against. Accepts the configured `UIMCPCatalog` as
19
+ * well as a bare descriptor, so a caller holding the value this server was
20
+ * built from does not have to unwrap it.
21
+ */
22
+ catalog?: CatalogPromptDescriptor | UIMCPCatalog;
21
23
  }
22
24
  export interface CreateUIMCPServerOptions {
23
- catalogs?: readonly CatalogPromptDescriptor[];
24
- defaultCatalogId?: string;
25
+ /** The single catalog this server serves. Defaults to the A2UI basic catalog. */
26
+ catalog?: CatalogPromptDescriptor;
25
27
  catalogInstructionMode?: UIMCPCatalogInstructionMode;
26
28
  title?: string;
27
29
  annotations?: ToolAnnotations;
@@ -37,24 +39,22 @@ export declare function createUIMCPNormalize(options?: UIMCPNormalizeMessagesOpt
37
39
  * UI payload, but does not mutate any UI runtime.
38
40
  */
39
41
  export declare function createUIToolCallResult(args: UIMCPToolArguments, normalize?: UIMCPNormalize): Promise<CallToolResult>;
40
- export declare function registerUICatalogResources(server: McpServer, registry: UIMCPCatalogRegistry): {
41
- basic: RegisteredResource;
42
- catalogs: RegisteredResource[];
43
- template: RegisteredResourceTemplate;
42
+ export declare function registerUICatalogResources(server: McpServer, catalog: UIMCPCatalog): {
43
+ catalog: RegisteredResource;
44
44
  };
45
- export declare function registerUICatalogTools(server: McpServer, registry: UIMCPCatalogRegistry): {
46
- list: RegisteredTool;
45
+ export declare function registerUICatalogTools(server: McpServer, catalog: UIMCPCatalog): {
47
46
  get: RegisteredTool;
48
47
  };
49
48
  /**
50
49
  * Register the generic deployable A2UI MCP tool. The server is
51
- * scenario-independent; catalog-specific schema comes from the registry.
50
+ * scenario-independent; catalog-specific schema comes from the one catalog it
51
+ * was configured with.
52
52
  */
53
- export declare function registerGenericUITool(server: McpServer, registry: UIMCPCatalogRegistry, options?: Pick<CreateUIMCPServerOptions, "title" | "annotations" | "normalize">): RegisteredTool;
53
+ export declare function registerGenericUITool(server: McpServer, catalog: UIMCPCatalog, options?: Pick<CreateUIMCPServerOptions, "title" | "annotations" | "normalize">): RegisteredTool;
54
54
  /**
55
55
  * Create a generic A2UI MCP server. Transport ownership stays with the caller
56
56
  * so this can be used with stdio, SSE, or streamable HTTP.
57
57
  */
58
58
  export declare function createUIMCPServer(options?: CreateUIMCPServerOptions): McpServer;
59
- export { McpServer, ResourceTemplate };
59
+ export { McpServer };
60
60
  export type { CallToolResult, ToolAnnotations, CatalogPromptDescriptor };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- const _0x64b4a7=_0x359f;(function(_0x515baf,_0x17d11a){const _0x4b5eff=_0x359f,_0x30fe34=_0x515baf();while(!![]){try{const _0x43fc51=-parseInt(_0x4b5eff(0xb4))/0x1*(-parseInt(_0x4b5eff(0xc3))/0x2)+-parseInt(_0x4b5eff(0x8e))/0x3+parseInt(_0x4b5eff(0x99))/0x4+parseInt(_0x4b5eff(0x89))/0x5*(-parseInt(_0x4b5eff(0xad))/0x6)+-parseInt(_0x4b5eff(0x8c))/0x7*(-parseInt(_0x4b5eff(0xbb))/0x8)+-parseInt(_0x4b5eff(0xc0))/0x9+parseInt(_0x4b5eff(0xac))/0xa;if(_0x43fc51===_0x17d11a)break;else _0x30fe34['push'](_0x30fe34['shift']());}catch(_0x52ef64){_0x30fe34['push'](_0x30fe34['shift']());}}}(_0x2619,0x4c92a));function _0x2619(){const _0x65927b=['filter','-\x20createSurface.surfaceId\x20must\x20match\x20the\x20top-level\x20surfaceId\x20when\x20supplied.','componentNames','a2ui-catalog-','The\x20complete\x20A2UI\x20v0.9-compatible\x20UI\x20message\x20array.','If\x20the\x20tool\x20call\x20includes\x20top-level\x20`catalogId`,\x20`messages[0].createSurface.catalogId`\x20must\x20repeat\x20the\x20same\x20value.','literal','normalize','mode','Top-level\x20`catalogId`\x20is\x20only\x20an\x20expected-value\x20guard;\x20it\x20does\x20not\x20populate\x20the\x20A2UI\x20message.\x20The\x20first\x20message\x20must\x20repeat\x20the\x20catalog\x20id\x20at\x20`messages[0].createSurface.catalogId`.','boolean','object','a2ui-catalog','passthrough','optional','full','Optional\x20expected\x20catalog\x20id\x20for\x20this\x20UI\x20call.\x20This\x20is\x20a\x20validator\x20only:\x20still\x20include\x20the\x20same\x20value\x20in\x20`messages[0].createSurface.catalogId`.\x20Defaults\x20to\x20the\x20MCP\x20server\x20default\x20catalog\x20id,\x20then\x20the\x20A2UI\x20basic\x20catalog\x20id.','Do\x20not\x20call\x20this\x20tool\x20before\x20using\x20the\x20catalog\x20discovery\x20tools\x20in\x20the\x20same\x20task.\x20This\x20tool\x20validates\x20and\x20returns\x20A2UI\x20messages;\x20it\x20is\x20not\x20the\x20source\x20of\x20component\x20schemas.','10185120rANjah','24qWLGqh','\x20A2UI\x20UI\x20message(s).','unknown','registerResource','Step\x201\x20of\x20the\x20A2UI\x20MCP\x20workflow.\x20Call\x20this\x20before\x20get_ui_catalog\x20or\x20send_ui_to_client.','join','registerTool','2161wtASva','array','-\x20createSurface.catalogId\x20must\x20be\x20present\x20and\x20must\x20match\x20the\x20top-level\x20catalogId\x20when\x20supplied;\x20otherwise\x20it\x20must\x20match\x20the\x20registered\x20default\x20catalog\x20id.','List\x20A2UI\x20Catalogs','Optional\x20component\x20names\x20to\x20fetch.\x20Use\x20list_ui_catalogs\x20first,\x20then\x20pass\x20only\x20the\x20basic\x20or\x20custom\x20components\x20needed\x20for\x20this\x20UI\x20response.\x20Omit\x20to\x20fetch\x20the\x20complete\x20catalog.','Do\x20not\x20send\x20`ui_json`;\x20do\x20not\x20serialize\x20the\x20messages\x20into\x20a\x20JSON\x20string.','A2UI\x20Catalog\x20','16aZxwyS','catalogId','describe','Optional\x20expected\x20surface\x20id\x20for\x20this\x20UI\x20call.\x20When\x20supplied,\x20`messages[0].createSurface.surfaceId`\x20must\x20match\x20it.','-\x20Component\x20objects\x20belong\x20only\x20inside\x20updateComponents.components\x20and\x20must\x20conform\x20to\x20the\x20schemas\x20returned\x20by\x20get_ui_catalog.','4474341ErTNYk','map','catalogs','128WAHteq','Registered\x20A2UI\x20catalog\x20instructions\x20and\x20custom\x20component\x20schema.','Do\x20not\x20pass\x20a\x20JSON\x20string\x20and\x20do\x20not\x20use\x20a\x20ui_json\x20field.','Registered\x20catalogs:\x20','Final\x20step:\x20render\x20UI\x20on\x20the\x20client\x20by\x20submitting\x20structured\x20A2UI\x20messages.','626840McNmPy','string','application/json','1294965AUuIXU','Optional\x20catalog\x20id.\x20Defaults\x20to\x20the\x20MCP\x20server\x20default\x20catalog\x20id,\x20then\x20the\x20A2UI\x20basic\x20catalog\x20id.','1827687gVNOtQ','surfaceId','Every\x20entry\x20contains\x20`version`\x20and\x20exactly\x20one\x20of\x20`createSurface`/`updateComponents`/`updateDataModel`/`deleteSurface`.','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.','server','title','annotations','text','defaultCatalogId','v0.9','message','1578744OKhvOQ'];_0x2619=function(){return _0x65927b;};return _0x2619();}import{McpServer,ResourceTemplate}from'@modelcontextprotocol/sdk/server/mcp.js';import{McpServer as _0x11c2fe,ResourceTemplate as _0x2b8fca}from'@modelcontextprotocol/sdk/server/mcp.js';import{z}from'zod/v4';function _0x359f(_0x33df1e,_0x593da8){_0x33df1e=_0x33df1e-0x87;const _0x2619ae=_0x2619();let _0x359fe4=_0x2619ae[_0x33df1e];return _0x359fe4;}import{createUISendNormalizer,createUICatalogRegistry,BASIC_CATALOG_RESOURCE_URI,catalogIdFromResourceVariable,catalogResourceUri,CATALOG_RESOURCE_URI_TEMPLATE,LIST_UI_CATALOGS_TOOL_NAME,UI_TOOL_WORKFLOW,listUICatalogs,GET_UI_CATALOG_TOOL_NAME,getUICatalog,UI_TOOL_NAME,createUICatalogResourcePayload,normalizeUISendToolArguments}from'@agentic-ui-experience/ui-core/tool-mode';const sendUIOutputSchema={'uiJson':z['string'](),'uiMessages':z[_0x64b4a7(0xb5)](z['unknown']())},listCatalogsOutputSchema={'catalogs':z[_0x64b4a7(0xb5)](z[_0x64b4a7(0xa5)]({'id':z['string'](),'resourceUri':z[_0x64b4a7(0x8a)](),'isDefault':z['boolean'](),'baseCatalogId':z['string'](),'baseComponentNames':z[_0x64b4a7(0xb5)](z[_0x64b4a7(0x8a)]()),'customComponents':z['array'](z['string']())}))},getCatalogOutputSchema={'catalog':z['object']({'id':z[_0x64b4a7(0x8a)](),'resourceUri':z['string'](),'isDefault':z[_0x64b4a7(0xa4)](),'baseCatalogId':z[_0x64b4a7(0x8a)](),'instructionMode':z['enum'](['compact',_0x64b4a7(0xa9)]),'descriptor':z[_0x64b4a7(0xaf)](),'instructions':z[_0x64b4a7(0x8a)](),'catalogPrompt':z[_0x64b4a7(0x8a)](),'basicCatalogSchema':z['unknown']()['optional']()})},componentSchema=z['record'](z[_0x64b4a7(0x8a)](),z['unknown']()),createSurfaceMessageSchema=z['object']({'version':z['literal']('v0.9'),'createSurface':z['object']({'surfaceId':z[_0x64b4a7(0x8a)](),'catalogId':z['string']()})[_0x64b4a7(0xa7)]()})['passthrough'](),updateComponentsMessageSchema=z[_0x64b4a7(0xa5)]({'version':z['literal']('v0.9'),'updateComponents':z['object']({'surfaceId':z[_0x64b4a7(0x8a)](),'components':z[_0x64b4a7(0xb5)](componentSchema)})[_0x64b4a7(0xa7)]()})[_0x64b4a7(0xa7)](),updateDataModelMessageSchema=z[_0x64b4a7(0xa5)]({'version':z[_0x64b4a7(0xa0)]('v0.9'),'updateDataModel':z['object']({'surfaceId':z['string'](),'path':z['string']()['optional'](),'value':z['unknown']()[_0x64b4a7(0xa8)]()})['passthrough']()})[_0x64b4a7(0xa7)](),deleteSurfaceMessageSchema=z[_0x64b4a7(0xa5)]({'version':z['literal'](_0x64b4a7(0x97)),'deleteSurface':z['object']({'surfaceId':z['string']()})[_0x64b4a7(0xa7)]()})[_0x64b4a7(0xa7)]();function createSendUIInputSchema(){const _0x53593d=_0x64b4a7;return{'catalogId':z['string']()[_0x53593d(0xa8)]()['describe'](_0x53593d(0xaa)),'surfaceId':z['string']()['optional']()['describe'](_0x53593d(0xbe)),'messages':z['array'](z['union']([createSurfaceMessageSchema,updateComponentsMessageSchema,updateDataModelMessageSchema,deleteSurfaceMessageSchema]))['describe']([_0x53593d(0x9e),'Use\x20this\x20only\x20as\x20workflow\x20step\x203,\x20after\x20inspecting\x20catalog\x20metadata\x20with\x20'+LIST_UI_CATALOGS_TOOL_NAME+'\x20and\x20'+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.',_0x53593d(0xc5),_0x53593d(0x90),'The\x20first\x20entry\x20must\x20be\x20`createSurface`\x20with\x20both\x20`surfaceId`\x20and\x20`catalogId`\x20inside\x20`createSurface`.',_0x53593d(0x9f),'Component\x20objects\x20belong\x20inside\x20a\x20later\x20`updateComponents.components`\x20array.']['join']('\x20'))};}function createGetCatalogInputSchema(){const _0x4d5b02=_0x64b4a7;return{'catalogId':z['string']()[_0x4d5b02(0xa8)]()[_0x4d5b02(0xbd)](_0x4d5b02(0x8d)),'componentNames':z['array'](z[_0x4d5b02(0x8a)]())['min'](0x1)['optional']()['describe'](_0x4d5b02(0xb8)),'instructionMode':z['enum'](['compact',_0x4d5b02(0xa9)])[_0x4d5b02(0xa8)]()[_0x4d5b02(0xbd)](_0x4d5b02(0x91))};}function createGenericToolDescription(_0x4276ca){const _0x129128=_0x64b4a7,_0x28d5ae=listUICatalogs(_0x4276ca)[_0x129128(0xc2)];return[_0x129128(0x88),UI_TOOL_WORKFLOW,_0x129128(0xab),'Default\x20catalog\x20id:\x20'+_0x4276ca[_0x129128(0x96)]+'.',_0x129128(0x87)+_0x28d5ae[_0x129128(0xc1)](_0x76363d=>_0x76363d['id'])[_0x129128(0xb2)](',\x20')+'.','Message\x20list\x20rules:','-\x20Every\x20message\x20must\x20include\x20\x22version\x22:\x20\x22v0.9\x22.','-\x20The\x20first\x20message\x20must\x20be\x20createSurface.',_0x129128(0x9b),_0x129128(0xb6),'-\x20Later\x20updateComponents/updateDataModel/deleteSurface\x20messages\x20must\x20target\x20the\x20same\x20surface.',_0x129128(0xbf),_0x129128(0xb9),_0x129128(0xa3)][_0x129128(0xb2)]('\x0a\x0a');}function createUIMCPNormalize(_0x4ea9ff={}){const _0x1f07e4=_0x64b4a7;return createUISendNormalizer({'mode':_0x4ea9ff[_0x1f07e4(0xa2)],'surfaceId':_0x4ea9ff[_0x1f07e4(0x8f)],'defaultCatalogId':_0x4ea9ff['defaultCatalogId'],'catalogs':_0x4ea9ff[_0x1f07e4(0xc2)]});}const defaultNormalize=createUIMCPNormalize();function toToolError(_0x51799f){return{'isError':!![],'content':[{'type':'text','text':_0x51799f}]};}function toToolResult(_0x2db8c0){const _0x1ee981=_0x64b4a7;return{'content':[{'type':_0x1ee981(0x95),'text':'Accepted\x20'+_0x2db8c0['uiMessages']['length']+_0x1ee981(0xae)}],'structuredContent':_0x2db8c0};}function toCatalogToolResult(_0x470a00){const _0x566a78=_0x64b4a7;return{'content':[{'type':_0x566a78(0x95),'text':JSON['stringify'](_0x470a00)}],'structuredContent':_0x470a00};}async function createUIToolCallResult(_0x24ff89,_0x55f838=defaultNormalize){const _0x287d1e=_0x64b4a7;try{const _0x3b8e7f=await _0x55f838(_0x24ff89);return toToolResult(normalizeUISendToolArguments(_0x24ff89,()=>_0x3b8e7f));}catch(_0x419ca2){const _0x5a9227=_0x419ca2 instanceof Error?_0x419ca2[_0x287d1e(0x98)]:String(_0x419ca2);return toToolError(_0x5a9227);}}function toMCPResourceResult(_0x1ee591){return _0x1ee591;}function createCatalogResourceResult(_0x13ea36,_0x1c3c1b,_0x3b6630){return toMCPResourceResult(createUICatalogResourcePayload(_0x13ea36,_0x1c3c1b,_0x3b6630));}function registerUICatalogResources(_0x57f506,_0x516e4d){const _0x6218d1=_0x64b4a7,_0x40efb9=_0x57f506['registerResource']('a2ui-basic-catalog',BASIC_CATALOG_RESOURCE_URI,{'title':'A2UI\x20Basic\x20Catalog','description':'Built-in\x20A2UI\x20basic\x20catalog\x20instructions\x20and\x20component\x20schema.','mimeType':'application/json'},_0x10f803=>createCatalogResourceResult(_0x516e4d,catalogIdFromResourceVariable('basic'),_0x10f803['href'])),_0x45ad8c=[..._0x516e4d[_0x6218d1(0xc2)]['values']()]['filter'](_0x4ecfbd=>catalogResourceUri(_0x4ecfbd['id'])!==BASIC_CATALOG_RESOURCE_URI)['map'](_0x275c57=>_0x57f506['registerResource'](_0x6218d1(0x9d)+_0x275c57['id'],catalogResourceUri(_0x275c57['id']),{'title':_0x6218d1(0xba)+_0x275c57['id'],'description':_0x6218d1(0xc4),'mimeType':'application/json'},_0x20ac5f=>createCatalogResourceResult(_0x516e4d,_0x275c57['id'],_0x20ac5f['href']))),_0x3b625d=_0x57f506[_0x6218d1(0xb0)](_0x6218d1(0xa6),new ResourceTemplate(CATALOG_RESOURCE_URI_TEMPLATE,{'list':()=>({'resources':[..._0x516e4d[_0x6218d1(0xc2)]['values']()][_0x6218d1(0xc1)](_0x3188ef=>({'uri':catalogResourceUri(_0x3188ef['id']),'name':_0x3188ef['id'],'title':_0x3188ef['id'],'mimeType':_0x6218d1(0x8b)}))}),'complete':{'catalogId':_0x146669=>{const _0x2d3402=_0x6218d1,_0x40a801=_0x146669['toLowerCase']();return[..._0x516e4d['catalogs']['keys']()][_0x2d3402(0xc1)](_0x1a06d0=>catalogResourceUri(_0x1a06d0)===BASIC_CATALOG_RESOURCE_URI?'basic':encodeURIComponent(_0x1a06d0))[_0x2d3402(0x9a)](_0x4c53b5=>_0x4c53b5['toLowerCase']()['startsWith'](_0x40a801));}}}),{'title':'A2UI\x20Catalog','description':_0x6218d1(0xc4),'mimeType':_0x6218d1(0x8b)},(_0x233666,_0x4411ca)=>createCatalogResourceResult(_0x516e4d,catalogIdFromResourceVariable(String(_0x4411ca['catalogId'])),_0x233666['href']));return{'basic':_0x40efb9,'catalogs':_0x45ad8c,'template':_0x3b625d};}function registerUICatalogTools(_0x8d6a27,_0x460038){const _0x123403=_0x64b4a7,_0x45e4ed=_0x8d6a27[_0x123403(0xb3)](LIST_UI_CATALOGS_TOOL_NAME,{'title':_0x123403(0xb7),'description':[_0x123403(0xb1),UI_TOOL_WORKFLOW,'Returns\x20registered\x20catalog\x20ids,\x20the\x20default\x20catalog,\x20base\x20component\x20names,\x20and\x20custom\x20component\x20names.\x20Use\x20the\x20returned\x20component\x20names\x20to\x20choose\x20the\x20componentNames\x20for\x20get_ui_catalog.']['join']('\x0a\x0a'),'outputSchema':listCatalogsOutputSchema,'annotations':{'readOnlyHint':!![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':![]}},async()=>toCatalogToolResult(listUICatalogs(_0x460038))),_0xd48ff=_0x8d6a27['registerTool'](GET_UI_CATALOG_TOOL_NAME,{'title':'Get\x20A2UI\x20Catalog','description':['Step\x202\x20of\x20the\x20A2UI\x20MCP\x20workflow.\x20Call\x20this\x20after\x20list_ui_catalogs\x20and\x20before\x20send_ui_to_client.',UI_TOOL_WORKFLOW,'Returns\x20LLM-facing\x20A2UI\x20message\x20rules,\x20basic\x20catalog\x20schema,\x20custom\x20component\x20schemas,\x20style\x20guide,\x20and\x20examples\x20for\x20a\x20registered\x20catalog.','Pass\x20only\x20the\x20componentNames\x20needed\x20for\x20the\x20current\x20UI\x20response.\x20Omit\x20componentNames\x20only\x20when\x20the\x20complete\x20catalog\x20is\x20needed.','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 _0x276064=>{const _0x5e3cd1=_0x123403;try{return toCatalogToolResult(getUICatalog(_0x460038,{'catalogId':_0x276064[_0x5e3cd1(0xbc)],'componentNames':_0x276064[_0x5e3cd1(0x9c)],'instructionMode':_0x276064['instructionMode']}));}catch(_0x31a2f3){const _0x519a1e=_0x31a2f3 instanceof Error?_0x31a2f3[_0x5e3cd1(0x98)]:String(_0x31a2f3);return toToolError(_0x519a1e);}});return{'list':_0x45e4ed,'get':_0xd48ff};}function registerGenericUITool(_0x432023,_0x3c3061,_0x2432d6={}){const _0x5a7ac3=_0x64b4a7,_0xa50bd0=_0x2432d6['normalize']??createUISendNormalizer({'registry':_0x3c3061});return _0x432023['registerTool'](UI_TOOL_NAME,{'title':_0x2432d6[_0x5a7ac3(0x93)],'description':createGenericToolDescription(_0x3c3061),'inputSchema':createSendUIInputSchema(),'outputSchema':sendUIOutputSchema,'annotations':{'readOnlyHint':![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':![],..._0x2432d6[_0x5a7ac3(0x94)]}},async _0x41f789=>createUIToolCallResult(_0x41f789,_0xa50bd0));}function createUIMCPServer(_0x8747da={}){const _0x1bceea=_0x64b4a7,_0x2efdae=createUICatalogRegistry(_0x8747da[_0x1bceea(0xc2)],_0x8747da['defaultCatalogId'],_0x8747da['catalogInstructionMode']),_0x43fd1e=_0x8747da[_0x1bceea(0xa1)]??createUIMCPNormalize({'catalogs':_0x8747da['catalogs'],'defaultCatalogId':_0x8747da[_0x1bceea(0x96)]}),_0x4a16b0=new McpServer({'name':_0x8747da['server']?.['name']??'@agentic-ui-experience/ui-mcp','version':_0x8747da[_0x1bceea(0x92)]?.['version']??'0.0.0'});return registerUICatalogResources(_0x4a16b0,_0x2efdae),registerUICatalogTools(_0x4a16b0,_0x2efdae),registerGenericUITool(_0x4a16b0,_0x2efdae,{..._0x8747da,'normalize':_0x43fd1e}),_0x4a16b0;}export{_0x11c2fe as McpServer,_0x2b8fca as ResourceTemplate,createUIMCPNormalize,createUIMCPServer,createUIToolCallResult,registerGenericUITool,registerUICatalogResources,registerUICatalogTools};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentic-ui-experience/ui-mcp",
3
- "version": "0.0.1-beta.2",
3
+ "version": "0.0.1-beta.4",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -22,8 +22,8 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@modelcontextprotocol/sdk": "^1.29.0",
25
- "zod": "^4.0.0",
26
- "@agentic-ui-experience/ui-core": "0.0.1-beta.2"
25
+ "zod": "^4.4.3",
26
+ "@agentic-ui-experience/ui-core": "0.0.1-beta.4"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/node": "^24.10.1"