xmcp 0.6.7 → 0.6.8
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/dist/cli.js +36 -15
- package/dist/compiler/config/index.d.ts +7 -0
- package/dist/compiler/config/schemas/template.d.ts +5 -0
- package/dist/host-bridge.d.ts +4 -0
- package/dist/host-bridge.js +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +5 -5
- package/dist/runtime/adapter-express.js +21 -19
- package/dist/runtime/adapter-nestjs.js +21 -19
- package/dist/runtime/adapter-nextjs.js +21 -19
- package/dist/runtime/contexts/client-info-context.d.ts +8 -0
- package/dist/runtime/http.js +26 -24
- package/dist/runtime/stdio.js +32 -30
- package/dist/runtime/utils/mcp-app-protocol.d.ts +14 -0
- package/dist/runtime/utils/mcp-app-types.d.ts +103 -0
- package/dist/runtime/utils/mcp-host-bridge.d.ts +43 -0
- package/dist/runtime/utils/server.d.ts +3 -1
- package/dist/types/ui-meta.d.ts +15 -0
- package/package.json +12 -1
- package/src/compiler/client/component-compiler.ts +26 -5
- package/src/compiler/config/injection.ts +1 -0
- package/src/compiler/config/schemas/template.ts +13 -0
- package/src/compiler/get-bundler-config/index.ts +1 -0
- package/src/host-bridge.ts +36 -0
- package/src/index.ts +36 -0
- package/src/runtime/adapters/nextjs/handler/server-lifecycle.ts +2 -1
- package/src/runtime/contexts/client-info-context.ts +16 -0
- package/src/runtime/transports/stdio/index.ts +40 -7
- package/src/runtime/utils/__tests__/client-info.test.ts +19 -0
- package/src/runtime/utils/__tests__/tool-extra.test.ts +39 -0
- package/src/runtime/utils/client-info.ts +7 -0
- package/src/runtime/utils/mcp-app-protocol.ts +16 -0
- package/src/runtime/utils/mcp-app-types.ts +113 -0
- package/src/runtime/utils/mcp-host-bridge.ts +473 -0
- package/src/runtime/utils/react/generate-html.ts +12 -4
- package/src/runtime/utils/server.ts +3 -2
- package/src/runtime/utils/transformers/tool.ts +10 -1
- package/src/runtime/utils/ui/__tests__/split-meta.test.ts +42 -0
- package/src/runtime/utils/ui/split-meta.ts +4 -1
- package/src/types/ui-meta.ts +17 -1
|
@@ -80,6 +80,22 @@ describe("splitUIMetaNested", () => {
|
|
|
80
80
|
);
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
|
+
|
|
84
|
+
it("should split visibility to toolMeta", () => {
|
|
85
|
+
const meta = {
|
|
86
|
+
ui: {
|
|
87
|
+
visibility: ["model", "app"],
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
const result = splitUIMetaNested(meta);
|
|
91
|
+
|
|
92
|
+
assert.deepStrictEqual(result.toolMeta, {
|
|
93
|
+
ui: {
|
|
94
|
+
visibility: ["model", "app"],
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
assert.deepStrictEqual(result.resourceMeta, {});
|
|
98
|
+
});
|
|
83
99
|
});
|
|
84
100
|
|
|
85
101
|
describe("Resource Metadata Keys (CSP and Display)", () => {
|
|
@@ -121,6 +137,8 @@ describe("splitUIMetaNested", () => {
|
|
|
121
137
|
csp: {
|
|
122
138
|
connectDomains: ["https://api.weather.com"],
|
|
123
139
|
resourceDomains: ["https://cdn.jsdelivr.net"],
|
|
140
|
+
frameDomains: ["https://widgets.example.com"],
|
|
141
|
+
baseUriDomains: ["https://assets.example.com"],
|
|
124
142
|
},
|
|
125
143
|
},
|
|
126
144
|
};
|
|
@@ -132,6 +150,30 @@ describe("splitUIMetaNested", () => {
|
|
|
132
150
|
csp: {
|
|
133
151
|
connectDomains: ["https://api.weather.com"],
|
|
134
152
|
resourceDomains: ["https://cdn.jsdelivr.net"],
|
|
153
|
+
frameDomains: ["https://widgets.example.com"],
|
|
154
|
+
baseUriDomains: ["https://assets.example.com"],
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it("should split permissions to resourceMeta", () => {
|
|
161
|
+
const meta = {
|
|
162
|
+
ui: {
|
|
163
|
+
permissions: {
|
|
164
|
+
camera: {},
|
|
165
|
+
microphone: {},
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
const result = splitUIMetaNested(meta);
|
|
170
|
+
|
|
171
|
+
assert.deepStrictEqual(result.toolMeta, {});
|
|
172
|
+
assert.deepStrictEqual(result.resourceMeta, {
|
|
173
|
+
ui: {
|
|
174
|
+
permissions: {
|
|
175
|
+
camera: {},
|
|
176
|
+
microphone: {},
|
|
135
177
|
},
|
|
136
178
|
},
|
|
137
179
|
});
|
|
@@ -10,7 +10,7 @@ export interface SplitMetadata {
|
|
|
10
10
|
/**
|
|
11
11
|
* Tool-specific metadata keys in nested format
|
|
12
12
|
*/
|
|
13
|
-
const TOOL_META_KEYS_NESTED = ["ui/resourceUri"];
|
|
13
|
+
const TOOL_META_KEYS_NESTED = ["ui/resourceUri", "resourceUri", "visibility"];
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Resource-specific metadata keys in nested format
|
|
@@ -19,8 +19,11 @@ const RESOURCE_META_KEYS_NESTED = [
|
|
|
19
19
|
"prefersBorder",
|
|
20
20
|
"domain",
|
|
21
21
|
"csp",
|
|
22
|
+
"permissions",
|
|
22
23
|
"connectDomains",
|
|
23
24
|
"resourceDomains",
|
|
25
|
+
"frameDomains",
|
|
26
|
+
"baseUriDomains",
|
|
24
27
|
];
|
|
25
28
|
|
|
26
29
|
/**
|
package/src/types/ui-meta.ts
CHANGED
|
@@ -5,12 +5,29 @@ export interface UIMetadata {
|
|
|
5
5
|
*/
|
|
6
6
|
resourceUri?: string;
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Visibility hint for how prominently hosts should surface the widget entry point.
|
|
10
|
+
*/
|
|
11
|
+
visibility?: Array<"model" | "app">;
|
|
12
|
+
|
|
8
13
|
/**
|
|
9
14
|
* Content Security Policy configuration for widget resources.
|
|
10
15
|
*/
|
|
11
16
|
csp?: {
|
|
12
17
|
connectDomains?: string[];
|
|
13
18
|
resourceDomains?: string[];
|
|
19
|
+
frameDomains?: string[];
|
|
20
|
+
baseUriDomains?: string[];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Browser permission hints requested by the widget iframe.
|
|
25
|
+
*/
|
|
26
|
+
permissions?: {
|
|
27
|
+
camera?: Record<string, never>;
|
|
28
|
+
microphone?: Record<string, never>;
|
|
29
|
+
geolocation?: Record<string, never>;
|
|
30
|
+
clipboardWrite?: Record<string, never>;
|
|
14
31
|
};
|
|
15
32
|
|
|
16
33
|
/**
|
|
@@ -23,4 +40,3 @@ export interface UIMetadata {
|
|
|
23
40
|
*/
|
|
24
41
|
prefersBorder?: boolean;
|
|
25
42
|
}
|
|
26
|
-
|