mcp-native 0.0.2 → 0.1.0
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 +127 -1
- package/package.json +26 -6
package/README.md
CHANGED
|
@@ -1,3 +1,129 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
1
3
|
# mcp-native
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
### One entry point for the MCP Native experimental runtime
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/mcp-native)
|
|
8
|
+
[](https://www.npmjs.com/package/mcp-native)
|
|
9
|
+
[](https://github.com/pablospaniard/mcp-native/blob/main/LICENSE)
|
|
10
|
+
[](https://github.com/pablospaniard/mcp-native/actions/workflows/ci.yml)
|
|
11
|
+
|
|
12
|
+
[GitHub](https://github.com/pablospaniard/mcp-native) · [Architecture](https://github.com/pablospaniard/mcp-native/blob/main/docs/RFC-0001-architecture.md) · [Standards status](https://github.com/pablospaniard/mcp-native/blob/main/docs/standards-compatibility.md) · [Contributing](https://github.com/pablospaniard/mcp-native/blob/main/CONTRIBUTING.md) · [Security](https://github.com/pablospaniard/mcp-native/blob/main/SECURITY.md)
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
> **Experimental:** MCP Native is a proof of concept, not a production-ready MCP or React Native runtime. APIs may change before `1.0.0`.
|
|
17
|
+
|
|
18
|
+
> **Compatibility:** the initial tool/resource boundary preserves MCP `2026-07-28` fields, but complete MCP conformance is still in progress. The current declarative `0.1` surface is not A2UI v1.0, and the WebView primitives are not a complete MCP Apps host. See the [standards compatibility matrix](https://github.com/pablospaniard/mcp-native/blob/main/docs/standards-compatibility.md).
|
|
19
|
+
|
|
20
|
+
`mcp-native` is the convenience package for the runtime and UI APIs. It re-exports the runtime contracts, declarative surface parser, trusted native renderer and hooks, and policy-gated WebView compatibility primitives from focused `@mcp-native/*` packages. Transport adapters are installed separately.
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install mcp-native react
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Add `react-native` when mounting native surfaces. The package is ESM-only and includes TypeScript declarations.
|
|
29
|
+
|
|
30
|
+
## End-to-end preview
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import {
|
|
34
|
+
McpNativeSurface,
|
|
35
|
+
McpNativeRuntime,
|
|
36
|
+
createAllowlistActionPolicy,
|
|
37
|
+
parseA2uiSurface,
|
|
38
|
+
useMcpNativeActionDispatcher,
|
|
39
|
+
type McpClient,
|
|
40
|
+
} from "mcp-native";
|
|
41
|
+
import { Button, Text, TextInput, View } from "react-native";
|
|
42
|
+
|
|
43
|
+
const components = { Button, Text, TextInput, View };
|
|
44
|
+
|
|
45
|
+
const client: McpClient = {
|
|
46
|
+
async listTools() {
|
|
47
|
+
return { tools: [] };
|
|
48
|
+
},
|
|
49
|
+
async callTool(name, arguments_) {
|
|
50
|
+
return {
|
|
51
|
+
content: [{ type: "text", text: `Called ${name}` }],
|
|
52
|
+
structuredContent: { name, arguments: arguments_ },
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
async readResource(uri) {
|
|
56
|
+
return { contents: [{ uri, text: "" }] };
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const runtime = new McpNativeRuntime(client, {
|
|
61
|
+
actionPolicy: createAllowlistActionPolicy([{ name: "continue_flow" }]),
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const surface = parseA2uiSurface({
|
|
65
|
+
version: "0.1",
|
|
66
|
+
root: {
|
|
67
|
+
id: "welcome",
|
|
68
|
+
type: "container",
|
|
69
|
+
children: [
|
|
70
|
+
{ id: "title", type: "text", text: "Hello from MCP" },
|
|
71
|
+
{
|
|
72
|
+
id: "continue",
|
|
73
|
+
type: "button",
|
|
74
|
+
label: "Continue",
|
|
75
|
+
action: { type: "tool", name: "continue_flow" },
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
function NativeScreen() {
|
|
82
|
+
const onAction = useMcpNativeActionDispatcher(runtime, {
|
|
83
|
+
onError: (error) => console.error("MCP action failed", error),
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
return <McpNativeSurface surface={surface} components={components} onAction={onAction} />;
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The host supplies the locally bundled native components and explicitly allows the tools a surface may dispatch, including their arguments. Without an `actionPolicy`, surface action dispatch is denied; trusted host code can still call `callTool()` directly after JSON validation. MCP Native never downloads and executes server-provided React Native JavaScript.
|
|
91
|
+
|
|
92
|
+
## Included packages
|
|
93
|
+
|
|
94
|
+
| Package | What it provides |
|
|
95
|
+
| ------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------- |
|
|
96
|
+
| [`@mcp-native/core`](https://www.npmjs.com/package/@mcp-native/core) | MCP client contracts, runtime delegation, JSON types, and declared tool actions. |
|
|
97
|
+
| [`@mcp-native/a2ui`](https://www.npmjs.com/package/@mcp-native/a2ui) | Strict parsing for the internal `0.1` proof-of-concept surface. |
|
|
98
|
+
| [`@mcp-native/react-native`](https://www.npmjs.com/package/@mcp-native/react-native) | Trusted render plans, React hooks, and a fixed host-owned component catalog. |
|
|
99
|
+
| [`@mcp-native/webview`](https://www.npmjs.com/package/@mcp-native/webview) | HTML policy primitives for the planned MCP Apps compatibility path. |
|
|
100
|
+
|
|
101
|
+
Install an individual package instead when you only need one layer.
|
|
102
|
+
|
|
103
|
+
Use the separately installable [`@mcp-native/mcp`](https://github.com/pablospaniard/mcp-native/tree/main/packages/mcp) package to connect these APIs to the official MCP TypeScript SDK without forcing that SDK dependency on every `mcp-native` consumer.
|
|
104
|
+
|
|
105
|
+
## What works today
|
|
106
|
+
|
|
107
|
+
- transport-independent MCP runtime contracts;
|
|
108
|
+
- strict validation for container, text, button, and text-input nodes;
|
|
109
|
+
- declared tool-action dispatch;
|
|
110
|
+
- strict A2UI resource-link resolution from tool results;
|
|
111
|
+
- trusted render plans for `View`, `Text`, `Button`, and `TextInput`;
|
|
112
|
+
- mounting through host-provided components with action and text-binding event translation;
|
|
113
|
+
- memoized render-plan and safely observed asynchronous action-dispatch hooks;
|
|
114
|
+
- policy-gated inline and remote HTML document descriptions;
|
|
115
|
+
- MCP `2026-07-28` tool/resource field preservation through the official SDK adapter;
|
|
116
|
+
- pinned current-protocol integration coverage through the SDK HTTP handler/fetch path;
|
|
117
|
+
- ESM exports, TypeScript declarations, automated tests, and signed npm provenance.
|
|
118
|
+
|
|
119
|
+
The project does not yet include local binding state, streaming UI updates, capability negotiation, authentication helpers, or a runnable mobile demo. Follow the [roadmap](https://github.com/pablospaniard/mcp-native#roadmap) for progress.
|
|
120
|
+
|
|
121
|
+
## Security model
|
|
122
|
+
|
|
123
|
+
Remote servers may provide declarative UI and actions, but the host owns component resolution, tool execution, permissions, and every sensitive capability. Unknown data fails closed at validation and policy boundaries.
|
|
124
|
+
|
|
125
|
+
Read the full [architecture](https://github.com/pablospaniard/mcp-native/blob/main/docs/RFC-0001-architecture.md) and [security policy](https://github.com/pablospaniard/mcp-native/blob/main/SECURITY.md) before using or extending the proof of concept.
|
|
126
|
+
|
|
127
|
+
## License
|
|
128
|
+
|
|
129
|
+
[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",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Convenience package for the MCP Native runtime.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"a2ui",
|
|
7
|
+
"mcp",
|
|
8
|
+
"model-context-protocol",
|
|
9
|
+
"native-ui",
|
|
10
|
+
"react-native"
|
|
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/mcp-native"
|
|
10
21
|
},
|
|
11
22
|
"files": [
|
|
@@ -26,9 +37,18 @@
|
|
|
26
37
|
"access": "public"
|
|
27
38
|
},
|
|
28
39
|
"dependencies": {
|
|
29
|
-
"@mcp-native/a2ui": "^0.0
|
|
30
|
-
"@mcp-native/core": "^0.0
|
|
31
|
-
"@mcp-native/react-native": "^0.0
|
|
32
|
-
"@mcp-native/webview": "^0.0
|
|
40
|
+
"@mcp-native/a2ui": "^0.1.0",
|
|
41
|
+
"@mcp-native/core": "^0.1.0",
|
|
42
|
+
"@mcp-native/react-native": "^0.1.0",
|
|
43
|
+
"@mcp-native/webview": "^0.1.0"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"react": ">=18.3.1 <20",
|
|
47
|
+
"react-native": ">=0.76.0 <1"
|
|
48
|
+
},
|
|
49
|
+
"peerDependenciesMeta": {
|
|
50
|
+
"react-native": {
|
|
51
|
+
"optional": true
|
|
52
|
+
}
|
|
33
53
|
}
|
|
34
54
|
}
|