@mcp-native/webview 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.
Files changed (2) hide show
  1. package/README.md +88 -1
  2. package/package.json +14 -3
package/README.md CHANGED
@@ -1,3 +1,90 @@
1
+ <div align="center">
2
+
1
3
  # @mcp-native/webview
2
4
 
3
- Policy-gated HTML MCP App compatibility primitives for MCP Native.
5
+ ### A deny-by-default HTML MCP App compatibility boundary
6
+
7
+ [![npm](https://img.shields.io/npm/v/@mcp-native/webview)](https://www.npmjs.com/package/@mcp-native/webview)
8
+ [![downloads](https://img.shields.io/npm/dm/@mcp-native/webview)](https://www.npmjs.com/package/@mcp-native/webview)
9
+ [![license](https://img.shields.io/npm/l/@mcp-native/webview)](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 defines document validation and policy decisions. It does not yet mount or sandbox a platform WebView.
16
+
17
+ `@mcp-native/webview` handles the compatibility path for MCP resources that contain HTML. It recognizes supported MIME types, prefers inline documents, and rejects remote documents unless the host explicitly grants them through policy.
18
+
19
+ ## Install
20
+
21
+ ```bash
22
+ npm install @mcp-native/webview
23
+ ```
24
+
25
+ `@mcp-native/core` is installed as a dependency. The package is ESM-only and includes TypeScript declarations.
26
+
27
+ ## Inline HTML
28
+
29
+ ```ts
30
+ import { createWebViewDocument } from "@mcp-native/webview";
31
+
32
+ const document = createWebViewDocument({
33
+ uri: "mcp://example/app",
34
+ mimeType: "text/html",
35
+ text: "<main>Hello from an MCP App</main>",
36
+ });
37
+
38
+ // { kind: "inline", html: "...", baseUrl: "mcp://example/app" }
39
+ ```
40
+
41
+ ## Remote documents are denied by default
42
+
43
+ ```ts
44
+ import { createWebViewDocument, WebViewPolicyError } from "@mcp-native/webview";
45
+
46
+ const resource = {
47
+ uri: "https://example.com/app",
48
+ mimeType: "text/html",
49
+ };
50
+
51
+ try {
52
+ createWebViewDocument(resource);
53
+ } catch (error) {
54
+ if (error instanceof WebViewPolicyError) {
55
+ console.error(error.message);
56
+ }
57
+ }
58
+
59
+ const allowed = createWebViewDocument(resource, {
60
+ allowRemoteDocuments: true,
61
+ });
62
+ ```
63
+
64
+ ## Public API
65
+
66
+ | Export | Purpose |
67
+ | ----------------------- | ------------------------------------------------------------------------------ |
68
+ | `isHtmlResource` | Returns whether a resource declares a supported HTML MIME type. |
69
+ | `createWebViewDocument` | Validates a resource and returns an inline or policy-approved remote document. |
70
+ | `WebViewPolicy` | Host policy controlling whether remote documents are allowed. |
71
+ | `WebViewDocument` | Discriminated union for inline and remote documents. |
72
+ | `WebViewPolicyError` | Error thrown for unsupported MIME types or denied remote documents. |
73
+
74
+ Supported MIME types are `text/html` and `text/html+skybridge`.
75
+
76
+ ## Host responsibilities
77
+
78
+ Returning a `WebViewDocument` is not permission to render it without further controls. A production host must still define:
79
+
80
+ - allowed origins and navigation rules;
81
+ - bridge message schemas and directionality;
82
+ - storage, cookie, download, and external-link policy;
83
+ - camera, microphone, location, clipboard, and filesystem permissions;
84
+ - process isolation and platform-specific WebView hardening.
85
+
86
+ See the repository's [security policy](https://github.com/pablospaniard/mcp-native/blob/main/SECURITY.md) before expanding this boundary. Install [`mcp-native`](https://www.npmjs.com/package/mcp-native) for the complete public API.
87
+
88
+ ## License
89
+
90
+ [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/webview",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Policy-gated WebView fallback primitives for MCP Native.",
5
+ "keywords": [
6
+ "mcp",
7
+ "mcp-apps",
8
+ "model-context-protocol",
9
+ "security",
10
+ "webview"
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/webview"
10
21
  },
11
22
  "files": [
@@ -26,6 +37,6 @@
26
37
  "access": "public"
27
38
  },
28
39
  "dependencies": {
29
- "@mcp-native/core": "^0.0.2"
40
+ "@mcp-native/core": "^0.0.3"
30
41
  }
31
42
  }