@mcp-native/a2ui 0.0.2 → 0.0.3
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 +101 -1
- package/package.json +14 -3
package/README.md
CHANGED
|
@@ -1,3 +1,103 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
1
3
|
# @mcp-native/a2ui
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
### Strict parsing for declarative MCP Native surfaces
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@mcp-native/a2ui)
|
|
8
|
+
[](https://www.npmjs.com/package/@mcp-native/a2ui)
|
|
9
|
+
[](https://github.com/pablospaniard/mcp-native/blob/main/LICENSE)
|
|
10
|
+
|
|
11
|
+
[GitHub](https://github.com/pablospaniard/mcp-native) · [Architecture](https://github.com/pablospaniard/mcp-native/blob/main/docs/RFC-0001-architecture.md) · [Security](https://github.com/pablospaniard/mcp-native/blob/main/SECURITY.md)
|
|
12
|
+
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
> **Experimental:** this package implements MCP Native's deliberately small `0.1` proof-of-concept surface. It is not a claim of complete A2UI specification compatibility.
|
|
16
|
+
|
|
17
|
+
`@mcp-native/a2ui` parses untrusted JSON or JavaScript values into a validated, typed surface before a host renders anything. Unknown versions, node types, action types, and invalid JSON values fail closed with an `A2uiParseError`.
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @mcp-native/a2ui
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`@mcp-native/core` is installed as a dependency. The package is ESM-only and includes TypeScript declarations.
|
|
26
|
+
|
|
27
|
+
## Quick start
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { parseA2uiSurface } from "@mcp-native/a2ui";
|
|
31
|
+
|
|
32
|
+
const surface = parseA2uiSurface({
|
|
33
|
+
version: "0.1",
|
|
34
|
+
root: {
|
|
35
|
+
id: "welcome",
|
|
36
|
+
type: "container",
|
|
37
|
+
children: [
|
|
38
|
+
{ id: "title", type: "text", text: "Welcome" },
|
|
39
|
+
{
|
|
40
|
+
id: "name",
|
|
41
|
+
type: "text-input",
|
|
42
|
+
label: "Display name",
|
|
43
|
+
binding: "profile.displayName",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: "save",
|
|
47
|
+
type: "button",
|
|
48
|
+
label: "Save",
|
|
49
|
+
action: {
|
|
50
|
+
type: "tool",
|
|
51
|
+
name: "save_profile",
|
|
52
|
+
arguments: { source: "onboarding" },
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The parser also accepts a JSON string:
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
const surface = parseA2uiSurface(
|
|
64
|
+
'{"version":"0.1","root":{"id":"title","type":"text","text":"Hello"}}',
|
|
65
|
+
);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Supported surface
|
|
69
|
+
|
|
70
|
+
| Node | Required fields | Purpose |
|
|
71
|
+
| ------------ | ----------------------- | ------------------------------------------------------ |
|
|
72
|
+
| `container` | `id`, `children` | Groups nested surface nodes. |
|
|
73
|
+
| `text` | `id`, `text` | Declares trusted text content. |
|
|
74
|
+
| `button` | `id`, `label`, `action` | Declares a tool action for host-controlled dispatch. |
|
|
75
|
+
| `text-input` | `id`, `label` | Declares an input with optional `value` and `binding`. |
|
|
76
|
+
|
|
77
|
+
The only supported action is `{ type: "tool", name, arguments? }`. Arguments must contain JSON-safe values.
|
|
78
|
+
|
|
79
|
+
## Public API
|
|
80
|
+
|
|
81
|
+
| Export | Purpose |
|
|
82
|
+
| ------------------------- | ---------------------------------------------------- |
|
|
83
|
+
| `parseA2uiSurface` | Validates input and returns a typed `A2uiSurface`. |
|
|
84
|
+
| `A2uiParseError` | Error thrown for malformed or unsupported input. |
|
|
85
|
+
| `A2UI_VERSION` | Current proof-of-concept wire version, `"0.1"`. |
|
|
86
|
+
| `A2uiSurface`, `A2uiNode` | Validated surface and node unions. |
|
|
87
|
+
| Node interfaces | Typed container, text, button, and text-input nodes. |
|
|
88
|
+
|
|
89
|
+
## Security behavior
|
|
90
|
+
|
|
91
|
+
- Input is treated as untrusted at the parser boundary.
|
|
92
|
+
- Unknown surface versions, nodes, and actions are rejected.
|
|
93
|
+
- Tool arguments are recursively constrained to JSON values.
|
|
94
|
+
- Parsing never resolves components or executes server-provided code.
|
|
95
|
+
- Successful parsing does not grant device capabilities or permission to call a tool; the host still owns those decisions.
|
|
96
|
+
|
|
97
|
+
## Next layer
|
|
98
|
+
|
|
99
|
+
Use [`@mcp-native/react-native`](https://www.npmjs.com/package/@mcp-native/react-native) to convert a validated surface into a trusted native render plan, or install [`mcp-native`](https://www.npmjs.com/package/mcp-native) for the complete public API.
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
|
|
103
|
+
[MIT](https://github.com/pablospaniard/mcp-native/blob/main/LICENSE)
|
package/package.json
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-native/a2ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "A2UI parsing and bindings for MCP Native.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"a2ui",
|
|
7
|
+
"declarative-ui",
|
|
8
|
+
"mcp",
|
|
9
|
+
"model-context-protocol",
|
|
10
|
+
"typescript"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/pablospaniard/mcp-native#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/pablospaniard/mcp-native/issues"
|
|
15
|
+
},
|
|
5
16
|
"license": "MIT",
|
|
6
17
|
"repository": {
|
|
7
18
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/pablospaniard/mcp-native.git",
|
|
19
|
+
"url": "git+https://github.com/pablospaniard/mcp-native.git",
|
|
9
20
|
"directory": "packages/a2ui"
|
|
10
21
|
},
|
|
11
22
|
"files": [
|
|
@@ -26,6 +37,6 @@
|
|
|
26
37
|
"access": "public"
|
|
27
38
|
},
|
|
28
39
|
"dependencies": {
|
|
29
|
-
"@mcp-native/core": "^0.0.
|
|
40
|
+
"@mcp-native/core": "^0.0.3"
|
|
30
41
|
}
|
|
31
42
|
}
|