xmcp 0.6.6 → 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/README.md +32 -0
- package/dist/cli.js +55 -36
- package/dist/compiler/config/index.d.ts +61 -54
- package/dist/compiler/config/schemas/template.d.ts +5 -0
- package/dist/compiler/config/schemas/transport/http.d.ts +82 -82
- package/dist/host-bridge.d.ts +4 -0
- package/dist/host-bridge.js +1 -0
- package/dist/index.d.ts +8 -2
- package/dist/index.js +5 -5
- package/dist/runtime/adapter-express.js +45 -26
- package/dist/runtime/adapter-nestjs.js +45 -26
- package/dist/runtime/adapter-nextjs.js +44 -25
- package/dist/runtime/contexts/client-info-context.d.ts +8 -0
- package/dist/runtime/contexts/http-request-context.d.ts +3 -1
- package/dist/runtime/headers.js +1 -1
- package/dist/runtime/http.js +53 -34
- package/dist/runtime/stdio.js +32 -24
- package/dist/runtime/utils/elicitation.d.ts +4 -0
- package/dist/runtime/utils/ext-apps-registry.d.ts +132 -0
- 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/path-to-tool-name.d.ts +20 -0
- package/dist/runtime/utils/prompt-loader.d.ts +11 -0
- package/dist/runtime/utils/prompts.d.ts +8 -0
- package/dist/runtime/utils/react/generate-html.d.ts +1 -0
- package/dist/runtime/utils/react/index.d.ts +4 -0
- package/dist/runtime/utils/resource-loader.d.ts +11 -0
- package/dist/runtime/utils/resources.d.ts +4 -0
- package/dist/runtime/utils/server.d.ts +37 -0
- package/dist/runtime/utils/tool-loader.d.ts +11 -0
- package/dist/runtime/utils/tools.d.ts +11 -0
- package/dist/runtime/utils/transformers/prompt.d.ts +32 -0
- package/dist/runtime/utils/transformers/resource.d.ts +26 -0
- package/dist/runtime/utils/transformers/tool.d.ts +30 -0
- package/dist/runtime/utils/ui/flatten-meta.d.ts +6 -0
- package/dist/runtime/utils/ui/split-meta.d.ts +17 -0
- package/dist/runtime/utils/utils/resource-uri-composer.d.ts +60 -0
- package/dist/runtime/utils/validators/index.d.ts +13 -0
- package/dist/types/client-info.d.ts +12 -0
- package/dist/types/tool.d.ts +69 -14
- package/dist/types/ui-meta.d.ts +15 -0
- package/dist/utils/context.d.ts +1 -1
- package/package.json +20 -1
- package/src/client/index.ts +4 -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/generate-tools-code.ts +4 -6
- package/src/compiler/get-bundler-config/index.ts +1 -0
- package/src/compiler/get-bundler-config/plugins/index.ts +0 -1
- package/src/compiler/index.ts +24 -7
- package/src/host-bridge.ts +36 -0
- package/src/index.ts +44 -1
- package/src/runtime/adapters/express/index.ts +45 -47
- package/src/runtime/adapters/nestjs/xmcp.service.ts +4 -3
- package/src/runtime/adapters/nextjs/handler/node-to-web-adapter.ts +40 -6
- package/src/runtime/adapters/nextjs/handler/request-converter.ts +20 -0
- package/src/runtime/adapters/nextjs/handler/server-lifecycle.ts +10 -6
- package/src/runtime/adapters/nextjs/index.ts +41 -25
- package/src/runtime/contexts/client-info-context.ts +16 -0
- package/src/runtime/contexts/http-request-context.ts +2 -0
- package/src/runtime/headers.ts +37 -2
- package/src/runtime/platforms/cloudflare/cors.ts +0 -1
- package/src/runtime/platforms/cloudflare/worker.ts +46 -44
- package/src/runtime/transports/http/index.ts +0 -4
- package/src/runtime/transports/http/stateless-streamable-http.ts +131 -233
- package/src/runtime/transports/stdio/index.ts +40 -9
- package/src/runtime/utils/__tests__/client-info.test.ts +99 -0
- package/src/runtime/utils/__tests__/tool-extra.test.ts +149 -0
- package/src/runtime/utils/client-info.ts +78 -0
- package/src/runtime/utils/elicitation.ts +396 -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/prompt-loader.ts +151 -0
- package/src/runtime/utils/react/generate-html.ts +12 -4
- package/src/runtime/utils/resource-loader.ts +151 -0
- package/src/runtime/utils/resources.ts +0 -8
- package/src/runtime/utils/server.ts +31 -40
- package/src/runtime/utils/tool-loader.ts +149 -0
- package/src/runtime/utils/tools.ts +9 -6
- package/src/runtime/utils/transformers/tool.ts +35 -5
- 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/client-info.ts +12 -0
- package/src/types/injected.d.ts +62 -0
- package/src/types/tool.ts +99 -17
- package/src/types/ui-meta.ts +17 -1
- package/src/utils/context.ts +2 -2
|
@@ -7,33 +7,33 @@ export declare const corsConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
7
7
|
credentials: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
8
8
|
maxAge: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
9
9
|
}, "strip", z.ZodTypeAny, {
|
|
10
|
-
maxAge?: number | undefined;
|
|
11
10
|
origin?: string | boolean | string[] | undefined;
|
|
12
11
|
methods?: string | string[] | undefined;
|
|
13
12
|
allowedHeaders?: string | string[] | undefined;
|
|
14
13
|
exposedHeaders?: string | string[] | undefined;
|
|
15
14
|
credentials?: boolean | undefined;
|
|
16
|
-
}, {
|
|
17
15
|
maxAge?: number | undefined;
|
|
16
|
+
}, {
|
|
18
17
|
origin?: string | boolean | string[] | undefined;
|
|
19
18
|
methods?: string | string[] | undefined;
|
|
20
19
|
allowedHeaders?: string | string[] | undefined;
|
|
21
20
|
exposedHeaders?: string | string[] | undefined;
|
|
22
21
|
credentials?: boolean | undefined;
|
|
22
|
+
maxAge?: number | undefined;
|
|
23
23
|
}>, {
|
|
24
|
-
maxAge: number;
|
|
25
24
|
origin: string | boolean | string[];
|
|
26
25
|
methods: string | string[];
|
|
27
26
|
allowedHeaders: string | string[];
|
|
28
27
|
exposedHeaders: string | string[];
|
|
29
28
|
credentials: boolean;
|
|
29
|
+
maxAge: number;
|
|
30
30
|
}, {
|
|
31
|
-
maxAge?: number | undefined;
|
|
32
31
|
origin?: string | boolean | string[] | undefined;
|
|
33
32
|
methods?: string | string[] | undefined;
|
|
34
33
|
allowedHeaders?: string | string[] | undefined;
|
|
35
34
|
exposedHeaders?: string | string[] | undefined;
|
|
36
35
|
credentials?: boolean | undefined;
|
|
36
|
+
maxAge?: number | undefined;
|
|
37
37
|
}>;
|
|
38
38
|
export type CorsConfig = z.infer<typeof corsConfigSchema>;
|
|
39
39
|
export declare const httpTransportConfigSchema: z.ZodUnion<[z.ZodBoolean, z.ZodEffects<z.ZodObject<{
|
|
@@ -50,90 +50,90 @@ export declare const httpTransportConfigSchema: z.ZodUnion<[z.ZodBoolean, z.ZodE
|
|
|
50
50
|
credentials: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
51
51
|
maxAge: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
52
52
|
}, "strip", z.ZodTypeAny, {
|
|
53
|
-
maxAge?: number | undefined;
|
|
54
53
|
origin?: string | boolean | string[] | undefined;
|
|
55
54
|
methods?: string | string[] | undefined;
|
|
56
55
|
allowedHeaders?: string | string[] | undefined;
|
|
57
56
|
exposedHeaders?: string | string[] | undefined;
|
|
58
57
|
credentials?: boolean | undefined;
|
|
59
|
-
}, {
|
|
60
58
|
maxAge?: number | undefined;
|
|
59
|
+
}, {
|
|
61
60
|
origin?: string | boolean | string[] | undefined;
|
|
62
61
|
methods?: string | string[] | undefined;
|
|
63
62
|
allowedHeaders?: string | string[] | undefined;
|
|
64
63
|
exposedHeaders?: string | string[] | undefined;
|
|
65
64
|
credentials?: boolean | undefined;
|
|
65
|
+
maxAge?: number | undefined;
|
|
66
66
|
}>, {
|
|
67
|
-
maxAge: number;
|
|
68
67
|
origin: string | boolean | string[];
|
|
69
68
|
methods: string | string[];
|
|
70
69
|
allowedHeaders: string | string[];
|
|
71
70
|
exposedHeaders: string | string[];
|
|
72
71
|
credentials: boolean;
|
|
72
|
+
maxAge: number;
|
|
73
73
|
}, {
|
|
74
|
-
maxAge?: number | undefined;
|
|
75
74
|
origin?: string | boolean | string[] | undefined;
|
|
76
75
|
methods?: string | string[] | undefined;
|
|
77
76
|
allowedHeaders?: string | string[] | undefined;
|
|
78
77
|
exposedHeaders?: string | string[] | undefined;
|
|
79
78
|
credentials?: boolean | undefined;
|
|
79
|
+
maxAge?: number | undefined;
|
|
80
80
|
}>>;
|
|
81
81
|
}, "strip", z.ZodTypeAny, {
|
|
82
|
+
debug?: boolean | undefined;
|
|
83
|
+
port?: number | undefined;
|
|
84
|
+
host?: string | undefined;
|
|
85
|
+
bodySizeLimit?: number | undefined;
|
|
86
|
+
endpoint?: string | undefined;
|
|
82
87
|
cors?: {
|
|
83
|
-
maxAge: number;
|
|
84
88
|
origin: string | boolean | string[];
|
|
85
89
|
methods: string | string[];
|
|
86
90
|
allowedHeaders: string | string[];
|
|
87
91
|
exposedHeaders: string | string[];
|
|
88
92
|
credentials: boolean;
|
|
93
|
+
maxAge: number;
|
|
89
94
|
} | undefined;
|
|
95
|
+
}, {
|
|
96
|
+
debug?: boolean | undefined;
|
|
90
97
|
port?: number | undefined;
|
|
91
98
|
host?: string | undefined;
|
|
92
99
|
bodySizeLimit?: number | undefined;
|
|
93
|
-
debug?: boolean | undefined;
|
|
94
100
|
endpoint?: string | undefined;
|
|
95
|
-
}, {
|
|
96
101
|
cors?: {
|
|
97
|
-
maxAge?: number | undefined;
|
|
98
102
|
origin?: string | boolean | string[] | undefined;
|
|
99
103
|
methods?: string | string[] | undefined;
|
|
100
104
|
allowedHeaders?: string | string[] | undefined;
|
|
101
105
|
exposedHeaders?: string | string[] | undefined;
|
|
102
106
|
credentials?: boolean | undefined;
|
|
107
|
+
maxAge?: number | undefined;
|
|
103
108
|
} | undefined;
|
|
104
|
-
port?: number | undefined;
|
|
105
|
-
host?: string | undefined;
|
|
106
|
-
bodySizeLimit?: number | undefined;
|
|
107
|
-
debug?: boolean | undefined;
|
|
108
|
-
endpoint?: string | undefined;
|
|
109
109
|
}>, {
|
|
110
|
+
debug: boolean;
|
|
111
|
+
port: number;
|
|
112
|
+
host: string;
|
|
113
|
+
bodySizeLimit: number;
|
|
114
|
+
endpoint: string;
|
|
110
115
|
cors: {
|
|
111
|
-
maxAge: number;
|
|
112
116
|
origin: string | boolean | string[];
|
|
113
117
|
methods: string | string[];
|
|
114
118
|
allowedHeaders: string | string[];
|
|
115
119
|
exposedHeaders: string | string[];
|
|
116
120
|
credentials: boolean;
|
|
121
|
+
maxAge: number;
|
|
117
122
|
};
|
|
118
|
-
port: number;
|
|
119
|
-
host: string;
|
|
120
|
-
bodySizeLimit: number;
|
|
121
|
-
debug: boolean;
|
|
122
|
-
endpoint: string;
|
|
123
123
|
}, {
|
|
124
|
+
debug?: boolean | undefined;
|
|
125
|
+
port?: number | undefined;
|
|
126
|
+
host?: string | undefined;
|
|
127
|
+
bodySizeLimit?: number | undefined;
|
|
128
|
+
endpoint?: string | undefined;
|
|
124
129
|
cors?: {
|
|
125
|
-
maxAge?: number | undefined;
|
|
126
130
|
origin?: string | boolean | string[] | undefined;
|
|
127
131
|
methods?: string | string[] | undefined;
|
|
128
132
|
allowedHeaders?: string | string[] | undefined;
|
|
129
133
|
exposedHeaders?: string | string[] | undefined;
|
|
130
134
|
credentials?: boolean | undefined;
|
|
135
|
+
maxAge?: number | undefined;
|
|
131
136
|
} | undefined;
|
|
132
|
-
port?: number | undefined;
|
|
133
|
-
host?: string | undefined;
|
|
134
|
-
bodySizeLimit?: number | undefined;
|
|
135
|
-
debug?: boolean | undefined;
|
|
136
|
-
endpoint?: string | undefined;
|
|
137
137
|
}>]>;
|
|
138
138
|
export declare const resolvedHttpTransportConfigSchema: z.ZodPipeline<z.ZodEffects<z.ZodUnion<[z.ZodBoolean, z.ZodEffects<z.ZodObject<{
|
|
139
139
|
port: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
@@ -149,104 +149,104 @@ export declare const resolvedHttpTransportConfigSchema: z.ZodPipeline<z.ZodEffec
|
|
|
149
149
|
credentials: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
150
150
|
maxAge: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
151
151
|
}, "strip", z.ZodTypeAny, {
|
|
152
|
-
maxAge?: number | undefined;
|
|
153
152
|
origin?: string | boolean | string[] | undefined;
|
|
154
153
|
methods?: string | string[] | undefined;
|
|
155
154
|
allowedHeaders?: string | string[] | undefined;
|
|
156
155
|
exposedHeaders?: string | string[] | undefined;
|
|
157
156
|
credentials?: boolean | undefined;
|
|
158
|
-
}, {
|
|
159
157
|
maxAge?: number | undefined;
|
|
158
|
+
}, {
|
|
160
159
|
origin?: string | boolean | string[] | undefined;
|
|
161
160
|
methods?: string | string[] | undefined;
|
|
162
161
|
allowedHeaders?: string | string[] | undefined;
|
|
163
162
|
exposedHeaders?: string | string[] | undefined;
|
|
164
163
|
credentials?: boolean | undefined;
|
|
164
|
+
maxAge?: number | undefined;
|
|
165
165
|
}>, {
|
|
166
|
-
maxAge: number;
|
|
167
166
|
origin: string | boolean | string[];
|
|
168
167
|
methods: string | string[];
|
|
169
168
|
allowedHeaders: string | string[];
|
|
170
169
|
exposedHeaders: string | string[];
|
|
171
170
|
credentials: boolean;
|
|
171
|
+
maxAge: number;
|
|
172
172
|
}, {
|
|
173
|
-
maxAge?: number | undefined;
|
|
174
173
|
origin?: string | boolean | string[] | undefined;
|
|
175
174
|
methods?: string | string[] | undefined;
|
|
176
175
|
allowedHeaders?: string | string[] | undefined;
|
|
177
176
|
exposedHeaders?: string | string[] | undefined;
|
|
178
177
|
credentials?: boolean | undefined;
|
|
178
|
+
maxAge?: number | undefined;
|
|
179
179
|
}>>;
|
|
180
180
|
}, "strip", z.ZodTypeAny, {
|
|
181
|
+
debug?: boolean | undefined;
|
|
182
|
+
port?: number | undefined;
|
|
183
|
+
host?: string | undefined;
|
|
184
|
+
bodySizeLimit?: number | undefined;
|
|
185
|
+
endpoint?: string | undefined;
|
|
181
186
|
cors?: {
|
|
182
|
-
maxAge: number;
|
|
183
187
|
origin: string | boolean | string[];
|
|
184
188
|
methods: string | string[];
|
|
185
189
|
allowedHeaders: string | string[];
|
|
186
190
|
exposedHeaders: string | string[];
|
|
187
191
|
credentials: boolean;
|
|
192
|
+
maxAge: number;
|
|
188
193
|
} | undefined;
|
|
194
|
+
}, {
|
|
195
|
+
debug?: boolean | undefined;
|
|
189
196
|
port?: number | undefined;
|
|
190
197
|
host?: string | undefined;
|
|
191
198
|
bodySizeLimit?: number | undefined;
|
|
192
|
-
debug?: boolean | undefined;
|
|
193
199
|
endpoint?: string | undefined;
|
|
194
|
-
}, {
|
|
195
200
|
cors?: {
|
|
196
|
-
maxAge?: number | undefined;
|
|
197
201
|
origin?: string | boolean | string[] | undefined;
|
|
198
202
|
methods?: string | string[] | undefined;
|
|
199
203
|
allowedHeaders?: string | string[] | undefined;
|
|
200
204
|
exposedHeaders?: string | string[] | undefined;
|
|
201
205
|
credentials?: boolean | undefined;
|
|
206
|
+
maxAge?: number | undefined;
|
|
202
207
|
} | undefined;
|
|
203
|
-
port?: number | undefined;
|
|
204
|
-
host?: string | undefined;
|
|
205
|
-
bodySizeLimit?: number | undefined;
|
|
206
|
-
debug?: boolean | undefined;
|
|
207
|
-
endpoint?: string | undefined;
|
|
208
208
|
}>, {
|
|
209
|
+
debug: boolean;
|
|
210
|
+
port: number;
|
|
211
|
+
host: string;
|
|
212
|
+
bodySizeLimit: number;
|
|
213
|
+
endpoint: string;
|
|
209
214
|
cors: {
|
|
210
|
-
maxAge: number;
|
|
211
215
|
origin: string | boolean | string[];
|
|
212
216
|
methods: string | string[];
|
|
213
217
|
allowedHeaders: string | string[];
|
|
214
218
|
exposedHeaders: string | string[];
|
|
215
219
|
credentials: boolean;
|
|
220
|
+
maxAge: number;
|
|
216
221
|
};
|
|
217
|
-
port: number;
|
|
218
|
-
host: string;
|
|
219
|
-
bodySizeLimit: number;
|
|
220
|
-
debug: boolean;
|
|
221
|
-
endpoint: string;
|
|
222
222
|
}, {
|
|
223
|
+
debug?: boolean | undefined;
|
|
224
|
+
port?: number | undefined;
|
|
225
|
+
host?: string | undefined;
|
|
226
|
+
bodySizeLimit?: number | undefined;
|
|
227
|
+
endpoint?: string | undefined;
|
|
223
228
|
cors?: {
|
|
224
|
-
maxAge?: number | undefined;
|
|
225
229
|
origin?: string | boolean | string[] | undefined;
|
|
226
230
|
methods?: string | string[] | undefined;
|
|
227
231
|
allowedHeaders?: string | string[] | undefined;
|
|
228
232
|
exposedHeaders?: string | string[] | undefined;
|
|
229
233
|
credentials?: boolean | undefined;
|
|
234
|
+
maxAge?: number | undefined;
|
|
230
235
|
} | undefined;
|
|
236
|
+
}>]>, {} | null, boolean | {
|
|
237
|
+
debug?: boolean | undefined;
|
|
231
238
|
port?: number | undefined;
|
|
232
239
|
host?: string | undefined;
|
|
233
240
|
bodySizeLimit?: number | undefined;
|
|
234
|
-
debug?: boolean | undefined;
|
|
235
241
|
endpoint?: string | undefined;
|
|
236
|
-
}>]>, {} | null, boolean | {
|
|
237
242
|
cors?: {
|
|
238
|
-
maxAge?: number | undefined;
|
|
239
243
|
origin?: string | boolean | string[] | undefined;
|
|
240
244
|
methods?: string | string[] | undefined;
|
|
241
245
|
allowedHeaders?: string | string[] | undefined;
|
|
242
246
|
exposedHeaders?: string | string[] | undefined;
|
|
243
247
|
credentials?: boolean | undefined;
|
|
248
|
+
maxAge?: number | undefined;
|
|
244
249
|
} | undefined;
|
|
245
|
-
port?: number | undefined;
|
|
246
|
-
host?: string | undefined;
|
|
247
|
-
bodySizeLimit?: number | undefined;
|
|
248
|
-
debug?: boolean | undefined;
|
|
249
|
-
endpoint?: string | undefined;
|
|
250
250
|
}>, z.ZodUnion<[z.ZodLiteral<null>, z.ZodEffects<z.ZodObject<{
|
|
251
251
|
port: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
252
252
|
host: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
@@ -261,90 +261,90 @@ export declare const resolvedHttpTransportConfigSchema: z.ZodPipeline<z.ZodEffec
|
|
|
261
261
|
credentials: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
262
262
|
maxAge: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
263
263
|
}, "strip", z.ZodTypeAny, {
|
|
264
|
-
maxAge?: number | undefined;
|
|
265
264
|
origin?: string | boolean | string[] | undefined;
|
|
266
265
|
methods?: string | string[] | undefined;
|
|
267
266
|
allowedHeaders?: string | string[] | undefined;
|
|
268
267
|
exposedHeaders?: string | string[] | undefined;
|
|
269
268
|
credentials?: boolean | undefined;
|
|
270
|
-
}, {
|
|
271
269
|
maxAge?: number | undefined;
|
|
270
|
+
}, {
|
|
272
271
|
origin?: string | boolean | string[] | undefined;
|
|
273
272
|
methods?: string | string[] | undefined;
|
|
274
273
|
allowedHeaders?: string | string[] | undefined;
|
|
275
274
|
exposedHeaders?: string | string[] | undefined;
|
|
276
275
|
credentials?: boolean | undefined;
|
|
276
|
+
maxAge?: number | undefined;
|
|
277
277
|
}>, {
|
|
278
|
-
maxAge: number;
|
|
279
278
|
origin: string | boolean | string[];
|
|
280
279
|
methods: string | string[];
|
|
281
280
|
allowedHeaders: string | string[];
|
|
282
281
|
exposedHeaders: string | string[];
|
|
283
282
|
credentials: boolean;
|
|
283
|
+
maxAge: number;
|
|
284
284
|
}, {
|
|
285
|
-
maxAge?: number | undefined;
|
|
286
285
|
origin?: string | boolean | string[] | undefined;
|
|
287
286
|
methods?: string | string[] | undefined;
|
|
288
287
|
allowedHeaders?: string | string[] | undefined;
|
|
289
288
|
exposedHeaders?: string | string[] | undefined;
|
|
290
289
|
credentials?: boolean | undefined;
|
|
290
|
+
maxAge?: number | undefined;
|
|
291
291
|
}>>;
|
|
292
292
|
}, "strip", z.ZodTypeAny, {
|
|
293
|
+
debug?: boolean | undefined;
|
|
294
|
+
port?: number | undefined;
|
|
295
|
+
host?: string | undefined;
|
|
296
|
+
bodySizeLimit?: number | undefined;
|
|
297
|
+
endpoint?: string | undefined;
|
|
293
298
|
cors?: {
|
|
294
|
-
maxAge: number;
|
|
295
299
|
origin: string | boolean | string[];
|
|
296
300
|
methods: string | string[];
|
|
297
301
|
allowedHeaders: string | string[];
|
|
298
302
|
exposedHeaders: string | string[];
|
|
299
303
|
credentials: boolean;
|
|
304
|
+
maxAge: number;
|
|
300
305
|
} | undefined;
|
|
306
|
+
}, {
|
|
307
|
+
debug?: boolean | undefined;
|
|
301
308
|
port?: number | undefined;
|
|
302
309
|
host?: string | undefined;
|
|
303
310
|
bodySizeLimit?: number | undefined;
|
|
304
|
-
debug?: boolean | undefined;
|
|
305
311
|
endpoint?: string | undefined;
|
|
306
|
-
}, {
|
|
307
312
|
cors?: {
|
|
308
|
-
maxAge?: number | undefined;
|
|
309
313
|
origin?: string | boolean | string[] | undefined;
|
|
310
314
|
methods?: string | string[] | undefined;
|
|
311
315
|
allowedHeaders?: string | string[] | undefined;
|
|
312
316
|
exposedHeaders?: string | string[] | undefined;
|
|
313
317
|
credentials?: boolean | undefined;
|
|
318
|
+
maxAge?: number | undefined;
|
|
314
319
|
} | undefined;
|
|
315
|
-
port?: number | undefined;
|
|
316
|
-
host?: string | undefined;
|
|
317
|
-
bodySizeLimit?: number | undefined;
|
|
318
|
-
debug?: boolean | undefined;
|
|
319
|
-
endpoint?: string | undefined;
|
|
320
320
|
}>, {
|
|
321
|
+
debug: boolean;
|
|
322
|
+
port: number;
|
|
323
|
+
host: string;
|
|
324
|
+
bodySizeLimit: number;
|
|
325
|
+
endpoint: string;
|
|
321
326
|
cors: {
|
|
322
|
-
maxAge: number;
|
|
323
327
|
origin: string | boolean | string[];
|
|
324
328
|
methods: string | string[];
|
|
325
329
|
allowedHeaders: string | string[];
|
|
326
330
|
exposedHeaders: string | string[];
|
|
327
331
|
credentials: boolean;
|
|
332
|
+
maxAge: number;
|
|
328
333
|
};
|
|
329
|
-
port: number;
|
|
330
|
-
host: string;
|
|
331
|
-
bodySizeLimit: number;
|
|
332
|
-
debug: boolean;
|
|
333
|
-
endpoint: string;
|
|
334
334
|
}, {
|
|
335
|
+
debug?: boolean | undefined;
|
|
336
|
+
port?: number | undefined;
|
|
337
|
+
host?: string | undefined;
|
|
338
|
+
bodySizeLimit?: number | undefined;
|
|
339
|
+
endpoint?: string | undefined;
|
|
335
340
|
cors?: {
|
|
336
|
-
maxAge?: number | undefined;
|
|
337
341
|
origin?: string | boolean | string[] | undefined;
|
|
338
342
|
methods?: string | string[] | undefined;
|
|
339
343
|
allowedHeaders?: string | string[] | undefined;
|
|
340
344
|
exposedHeaders?: string | string[] | undefined;
|
|
341
345
|
credentials?: boolean | undefined;
|
|
346
|
+
maxAge?: number | undefined;
|
|
342
347
|
} | undefined;
|
|
343
|
-
port?: number | undefined;
|
|
344
|
-
host?: string | undefined;
|
|
345
|
-
bodySizeLimit?: number | undefined;
|
|
346
|
-
debug?: boolean | undefined;
|
|
347
|
-
endpoint?: string | undefined;
|
|
348
348
|
}>]>>;
|
|
349
349
|
export type HttpTransportConfig = z.input<typeof httpTransportConfigSchema>;
|
|
350
350
|
export type ResolvedHttpConfig = z.output<typeof resolvedHttpTransportConfigSchema>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createMcpHostBridge } from "./runtime/utils/mcp-host-bridge";
|
|
2
|
+
export type { McpHostBridge, McpHostBridgeState, CreateMcpHostBridgeOptions, } from "./runtime/utils/mcp-host-bridge";
|
|
3
|
+
export type { McpHostCallToolParams, McpHostContext, McpHostCapabilities, McpHostContainerDimensions, McpHostOpenLinkParams, McpHostReadResourceResult, McpHostRequestDisplayModeParams, McpHostRequestDisplayModeResult, McpHostSendMessageParams, McpHostMessageResult, McpHostModelContextResult, McpHostToolContentItem, McpHostToolResult, McpUiDisplayMode, McpHostUpdateModelContextParams, } from "./runtime/utils/mcp-app-types";
|
|
4
|
+
export { MCP_APPS_PROTOCOL_VERSION, INITIALIZE_METHOD, INITIALIZED_METHOD, REQUEST_DISPLAY_MODE_METHOD, OPEN_LINK_METHOD, UPDATE_MODEL_CONTEXT_METHOD, UI_MESSAGE_METHOD, LOG_MESSAGE_METHOD, RESOURCES_READ_METHOD, HOST_CONTEXT_CHANGED_METHOD, SIZE_CHANGED_METHOD, } from "./runtime/utils/mcp-app-protocol";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var s=t();for(var o in s)("object"==typeof exports?exports:e)[o]=s[o]}}(this,()=>(()=>{"use strict";var e={};e.d=(t,s)=>{for(var o in s)e.o(s,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:s[o]})},e.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var t={};e.r(t),e.d(t,{SIZE_CHANGED_METHOD:()=>p,HOST_CONTEXT_CHANGED_METHOD:()=>c,UI_MESSAGE_METHOD:()=>l,RESOURCES_READ_METHOD:()=>u,UPDATE_MODEL_CONTEXT_METHOD:()=>a,MCP_APPS_PROTOCOL_VERSION:()=>s,createMcpHostBridge:()=>h,INITIALIZE_METHOD:()=>o,LOG_MESSAGE_METHOD:()=>d,INITIALIZED_METHOD:()=>i,OPEN_LINK_METHOD:()=>r,REQUEST_DISPLAY_MODE_METHOD:()=>n});let s="2026-01-26",o="ui/initialize",i="ui/notifications/initialized",n="ui/request-display-mode",r="ui/open-link",a="ui/update-model-context",l="ui/message",d="notifications/message",u="resources/read",c="ui/notifications/host-context-changed",p="ui/notifications/size-changed";function C(e){return!!e&&"object"==typeof e}function f(e,t){return e instanceof Error&&e.message?e.message:t}function h(e={}){let t=e.targetWindow??("undefined"==typeof window?null:window),s=e.requestTimeoutMs??15e3,o=e.connectionTimeoutMs??2e3,i=100,m=!1,E=!1,b={isConnected:!!t&&t.parent!==t,hostContext:null,hostCapabilities:null},y=new Set,M=new Map,g=e=>{if(e.isConnected!==b.isConnected||e.hostContext!==b.hostContext||e.hostCapabilities!==b.hostCapabilities)for(let t of(b=e,y))t(b)},T=e=>{var t,s;let o;g({isConnected:!0,hostContext:e.hostContext?(t=b.hostContext,s=e.hostContext,o={...t??{},...s},(t?.safeAreaInsets||s.safeAreaInsets)&&(o.safeAreaInsets={...t?.safeAreaInsets??{},...s.safeAreaInsets??{}}),(t?.containerDimensions||s.containerDimensions)&&(o.containerDimensions={...t?.containerDimensions??{},...s.containerDimensions??{}}),(t?.styles||s.styles)&&(o.styles={...t?.styles??{},...s.styles??{},variables:t?.styles?.variables||s.styles?.variables?{...t?.styles?.variables??{},...s.styles?.variables??{}}:void 0,css:t?.styles?.css||s.styles?.css?{...t?.styles?.css??{},...s.styles?.css??{}}:void 0}),o):b.hostContext,hostCapabilities:e.hostCapabilities?{...b.hostCapabilities??{},...e.hostCapabilities}:b.hostCapabilities})},O=e=>{if(!t||e.source!==t.parent||!C(e.data))return;E=!0,b.isConnected||g({...b,isConnected:!0});let s=e.data;if("id"in s&&null!=s.id&&"number"==typeof s.id){let e=M.get(s.id);e&&(clearTimeout(e.timeoutId),M.delete(s.id),C(s.error)?e.reject(Error("string"==typeof s.error.message?s.error.message:"MCP request failed")):e.resolve(s.result))}1===s.id&&C(s.result)&&T({hostContext:C(s.result.hostContext)?s.result.hostContext:void 0,hostCapabilities:C(s.result.hostCapabilities)?s.result.hostCapabilities:void 0}),s.method===c&&C(s.params)&&T({hostContext:s.params}),"ui/hostContextChanged"===s.method&&C(s.params)&&C(s.params.hostContext)&&T({hostContext:s.params.hostContext})};t&&(t.addEventListener("message",O),t.parent!==t&&setTimeout(()=>{m||E||b.hostContext||g({...b,isConnected:!1})},o));let _=()=>{if(m)throw Error("MCP host bridge has been disposed");if(!t)throw Error("MCP host bridge requires a browser window");return t},w=(e,t)=>{_().parent.postMessage({jsonrpc:"2.0",method:e,params:t},"*")},x=(e,t={})=>{let o=_();return new Promise((n,r)=>{let a=i++,l=setTimeout(()=>{M.has(a)&&(M.delete(a),r(Error(`MCP request timed out: ${e}`)))},s);M.set(a,{resolve:n,reject:r,timeoutId:l}),o.parent.postMessage({jsonrpc:"2.0",id:a,method:e,params:t},"*")})},D=async(e,t)=>{let s;for(let o of e)try{return await x(o,t)}catch(t){s=t;let e=f(t,"MCP request failed");if(!/method not found|unknown method/i.test(e))throw t}throw s instanceof Error?s:Error("MCP request failed")},v=async e=>{if(t?.open)return void t.open(e,"_blank","noopener,noreferrer");throw Error("Unable to open link without a browser window")};return{callTool:(e,t)=>x("tools/call",{name:e,arguments:t??{}}),requestDisplayMode:e=>D([n,"ui/requestDisplayMode"],{mode:e}),async openLink(e){try{await D([r,"ui/openLink"],{url:e})}catch(s){if(!b.isConnected||!t)return void await v(e);throw Error(f(s,"Failed to open link"))}},readResource:e=>x(u,{uri:e}),sendMessage:e=>x(l,e),updateModelContext:e=>x(a,e),async logMessage(e){w(d,e)},async notifySizeChanged(e){w(p,e)},getState:()=>b,getHostContext:()=>b.hostContext,getHostCapabilities:()=>b.hostCapabilities,isConnected:()=>b.isConnected,subscribe:e=>(y.add(e),()=>{y.delete(e)}),dispose(){if(!m){for(let[e,s]of(m=!0,t&&t.removeEventListener("message",O),M.entries()))clearTimeout(s.timeoutId),s.reject(Error("MCP host bridge has been disposed")),M.delete(e);y.clear()}}}}return t})());
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export type { Middleware, WebMiddleware, WebMiddlewareContext } from "./types/middleware";
|
|
2
|
-
export type { ToolMetadata, ToolSchema, ToolOutputSchema, ToolExtraArguments, InferSchema, } from "./types/tool";
|
|
1
|
+
export type { Middleware, WebMiddleware, WebMiddlewareContext, } from "./types/middleware";
|
|
2
|
+
export type { ToolMetadata, ToolSchema, ToolOutputSchema, ToolExtraArguments, InferSchema, ElicitResult, } from "./types/tool";
|
|
3
|
+
export type { McpClientInfo } from "./types/client-info";
|
|
3
4
|
export type { PromptMetadata } from "./types/prompt";
|
|
4
5
|
export type { ResourceMetadata } from "./types/resource";
|
|
5
6
|
export type { UIMetadata } from "./types/ui-meta";
|
|
@@ -9,9 +10,14 @@ export { apiKeyAuthMiddleware } from "./auth/api-key";
|
|
|
9
10
|
export { jwtAuthMiddleware } from "./auth/jwt";
|
|
10
11
|
export { createContext } from "./utils/context";
|
|
11
12
|
export { completable } from "@modelcontextprotocol/sdk/server/completable";
|
|
13
|
+
export { UrlElicitationRequiredError } from "@modelcontextprotocol/sdk/types";
|
|
12
14
|
export { createHTTPClient, createSTDIOClient, listSTDIOClientTools, callSTDIOClientTool, disconnectSTDIOClient, } from "./client";
|
|
13
15
|
export type { HttpClient, StdioClient, StdioIOStrategy, ClientConnectionEntry, ClientConnections, ClientDefinition, HttpClientConfig, StdioClientConfig, } from "./client/types";
|
|
14
16
|
export type { StdioClientConnection, StdioClientOptions } from "./client";
|
|
15
17
|
export type { CustomHeaders, CustomHeader, StaticHeader, EnvHeader, } from "./client/headers";
|
|
16
18
|
export { isEnvHeader, headersToRecord } from "./client/headers";
|
|
17
19
|
export { extractToolNamesFromRequest } from "./runtime/utils/request-tool-names";
|
|
20
|
+
export { createMcpHostBridge } from "./runtime/utils/mcp-host-bridge";
|
|
21
|
+
export type { McpHostBridge, McpHostBridgeState, CreateMcpHostBridgeOptions, } from "./runtime/utils/mcp-host-bridge";
|
|
22
|
+
export type { McpHostCallToolParams, McpHostContext, McpHostCapabilities, McpHostContainerDimensions, McpHostOpenLinkParams, McpHostReadResourceResult, McpHostRequestDisplayModeParams, McpHostRequestDisplayModeResult, McpHostSendMessageParams, McpHostMessageResult, McpHostModelContextResult, McpHostToolContentItem, McpHostToolResult, McpUiDisplayMode, McpHostUpdateModelContextParams, } from "./runtime/utils/mcp-app-types";
|
|
23
|
+
export { MCP_APPS_PROTOCOL_VERSION, INITIALIZE_METHOD, INITIALIZED_METHOD, REQUEST_DISPLAY_MODE_METHOD, OPEN_LINK_METHOD, UPDATE_MODEL_CONTEXT_METHOD, UI_MESSAGE_METHOD, LOG_MESSAGE_METHOD, RESOURCES_READ_METHOD, HOST_CONTEXT_CHANGED_METHOD, SIZE_CHANGED_METHOD, } from "./runtime/utils/mcp-app-protocol";
|