mcp-native 0.0.3 → 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.
Files changed (2) hide show
  1. package/README.md +37 -19
  2. package/package.json +14 -5
package/README.md CHANGED
@@ -9,47 +9,57 @@
9
9
  [![license](https://img.shields.io/npm/l/mcp-native)](https://github.com/pablospaniard/mcp-native/blob/main/LICENSE)
10
10
  [![CI](https://github.com/pablospaniard/mcp-native/actions/workflows/ci.yml/badge.svg)](https://github.com/pablospaniard/mcp-native/actions/workflows/ci.yml)
11
11
 
12
- [GitHub](https://github.com/pablospaniard/mcp-native) · [Architecture](https://github.com/pablospaniard/mcp-native/blob/main/docs/RFC-0001-architecture.md) · [Contributing](https://github.com/pablospaniard/mcp-native/blob/main/CONTRIBUTING.md) · [Security](https://github.com/pablospaniard/mcp-native/blob/main/SECURITY.md)
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
13
 
14
14
  </div>
15
15
 
16
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
17
 
18
- `mcp-native` is the convenience package for the complete public API. It re-exports the runtime contracts, declarative surface parser, trusted native render-plan builder, and policy-gated WebView compatibility primitives from the focused `@mcp-native/*` packages.
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.
19
21
 
20
22
  ## Install
21
23
 
22
24
  ```bash
23
- npm install mcp-native
25
+ npm install mcp-native react
24
26
  ```
25
27
 
26
- The package is ESM-only and includes TypeScript declarations.
28
+ Add `react-native` when mounting native surfaces. The package is ESM-only and includes TypeScript declarations.
27
29
 
28
30
  ## End-to-end preview
29
31
 
30
- ```ts
32
+ ```tsx
31
33
  import {
34
+ McpNativeSurface,
32
35
  McpNativeRuntime,
33
- createNativeRenderPlan,
36
+ createAllowlistActionPolicy,
34
37
  parseA2uiSurface,
38
+ useMcpNativeActionDispatcher,
35
39
  type McpClient,
36
40
  } from "mcp-native";
41
+ import { Button, Text, TextInput, View } from "react-native";
42
+
43
+ const components = { Button, Text, TextInput, View };
37
44
 
38
45
  const client: McpClient = {
39
46
  async listTools() {
40
- return [];
47
+ return { tools: [] };
41
48
  },
42
49
  async callTool(name, arguments_) {
43
50
  return {
44
- content: [{ type: "json", data: { name, arguments: arguments_ } }],
51
+ content: [{ type: "text", text: `Called ${name}` }],
52
+ structuredContent: { name, arguments: arguments_ },
45
53
  };
46
54
  },
47
55
  async readResource(uri) {
48
- return { uri };
56
+ return { contents: [{ uri, text: "" }] };
49
57
  },
50
58
  };
51
59
 
52
- const runtime = new McpNativeRuntime(client);
60
+ const runtime = new McpNativeRuntime(client, {
61
+ actionPolicy: createAllowlistActionPolicy([{ name: "continue_flow" }]),
62
+ });
53
63
 
54
64
  const surface = parseA2uiSurface({
55
65
  version: "0.1",
@@ -68,37 +78,45 @@ const surface = parseA2uiSurface({
68
78
  },
69
79
  });
70
80
 
71
- const plan = createNativeRenderPlan(surface);
72
- const button = surface.root.type === "container" ? surface.root.children[1] : undefined;
81
+ function NativeScreen() {
82
+ const onAction = useMcpNativeActionDispatcher(runtime, {
83
+ onError: (error) => console.error("MCP action failed", error),
84
+ });
73
85
 
74
- if (button?.type === "button") {
75
- await runtime.dispatch(button.action);
86
+ return <McpNativeSurface surface={surface} components={components} onAction={onAction} />;
76
87
  }
77
88
  ```
78
89
 
79
- The host maps the trusted names in `plan` to locally bundled native components. MCP Native never downloads and executes server-provided React Native JavaScript.
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.
80
91
 
81
92
  ## Included packages
82
93
 
83
94
  | Package | What it provides |
84
95
  | ------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------- |
85
96
  | [`@mcp-native/core`](https://www.npmjs.com/package/@mcp-native/core) | MCP client contracts, runtime delegation, JSON types, and declared tool actions. |
86
- | [`@mcp-native/a2ui`](https://www.npmjs.com/package/@mcp-native/a2ui) | Strict parsing for the initial declarative surface model. |
87
- | [`@mcp-native/react-native`](https://www.npmjs.com/package/@mcp-native/react-native) | Serializable render plans with a fixed native component catalog. |
88
- | [`@mcp-native/webview`](https://www.npmjs.com/package/@mcp-native/webview) | MIME validation and deny-by-default remote HTML policy. |
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. |
89
100
 
90
101
  Install an individual package instead when you only need one layer.
91
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
+
92
105
  ## What works today
93
106
 
94
107
  - transport-independent MCP runtime contracts;
95
108
  - strict validation for container, text, button, and text-input nodes;
96
109
  - declared tool-action dispatch;
110
+ - strict A2UI resource-link resolution from tool results;
97
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;
98
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;
99
117
  - ESM exports, TypeScript declarations, automated tests, and signed npm provenance.
100
118
 
101
- The project does not yet include an official MCP SDK adapter, mounted React Native components, streaming UI updates, capability negotiation, or a runnable mobile demo. Follow the [roadmap](https://github.com/pablospaniard/mcp-native#roadmap) for progress.
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.
102
120
 
103
121
  ## Security model
104
122
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-native",
3
- "version": "0.0.3",
3
+ "version": "0.1.0",
4
4
  "description": "Convenience package for the MCP Native runtime.",
5
5
  "keywords": [
6
6
  "a2ui",
@@ -37,9 +37,18 @@
37
37
  "access": "public"
38
38
  },
39
39
  "dependencies": {
40
- "@mcp-native/a2ui": "^0.0.3",
41
- "@mcp-native/core": "^0.0.3",
42
- "@mcp-native/react-native": "^0.0.3",
43
- "@mcp-native/webview": "^0.0.3"
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
+ }
44
53
  }
45
54
  }