xmcp 1.11.0 → 1.12.1
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 +4 -2
- package/dist/client/handlers.d.ts +16 -0
- package/dist/client/index.d.ts +6 -1
- package/dist/client/managed.d.ts +3 -9
- package/dist/client.js +2 -2
- package/dist/cloudflare.js +1 -1
- package/dist/config/index.d.ts +165 -1
- package/dist/config/schemas/cache-hints.d.ts +119 -0
- package/dist/config/schemas/index.d.ts +1 -0
- package/dist/config.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +15 -15
- package/dist/runtime/adapter-express.js +16 -24
- package/dist/runtime/adapter-fastify.js +16 -24
- package/dist/runtime/adapter-fetch-cloudflare.js +21 -29
- package/dist/runtime/adapter-fetch.js +16 -24
- package/dist/runtime/adapter-nestjs.js +16 -24
- package/dist/runtime/adapter-nextjs.js +16 -24
- package/dist/runtime/cloudflare-worker.js +23 -31
- package/dist/runtime/contexts/request-context.d.ts +6 -0
- package/dist/runtime/http.js +22 -30
- package/dist/runtime/stdio.js +19 -27
- package/dist/runtime/utils/schema-compat.d.ts +26 -0
- package/dist/runtime/utils/server.d.ts +5 -2
- package/dist/runtime/utils/transformers/tool.d.ts +4 -3
- package/dist/runtime/vercel.js +23 -31
- package/dist/types/resource.d.ts +7 -1
- package/dist/types/tool.d.ts +5 -3
- package/package.json +1 -1
package/dist/config/index.d.ts
CHANGED
|
@@ -285,6 +285,118 @@ export declare const configSchema: z.ZodObject<{
|
|
|
285
285
|
names?: string[] | undefined;
|
|
286
286
|
} | undefined;
|
|
287
287
|
}>>;
|
|
288
|
+
cacheHints: z.ZodOptional<z.ZodObject<{
|
|
289
|
+
"tools/list": z.ZodOptional<z.ZodObject<{
|
|
290
|
+
ttlMs: z.ZodOptional<z.ZodNumber>;
|
|
291
|
+
cacheScope: z.ZodOptional<z.ZodEnum<["private", "public"]>>;
|
|
292
|
+
}, "strict", z.ZodTypeAny, {
|
|
293
|
+
ttlMs?: number | undefined;
|
|
294
|
+
cacheScope?: "private" | "public" | undefined;
|
|
295
|
+
}, {
|
|
296
|
+
ttlMs?: number | undefined;
|
|
297
|
+
cacheScope?: "private" | "public" | undefined;
|
|
298
|
+
}>>;
|
|
299
|
+
"prompts/list": z.ZodOptional<z.ZodObject<{
|
|
300
|
+
ttlMs: z.ZodOptional<z.ZodNumber>;
|
|
301
|
+
cacheScope: z.ZodOptional<z.ZodEnum<["private", "public"]>>;
|
|
302
|
+
}, "strict", z.ZodTypeAny, {
|
|
303
|
+
ttlMs?: number | undefined;
|
|
304
|
+
cacheScope?: "private" | "public" | undefined;
|
|
305
|
+
}, {
|
|
306
|
+
ttlMs?: number | undefined;
|
|
307
|
+
cacheScope?: "private" | "public" | undefined;
|
|
308
|
+
}>>;
|
|
309
|
+
"resources/list": z.ZodOptional<z.ZodObject<{
|
|
310
|
+
ttlMs: z.ZodOptional<z.ZodNumber>;
|
|
311
|
+
cacheScope: z.ZodOptional<z.ZodEnum<["private", "public"]>>;
|
|
312
|
+
}, "strict", z.ZodTypeAny, {
|
|
313
|
+
ttlMs?: number | undefined;
|
|
314
|
+
cacheScope?: "private" | "public" | undefined;
|
|
315
|
+
}, {
|
|
316
|
+
ttlMs?: number | undefined;
|
|
317
|
+
cacheScope?: "private" | "public" | undefined;
|
|
318
|
+
}>>;
|
|
319
|
+
"resources/templates/list": z.ZodOptional<z.ZodObject<{
|
|
320
|
+
ttlMs: z.ZodOptional<z.ZodNumber>;
|
|
321
|
+
cacheScope: z.ZodOptional<z.ZodEnum<["private", "public"]>>;
|
|
322
|
+
}, "strict", z.ZodTypeAny, {
|
|
323
|
+
ttlMs?: number | undefined;
|
|
324
|
+
cacheScope?: "private" | "public" | undefined;
|
|
325
|
+
}, {
|
|
326
|
+
ttlMs?: number | undefined;
|
|
327
|
+
cacheScope?: "private" | "public" | undefined;
|
|
328
|
+
}>>;
|
|
329
|
+
"resources/read": z.ZodOptional<z.ZodObject<{
|
|
330
|
+
ttlMs: z.ZodOptional<z.ZodNumber>;
|
|
331
|
+
cacheScope: z.ZodOptional<z.ZodEnum<["private", "public"]>>;
|
|
332
|
+
}, "strict", z.ZodTypeAny, {
|
|
333
|
+
ttlMs?: number | undefined;
|
|
334
|
+
cacheScope?: "private" | "public" | undefined;
|
|
335
|
+
}, {
|
|
336
|
+
ttlMs?: number | undefined;
|
|
337
|
+
cacheScope?: "private" | "public" | undefined;
|
|
338
|
+
}>>;
|
|
339
|
+
"server/discover": z.ZodOptional<z.ZodObject<{
|
|
340
|
+
ttlMs: z.ZodOptional<z.ZodNumber>;
|
|
341
|
+
cacheScope: z.ZodOptional<z.ZodEnum<["private", "public"]>>;
|
|
342
|
+
}, "strict", z.ZodTypeAny, {
|
|
343
|
+
ttlMs?: number | undefined;
|
|
344
|
+
cacheScope?: "private" | "public" | undefined;
|
|
345
|
+
}, {
|
|
346
|
+
ttlMs?: number | undefined;
|
|
347
|
+
cacheScope?: "private" | "public" | undefined;
|
|
348
|
+
}>>;
|
|
349
|
+
}, "strict", z.ZodTypeAny, {
|
|
350
|
+
"tools/list"?: {
|
|
351
|
+
ttlMs?: number | undefined;
|
|
352
|
+
cacheScope?: "private" | "public" | undefined;
|
|
353
|
+
} | undefined;
|
|
354
|
+
"prompts/list"?: {
|
|
355
|
+
ttlMs?: number | undefined;
|
|
356
|
+
cacheScope?: "private" | "public" | undefined;
|
|
357
|
+
} | undefined;
|
|
358
|
+
"resources/list"?: {
|
|
359
|
+
ttlMs?: number | undefined;
|
|
360
|
+
cacheScope?: "private" | "public" | undefined;
|
|
361
|
+
} | undefined;
|
|
362
|
+
"resources/templates/list"?: {
|
|
363
|
+
ttlMs?: number | undefined;
|
|
364
|
+
cacheScope?: "private" | "public" | undefined;
|
|
365
|
+
} | undefined;
|
|
366
|
+
"resources/read"?: {
|
|
367
|
+
ttlMs?: number | undefined;
|
|
368
|
+
cacheScope?: "private" | "public" | undefined;
|
|
369
|
+
} | undefined;
|
|
370
|
+
"server/discover"?: {
|
|
371
|
+
ttlMs?: number | undefined;
|
|
372
|
+
cacheScope?: "private" | "public" | undefined;
|
|
373
|
+
} | undefined;
|
|
374
|
+
}, {
|
|
375
|
+
"tools/list"?: {
|
|
376
|
+
ttlMs?: number | undefined;
|
|
377
|
+
cacheScope?: "private" | "public" | undefined;
|
|
378
|
+
} | undefined;
|
|
379
|
+
"prompts/list"?: {
|
|
380
|
+
ttlMs?: number | undefined;
|
|
381
|
+
cacheScope?: "private" | "public" | undefined;
|
|
382
|
+
} | undefined;
|
|
383
|
+
"resources/list"?: {
|
|
384
|
+
ttlMs?: number | undefined;
|
|
385
|
+
cacheScope?: "private" | "public" | undefined;
|
|
386
|
+
} | undefined;
|
|
387
|
+
"resources/templates/list"?: {
|
|
388
|
+
ttlMs?: number | undefined;
|
|
389
|
+
cacheScope?: "private" | "public" | undefined;
|
|
390
|
+
} | undefined;
|
|
391
|
+
"resources/read"?: {
|
|
392
|
+
ttlMs?: number | undefined;
|
|
393
|
+
cacheScope?: "private" | "public" | undefined;
|
|
394
|
+
} | undefined;
|
|
395
|
+
"server/discover"?: {
|
|
396
|
+
ttlMs?: number | undefined;
|
|
397
|
+
cacheScope?: "private" | "public" | undefined;
|
|
398
|
+
} | undefined;
|
|
399
|
+
}>>;
|
|
288
400
|
}, "strip", z.ZodTypeAny, {
|
|
289
401
|
stdio?: boolean | {
|
|
290
402
|
debug: boolean;
|
|
@@ -345,6 +457,32 @@ export declare const configSchema: z.ZodObject<{
|
|
|
345
457
|
names?: string[] | undefined;
|
|
346
458
|
} | undefined;
|
|
347
459
|
} | undefined;
|
|
460
|
+
cacheHints?: {
|
|
461
|
+
"tools/list"?: {
|
|
462
|
+
ttlMs?: number | undefined;
|
|
463
|
+
cacheScope?: "private" | "public" | undefined;
|
|
464
|
+
} | undefined;
|
|
465
|
+
"prompts/list"?: {
|
|
466
|
+
ttlMs?: number | undefined;
|
|
467
|
+
cacheScope?: "private" | "public" | undefined;
|
|
468
|
+
} | undefined;
|
|
469
|
+
"resources/list"?: {
|
|
470
|
+
ttlMs?: number | undefined;
|
|
471
|
+
cacheScope?: "private" | "public" | undefined;
|
|
472
|
+
} | undefined;
|
|
473
|
+
"resources/templates/list"?: {
|
|
474
|
+
ttlMs?: number | undefined;
|
|
475
|
+
cacheScope?: "private" | "public" | undefined;
|
|
476
|
+
} | undefined;
|
|
477
|
+
"resources/read"?: {
|
|
478
|
+
ttlMs?: number | undefined;
|
|
479
|
+
cacheScope?: "private" | "public" | undefined;
|
|
480
|
+
} | undefined;
|
|
481
|
+
"server/discover"?: {
|
|
482
|
+
ttlMs?: number | undefined;
|
|
483
|
+
cacheScope?: "private" | "public" | undefined;
|
|
484
|
+
} | undefined;
|
|
485
|
+
} | undefined;
|
|
348
486
|
}, {
|
|
349
487
|
stdio?: boolean | {
|
|
350
488
|
debug?: boolean | undefined;
|
|
@@ -405,6 +543,32 @@ export declare const configSchema: z.ZodObject<{
|
|
|
405
543
|
names?: string[] | undefined;
|
|
406
544
|
} | undefined;
|
|
407
545
|
} | undefined;
|
|
546
|
+
cacheHints?: {
|
|
547
|
+
"tools/list"?: {
|
|
548
|
+
ttlMs?: number | undefined;
|
|
549
|
+
cacheScope?: "private" | "public" | undefined;
|
|
550
|
+
} | undefined;
|
|
551
|
+
"prompts/list"?: {
|
|
552
|
+
ttlMs?: number | undefined;
|
|
553
|
+
cacheScope?: "private" | "public" | undefined;
|
|
554
|
+
} | undefined;
|
|
555
|
+
"resources/list"?: {
|
|
556
|
+
ttlMs?: number | undefined;
|
|
557
|
+
cacheScope?: "private" | "public" | undefined;
|
|
558
|
+
} | undefined;
|
|
559
|
+
"resources/templates/list"?: {
|
|
560
|
+
ttlMs?: number | undefined;
|
|
561
|
+
cacheScope?: "private" | "public" | undefined;
|
|
562
|
+
} | undefined;
|
|
563
|
+
"resources/read"?: {
|
|
564
|
+
ttlMs?: number | undefined;
|
|
565
|
+
cacheScope?: "private" | "public" | undefined;
|
|
566
|
+
} | undefined;
|
|
567
|
+
"server/discover"?: {
|
|
568
|
+
ttlMs?: number | undefined;
|
|
569
|
+
cacheScope?: "private" | "public" | undefined;
|
|
570
|
+
} | undefined;
|
|
571
|
+
} | undefined;
|
|
408
572
|
}>;
|
|
409
573
|
type BundlerConfigType = {
|
|
410
574
|
bundler?: (config: RspackOptions) => RspackOptions;
|
|
@@ -412,5 +576,5 @@ type BundlerConfigType = {
|
|
|
412
576
|
export type XmcpConfigInputSchema = Omit<z.input<typeof configSchema>, "bundler"> & BundlerConfigType;
|
|
413
577
|
export type XmcpConfigOutputSchema = Omit<z.output<typeof configSchema>, "bundler"> & BundlerConfigType;
|
|
414
578
|
export type { ResolvedExperimentalConfig, ResolvedHttpConfig, ResolvedPathsConfig, ResolvedStdioConfig, } from "./utils";
|
|
415
|
-
export type { BundlerConfig, ComponentsConfig, ComponentSelector, CorsConfig, ExperimentalConfig, HttpTransportConfig, PathsConfig, StdioTransportConfig, TemplateConfig, TypescriptConfig, } from "./schemas";
|
|
579
|
+
export type { BundlerConfig, CacheHintsConfig, ComponentsConfig, ComponentSelector, CorsConfig, ExperimentalConfig, HttpTransportConfig, PathsConfig, StdioTransportConfig, TemplateConfig, TypescriptConfig, } from "./schemas";
|
|
416
580
|
export { getResolvedCorsConfig, getResolvedExperimentalConfig, getResolvedHttpConfig, getResolvedPathsConfig, getResolvedStdioConfig, getResolvedTemplateConfig, getResolvedTypescriptConfig, } from "./utils";
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { z } from "zod/v3";
|
|
2
|
+
/**
|
|
3
|
+
* Server-wide cache hints for MCP 2026-07-28 cacheable results, keyed by
|
|
4
|
+
* method. Unset methods keep the SDK default (`ttlMs: 0`, `cacheScope:
|
|
5
|
+
* "private"`). Handler- or middleware-returned fields still take precedence.
|
|
6
|
+
*/
|
|
7
|
+
export declare const cacheHintsConfigSchema: z.ZodObject<{
|
|
8
|
+
"tools/list": z.ZodOptional<z.ZodObject<{
|
|
9
|
+
ttlMs: z.ZodOptional<z.ZodNumber>;
|
|
10
|
+
cacheScope: z.ZodOptional<z.ZodEnum<["private", "public"]>>;
|
|
11
|
+
}, "strict", z.ZodTypeAny, {
|
|
12
|
+
ttlMs?: number | undefined;
|
|
13
|
+
cacheScope?: "private" | "public" | undefined;
|
|
14
|
+
}, {
|
|
15
|
+
ttlMs?: number | undefined;
|
|
16
|
+
cacheScope?: "private" | "public" | undefined;
|
|
17
|
+
}>>;
|
|
18
|
+
"prompts/list": z.ZodOptional<z.ZodObject<{
|
|
19
|
+
ttlMs: z.ZodOptional<z.ZodNumber>;
|
|
20
|
+
cacheScope: z.ZodOptional<z.ZodEnum<["private", "public"]>>;
|
|
21
|
+
}, "strict", z.ZodTypeAny, {
|
|
22
|
+
ttlMs?: number | undefined;
|
|
23
|
+
cacheScope?: "private" | "public" | undefined;
|
|
24
|
+
}, {
|
|
25
|
+
ttlMs?: number | undefined;
|
|
26
|
+
cacheScope?: "private" | "public" | undefined;
|
|
27
|
+
}>>;
|
|
28
|
+
"resources/list": z.ZodOptional<z.ZodObject<{
|
|
29
|
+
ttlMs: z.ZodOptional<z.ZodNumber>;
|
|
30
|
+
cacheScope: z.ZodOptional<z.ZodEnum<["private", "public"]>>;
|
|
31
|
+
}, "strict", z.ZodTypeAny, {
|
|
32
|
+
ttlMs?: number | undefined;
|
|
33
|
+
cacheScope?: "private" | "public" | undefined;
|
|
34
|
+
}, {
|
|
35
|
+
ttlMs?: number | undefined;
|
|
36
|
+
cacheScope?: "private" | "public" | undefined;
|
|
37
|
+
}>>;
|
|
38
|
+
"resources/templates/list": z.ZodOptional<z.ZodObject<{
|
|
39
|
+
ttlMs: z.ZodOptional<z.ZodNumber>;
|
|
40
|
+
cacheScope: z.ZodOptional<z.ZodEnum<["private", "public"]>>;
|
|
41
|
+
}, "strict", z.ZodTypeAny, {
|
|
42
|
+
ttlMs?: number | undefined;
|
|
43
|
+
cacheScope?: "private" | "public" | undefined;
|
|
44
|
+
}, {
|
|
45
|
+
ttlMs?: number | undefined;
|
|
46
|
+
cacheScope?: "private" | "public" | undefined;
|
|
47
|
+
}>>;
|
|
48
|
+
"resources/read": z.ZodOptional<z.ZodObject<{
|
|
49
|
+
ttlMs: z.ZodOptional<z.ZodNumber>;
|
|
50
|
+
cacheScope: z.ZodOptional<z.ZodEnum<["private", "public"]>>;
|
|
51
|
+
}, "strict", z.ZodTypeAny, {
|
|
52
|
+
ttlMs?: number | undefined;
|
|
53
|
+
cacheScope?: "private" | "public" | undefined;
|
|
54
|
+
}, {
|
|
55
|
+
ttlMs?: number | undefined;
|
|
56
|
+
cacheScope?: "private" | "public" | undefined;
|
|
57
|
+
}>>;
|
|
58
|
+
"server/discover": z.ZodOptional<z.ZodObject<{
|
|
59
|
+
ttlMs: z.ZodOptional<z.ZodNumber>;
|
|
60
|
+
cacheScope: z.ZodOptional<z.ZodEnum<["private", "public"]>>;
|
|
61
|
+
}, "strict", z.ZodTypeAny, {
|
|
62
|
+
ttlMs?: number | undefined;
|
|
63
|
+
cacheScope?: "private" | "public" | undefined;
|
|
64
|
+
}, {
|
|
65
|
+
ttlMs?: number | undefined;
|
|
66
|
+
cacheScope?: "private" | "public" | undefined;
|
|
67
|
+
}>>;
|
|
68
|
+
}, "strict", z.ZodTypeAny, {
|
|
69
|
+
"tools/list"?: {
|
|
70
|
+
ttlMs?: number | undefined;
|
|
71
|
+
cacheScope?: "private" | "public" | undefined;
|
|
72
|
+
} | undefined;
|
|
73
|
+
"prompts/list"?: {
|
|
74
|
+
ttlMs?: number | undefined;
|
|
75
|
+
cacheScope?: "private" | "public" | undefined;
|
|
76
|
+
} | undefined;
|
|
77
|
+
"resources/list"?: {
|
|
78
|
+
ttlMs?: number | undefined;
|
|
79
|
+
cacheScope?: "private" | "public" | undefined;
|
|
80
|
+
} | undefined;
|
|
81
|
+
"resources/templates/list"?: {
|
|
82
|
+
ttlMs?: number | undefined;
|
|
83
|
+
cacheScope?: "private" | "public" | undefined;
|
|
84
|
+
} | undefined;
|
|
85
|
+
"resources/read"?: {
|
|
86
|
+
ttlMs?: number | undefined;
|
|
87
|
+
cacheScope?: "private" | "public" | undefined;
|
|
88
|
+
} | undefined;
|
|
89
|
+
"server/discover"?: {
|
|
90
|
+
ttlMs?: number | undefined;
|
|
91
|
+
cacheScope?: "private" | "public" | undefined;
|
|
92
|
+
} | undefined;
|
|
93
|
+
}, {
|
|
94
|
+
"tools/list"?: {
|
|
95
|
+
ttlMs?: number | undefined;
|
|
96
|
+
cacheScope?: "private" | "public" | undefined;
|
|
97
|
+
} | undefined;
|
|
98
|
+
"prompts/list"?: {
|
|
99
|
+
ttlMs?: number | undefined;
|
|
100
|
+
cacheScope?: "private" | "public" | undefined;
|
|
101
|
+
} | undefined;
|
|
102
|
+
"resources/list"?: {
|
|
103
|
+
ttlMs?: number | undefined;
|
|
104
|
+
cacheScope?: "private" | "public" | undefined;
|
|
105
|
+
} | undefined;
|
|
106
|
+
"resources/templates/list"?: {
|
|
107
|
+
ttlMs?: number | undefined;
|
|
108
|
+
cacheScope?: "private" | "public" | undefined;
|
|
109
|
+
} | undefined;
|
|
110
|
+
"resources/read"?: {
|
|
111
|
+
ttlMs?: number | undefined;
|
|
112
|
+
cacheScope?: "private" | "public" | undefined;
|
|
113
|
+
} | undefined;
|
|
114
|
+
"server/discover"?: {
|
|
115
|
+
ttlMs?: number | undefined;
|
|
116
|
+
cacheScope?: "private" | "public" | undefined;
|
|
117
|
+
} | undefined;
|
|
118
|
+
}>;
|
|
119
|
+
export type CacheHintsConfig = z.infer<typeof cacheHintsConfigSchema>;
|
|
@@ -5,4 +5,5 @@ export { pathsConfigSchema, type PathsConfig, DEFAULT_PATHS } from "./paths";
|
|
|
5
5
|
export { bundlerConfigSchema, type BundlerConfig } from "./bundler";
|
|
6
6
|
export { templateConfigSchema, type TemplateConfig } from "./template";
|
|
7
7
|
export { typescriptConfigSchema, type TypescriptConfig } from "./typescript";
|
|
8
|
+
export { cacheHintsConfigSchema, type CacheHintsConfig } from "./cache-hints";
|
|
8
9
|
export { componentsConfigSchema, type ComponentsConfig, type ComponentSelector, } from "./components";
|
package/dist/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(
|
|
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 o=t();for(var r in o)("object"==typeof exports?exports:e)[r]=o[r]}}(this,()=>(()=>{"use strict";var e={};e.n=t=>{var o=t&&t.__esModule?()=>t.default:()=>t;return e.d(o,{a:o}),o},e.d=(t,o,r)=>{var n=(o,r)=>{for(var n in o)e.o(o,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,[r]:o[n]})};n(o,"get"),n(r,"value")},e.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e.r=e=>{"u">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,{configSchema:()=>F,getResolvedCorsConfig:()=>R,getResolvedExperimentalConfig:()=>N,getResolvedHttpConfig:()=>P,getResolvedPathsConfig:()=>M,getResolvedStdioConfig:()=>_,getResolvedTemplateConfig:()=>G,getResolvedTypescriptConfig:()=>q});let o=require("zod/v3");var r=e.n(o);let n=["x-mcp-client-name","x-mcp-client-version","x-mcp-client-title","x-mcp-client-website-url","x-mcp-client-description"],l={origin:"*",methods:["GET","POST"],allowedHeaders:["Content-Type","Authorization","mcp-session-id","mcp-protocol-version","mcp-method","mcp-name",...n],exposedHeaders:["Content-Type","Authorization","mcp-session-id"],credentials:!1,maxAge:86400},s=o.z.object({origin:o.z.union([o.z.string(),o.z.array(o.z.string()),o.z.boolean()]).default(l.origin),methods:o.z.union([o.z.string(),o.z.array(o.z.string())]).default([...l.methods]),allowedHeaders:o.z.union([o.z.string(),o.z.array(o.z.string())]).default([...l.allowedHeaders]),exposedHeaders:o.z.union([o.z.string(),o.z.array(o.z.string())]).default([...l.exposedHeaders]),credentials:o.z.boolean().default(l.credentials),maxAge:o.z.number().default(l.maxAge)}),i=s.parse({}),a=s.partial().transform(e=>{let t=Object.fromEntries(Object.entries(e).filter(([e,t])=>void 0!==t)),o={...i,...t};if(Array.isArray(o.allowedHeaders)){let e=new Set(o.allowedHeaders);for(let t of(e.add("mcp-session-id"),e.add("mcp-protocol-version"),e.add("mcp-method"),e.add("mcp-name"),n))e.add(t);o.allowedHeaders=Array.from(e)}if(Array.isArray(o.exposedHeaders)){let e=new Set(o.exposedHeaders);e.add("mcp-session-id"),o.exposedHeaders=Array.from(e)}return o}),p=o.z.object({port:o.z.number().default(3001),host:o.z.string().default("127.0.0.1"),bodySizeLimit:o.z.number().default(0xa00000),debug:o.z.boolean().default(!1),endpoint:o.z.string().default("/mcp"),maxSubscriptions:o.z.number().int().min(0).optional(),cors:a}),u=p.partial().transform(e=>{let t=p.parse({cors:{}}),o=Object.fromEntries(Object.entries(e).filter(([e,t])=>void 0!==t));return{...t,...o}}),c=o.z.union([o.z.boolean(),u]);c.transform(e=>"boolean"==typeof e?e?{}:null:e).pipe(o.z.union([o.z.literal(null),u]));let d=o.z.object({debug:o.z.boolean().default(!1),silent:o.z.boolean().default(!1)}),f=d.partial().transform(e=>{let t=d.parse({}),o=Object.fromEntries(Object.entries(e).filter(([e,t])=>void 0!==t));return{...t,...o}}),m=o.z.union([o.z.boolean(),f]).optional(),z=o.z.enum(["express","nextjs","nestjs","fastify","tanstack","hono","sveltekit","nuxt","react-router","astro"]),b=o.z.object({adapter:z.optional(),inferToolSchemas:o.z.boolean().optional()}),g=o.z.object({tools:o.z.union([o.z.boolean(),o.z.string()]).default(!0),prompts:o.z.union([o.z.boolean(),o.z.string()]).default(!0),resources:o.z.union([o.z.boolean(),o.z.string()]).default(!0),skills:o.z.union([o.z.boolean(),o.z.string()]).default(!0)}),y=g.partial().transform(e=>{let t=g.parse({}),o=Object.fromEntries(Object.entries(e).filter(([e,t])=>void 0!==t));return{...t,...o}}),j="src/tools",v="src/prompts",x="src/resources",h="src/skills",O=r().function().args(r().any()).returns(r().any()).optional(),k=o.z.object({name:o.z.string().default("xmcp server"),description:o.z.string().default("This MCP server was bootstrapped with xmcp."),icons:o.z.array(o.z.object({src:o.z.string(),mimeType:o.z.string().optional(),sizes:o.z.array(o.z.string()).optional(),theme:o.z.enum(["light","dark"]).optional()})).optional(),instructions:o.z.string().optional(),homePage:o.z.string().optional()}),S=k.partial().transform(e=>{let t=k.parse({}),o=Object.fromEntries(Object.entries(e).filter(([e,t])=>void 0!==t));return{...t,...o}}),H=o.z.object({skipTypeCheck:o.z.boolean().default(!1)}),A=H.partial().transform(e=>{let t=H.parse({}),o=Object.fromEntries(Object.entries(e).filter(([e,t])=>void 0!==t));return{...t,...o}}),T=o.z.object({ttlMs:o.z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).optional(),cacheScope:o.z.enum(["private","public"]).optional()}).strict(),w=o.z.object({"tools/list":T.optional(),"prompts/list":T.optional(),"resources/list":T.optional(),"resources/templates/list":T.optional(),"resources/read":T.optional(),"server/discover":T.optional()}).strict(),C=o.z.object({names:o.z.array(o.z.string().min(1)).optional(),tags:o.z.array(o.z.string().min(1)).optional()}).strict(),E=o.z.object({include:C.optional(),exclude:C.optional()}).strict();function P(e){if("boolean"==typeof e){if(!e)return null;let t=c.parse({});return"object"!=typeof t||null===t?null:t}if("object"==typeof e&&null!==e){let t=c.parse(e);return"object"!=typeof t||null===t?null:t}return null}function R(e){return a.parse(e?.cors??{})}function M(e){let t=e?.paths;if(!t)return{tools:j,prompts:v,resources:x,skills:h};let o={tools:j,prompts:v,resources:x,skills:h};return"boolean"==typeof t.tools?o.tools=t.tools?j:null:"string"==typeof t.tools&&(o.tools=t.tools),"boolean"==typeof t.prompts?o.prompts=t.prompts?v:null:"string"==typeof t.prompts&&(o.prompts=t.prompts),"boolean"==typeof t.resources?o.resources=t.resources?x:null:"string"==typeof t.resources&&(o.resources=t.resources),"boolean"==typeof t.skills?o.skills=t.skills?h:null:"string"==typeof t.skills&&(o.skills=t.skills),o}function _(e){let t=e?.stdio;if("boolean"==typeof t){if(!t)return null;let e=m.parse({});return"object"!=typeof e||null===e?null:e}if(t){let e=m.parse(t);return"object"!=typeof e||null===e?null:e}let o=m.parse({});return"object"!=typeof o||null===o?null:o}function G(e){let t=e?.template;return S.parse(t??{})}function N(e){let t=e?.experimental;return{adapter:t?.adapter}}function q(e){let t=e?.typescript;return A.parse(t??{})}let F=o.z.object({stdio:m.optional(),http:c.optional(),experimental:b.optional(),paths:y.optional(),bundler:O.optional(),template:S.optional(),typescript:A.optional(),observability:o.z.object({enabled:o.z.boolean()}).optional(),components:E.optional(),cacheHints:w.optional()});return t})());
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export type { InputRequiredResult, InputRequests, InputResponses, RequestStateCo
|
|
|
18
18
|
export { createHTTPClient, createSTDIOClient, listSTDIOClientTools, callSTDIOClientTool, disconnectSTDIOClient, } from "./client/index";
|
|
19
19
|
export type { HttpClient, StdioClient, StdioIOStrategy, ClientConnectionEntry, ClientConnections, ClientDefinition, HttpClientConfig, StdioClientConfig, } from "./client/types";
|
|
20
20
|
export type { StdioClientConnection, StdioClientOptions } from "./client/index";
|
|
21
|
+
export type { ClientHandlers } from "./client/handlers";
|
|
21
22
|
export type { CustomHeaders, CustomHeader, StaticHeader, EnvHeader, } from "./client/headers";
|
|
22
23
|
export { isEnvHeader, headersToRecord } from "./client/headers";
|
|
23
24
|
export { extractToolNamesFromRequest } from "./runtime/utils/request-tool-names";
|