@mcp-native/core 0.0.1 → 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 +87 -2
- package/dist/index.d.ts +53 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/package.json +33 -7
- package/index.js +0 -1
package/README.md
CHANGED
|
@@ -1,5 +1,90 @@
|
|
|
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) · [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, type McpClient } from "@mcp-native/core";
|
|
33
|
+
|
|
34
|
+
const client: McpClient = {
|
|
35
|
+
async listTools() {
|
|
36
|
+
return [
|
|
37
|
+
{
|
|
38
|
+
name: "save_profile",
|
|
39
|
+
description: "Save profile details",
|
|
40
|
+
inputSchema: { type: "object" },
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
},
|
|
44
|
+
async callTool(name, arguments_) {
|
|
45
|
+
return {
|
|
46
|
+
content: [{ type: "json", data: { name, arguments: arguments_ } }],
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
async readResource(uri) {
|
|
50
|
+
return { uri, mimeType: "text/plain", text: "Hello from MCP" };
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const runtime = new McpNativeRuntime(client);
|
|
55
|
+
|
|
56
|
+
await runtime.dispatch({
|
|
57
|
+
type: "tool",
|
|
58
|
+
name: "save_profile",
|
|
59
|
+
arguments: { displayName: "Ada" },
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Public API
|
|
64
|
+
|
|
65
|
+
| Export | Purpose |
|
|
66
|
+
| --------------------------------------------- | ------------------------------------------------------------------------------------------- |
|
|
67
|
+
| `McpNativeRuntime` | Delegates tool listing, tool calls, resource reads, and declared actions to an `McpClient`. |
|
|
68
|
+
| `McpClient` | Minimal interface implemented by an SDK- or transport-specific adapter. |
|
|
69
|
+
| `McpTool`, `McpResource`, `McpToolCallResult` | Transport-neutral MCP data contracts used by the runtime. |
|
|
70
|
+
| `ToolAction`, `McpNativeAction` | Declarative actions that can be dispatched through the runtime. |
|
|
71
|
+
| `JsonPrimitive`, `JsonValue`, `JsonObject` | JSON-safe value types for untrusted protocol data. |
|
|
72
|
+
|
|
73
|
+
## Design boundaries
|
|
74
|
+
|
|
75
|
+
- No React Native dependency.
|
|
76
|
+
- No A2UI or WebView dependency.
|
|
77
|
+
- No transport or official MCP SDK dependency yet.
|
|
78
|
+
- No remote code loading or execution.
|
|
79
|
+
- Host applications remain responsible for authentication, permissions, transport security, and user approval.
|
|
80
|
+
|
|
81
|
+
## Related packages
|
|
82
|
+
|
|
83
|
+
- [`@mcp-native/a2ui`](https://www.npmjs.com/package/@mcp-native/a2ui) validates declarative surfaces and actions.
|
|
84
|
+
- [`@mcp-native/react-native`](https://www.npmjs.com/package/@mcp-native/react-native) converts validated surfaces into trusted native render plans.
|
|
85
|
+
- [`@mcp-native/webview`](https://www.npmjs.com/package/@mcp-native/webview) defines the HTML compatibility policy boundary.
|
|
86
|
+
- [`mcp-native`](https://www.npmjs.com/package/mcp-native) re-exports the complete public API.
|
|
87
|
+
|
|
88
|
+
## License
|
|
4
89
|
|
|
5
|
-
|
|
90
|
+
[MIT](https://github.com/pablospaniard/mcp-native/blob/main/LICENSE)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export type JsonPrimitive = boolean | null | number | string;
|
|
2
|
+
export type JsonValue = JsonPrimitive | JsonObject | readonly JsonValue[];
|
|
3
|
+
export interface JsonObject {
|
|
4
|
+
readonly [key: string]: JsonValue;
|
|
5
|
+
}
|
|
6
|
+
export interface McpTool {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly description?: string;
|
|
9
|
+
readonly inputSchema: JsonObject;
|
|
10
|
+
}
|
|
11
|
+
export interface McpContent {
|
|
12
|
+
readonly type: string;
|
|
13
|
+
readonly data: JsonObject;
|
|
14
|
+
}
|
|
15
|
+
export interface McpToolCallResult {
|
|
16
|
+
readonly content: readonly McpContent[];
|
|
17
|
+
readonly isError?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface McpResource {
|
|
20
|
+
readonly uri: string;
|
|
21
|
+
readonly mimeType?: string;
|
|
22
|
+
readonly text?: string;
|
|
23
|
+
readonly blob?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The small client boundary consumed by the runtime. SDK-specific clients can
|
|
27
|
+
* implement this interface without coupling the core package to a transport.
|
|
28
|
+
*/
|
|
29
|
+
export interface McpClient {
|
|
30
|
+
listTools(): Promise<readonly McpTool[]>;
|
|
31
|
+
callTool(name: string, arguments_: JsonObject): Promise<McpToolCallResult>;
|
|
32
|
+
readResource(uri: string): Promise<McpResource>;
|
|
33
|
+
}
|
|
34
|
+
export interface ToolAction {
|
|
35
|
+
readonly type: "tool";
|
|
36
|
+
readonly name: string;
|
|
37
|
+
readonly arguments?: JsonObject;
|
|
38
|
+
}
|
|
39
|
+
export type McpNativeAction = ToolAction;
|
|
40
|
+
/**
|
|
41
|
+
* Coordinates MCP operations without knowing about A2UI, React Native, or any
|
|
42
|
+
* other renderer. It deliberately routes declared actions instead of loading
|
|
43
|
+
* executable code from a server.
|
|
44
|
+
*/
|
|
45
|
+
export declare class McpNativeRuntime {
|
|
46
|
+
#private;
|
|
47
|
+
constructor(client: McpClient);
|
|
48
|
+
listTools(): Promise<readonly McpTool[]>;
|
|
49
|
+
callTool(name: string, arguments_?: JsonObject): Promise<McpToolCallResult>;
|
|
50
|
+
readResource(uri: string): Promise<McpResource>;
|
|
51
|
+
dispatch(action: McpNativeAction): Promise<McpToolCallResult>;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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;IAC9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C,CAE9E;IAED,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAE9C;IAED,QAAQ,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAE5D;CACF"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coordinates MCP operations without knowing about A2UI, React Native, or any
|
|
3
|
+
* other renderer. It deliberately routes declared actions instead of loading
|
|
4
|
+
* executable code from a server.
|
|
5
|
+
*/
|
|
6
|
+
export class McpNativeRuntime {
|
|
7
|
+
#client;
|
|
8
|
+
constructor(client) {
|
|
9
|
+
this.#client = client;
|
|
10
|
+
}
|
|
11
|
+
listTools() {
|
|
12
|
+
return this.#client.listTools();
|
|
13
|
+
}
|
|
14
|
+
callTool(name, arguments_ = {}) {
|
|
15
|
+
return this.#client.callTool(name, arguments_);
|
|
16
|
+
}
|
|
17
|
+
readResource(uri) {
|
|
18
|
+
return this.#client.readResource(uri);
|
|
19
|
+
}
|
|
20
|
+
dispatch(action) {
|
|
21
|
+
return this.callTool(action.name, action.arguments ?? {});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiDA;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IAClB,OAAO,CAAY;IAE5B,YAAY,MAAiB;QAC3B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;IAClC,CAAC;IAED,QAAQ,CAAC,IAAY,EAAE,UAAU,GAAe,EAAE;QAChD,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACjD,CAAC;IAED,YAAY,CAAC,GAAW;QACtB,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IACxC,CAAC;IAED,QAAQ,CAAC,MAAuB;QAC9B,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;IAC5D,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-native/core",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
3
|
+
"version": "0.0.3",
|
|
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"
|
|
7
14
|
},
|
|
8
|
-
"keywords": [],
|
|
9
|
-
"author": "",
|
|
10
15
|
"license": "MIT",
|
|
11
|
-
"
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/pablospaniard/mcp-native.git",
|
|
19
|
+
"directory": "packages/core"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"README.md"
|
|
24
|
+
],
|
|
25
|
+
"type": "module",
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"main": "./dist/index.js",
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"import": "./dist/index.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
}
|
|
12
38
|
}
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = {};
|