@mcp-native/core 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 +137 -1
- package/dist/index.d.ts +152 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +250 -5
- package/dist/index.js.map +1 -1
- package/package.json +12 -2
package/README.md
CHANGED
|
@@ -1,3 +1,139 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
1
3
|
# @mcp-native/core
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
### Transport-neutral MCP runtime contracts and safe action routing
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@mcp-native/core)
|
|
8
|
+
[](https://www.npmjs.com/package/@mcp-native/core)
|
|
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) · [Standards status](https://github.com/pablospaniard/mcp-native/blob/main/docs/standards-compatibility.md) · [Security](https://github.com/pablospaniard/mcp-native/blob/main/SECURITY.md)
|
|
12
|
+
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
> **Experimental:** this package is an early proof of concept. Its public API may change before `1.0.0`.
|
|
16
|
+
|
|
17
|
+
`@mcp-native/core` is the protocol- and renderer-independent foundation of MCP Native. It defines the small MCP client boundary consumed by the runtime and routes declared actions without depending on A2UI, React Native, WebViews, or a specific MCP SDK transport.
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @mcp-native/core
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The package is ESM-only and includes TypeScript declarations.
|
|
26
|
+
|
|
27
|
+
## Quick start
|
|
28
|
+
|
|
29
|
+
Adapt any MCP client to the `McpClient` interface, then use `McpNativeRuntime` to coordinate operations:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { McpNativeRuntime, createAllowlistActionPolicy, type McpClient } from "@mcp-native/core";
|
|
33
|
+
|
|
34
|
+
const client: McpClient = {
|
|
35
|
+
async listTools() {
|
|
36
|
+
return {
|
|
37
|
+
tools: [
|
|
38
|
+
{
|
|
39
|
+
name: "save_profile",
|
|
40
|
+
description: "Save profile details",
|
|
41
|
+
inputSchema: { type: "object" },
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
async callTool(name, arguments_) {
|
|
47
|
+
return {
|
|
48
|
+
content: [{ type: "text", text: `Called ${name}` }],
|
|
49
|
+
structuredContent: { name, arguments: arguments_ },
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
async readResource(uri) {
|
|
53
|
+
return {
|
|
54
|
+
contents: [{ uri, mimeType: "text/plain", text: "Hello from MCP" }],
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const runtime = new McpNativeRuntime(client, {
|
|
60
|
+
actionPolicy: createAllowlistActionPolicy([
|
|
61
|
+
{ name: "save_profile", arguments: { displayName: "Ada" } },
|
|
62
|
+
]),
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
await runtime.dispatch({
|
|
66
|
+
type: "tool",
|
|
67
|
+
name: "save_profile",
|
|
68
|
+
arguments: { displayName: "Ada" },
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Public API
|
|
73
|
+
|
|
74
|
+
| Export | Purpose |
|
|
75
|
+
| -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
|
|
76
|
+
| `McpNativeRuntime` | Delegates tool listing, tool calls, resource reads, and declared actions to an `McpClient`. |
|
|
77
|
+
| `McpClient` | Minimal interface implemented by an SDK- or transport-specific adapter. |
|
|
78
|
+
| `McpTool`, `McpListToolsResult`, `McpResource`, `McpReadResourceResult`, `McpToolCallResult` | Transport-neutral MCP data contracts used by the runtime. |
|
|
79
|
+
| `McpContent` and its discriminated content interfaces | Exact text, image, audio, resource-link, and embedded-resource shapes. |
|
|
80
|
+
| `McpAnnotations`, `McpToolAnnotations`, `McpIcon`, `McpCacheScope` | Official metadata, presentation hints, and response-cache contracts. |
|
|
81
|
+
| `ToolAction`, `McpNativeAction` | Declarative actions that can be dispatched through the runtime. |
|
|
82
|
+
| `McpNativeRuntimeOptions`, `McpNativeActionPolicy` | Host policy controlling which validated surface actions `dispatch()` may execute. |
|
|
83
|
+
| `createAllowlistActionPolicy`, `McpNativeToolAllowlistEntry` | Fail-closed helper that authorizes tools by name and exact or predicated arguments. |
|
|
84
|
+
| `McpNativeActionDeniedError` | Fail-closed error for actions not explicitly allowed by the host. |
|
|
85
|
+
| `parseMcpNativeAction`, `parseJsonObject`, `parseJsonValue` | Strict validators that return safely reconstructed untrusted data. |
|
|
86
|
+
| `JSON_MAX_DEPTH`, `JSON_MAX_VALUES`, `JSON_MAX_STRING_LENGTH` | Fixed complexity limits applied by the public JSON validators. |
|
|
87
|
+
| `JsonValidationError` | Error for non-JSON, circular, non-plain, or non-finite input. |
|
|
88
|
+
| `JsonPrimitive`, `JsonValue`, `JsonObject` | JSON-safe value types for untrusted protocol data. |
|
|
89
|
+
|
|
90
|
+
## Pre-1.0 MCP result migration
|
|
91
|
+
|
|
92
|
+
The initial `0.0.x` proof of concept returned one `McpResource` directly from `readResource`. The official SDK returns a content collection, so implementations now return `McpReadResourceResult`:
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
// Before
|
|
96
|
+
return { uri, text: "Hello" };
|
|
97
|
+
|
|
98
|
+
// Current RFC-0001 contract
|
|
99
|
+
return { contents: [{ uri, text: "Hello" }] };
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Preserving the collection avoids silently discarding valid resource items.
|
|
103
|
+
|
|
104
|
+
Tool listings likewise preserve result metadata and cache hints, so `listTools()` now returns an object:
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
// Before
|
|
108
|
+
return [{ name: "save", inputSchema: { type: "object" } }];
|
|
109
|
+
|
|
110
|
+
// Current RFC-0001 contract
|
|
111
|
+
return { tools: [{ name: "save", inputSchema: { type: "object" } }] };
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Content blocks now use MCP's official discriminated fields. Replace `{ type: "text", data: { text } }` with `{ type: "text", text }`; resource links similarly expose `name`, `uri`, and `mimeType` directly.
|
|
115
|
+
|
|
116
|
+
## Design boundaries
|
|
117
|
+
|
|
118
|
+
- No React Native dependency.
|
|
119
|
+
- No A2UI or WebView dependency.
|
|
120
|
+
- No transport or official MCP SDK dependency.
|
|
121
|
+
- No remote code loading or execution.
|
|
122
|
+
- Surface-driven `dispatch()` is denied unless the host's action policy explicitly allows it.
|
|
123
|
+
- Direct `callTool()` is a lower-level API for trusted host code. It validates JSON arguments but does not apply the surface action policy.
|
|
124
|
+
- Prefer `createAllowlistActionPolicy()` so surface authorization covers tool arguments, not only tool names.
|
|
125
|
+
- Untrusted JSON is reconstructed without prototype mutation and rejects cycles, non-plain objects, non-finite numbers, excessive depth, excessive value counts, and oversized strings or object keys.
|
|
126
|
+
- Declared actions reject fields outside the exact `{ type, name, arguments? }` contract.
|
|
127
|
+
- Host applications remain responsible for authentication, permissions, transport security, and user approval.
|
|
128
|
+
|
|
129
|
+
## Related packages
|
|
130
|
+
|
|
131
|
+
- [`@mcp-native/a2ui`](https://www.npmjs.com/package/@mcp-native/a2ui) validates declarative surfaces and actions.
|
|
132
|
+
- [`@mcp-native/mcp`](https://github.com/pablospaniard/mcp-native/tree/main/packages/mcp) adapts connected official SDK clients to this package's contracts.
|
|
133
|
+
- [`@mcp-native/react-native`](https://www.npmjs.com/package/@mcp-native/react-native) converts validated surfaces into trusted native render plans.
|
|
134
|
+
- [`@mcp-native/webview`](https://www.npmjs.com/package/@mcp-native/webview) defines the HTML compatibility policy boundary.
|
|
135
|
+
- [`mcp-native`](https://www.npmjs.com/package/mcp-native) re-exports the runtime and UI APIs.
|
|
136
|
+
|
|
137
|
+
## License
|
|
138
|
+
|
|
139
|
+
[MIT](https://github.com/pablospaniard/mcp-native/blob/main/LICENSE)
|
package/dist/index.d.ts
CHANGED
|
@@ -3,33 +3,135 @@ export type JsonValue = JsonPrimitive | JsonObject | readonly JsonValue[];
|
|
|
3
3
|
export interface JsonObject {
|
|
4
4
|
readonly [key: string]: JsonValue;
|
|
5
5
|
}
|
|
6
|
+
/** Maximum nesting depth accepted by the public JSON validators (root is depth 0). */
|
|
7
|
+
export declare const JSON_MAX_DEPTH = 64;
|
|
8
|
+
/** Maximum number of values accepted in one JSON graph. */
|
|
9
|
+
export declare const JSON_MAX_VALUES = 10000;
|
|
10
|
+
/** Maximum UTF-16 code units accepted in one JSON string. */
|
|
11
|
+
export declare const JSON_MAX_STRING_LENGTH = 65536;
|
|
12
|
+
/** Thrown when an untrusted value cannot be represented as JSON data. */
|
|
13
|
+
export declare class JsonValidationError extends TypeError {
|
|
14
|
+
constructor(message: string);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Validates and safely reconstructs an untrusted JSON object.
|
|
18
|
+
*
|
|
19
|
+
* The returned object keeps keys such as `__proto__` as ordinary own data
|
|
20
|
+
* properties instead of invoking legacy prototype setters.
|
|
21
|
+
*/
|
|
22
|
+
export declare function parseJsonObject(value: unknown, path?: string): JsonObject;
|
|
23
|
+
/** Validates and safely reconstructs an untrusted JSON value. */
|
|
24
|
+
export declare function parseJsonValue(value: unknown, path?: string): JsonValue;
|
|
25
|
+
export type McpRole = "assistant" | "user";
|
|
26
|
+
export interface McpAnnotations {
|
|
27
|
+
readonly audience?: readonly McpRole[];
|
|
28
|
+
readonly priority?: number;
|
|
29
|
+
readonly lastModified?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface McpIcon {
|
|
32
|
+
readonly src: string;
|
|
33
|
+
readonly mimeType?: string;
|
|
34
|
+
readonly sizes?: readonly string[];
|
|
35
|
+
readonly theme?: "dark" | "light";
|
|
36
|
+
}
|
|
37
|
+
export interface McpToolAnnotations {
|
|
38
|
+
readonly title?: string;
|
|
39
|
+
readonly readOnlyHint?: boolean;
|
|
40
|
+
readonly destructiveHint?: boolean;
|
|
41
|
+
readonly idempotentHint?: boolean;
|
|
42
|
+
readonly openWorldHint?: boolean;
|
|
43
|
+
}
|
|
6
44
|
export interface McpTool {
|
|
45
|
+
readonly icons?: readonly McpIcon[];
|
|
7
46
|
readonly name: string;
|
|
47
|
+
readonly title?: string;
|
|
8
48
|
readonly description?: string;
|
|
9
49
|
readonly inputSchema: JsonObject;
|
|
50
|
+
readonly outputSchema?: JsonObject;
|
|
51
|
+
readonly annotations?: McpToolAnnotations;
|
|
52
|
+
readonly _meta?: JsonObject;
|
|
53
|
+
}
|
|
54
|
+
export interface McpTextContent {
|
|
55
|
+
readonly type: "text";
|
|
56
|
+
readonly text: string;
|
|
57
|
+
readonly annotations?: McpAnnotations;
|
|
58
|
+
readonly _meta?: JsonObject;
|
|
59
|
+
}
|
|
60
|
+
export interface McpImageContent {
|
|
61
|
+
readonly type: "image";
|
|
62
|
+
readonly data: string;
|
|
63
|
+
readonly mimeType: string;
|
|
64
|
+
readonly annotations?: McpAnnotations;
|
|
65
|
+
readonly _meta?: JsonObject;
|
|
66
|
+
}
|
|
67
|
+
export interface McpAudioContent {
|
|
68
|
+
readonly type: "audio";
|
|
69
|
+
readonly data: string;
|
|
70
|
+
readonly mimeType: string;
|
|
71
|
+
readonly annotations?: McpAnnotations;
|
|
72
|
+
readonly _meta?: JsonObject;
|
|
73
|
+
}
|
|
74
|
+
export interface McpResourceLink {
|
|
75
|
+
readonly type: "resource_link";
|
|
76
|
+
readonly icons?: readonly McpIcon[];
|
|
77
|
+
readonly name: string;
|
|
78
|
+
readonly title?: string;
|
|
79
|
+
readonly uri: string;
|
|
80
|
+
readonly description?: string;
|
|
81
|
+
readonly mimeType?: string;
|
|
82
|
+
readonly annotations?: McpAnnotations;
|
|
83
|
+
readonly size?: number;
|
|
84
|
+
readonly _meta?: JsonObject;
|
|
10
85
|
}
|
|
11
|
-
|
|
12
|
-
readonly
|
|
13
|
-
readonly
|
|
86
|
+
interface McpResourceContentsBase {
|
|
87
|
+
readonly uri: string;
|
|
88
|
+
readonly mimeType?: string;
|
|
89
|
+
readonly _meta?: JsonObject;
|
|
90
|
+
}
|
|
91
|
+
export interface McpTextResourceContents extends McpResourceContentsBase {
|
|
92
|
+
readonly text: string;
|
|
93
|
+
readonly blob?: never;
|
|
94
|
+
}
|
|
95
|
+
export interface McpBlobResourceContents extends McpResourceContentsBase {
|
|
96
|
+
readonly blob: string;
|
|
97
|
+
readonly text?: never;
|
|
14
98
|
}
|
|
99
|
+
export type McpResource = McpTextResourceContents | McpBlobResourceContents;
|
|
100
|
+
export interface McpEmbeddedResource {
|
|
101
|
+
readonly type: "resource";
|
|
102
|
+
readonly resource: McpResource;
|
|
103
|
+
readonly annotations?: McpAnnotations;
|
|
104
|
+
readonly _meta?: JsonObject;
|
|
105
|
+
}
|
|
106
|
+
export type McpContent = McpAudioContent | McpEmbeddedResource | McpImageContent | McpResourceLink | McpTextContent;
|
|
15
107
|
export interface McpToolCallResult {
|
|
16
108
|
readonly content: readonly McpContent[];
|
|
17
109
|
readonly isError?: boolean;
|
|
110
|
+
readonly structuredContent?: JsonValue;
|
|
111
|
+
readonly _meta?: JsonObject;
|
|
18
112
|
}
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
readonly
|
|
22
|
-
readonly
|
|
23
|
-
readonly
|
|
113
|
+
export type McpCacheScope = "private" | "public";
|
|
114
|
+
export interface McpListToolsResult {
|
|
115
|
+
readonly tools: readonly McpTool[];
|
|
116
|
+
readonly nextCursor?: string;
|
|
117
|
+
readonly ttlMs?: number;
|
|
118
|
+
readonly cacheScope?: McpCacheScope;
|
|
119
|
+
readonly _meta?: JsonObject;
|
|
120
|
+
}
|
|
121
|
+
export interface McpReadResourceResult {
|
|
122
|
+
readonly contents: readonly McpResource[];
|
|
123
|
+
readonly ttlMs?: number;
|
|
124
|
+
readonly cacheScope?: McpCacheScope;
|
|
125
|
+
readonly _meta?: JsonObject;
|
|
24
126
|
}
|
|
25
127
|
/**
|
|
26
128
|
* The small client boundary consumed by the runtime. SDK-specific clients can
|
|
27
129
|
* implement this interface without coupling the core package to a transport.
|
|
28
130
|
*/
|
|
29
131
|
export interface McpClient {
|
|
30
|
-
listTools(): Promise<
|
|
132
|
+
listTools(): Promise<McpListToolsResult>;
|
|
31
133
|
callTool(name: string, arguments_: JsonObject): Promise<McpToolCallResult>;
|
|
32
|
-
readResource(uri: string): Promise<
|
|
134
|
+
readResource(uri: string): Promise<McpReadResourceResult>;
|
|
33
135
|
}
|
|
34
136
|
export interface ToolAction {
|
|
35
137
|
readonly type: "tool";
|
|
@@ -37,6 +139,42 @@ export interface ToolAction {
|
|
|
37
139
|
readonly arguments?: JsonObject;
|
|
38
140
|
}
|
|
39
141
|
export type McpNativeAction = ToolAction;
|
|
142
|
+
/** Validates and safely reconstructs a surface-declared native action. */
|
|
143
|
+
export declare function parseMcpNativeAction(value: unknown, path?: string): McpNativeAction;
|
|
144
|
+
/** A host-owned policy deciding which validated tool actions may execute. */
|
|
145
|
+
export type McpNativeActionPolicy = (action: McpNativeAction) => boolean | Promise<boolean>;
|
|
146
|
+
/**
|
|
147
|
+
* An allowlist entry that authorizes a tool by name and either exact arguments
|
|
148
|
+
* or a host-provided argument predicate. Name-only allowlists are intentionally
|
|
149
|
+
* unsupported — omit `arguments` to require empty/missing arguments, or supply
|
|
150
|
+
* `authorizeArguments` for dynamic checks.
|
|
151
|
+
*
|
|
152
|
+
* `authorizeArguments` may be sync or async, but must resolve to a boolean.
|
|
153
|
+
* Only an explicit `true` authorizes; thenables are awaited so a denied async
|
|
154
|
+
* predicate cannot be treated as a truthy Promise object.
|
|
155
|
+
*/
|
|
156
|
+
export type McpNativeToolAllowlistEntry = {
|
|
157
|
+
readonly name: string;
|
|
158
|
+
/** Exact JSON arguments required. Omit to allow only empty/missing arguments. */
|
|
159
|
+
readonly arguments?: JsonObject;
|
|
160
|
+
} | {
|
|
161
|
+
readonly name: string;
|
|
162
|
+
readonly authorizeArguments: (arguments_?: JsonObject) => boolean | Promise<boolean>;
|
|
163
|
+
};
|
|
164
|
+
/** Builds a fail-closed action policy from an explicit tool/argument allowlist. */
|
|
165
|
+
export declare function createAllowlistActionPolicy(allowlist: readonly McpNativeToolAllowlistEntry[]): McpNativeActionPolicy;
|
|
166
|
+
export interface McpNativeRuntimeOptions {
|
|
167
|
+
/**
|
|
168
|
+
* Authorizes surface-driven actions through `dispatch()` only. When omitted,
|
|
169
|
+
* `dispatch()` denies every action. Trusted host code can continue to use
|
|
170
|
+
* `callTool()` directly after JSON argument validation.
|
|
171
|
+
*/
|
|
172
|
+
readonly actionPolicy?: McpNativeActionPolicy;
|
|
173
|
+
}
|
|
174
|
+
export declare class McpNativeActionDeniedError extends Error {
|
|
175
|
+
readonly toolName: string;
|
|
176
|
+
constructor(toolName: string);
|
|
177
|
+
}
|
|
40
178
|
/**
|
|
41
179
|
* Coordinates MCP operations without knowing about A2UI, React Native, or any
|
|
42
180
|
* other renderer. It deliberately routes declared actions instead of loading
|
|
@@ -44,10 +182,11 @@ export type McpNativeAction = ToolAction;
|
|
|
44
182
|
*/
|
|
45
183
|
export declare class McpNativeRuntime {
|
|
46
184
|
#private;
|
|
47
|
-
constructor(client: McpClient);
|
|
48
|
-
listTools(): Promise<
|
|
185
|
+
constructor(client: McpClient, options?: McpNativeRuntimeOptions);
|
|
186
|
+
listTools(): Promise<McpListToolsResult>;
|
|
49
187
|
callTool(name: string, arguments_?: JsonObject): Promise<McpToolCallResult>;
|
|
50
|
-
readResource(uri: string): Promise<
|
|
188
|
+
readResource(uri: string): Promise<McpReadResourceResult>;
|
|
51
189
|
dispatch(action: McpNativeAction): Promise<McpToolCallResult>;
|
|
52
190
|
}
|
|
191
|
+
export {};
|
|
53
192
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7D,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,UAAU,GAAG,SAAS,SAAS,EAAE,CAAC;AAE1E,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC;AAED,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7D,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,UAAU,GAAG,SAAS,SAAS,EAAE,CAAC;AAE1E,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC;AAED,sFAAsF;AACtF,eAAO,MAAM,cAAc,KAAK,CAAC;AACjC,2DAA2D;AAC3D,eAAO,MAAM,eAAe,QAAS,CAAC;AACtC,6DAA6D;AAC7D,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAE7C,yEAAyE;AACzE,qBAAa,mBAAoB,SAAQ,SAAS;IAChD,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,SAAU,GAAG,UAAU,CAE1E;AAED,iEAAiE;AACjE,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI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IACtB,iFAAiF;IACjF,QAAQ,CAAC,SAAS,CAAC,EAAE,UAAU,CAAC;CACjC,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,kBAAkB,EAAE,CAAC,UAAU,CAAC,EAAE,UAAU,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACtF,CAAC;AAEN,mFAAmF;AACnF,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,SAAS,2BAA2B,EAAE,GAChD,qBAAqB,CA+CvB;AAED,MAAM,WAAW,uBAAuB;IACtC;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,qBAAqB,CAAC;CAC/C;AAED,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B,YAAY,QAAQ,EAAE,MAAM,EAI3B;CACF;AAED;;;;GAIG;AACH,qBAAa,gBAAgB;;IAI3B,YAAY,MAAM,EAAE,SAAS,EAAE,OAAO,GAAE,uBAA4B,EAGnE;IAED,SAAS,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAEvC;IAEK,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,GAAE,UAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAOpF;IAED,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAExD;IAEK,QAAQ,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAUlE;CACF"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,104 @@
|
|
|
1
|
+
/** Maximum nesting depth accepted by the public JSON validators (root is depth 0). */
|
|
2
|
+
export const JSON_MAX_DEPTH = 64;
|
|
3
|
+
/** Maximum number of values accepted in one JSON graph. */
|
|
4
|
+
export const JSON_MAX_VALUES = 10_000;
|
|
5
|
+
/** Maximum UTF-16 code units accepted in one JSON string. */
|
|
6
|
+
export const JSON_MAX_STRING_LENGTH = 65_536;
|
|
7
|
+
/** Thrown when an untrusted value cannot be represented as JSON data. */
|
|
8
|
+
export class JsonValidationError extends TypeError {
|
|
9
|
+
constructor(message) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = "JsonValidationError";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Validates and safely reconstructs an untrusted JSON object.
|
|
16
|
+
*
|
|
17
|
+
* The returned object keeps keys such as `__proto__` as ordinary own data
|
|
18
|
+
* properties instead of invoking legacy prototype setters.
|
|
19
|
+
*/
|
|
20
|
+
export function parseJsonObject(value, path = "value") {
|
|
21
|
+
return parseJsonObjectWithState(value, path, createJsonValidationState(), 0);
|
|
22
|
+
}
|
|
23
|
+
/** Validates and safely reconstructs an untrusted JSON value. */
|
|
24
|
+
export function parseJsonValue(value, path = "value") {
|
|
25
|
+
return parseJsonValueWithState(value, path, createJsonValidationState(), 0);
|
|
26
|
+
}
|
|
27
|
+
/** Validates and safely reconstructs a surface-declared native action. */
|
|
28
|
+
export function parseMcpNativeAction(value, path = "action") {
|
|
29
|
+
const action = expectPlainObject(value, path);
|
|
30
|
+
expectOnlyKeys(action, ["arguments", "name", "type"], path);
|
|
31
|
+
if (action.type !== "tool") {
|
|
32
|
+
throw new JsonValidationError(`Expected the string "tool" at ${path}.type`);
|
|
33
|
+
}
|
|
34
|
+
if (typeof action.name !== "string") {
|
|
35
|
+
throw new JsonValidationError(`Expected a string at ${path}.name`);
|
|
36
|
+
}
|
|
37
|
+
if (action.name.length === 0) {
|
|
38
|
+
throw new JsonValidationError(`Expected a non-empty string at ${path}.name`);
|
|
39
|
+
}
|
|
40
|
+
if (action.name.length > JSON_MAX_STRING_LENGTH) {
|
|
41
|
+
throw new JsonValidationError(`String at ${path}.name exceeds maximum length of ${JSON_MAX_STRING_LENGTH}`);
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
type: "tool",
|
|
45
|
+
name: action.name,
|
|
46
|
+
...(action.arguments === undefined
|
|
47
|
+
? {}
|
|
48
|
+
: { arguments: parseJsonObject(action.arguments, `${path}.arguments`) }),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** Builds a fail-closed action policy from an explicit tool/argument allowlist. */
|
|
52
|
+
export function createAllowlistActionPolicy(allowlist) {
|
|
53
|
+
const entries = allowlist.map((entry) => {
|
|
54
|
+
if (typeof entry.name !== "string" || entry.name.length === 0) {
|
|
55
|
+
throw new JsonValidationError("Expected a non-empty allowlist tool name");
|
|
56
|
+
}
|
|
57
|
+
if ("authorizeArguments" in entry) {
|
|
58
|
+
if (typeof entry.authorizeArguments !== "function") {
|
|
59
|
+
throw new JsonValidationError(`Expected authorizeArguments to be a function for tool ${entry.name}`);
|
|
60
|
+
}
|
|
61
|
+
return entry;
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
name: entry.name,
|
|
65
|
+
arguments: entry.arguments === undefined
|
|
66
|
+
? undefined
|
|
67
|
+
: parseJsonObject(entry.arguments, `allowlist.${entry.name}.arguments`),
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
return async (action) => {
|
|
71
|
+
for (const entry of entries) {
|
|
72
|
+
if (entry.name !== action.name) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if ("authorizeArguments" in entry) {
|
|
76
|
+
// Predicates must run sequentially so a denied match does not race later entries.
|
|
77
|
+
// eslint-disable-next-line no-await-in-loop -- intentional fail-closed short-circuit
|
|
78
|
+
const allowed = await entry.authorizeArguments(action.arguments);
|
|
79
|
+
if (allowed === true) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
if (allowed !== false) {
|
|
83
|
+
throw new JsonValidationError(`authorizeArguments for tool ${entry.name} must return a boolean`);
|
|
84
|
+
}
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (jsonArgumentsMatch(entry.arguments, action.arguments)) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return false;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export class McpNativeActionDeniedError extends Error {
|
|
95
|
+
toolName;
|
|
96
|
+
constructor(toolName) {
|
|
97
|
+
super(`MCP native action denied by host policy: ${toolName}`);
|
|
98
|
+
this.name = "McpNativeActionDeniedError";
|
|
99
|
+
this.toolName = toolName;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
1
102
|
/**
|
|
2
103
|
* Coordinates MCP operations without knowing about A2UI, React Native, or any
|
|
3
104
|
* other renderer. It deliberately routes declared actions instead of loading
|
|
@@ -5,20 +106,164 @@
|
|
|
5
106
|
*/
|
|
6
107
|
export class McpNativeRuntime {
|
|
7
108
|
#client;
|
|
8
|
-
|
|
109
|
+
#actionPolicy;
|
|
110
|
+
constructor(client, options = {}) {
|
|
9
111
|
this.#client = client;
|
|
112
|
+
this.#actionPolicy = options.actionPolicy;
|
|
10
113
|
}
|
|
11
114
|
listTools() {
|
|
12
115
|
return this.#client.listTools();
|
|
13
116
|
}
|
|
14
|
-
callTool(name, arguments_ = {}) {
|
|
15
|
-
|
|
117
|
+
async callTool(name, arguments_ = {}) {
|
|
118
|
+
const validatedAction = parseMcpNativeAction({
|
|
119
|
+
type: "tool",
|
|
120
|
+
name,
|
|
121
|
+
arguments: arguments_,
|
|
122
|
+
});
|
|
123
|
+
return this.#client.callTool(validatedAction.name, validatedAction.arguments ?? {});
|
|
16
124
|
}
|
|
17
125
|
readResource(uri) {
|
|
18
126
|
return this.#client.readResource(uri);
|
|
19
127
|
}
|
|
20
|
-
dispatch(action) {
|
|
21
|
-
|
|
128
|
+
async dispatch(action) {
|
|
129
|
+
const validatedAction = parseMcpNativeAction(action);
|
|
130
|
+
if (this.#actionPolicy === undefined) {
|
|
131
|
+
throw new McpNativeActionDeniedError(validatedAction.name);
|
|
132
|
+
}
|
|
133
|
+
const allowed = await this.#actionPolicy(validatedAction);
|
|
134
|
+
if (allowed !== true) {
|
|
135
|
+
throw new McpNativeActionDeniedError(validatedAction.name);
|
|
136
|
+
}
|
|
137
|
+
return this.#client.callTool(validatedAction.name, validatedAction.arguments ?? {});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function jsonArgumentsMatch(expected, actual) {
|
|
141
|
+
if (expected === undefined) {
|
|
142
|
+
return actual === undefined || Object.keys(actual).length === 0;
|
|
143
|
+
}
|
|
144
|
+
if (actual === undefined) {
|
|
145
|
+
return Object.keys(expected).length === 0;
|
|
146
|
+
}
|
|
147
|
+
return jsonValuesEqual(expected, actual);
|
|
148
|
+
}
|
|
149
|
+
function jsonValuesEqual(left, right) {
|
|
150
|
+
if (left === right) {
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
if (left === null || right === null || typeof left !== typeof right) {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
if (typeof left !== "object" || typeof right !== "object") {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
if (Array.isArray(left)) {
|
|
160
|
+
if (!Array.isArray(right) || left.length !== right.length) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
return left.every((value, index) => jsonValuesEqual(value, right[index]));
|
|
22
164
|
}
|
|
165
|
+
if (Array.isArray(right)) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
const leftObject = left;
|
|
169
|
+
const rightObject = right;
|
|
170
|
+
const leftKeys = Object.keys(leftObject);
|
|
171
|
+
const rightKeys = Object.keys(rightObject);
|
|
172
|
+
if (leftKeys.length !== rightKeys.length) {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
return leftKeys.every((key) => Object.hasOwn(rightObject, key) && jsonValuesEqual(leftObject[key], rightObject[key]));
|
|
176
|
+
}
|
|
177
|
+
function expectPlainObject(value, path) {
|
|
178
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
179
|
+
throw new JsonValidationError(`Expected an object at ${path}`);
|
|
180
|
+
}
|
|
181
|
+
const prototype = Object.getPrototypeOf(value);
|
|
182
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
183
|
+
throw new JsonValidationError(`Expected a plain object at ${path}`);
|
|
184
|
+
}
|
|
185
|
+
return value;
|
|
186
|
+
}
|
|
187
|
+
function createJsonValidationState() {
|
|
188
|
+
return { ancestors: new Set(), values: 0 };
|
|
189
|
+
}
|
|
190
|
+
function parseJsonObjectWithState(value, path, state, depth) {
|
|
191
|
+
consumeJsonBudget(state, path, depth);
|
|
192
|
+
const object = expectPlainObject(value, path);
|
|
193
|
+
if (state.ancestors.has(object)) {
|
|
194
|
+
throw new JsonValidationError(`Circular JSON value at ${path}`);
|
|
195
|
+
}
|
|
196
|
+
state.ancestors.add(object);
|
|
197
|
+
const result = {};
|
|
198
|
+
for (const [key, child] of Object.entries(object)) {
|
|
199
|
+
if (key.length > JSON_MAX_STRING_LENGTH) {
|
|
200
|
+
throw new JsonValidationError(`JSON object key at ${path} exceeds maximum length of ${JSON_MAX_STRING_LENGTH}`);
|
|
201
|
+
}
|
|
202
|
+
defineJsonProperty(result, key, parseJsonValueWithState(child, `${path}.${key}`, state, depth + 1));
|
|
203
|
+
}
|
|
204
|
+
state.ancestors.delete(object);
|
|
205
|
+
return result;
|
|
206
|
+
}
|
|
207
|
+
function parseJsonValueWithState(value, path, state, depth) {
|
|
208
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
209
|
+
return parseJsonObjectWithState(value, path, state, depth);
|
|
210
|
+
}
|
|
211
|
+
consumeJsonBudget(state, path, depth);
|
|
212
|
+
if (value === null || typeof value === "boolean") {
|
|
213
|
+
return value;
|
|
214
|
+
}
|
|
215
|
+
if (typeof value === "string") {
|
|
216
|
+
if (value.length > JSON_MAX_STRING_LENGTH) {
|
|
217
|
+
throw new JsonValidationError(`String at ${path} exceeds maximum length of ${JSON_MAX_STRING_LENGTH}`);
|
|
218
|
+
}
|
|
219
|
+
return value;
|
|
220
|
+
}
|
|
221
|
+
if (typeof value === "number") {
|
|
222
|
+
if (!Number.isFinite(value)) {
|
|
223
|
+
throw new JsonValidationError(`Expected a finite number at ${path}`);
|
|
224
|
+
}
|
|
225
|
+
return value;
|
|
226
|
+
}
|
|
227
|
+
if (Array.isArray(value)) {
|
|
228
|
+
if (state.ancestors.has(value)) {
|
|
229
|
+
throw new JsonValidationError(`Circular JSON value at ${path}`);
|
|
230
|
+
}
|
|
231
|
+
state.ancestors.add(value);
|
|
232
|
+
const result = [];
|
|
233
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
234
|
+
if (!Object.hasOwn(value, index)) {
|
|
235
|
+
throw new JsonValidationError(`Sparse JSON array item at ${path}[${index}]`);
|
|
236
|
+
}
|
|
237
|
+
result.push(parseJsonValueWithState(value[index], `${path}[${index}]`, state, depth + 1));
|
|
238
|
+
}
|
|
239
|
+
state.ancestors.delete(value);
|
|
240
|
+
return result;
|
|
241
|
+
}
|
|
242
|
+
throw new JsonValidationError(`Expected a JSON value at ${path}`);
|
|
243
|
+
}
|
|
244
|
+
function consumeJsonBudget(state, path, depth) {
|
|
245
|
+
if (depth > JSON_MAX_DEPTH) {
|
|
246
|
+
throw new JsonValidationError(`JSON value exceeds maximum depth of ${JSON_MAX_DEPTH} at ${path}`);
|
|
247
|
+
}
|
|
248
|
+
state.values += 1;
|
|
249
|
+
if (state.values > JSON_MAX_VALUES) {
|
|
250
|
+
throw new JsonValidationError(`JSON value exceeds maximum of ${JSON_MAX_VALUES} values`);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
function expectOnlyKeys(object, allowedKeys, path) {
|
|
254
|
+
const allowed = new Set(allowedKeys);
|
|
255
|
+
for (const key of Object.keys(object)) {
|
|
256
|
+
if (!allowed.has(key)) {
|
|
257
|
+
throw new JsonValidationError(`Unsupported field ${JSON.stringify(key)} at ${path}`);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
function defineJsonProperty(object, key, value) {
|
|
262
|
+
Object.defineProperty(object, key, {
|
|
263
|
+
value,
|
|
264
|
+
enumerable: true,
|
|
265
|
+
configurable: true,
|
|
266
|
+
writable: true,
|
|
267
|
+
});
|
|
23
268
|
}
|
|
24
269
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,sFAAsF;AACtF,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AACjC,2DAA2D;AAC3D,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC;AACtC,6DAA6D;AAC7D,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAE7C,yEAAyE;AACzE,MAAM,OAAO,mBAAoB,SAAQ,SAAS;IAChD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc,EAAE,IAAI,GAAG,OAAO;IAC5D,OAAO,wBAAwB,CAAC,KAAK,EAAE,IAAI,EAAE,yBAAyB,EAAE,EAAE,CAAC,CAAC,CAAC;AAC/E,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,cAAc,CAAC,KAAc,EAAE,IAAI,GAAG,OAAO;IAC3D,OAAO,uBAAuB,CAAC,KAAK,EAAE,IAAI,EAAE,yBAAyB,EAAE,EAAE,CAAC,CAAC,CAAC;AAC9E,CAAC;AAkJD,0EAA0E;AAC1E,MAAM,UAAU,oBAAoB,CAAC,KAAc,EAAE,IAAI,GAAG,QAAQ;IAClE,MAAM,MAAM,GAAG,iBAAiB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC9C,cAAc,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE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OAAO,IAAI,EAAE,CAAC,CAAC;QACvF,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,kBAAkB,CACzB,MAAiC,EACjC,GAAW,EACX,KAAgB;IAEhB,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE;QACjC,KAAK;QACL,UAAU,EAAE,IAAI;QAChB,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-native/core",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Protocol-independent runtime primitives for MCP Native.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"mcp",
|
|
7
|
+
"model-context-protocol",
|
|
8
|
+
"runtime",
|
|
9
|
+
"typescript"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://github.com/pablospaniard/mcp-native#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/pablospaniard/mcp-native/issues"
|
|
14
|
+
},
|
|
5
15
|
"license": "MIT",
|
|
6
16
|
"repository": {
|
|
7
17
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/pablospaniard/mcp-native.git",
|
|
18
|
+
"url": "git+https://github.com/pablospaniard/mcp-native.git",
|
|
9
19
|
"directory": "packages/core"
|
|
10
20
|
},
|
|
11
21
|
"files": [
|