@mastra/mcp 1.17.0 → 1.17.1-alpha.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/CHANGELOG.md +18 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +231 -2145
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +231 -2145
- package/dist/index.js.map +1 -1
- package/dist/server/server.d.ts +1 -0
- package/dist/server/server.d.ts.map +1 -1
- package/package.json +11 -8
package/dist/index.cjs
CHANGED
|
@@ -53,6 +53,7 @@ let _modelcontextprotocol_node = require("@modelcontextprotocol/node");
|
|
|
53
53
|
let _modelcontextprotocol_server = require("@modelcontextprotocol/server");
|
|
54
54
|
let _modelcontextprotocol_server_stdio = require("@modelcontextprotocol/server/stdio");
|
|
55
55
|
let _modelcontextprotocol_server_legacy_sse = require("@modelcontextprotocol/server-legacy/sse");
|
|
56
|
+
let _modelcontextprotocol_sdk_types_js = require("@modelcontextprotocol/sdk/types.js");
|
|
56
57
|
//#region ../schema-compat/dist/json-schema-traverse-B35mHRM8.js
|
|
57
58
|
var __create$1 = Object.create;
|
|
58
59
|
var __defProp$2 = Object.defineProperty;
|
|
@@ -2587,7 +2588,7 @@ const getDiscriminator = (type) => {
|
|
|
2587
2588
|
else if (type instanceof ZodCatch$1) return getDiscriminator(type._def.innerType);
|
|
2588
2589
|
else return [];
|
|
2589
2590
|
};
|
|
2590
|
-
var ZodDiscriminatedUnion
|
|
2591
|
+
var ZodDiscriminatedUnion = class ZodDiscriminatedUnion extends ZodType$1 {
|
|
2591
2592
|
_parse(input) {
|
|
2592
2593
|
const { ctx } = this._processInputParams(input);
|
|
2593
2594
|
if (ctx.parsedType !== ZodParsedType.object) {
|
|
@@ -2647,7 +2648,7 @@ var ZodDiscriminatedUnion$1 = class ZodDiscriminatedUnion$1 extends ZodType$1 {
|
|
|
2647
2648
|
optionsMap.set(value, type);
|
|
2648
2649
|
}
|
|
2649
2650
|
}
|
|
2650
|
-
return new ZodDiscriminatedUnion
|
|
2651
|
+
return new ZodDiscriminatedUnion({
|
|
2651
2652
|
typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
|
|
2652
2653
|
discriminator,
|
|
2653
2654
|
options,
|
|
@@ -3713,7 +3714,7 @@ const arrayType = ZodArray$1.create;
|
|
|
3713
3714
|
const objectType = ZodObject$1.create;
|
|
3714
3715
|
const strictObjectType = ZodObject$1.strictCreate;
|
|
3715
3716
|
const unionType = ZodUnion$1.create;
|
|
3716
|
-
const discriminatedUnionType = ZodDiscriminatedUnion
|
|
3717
|
+
const discriminatedUnionType = ZodDiscriminatedUnion.create;
|
|
3717
3718
|
const intersectionType = ZodIntersection$1.create;
|
|
3718
3719
|
const tupleType = ZodTuple$1.create;
|
|
3719
3720
|
const recordType = ZodRecord$1.create;
|
|
@@ -3775,7 +3776,7 @@ var v3_default = /* @__PURE__ */ __exportAll({
|
|
|
3775
3776
|
ZodCatch: () => ZodCatch$1,
|
|
3776
3777
|
ZodDate: () => ZodDate,
|
|
3777
3778
|
ZodDefault: () => ZodDefault$1,
|
|
3778
|
-
ZodDiscriminatedUnion: () => ZodDiscriminatedUnion
|
|
3779
|
+
ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
|
|
3779
3780
|
ZodEffects: () => ZodEffects,
|
|
3780
3781
|
ZodEnum: () => ZodEnum$1,
|
|
3781
3782
|
ZodError: () => ZodError,
|
|
@@ -6743,62 +6744,6 @@ const $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
|
|
|
6743
6744
|
});
|
|
6744
6745
|
};
|
|
6745
6746
|
});
|
|
6746
|
-
const $ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
6747
|
-
def.inclusive = false;
|
|
6748
|
-
$ZodUnion.init(inst, def);
|
|
6749
|
-
const _super = inst._zod.parse;
|
|
6750
|
-
defineLazy(inst._zod, "propValues", () => {
|
|
6751
|
-
const propValues = {};
|
|
6752
|
-
for (const option of def.options) {
|
|
6753
|
-
const pv = option._zod.propValues;
|
|
6754
|
-
if (!pv || Object.keys(pv).length === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
6755
|
-
for (const [k, v] of Object.entries(pv)) {
|
|
6756
|
-
if (!propValues[k]) propValues[k] = /* @__PURE__ */ new Set();
|
|
6757
|
-
for (const val of v) propValues[k].add(val);
|
|
6758
|
-
}
|
|
6759
|
-
}
|
|
6760
|
-
return propValues;
|
|
6761
|
-
});
|
|
6762
|
-
const disc = cached(() => {
|
|
6763
|
-
const opts = def.options;
|
|
6764
|
-
const map = /* @__PURE__ */ new Map();
|
|
6765
|
-
for (const o of opts) {
|
|
6766
|
-
const values = o._zod.propValues?.[def.discriminator];
|
|
6767
|
-
if (!values || values.size === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
|
6768
|
-
for (const v of values) {
|
|
6769
|
-
if (map.has(v)) throw new Error(`Duplicate discriminator value "${String(v)}"`);
|
|
6770
|
-
map.set(v, o);
|
|
6771
|
-
}
|
|
6772
|
-
}
|
|
6773
|
-
return map;
|
|
6774
|
-
});
|
|
6775
|
-
inst._zod.parse = (payload, ctx) => {
|
|
6776
|
-
const input = payload.value;
|
|
6777
|
-
if (!isObject(input)) {
|
|
6778
|
-
payload.issues.push({
|
|
6779
|
-
code: "invalid_type",
|
|
6780
|
-
expected: "object",
|
|
6781
|
-
input,
|
|
6782
|
-
inst
|
|
6783
|
-
});
|
|
6784
|
-
return payload;
|
|
6785
|
-
}
|
|
6786
|
-
const opt = disc.value.get(input?.[def.discriminator]);
|
|
6787
|
-
if (opt) return opt._zod.run(payload, ctx);
|
|
6788
|
-
if (def.unionFallback || ctx.direction === "backward") return _super(payload, ctx);
|
|
6789
|
-
payload.issues.push({
|
|
6790
|
-
code: "invalid_union",
|
|
6791
|
-
errors: [],
|
|
6792
|
-
note: "No matching discriminator",
|
|
6793
|
-
discriminator: def.discriminator,
|
|
6794
|
-
options: Array.from(disc.value.keys()),
|
|
6795
|
-
input,
|
|
6796
|
-
path: [def.discriminator],
|
|
6797
|
-
inst
|
|
6798
|
-
});
|
|
6799
|
-
return payload;
|
|
6800
|
-
};
|
|
6801
|
-
});
|
|
6802
6747
|
const $ZodIntersection = /*@__PURE__*/ $constructor("$ZodIntersection", (inst, def) => {
|
|
6803
6748
|
$ZodType.init(inst, def);
|
|
6804
6749
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -7334,9 +7279,6 @@ function handlePipeResult(left, next, ctx) {
|
|
|
7334
7279
|
fallback: left.fallback
|
|
7335
7280
|
}, ctx);
|
|
7336
7281
|
}
|
|
7337
|
-
const $ZodPreprocess = /*@__PURE__*/ $constructor("$ZodPreprocess", (inst, def) => {
|
|
7338
|
-
$ZodPipe.init(inst, def);
|
|
7339
|
-
});
|
|
7340
7282
|
const $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
|
|
7341
7283
|
$ZodType.init(inst, def);
|
|
7342
7284
|
defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
|
|
@@ -9356,14 +9298,6 @@ function object$1(shape, params) {
|
|
|
9356
9298
|
};
|
|
9357
9299
|
return new ZodObject(def);
|
|
9358
9300
|
}
|
|
9359
|
-
function looseObject(shape, params) {
|
|
9360
|
-
return new ZodObject({
|
|
9361
|
-
type: "object",
|
|
9362
|
-
shape,
|
|
9363
|
-
catchall: unknown(),
|
|
9364
|
-
...normalizeParams(params)
|
|
9365
|
-
});
|
|
9366
|
-
}
|
|
9367
9301
|
const ZodUnion = /*@__PURE__*/ $constructor("ZodUnion", (inst, def) => {
|
|
9368
9302
|
$ZodUnion.init(inst, def);
|
|
9369
9303
|
ZodType.init(inst, def);
|
|
@@ -9377,18 +9311,6 @@ function union(options, params) {
|
|
|
9377
9311
|
...normalizeParams(params)
|
|
9378
9312
|
});
|
|
9379
9313
|
}
|
|
9380
|
-
const ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("ZodDiscriminatedUnion", (inst, def) => {
|
|
9381
|
-
ZodUnion.init(inst, def);
|
|
9382
|
-
$ZodDiscriminatedUnion.init(inst, def);
|
|
9383
|
-
});
|
|
9384
|
-
function discriminatedUnion(discriminator, options, params) {
|
|
9385
|
-
return new ZodDiscriminatedUnion({
|
|
9386
|
-
type: "union",
|
|
9387
|
-
options,
|
|
9388
|
-
discriminator,
|
|
9389
|
-
...normalizeParams(params)
|
|
9390
|
-
});
|
|
9391
|
-
}
|
|
9392
9314
|
const ZodIntersection = /*@__PURE__*/ $constructor("ZodIntersection", (inst, def) => {
|
|
9393
9315
|
$ZodIntersection.init(inst, def);
|
|
9394
9316
|
ZodType.init(inst, def);
|
|
@@ -9648,10 +9570,6 @@ function pipe(in_, out) {
|
|
|
9648
9570
|
out
|
|
9649
9571
|
});
|
|
9650
9572
|
}
|
|
9651
|
-
const ZodPreprocess = /*@__PURE__*/ $constructor("ZodPreprocess", (inst, def) => {
|
|
9652
|
-
ZodPipe.init(inst, def);
|
|
9653
|
-
$ZodPreprocess.init(inst, def);
|
|
9654
|
-
});
|
|
9655
9573
|
const ZodReadonly = /*@__PURE__*/ $constructor("ZodReadonly", (inst, def) => {
|
|
9656
9574
|
$ZodReadonly.init(inst, def);
|
|
9657
9575
|
ZodType.init(inst, def);
|
|
@@ -9710,13 +9628,6 @@ function _instanceof(cls, params = {}) {
|
|
|
9710
9628
|
};
|
|
9711
9629
|
return inst;
|
|
9712
9630
|
}
|
|
9713
|
-
function preprocess(fn, schema) {
|
|
9714
|
-
return new ZodPreprocess({
|
|
9715
|
-
type: "pipe",
|
|
9716
|
-
in: transform(fn),
|
|
9717
|
-
out: schema
|
|
9718
|
-
});
|
|
9719
|
-
}
|
|
9720
9631
|
//#endregion
|
|
9721
9632
|
//#region ../schema-compat/dist/zod-to-json.js
|
|
9722
9633
|
const PATCHED = Symbol("__mastra_patched__");
|
|
@@ -20424,12 +20335,12 @@ var ClientOrServerImplementationSchema = object$1({
|
|
|
20424
20335
|
version: string()
|
|
20425
20336
|
}).passthrough();
|
|
20426
20337
|
var BaseParamsSchema = object$1({ _meta: optional(object$1({}).passthrough()) }).passthrough();
|
|
20427
|
-
var ResultSchema
|
|
20428
|
-
var RequestSchema
|
|
20338
|
+
var ResultSchema = BaseParamsSchema;
|
|
20339
|
+
var RequestSchema = object$1({
|
|
20429
20340
|
method: string(),
|
|
20430
20341
|
params: optional(BaseParamsSchema)
|
|
20431
20342
|
});
|
|
20432
|
-
var ServerCapabilitiesSchema
|
|
20343
|
+
var ServerCapabilitiesSchema = object$1({
|
|
20433
20344
|
experimental: optional(object$1({}).passthrough()),
|
|
20434
20345
|
logging: optional(object$1({}).passthrough()),
|
|
20435
20346
|
prompts: optional(object$1({ listChanged: optional(boolean()) }).passthrough()),
|
|
@@ -20439,14 +20350,14 @@ var ServerCapabilitiesSchema$1 = object$1({
|
|
|
20439
20350
|
}).passthrough()),
|
|
20440
20351
|
tools: optional(object$1({ listChanged: optional(boolean()) }).passthrough())
|
|
20441
20352
|
}).passthrough();
|
|
20442
|
-
ResultSchema
|
|
20353
|
+
ResultSchema.extend({
|
|
20443
20354
|
protocolVersion: string(),
|
|
20444
|
-
capabilities: ServerCapabilitiesSchema
|
|
20355
|
+
capabilities: ServerCapabilitiesSchema,
|
|
20445
20356
|
serverInfo: ClientOrServerImplementationSchema,
|
|
20446
20357
|
instructions: optional(string())
|
|
20447
20358
|
});
|
|
20448
|
-
var PaginatedResultSchema
|
|
20449
|
-
var ToolSchema
|
|
20359
|
+
var PaginatedResultSchema = ResultSchema.extend({ nextCursor: optional(string()) });
|
|
20360
|
+
var ToolSchema = object$1({
|
|
20450
20361
|
name: string(),
|
|
20451
20362
|
description: optional(string()),
|
|
20452
20363
|
inputSchema: object$1({
|
|
@@ -20454,17 +20365,17 @@ var ToolSchema$1 = object$1({
|
|
|
20454
20365
|
properties: optional(object$1({}).passthrough())
|
|
20455
20366
|
}).passthrough()
|
|
20456
20367
|
}).passthrough();
|
|
20457
|
-
PaginatedResultSchema
|
|
20458
|
-
var TextContentSchema
|
|
20368
|
+
PaginatedResultSchema.extend({ tools: array(ToolSchema) });
|
|
20369
|
+
var TextContentSchema = object$1({
|
|
20459
20370
|
type: literal("text"),
|
|
20460
20371
|
text: string()
|
|
20461
20372
|
}).passthrough();
|
|
20462
|
-
var ImageContentSchema
|
|
20373
|
+
var ImageContentSchema = object$1({
|
|
20463
20374
|
type: literal("image"),
|
|
20464
20375
|
data: string().base64(),
|
|
20465
20376
|
mimeType: string()
|
|
20466
20377
|
}).passthrough();
|
|
20467
|
-
var ResourceContentsSchema
|
|
20378
|
+
var ResourceContentsSchema = object$1({
|
|
20468
20379
|
/**
|
|
20469
20380
|
* The URI of this resource.
|
|
20470
20381
|
*/
|
|
@@ -20474,32 +20385,32 @@ var ResourceContentsSchema$1 = object$1({
|
|
|
20474
20385
|
*/
|
|
20475
20386
|
mimeType: optional(string())
|
|
20476
20387
|
}).passthrough();
|
|
20477
|
-
var TextResourceContentsSchema
|
|
20478
|
-
var BlobResourceContentsSchema
|
|
20479
|
-
var EmbeddedResourceSchema
|
|
20388
|
+
var TextResourceContentsSchema = ResourceContentsSchema.extend({ text: string() });
|
|
20389
|
+
var BlobResourceContentsSchema = ResourceContentsSchema.extend({ blob: string().base64() });
|
|
20390
|
+
var EmbeddedResourceSchema = object$1({
|
|
20480
20391
|
type: literal("resource"),
|
|
20481
|
-
resource: union([TextResourceContentsSchema
|
|
20392
|
+
resource: union([TextResourceContentsSchema, BlobResourceContentsSchema])
|
|
20482
20393
|
}).passthrough();
|
|
20483
|
-
ResultSchema
|
|
20394
|
+
ResultSchema.extend({
|
|
20484
20395
|
content: array(union([
|
|
20485
|
-
TextContentSchema
|
|
20486
|
-
ImageContentSchema
|
|
20487
|
-
EmbeddedResourceSchema
|
|
20396
|
+
TextContentSchema,
|
|
20397
|
+
ImageContentSchema,
|
|
20398
|
+
EmbeddedResourceSchema
|
|
20488
20399
|
])),
|
|
20489
20400
|
isError: boolean().default(false).optional()
|
|
20490
|
-
}).or(ResultSchema
|
|
20491
|
-
var JSONRPC_VERSION
|
|
20492
|
-
var JSONRPCRequestSchema
|
|
20493
|
-
jsonrpc: literal(JSONRPC_VERSION
|
|
20401
|
+
}).or(ResultSchema.extend({ toolResult: unknown() }));
|
|
20402
|
+
var JSONRPC_VERSION = "2.0";
|
|
20403
|
+
var JSONRPCRequestSchema = object$1({
|
|
20404
|
+
jsonrpc: literal(JSONRPC_VERSION),
|
|
20494
20405
|
id: union([string(), number().int()])
|
|
20495
|
-
}).merge(RequestSchema
|
|
20496
|
-
var JSONRPCResponseSchema
|
|
20497
|
-
jsonrpc: literal(JSONRPC_VERSION
|
|
20406
|
+
}).merge(RequestSchema).strict();
|
|
20407
|
+
var JSONRPCResponseSchema = object$1({
|
|
20408
|
+
jsonrpc: literal(JSONRPC_VERSION),
|
|
20498
20409
|
id: union([string(), number().int()]),
|
|
20499
|
-
result: ResultSchema
|
|
20410
|
+
result: ResultSchema
|
|
20500
20411
|
}).strict();
|
|
20501
20412
|
var JSONRPCErrorSchema = object$1({
|
|
20502
|
-
jsonrpc: literal(JSONRPC_VERSION
|
|
20413
|
+
jsonrpc: literal(JSONRPC_VERSION),
|
|
20503
20414
|
id: union([string(), number().int()]),
|
|
20504
20415
|
error: object$1({
|
|
20505
20416
|
code: number().int(),
|
|
@@ -20508,12 +20419,12 @@ var JSONRPCErrorSchema = object$1({
|
|
|
20508
20419
|
})
|
|
20509
20420
|
}).strict();
|
|
20510
20421
|
union([
|
|
20511
|
-
JSONRPCRequestSchema
|
|
20512
|
-
object$1({ jsonrpc: literal(JSONRPC_VERSION
|
|
20422
|
+
JSONRPCRequestSchema,
|
|
20423
|
+
object$1({ jsonrpc: literal(JSONRPC_VERSION) }).merge(object$1({
|
|
20513
20424
|
method: string(),
|
|
20514
20425
|
params: optional(BaseParamsSchema)
|
|
20515
20426
|
})).strict(),
|
|
20516
|
-
JSONRPCResponseSchema
|
|
20427
|
+
JSONRPCResponseSchema,
|
|
20517
20428
|
JSONRPCErrorSchema
|
|
20518
20429
|
]);
|
|
20519
20430
|
__export({}, {
|
|
@@ -24294,2039 +24205,208 @@ var streamSSE = (c, cb, onError) => {
|
|
|
24294
24205
|
return c.newResponse(stream.responseReadable);
|
|
24295
24206
|
};
|
|
24296
24207
|
//#endregion
|
|
24297
|
-
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links
|
|
24298
|
-
const
|
|
24299
|
-
|
|
24300
|
-
|
|
24301
|
-
|
|
24302
|
-
|
|
24303
|
-
|
|
24304
|
-
|
|
24305
|
-
|
|
24306
|
-
* A progress token, used to associate progress notifications with the original request.
|
|
24307
|
-
*/
|
|
24308
|
-
const ProgressTokenSchema = union([string(), number().int()]);
|
|
24309
|
-
/**
|
|
24310
|
-
* An opaque token used to represent a cursor for pagination.
|
|
24311
|
-
*/
|
|
24312
|
-
const CursorSchema = string();
|
|
24313
|
-
looseObject({
|
|
24208
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/hono-mcp-server-sse-transport/0.0.7/d5ae5a23aa2b79db7055621f11a7cbc8d27f7caba1eeb308ab2cf5bcb1a8e5b8/node_modules/hono-mcp-server-sse-transport/build/sse.js
|
|
24209
|
+
const MAXIMUM_MESSAGE_SIZE = 4 * 1024 * 1024;
|
|
24210
|
+
var SSETransport = class {
|
|
24211
|
+
messageUrl;
|
|
24212
|
+
stream;
|
|
24213
|
+
_sessionId;
|
|
24214
|
+
onclose;
|
|
24215
|
+
onerror;
|
|
24216
|
+
onmessage;
|
|
24314
24217
|
/**
|
|
24315
|
-
*
|
|
24218
|
+
* Creates a new SSETransport, which will direct the MPC client to POST messages to messageUrl
|
|
24316
24219
|
*/
|
|
24317
|
-
|
|
24220
|
+
constructor(messageUrl, stream) {
|
|
24221
|
+
this.messageUrl = messageUrl;
|
|
24222
|
+
this.stream = stream;
|
|
24223
|
+
this._sessionId = crypto.randomUUID();
|
|
24224
|
+
this.stream.onAbort(() => {
|
|
24225
|
+
this.close();
|
|
24226
|
+
});
|
|
24227
|
+
}
|
|
24228
|
+
get sessionId() {
|
|
24229
|
+
return this._sessionId;
|
|
24230
|
+
}
|
|
24231
|
+
async start() {
|
|
24232
|
+
if (this.stream == null) throw new Error("Stream not initialized");
|
|
24233
|
+
if (this.stream.closed) throw new Error("SSE transport already closed!");
|
|
24234
|
+
await this.stream.writeSSE({
|
|
24235
|
+
event: "ping",
|
|
24236
|
+
data: ""
|
|
24237
|
+
});
|
|
24238
|
+
await this.stream.writeSSE({
|
|
24239
|
+
event: "endpoint",
|
|
24240
|
+
data: `${this.messageUrl}?sessionId=${this.sessionId}`
|
|
24241
|
+
});
|
|
24242
|
+
}
|
|
24243
|
+
async handlePostMessage(context) {
|
|
24244
|
+
if (this.stream?.closed == null) return context.text("SSE connection not established", 500);
|
|
24245
|
+
try {
|
|
24246
|
+
const contentType = context.req.header("content-type") || "";
|
|
24247
|
+
if (!contentType.includes("application/json")) throw new Error(`Unsupported content-type: ${contentType}`);
|
|
24248
|
+
const contentLength = Number.parseInt(context.req.header("content-length") || "0", 10);
|
|
24249
|
+
if (contentLength > MAXIMUM_MESSAGE_SIZE) throw new Error(`Request body too large: ${contentLength} bytes`);
|
|
24250
|
+
const body = await context.req.json();
|
|
24251
|
+
await this.handleMessage(body);
|
|
24252
|
+
return context.text("Accepted", 202);
|
|
24253
|
+
} catch (error) {
|
|
24254
|
+
this.onerror?.(error);
|
|
24255
|
+
return context.text("Error", 400);
|
|
24256
|
+
}
|
|
24257
|
+
}
|
|
24318
24258
|
/**
|
|
24319
|
-
*
|
|
24259
|
+
* Handle a client message, regardless of how it arrived. This can be used to inform the server of messages that arrive via a means different than HTTP POST.
|
|
24320
24260
|
*/
|
|
24321
|
-
|
|
24322
|
-
|
|
24323
|
-
|
|
24261
|
+
async handleMessage(message) {
|
|
24262
|
+
let parsedMessage;
|
|
24263
|
+
try {
|
|
24264
|
+
parsedMessage = _modelcontextprotocol_sdk_types_js.JSONRPCMessageSchema.parse(message);
|
|
24265
|
+
} catch (error) {
|
|
24266
|
+
this.onerror?.(error);
|
|
24267
|
+
throw error;
|
|
24268
|
+
}
|
|
24269
|
+
this.onmessage?.(parsedMessage);
|
|
24270
|
+
}
|
|
24271
|
+
async close() {
|
|
24272
|
+
if (this.stream?.closed) this.stream.abort();
|
|
24273
|
+
}
|
|
24274
|
+
async send(message) {
|
|
24275
|
+
if (this.stream?.closed) throw new Error("Not connected");
|
|
24276
|
+
await this.stream.writeSSE({
|
|
24277
|
+
event: "message",
|
|
24278
|
+
data: JSON.stringify(message)
|
|
24279
|
+
});
|
|
24280
|
+
}
|
|
24281
|
+
};
|
|
24282
|
+
//#endregion
|
|
24283
|
+
//#region src/server/mrtrElicitation.ts
|
|
24324
24284
|
/**
|
|
24325
|
-
*
|
|
24326
|
-
*
|
|
24285
|
+
* Elicitation on the 2026-07-28 protocol revision (multi-round-trip requests).
|
|
24286
|
+
*
|
|
24287
|
+
* The modern era has no server→client request channel, so `server.elicitInput()`
|
|
24288
|
+
* throws there by design. Instead, the `tools/call` handler must RETURN an
|
|
24289
|
+
* `input_required` result carrying the embedded elicitation request; the client
|
|
24290
|
+
* answers it locally and RETRIES the call with the response attached
|
|
24291
|
+
* (`inputResponses`). This module keeps the promise-shaped
|
|
24292
|
+
* `elicitation.sendRequest()` API tools already use by replaying the tool:
|
|
24293
|
+
*
|
|
24294
|
+
* 1. Each `sendRequest` call is assigned a deterministic sequence key.
|
|
24295
|
+
* 2. If the current (retried) request carries an answer for that key — either in
|
|
24296
|
+
* this round's `inputResponses` or in the accumulated `requestState` from
|
|
24297
|
+
* prior rounds — the promise resolves with it immediately.
|
|
24298
|
+
* 3. Otherwise a {@link ElicitationReplayInterrupt} is thrown; the `tools/call`
|
|
24299
|
+
* handler converts it into an {@link InputRequiredResult} return, and the
|
|
24300
|
+
* client's retry re-executes the tool from the top.
|
|
24301
|
+
*
|
|
24302
|
+
* Consequences tools must live with on the modern leg:
|
|
24303
|
+
* - Code before an unanswered elicitation re-executes on every round; keep side
|
|
24304
|
+
* effects idempotent or place them after the last elicitation.
|
|
24305
|
+
* - Elicitation order must be deterministic for a given input, since answers are
|
|
24306
|
+
* matched by call sequence.
|
|
24327
24307
|
*/
|
|
24328
|
-
const
|
|
24329
|
-
const RequestMetaSchema = looseObject({
|
|
24330
|
-
/**
|
|
24331
|
-
* If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.
|
|
24332
|
-
*/
|
|
24333
|
-
progressToken: ProgressTokenSchema.optional(),
|
|
24334
|
-
/**
|
|
24335
|
-
* If specified, this request is related to the provided task.
|
|
24336
|
-
*/
|
|
24337
|
-
[RELATED_TASK_META_KEY]: RelatedTaskMetadataSchema.optional()
|
|
24338
|
-
});
|
|
24308
|
+
const ELICIT_KEY_PREFIX = "mastra_elicit_";
|
|
24339
24309
|
/**
|
|
24340
|
-
*
|
|
24310
|
+
* Thrown by the replay-based `sendRequest` when the current round carries no
|
|
24311
|
+
* answer for the elicitation. Never surfaces to tools or clients: the
|
|
24312
|
+
* `tools/call` handler converts it into an `input_required` result.
|
|
24341
24313
|
*/
|
|
24342
|
-
|
|
24314
|
+
var ElicitationReplayInterrupt = class extends Error {
|
|
24315
|
+
key;
|
|
24316
|
+
params;
|
|
24317
|
+
answered;
|
|
24318
|
+
constructor(key, params, answered) {
|
|
24319
|
+
super(`Elicitation '${key}' requires client input (multi-round-trip)`);
|
|
24320
|
+
this.key = key;
|
|
24321
|
+
this.params = params;
|
|
24322
|
+
this.answered = answered;
|
|
24323
|
+
this.name = "ElicitationReplayInterrupt";
|
|
24324
|
+
}
|
|
24325
|
+
};
|
|
24326
|
+
const isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24327
|
+
const looksLikeElicitResult = (value) => isPlainObject(value) && typeof value.action === "string";
|
|
24343
24328
|
/**
|
|
24344
|
-
*
|
|
24329
|
+
* Decodes the accumulated prior-round answers from the request's opaque
|
|
24330
|
+
* `requestState` echo. The state round-trips through the client, so it is
|
|
24331
|
+
* attacker-controlled input on re-entry — but its only content is the client's
|
|
24332
|
+
* own past elicitation answers, which are untrusted user input either way, so
|
|
24333
|
+
* tampering grants the client nothing it does not already control. Anything
|
|
24334
|
+
* that does not parse as a map of elicitation results is discarded.
|
|
24345
24335
|
*/
|
|
24346
|
-
|
|
24336
|
+
const decodePriorAnswers = (extra) => {
|
|
24337
|
+
const raw = extra.mcpReq.requestState();
|
|
24338
|
+
if (typeof raw !== "string" || raw.length === 0) return {};
|
|
24339
|
+
try {
|
|
24340
|
+
const parsed = JSON.parse(raw);
|
|
24341
|
+
if (!isPlainObject(parsed)) return {};
|
|
24342
|
+
const answers = {};
|
|
24343
|
+
for (const [key, value] of Object.entries(parsed)) if (key.startsWith(ELICIT_KEY_PREFIX) && looksLikeElicitResult(value)) answers[key] = value;
|
|
24344
|
+
return answers;
|
|
24345
|
+
} catch {
|
|
24346
|
+
return {};
|
|
24347
|
+
}
|
|
24348
|
+
};
|
|
24349
|
+
/** This round's bare responses that answer our elicitation keys. */
|
|
24350
|
+
const currentRoundAnswers = (extra) => {
|
|
24351
|
+
const answers = {};
|
|
24352
|
+
for (const [key, value] of Object.entries(extra.mcpReq.inputResponses ?? {})) if (key.startsWith(ELICIT_KEY_PREFIX) && looksLikeElicitResult(value)) answers[key] = value;
|
|
24353
|
+
return answers;
|
|
24354
|
+
};
|
|
24347
24355
|
/**
|
|
24348
|
-
*
|
|
24356
|
+
* Whether this request is served on the 2026-07-28 era. Modern clients always
|
|
24357
|
+
* attach the reserved per-request `_meta` envelope (the 2026 codec enforces the
|
|
24358
|
+
* required keys at dispatch); legacy requests never carry it.
|
|
24349
24359
|
*/
|
|
24350
|
-
const
|
|
24360
|
+
const isModernEraRequest = (extra) => extra.mcpReq.envelope !== void 0;
|
|
24351
24361
|
/**
|
|
24352
|
-
*
|
|
24353
|
-
*
|
|
24354
|
-
*
|
|
24362
|
+
* Builds the replay-based {@link ElicitationActions} for one modern-era tool
|
|
24363
|
+
* execution. Answers already provided by the client resolve immediately; the
|
|
24364
|
+
* first unanswered elicitation throws {@link ElicitationReplayInterrupt}.
|
|
24355
24365
|
*
|
|
24356
|
-
*
|
|
24357
|
-
*
|
|
24358
|
-
|
|
24359
|
-
|
|
24360
|
-
const RequestSchema = object$1({
|
|
24361
|
-
method: string(),
|
|
24362
|
-
params: BaseRequestParamsSchema.loose().optional()
|
|
24363
|
-
});
|
|
24364
|
-
const NotificationsParamsSchema = object$1({
|
|
24365
|
-
/**
|
|
24366
|
-
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
24367
|
-
* for notes on _meta usage.
|
|
24368
|
-
*/
|
|
24369
|
-
_meta: RequestMetaSchema.optional() });
|
|
24370
|
-
const NotificationSchema = object$1({
|
|
24371
|
-
method: string(),
|
|
24372
|
-
params: NotificationsParamsSchema.loose().optional()
|
|
24373
|
-
});
|
|
24374
|
-
const ResultSchema = looseObject({
|
|
24375
|
-
/**
|
|
24376
|
-
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
24377
|
-
* for notes on _meta usage.
|
|
24378
|
-
*/
|
|
24379
|
-
_meta: RequestMetaSchema.optional() });
|
|
24380
|
-
/**
|
|
24381
|
-
* A uniquely identifying ID for a request in JSON-RPC.
|
|
24366
|
+
* The interrupt is also reported through `onInterrupt` before it is thrown:
|
|
24367
|
+
* tool wrappers (e.g. Mastra's tool builder) re-wrap thrown errors, so the
|
|
24368
|
+
* `tools/call` handler cannot rely on `instanceof` on whatever escapes the
|
|
24369
|
+
* tool — the out-of-band capture is the authoritative signal.
|
|
24382
24370
|
*/
|
|
24383
|
-
const
|
|
24371
|
+
const createReplayElicitation = (extra, onInterrupt) => {
|
|
24372
|
+
const prior = decodePriorAnswers(extra);
|
|
24373
|
+
const current = currentRoundAnswers(extra);
|
|
24374
|
+
const answered = {
|
|
24375
|
+
...prior,
|
|
24376
|
+
...current
|
|
24377
|
+
};
|
|
24378
|
+
let sequence = 0;
|
|
24379
|
+
return { sendRequest: async (request) => {
|
|
24380
|
+
const key = `${ELICIT_KEY_PREFIX}${sequence++}`;
|
|
24381
|
+
const answer = answered[key];
|
|
24382
|
+
if (answer !== void 0) return answer;
|
|
24383
|
+
const interrupt = new ElicitationReplayInterrupt(key, request, answered);
|
|
24384
|
+
onInterrupt(interrupt);
|
|
24385
|
+
throw interrupt;
|
|
24386
|
+
} };
|
|
24387
|
+
};
|
|
24384
24388
|
/**
|
|
24385
|
-
*
|
|
24389
|
+
* Converts a caught {@link ElicitationReplayInterrupt} into the
|
|
24390
|
+
* `input_required` result the `tools/call` handler returns to the client.
|
|
24391
|
+
* Prior answers travel in `requestState` because each retry only carries the
|
|
24392
|
+
* current round's `inputResponses`.
|
|
24386
24393
|
*/
|
|
24387
|
-
const
|
|
24388
|
-
|
|
24389
|
-
|
|
24390
|
-
|
|
24391
|
-
}
|
|
24392
|
-
|
|
24393
|
-
|
|
24394
|
-
|
|
24395
|
-
|
|
24396
|
-
|
|
24397
|
-
|
|
24398
|
-
|
|
24399
|
-
|
|
24400
|
-
|
|
24401
|
-
|
|
24402
|
-
|
|
24403
|
-
jsonrpc: literal("2.0"),
|
|
24404
|
-
id: RequestIdSchema,
|
|
24405
|
-
result: ResultSchema
|
|
24406
|
-
}).strict();
|
|
24407
|
-
/**
|
|
24408
|
-
* Error codes defined by the JSON-RPC specification.
|
|
24409
|
-
*/
|
|
24410
|
-
var ErrorCode;
|
|
24411
|
-
(function(ErrorCode) {
|
|
24412
|
-
ErrorCode[ErrorCode["ConnectionClosed"] = -32e3] = "ConnectionClosed";
|
|
24413
|
-
ErrorCode[ErrorCode["RequestTimeout"] = -32001] = "RequestTimeout";
|
|
24414
|
-
ErrorCode[ErrorCode["ParseError"] = -32700] = "ParseError";
|
|
24415
|
-
ErrorCode[ErrorCode["InvalidRequest"] = -32600] = "InvalidRequest";
|
|
24416
|
-
ErrorCode[ErrorCode["MethodNotFound"] = -32601] = "MethodNotFound";
|
|
24417
|
-
ErrorCode[ErrorCode["InvalidParams"] = -32602] = "InvalidParams";
|
|
24418
|
-
ErrorCode[ErrorCode["InternalError"] = -32603] = "InternalError";
|
|
24419
|
-
ErrorCode[ErrorCode["UrlElicitationRequired"] = -32042] = "UrlElicitationRequired";
|
|
24420
|
-
})(ErrorCode || (ErrorCode = {}));
|
|
24421
|
-
/**
|
|
24422
|
-
* A response to a request that indicates an error occurred.
|
|
24423
|
-
*/
|
|
24424
|
-
const JSONRPCErrorResponseSchema = object$1({
|
|
24425
|
-
jsonrpc: literal("2.0"),
|
|
24426
|
-
id: RequestIdSchema.optional(),
|
|
24427
|
-
error: object$1({
|
|
24428
|
-
/**
|
|
24429
|
-
* The error type that occurred.
|
|
24430
|
-
*/
|
|
24431
|
-
code: number().int(),
|
|
24432
|
-
/**
|
|
24433
|
-
* A short description of the error. The message SHOULD be limited to a concise single sentence.
|
|
24434
|
-
*/
|
|
24435
|
-
message: string(),
|
|
24436
|
-
/**
|
|
24437
|
-
* Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
|
|
24438
|
-
*/
|
|
24439
|
-
data: unknown().optional()
|
|
24440
|
-
})
|
|
24441
|
-
}).strict();
|
|
24442
|
-
const JSONRPCMessageSchema = union([
|
|
24443
|
-
JSONRPCRequestSchema,
|
|
24444
|
-
JSONRPCNotificationSchema,
|
|
24445
|
-
JSONRPCResultResponseSchema,
|
|
24446
|
-
JSONRPCErrorResponseSchema
|
|
24447
|
-
]);
|
|
24448
|
-
union([JSONRPCResultResponseSchema, JSONRPCErrorResponseSchema]);
|
|
24449
|
-
/**
|
|
24450
|
-
* A response that indicates success but carries no data.
|
|
24451
|
-
*/
|
|
24452
|
-
const EmptyResultSchema = ResultSchema.strict();
|
|
24453
|
-
const CancelledNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
24454
|
-
/**
|
|
24455
|
-
* The ID of the request to cancel.
|
|
24456
|
-
*
|
|
24457
|
-
* This MUST correspond to the ID of a request previously issued in the same direction.
|
|
24458
|
-
*/
|
|
24459
|
-
requestId: RequestIdSchema.optional(),
|
|
24460
|
-
/**
|
|
24461
|
-
* An optional string describing the reason for the cancellation. This MAY be logged or presented to the user.
|
|
24462
|
-
*/
|
|
24463
|
-
reason: string().optional()
|
|
24464
|
-
});
|
|
24465
|
-
/**
|
|
24466
|
-
* This notification can be sent by either side to indicate that it is cancelling a previously-issued request.
|
|
24467
|
-
*
|
|
24468
|
-
* The request SHOULD still be in-flight, but due to communication latency, it is always possible that this notification MAY arrive after the request has already finished.
|
|
24469
|
-
*
|
|
24470
|
-
* This notification indicates that the result will be unused, so any associated processing SHOULD cease.
|
|
24471
|
-
*
|
|
24472
|
-
* A client MUST NOT attempt to cancel its `initialize` request.
|
|
24473
|
-
*/
|
|
24474
|
-
const CancelledNotificationSchema = NotificationSchema.extend({
|
|
24475
|
-
method: literal("notifications/cancelled"),
|
|
24476
|
-
params: CancelledNotificationParamsSchema
|
|
24477
|
-
});
|
|
24478
|
-
/**
|
|
24479
|
-
* Base schema to add `icons` property.
|
|
24480
|
-
*
|
|
24481
|
-
*/
|
|
24482
|
-
const IconsSchema = object$1({
|
|
24483
|
-
/**
|
|
24484
|
-
* Optional set of sized icons that the client can display in a user interface.
|
|
24485
|
-
*
|
|
24486
|
-
* Clients that support rendering icons MUST support at least the following MIME types:
|
|
24487
|
-
* - `image/png` - PNG images (safe, universal compatibility)
|
|
24488
|
-
* - `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)
|
|
24489
|
-
*
|
|
24490
|
-
* Clients that support rendering icons SHOULD also support:
|
|
24491
|
-
* - `image/svg+xml` - SVG images (scalable but requires security precautions)
|
|
24492
|
-
* - `image/webp` - WebP images (modern, efficient format)
|
|
24493
|
-
*/
|
|
24494
|
-
icons: array(object$1({
|
|
24495
|
-
/**
|
|
24496
|
-
* URL or data URI for the icon.
|
|
24497
|
-
*/
|
|
24498
|
-
src: string(),
|
|
24499
|
-
/**
|
|
24500
|
-
* Optional MIME type for the icon.
|
|
24501
|
-
*/
|
|
24502
|
-
mimeType: string().optional(),
|
|
24503
|
-
/**
|
|
24504
|
-
* Optional array of strings that specify sizes at which the icon can be used.
|
|
24505
|
-
* Each string should be in WxH format (e.g., `"48x48"`, `"96x96"`) or `"any"` for scalable formats like SVG.
|
|
24506
|
-
*
|
|
24507
|
-
* If not provided, the client should assume that the icon can be used at any size.
|
|
24508
|
-
*/
|
|
24509
|
-
sizes: array(string()).optional(),
|
|
24510
|
-
/**
|
|
24511
|
-
* Optional specifier for the theme this icon is designed for. `light` indicates
|
|
24512
|
-
* the icon is designed to be used with a light background, and `dark` indicates
|
|
24513
|
-
* the icon is designed to be used with a dark background.
|
|
24514
|
-
*
|
|
24515
|
-
* If not provided, the client should assume the icon can be used with any theme.
|
|
24516
|
-
*/
|
|
24517
|
-
theme: _enum(["light", "dark"]).optional()
|
|
24518
|
-
})).optional() });
|
|
24519
|
-
/**
|
|
24520
|
-
* Base metadata interface for common properties across resources, tools, prompts, and implementations.
|
|
24521
|
-
*/
|
|
24522
|
-
const BaseMetadataSchema = object$1({
|
|
24523
|
-
/** Intended for programmatic or logical use, but used as a display name in past specs or fallback */
|
|
24524
|
-
name: string(),
|
|
24525
|
-
/**
|
|
24526
|
-
* Intended for UI and end-user contexts — optimized to be human-readable and easily understood,
|
|
24527
|
-
* even by those unfamiliar with domain-specific terminology.
|
|
24528
|
-
*
|
|
24529
|
-
* If not provided, the name should be used for display (except for Tool,
|
|
24530
|
-
* where `annotations.title` should be given precedence over using `name`,
|
|
24531
|
-
* if present).
|
|
24532
|
-
*/
|
|
24533
|
-
title: string().optional()
|
|
24534
|
-
});
|
|
24535
|
-
/**
|
|
24536
|
-
* Describes the name and version of an MCP implementation.
|
|
24537
|
-
*/
|
|
24538
|
-
const ImplementationSchema = BaseMetadataSchema.extend({
|
|
24539
|
-
...BaseMetadataSchema.shape,
|
|
24540
|
-
...IconsSchema.shape,
|
|
24541
|
-
version: string(),
|
|
24542
|
-
/**
|
|
24543
|
-
* An optional URL of the website for this implementation.
|
|
24544
|
-
*/
|
|
24545
|
-
websiteUrl: string().optional(),
|
|
24546
|
-
/**
|
|
24547
|
-
* An optional human-readable description of what this implementation does.
|
|
24548
|
-
*
|
|
24549
|
-
* This can be used by clients or servers to provide context about their purpose
|
|
24550
|
-
* and capabilities. For example, a server might describe the types of resources
|
|
24551
|
-
* or tools it provides, while a client might describe its intended use case.
|
|
24552
|
-
*/
|
|
24553
|
-
description: string().optional()
|
|
24554
|
-
});
|
|
24555
|
-
const ElicitationCapabilitySchema = preprocess((value) => {
|
|
24556
|
-
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
24557
|
-
if (Object.keys(value).length === 0) return { form: {} };
|
|
24558
|
-
}
|
|
24559
|
-
return value;
|
|
24560
|
-
}, intersection(object$1({
|
|
24561
|
-
form: intersection(object$1({ applyDefaults: boolean().optional() }), record(string(), unknown())).optional(),
|
|
24562
|
-
url: AssertObjectSchema.optional()
|
|
24563
|
-
}), record(string(), unknown()).optional()));
|
|
24564
|
-
/**
|
|
24565
|
-
* Task capabilities for clients, indicating which request types support task creation.
|
|
24566
|
-
*/
|
|
24567
|
-
const ClientTasksCapabilitySchema = looseObject({
|
|
24568
|
-
/**
|
|
24569
|
-
* Present if the client supports listing tasks.
|
|
24570
|
-
*/
|
|
24571
|
-
list: AssertObjectSchema.optional(),
|
|
24572
|
-
/**
|
|
24573
|
-
* Present if the client supports cancelling tasks.
|
|
24574
|
-
*/
|
|
24575
|
-
cancel: AssertObjectSchema.optional(),
|
|
24576
|
-
/**
|
|
24577
|
-
* Capabilities for task creation on specific request types.
|
|
24578
|
-
*/
|
|
24579
|
-
requests: looseObject({
|
|
24580
|
-
/**
|
|
24581
|
-
* Task support for sampling requests.
|
|
24582
|
-
*/
|
|
24583
|
-
sampling: looseObject({ createMessage: AssertObjectSchema.optional() }).optional(),
|
|
24584
|
-
/**
|
|
24585
|
-
* Task support for elicitation requests.
|
|
24586
|
-
*/
|
|
24587
|
-
elicitation: looseObject({ create: AssertObjectSchema.optional() }).optional()
|
|
24588
|
-
}).optional()
|
|
24589
|
-
});
|
|
24590
|
-
/**
|
|
24591
|
-
* Task capabilities for servers, indicating which request types support task creation.
|
|
24592
|
-
*/
|
|
24593
|
-
const ServerTasksCapabilitySchema = looseObject({
|
|
24594
|
-
/**
|
|
24595
|
-
* Present if the server supports listing tasks.
|
|
24596
|
-
*/
|
|
24597
|
-
list: AssertObjectSchema.optional(),
|
|
24598
|
-
/**
|
|
24599
|
-
* Present if the server supports cancelling tasks.
|
|
24600
|
-
*/
|
|
24601
|
-
cancel: AssertObjectSchema.optional(),
|
|
24602
|
-
/**
|
|
24603
|
-
* Capabilities for task creation on specific request types.
|
|
24604
|
-
*/
|
|
24605
|
-
requests: looseObject({
|
|
24606
|
-
/**
|
|
24607
|
-
* Task support for tool requests.
|
|
24608
|
-
*/
|
|
24609
|
-
tools: looseObject({ call: AssertObjectSchema.optional() }).optional() }).optional()
|
|
24610
|
-
});
|
|
24611
|
-
/**
|
|
24612
|
-
* Capabilities a client may support. Known capabilities are defined here, in this schema, but this is not a closed set: any client can define its own, additional capabilities.
|
|
24613
|
-
*/
|
|
24614
|
-
const ClientCapabilitiesSchema = object$1({
|
|
24615
|
-
/**
|
|
24616
|
-
* Experimental, non-standard capabilities that the client supports.
|
|
24617
|
-
*/
|
|
24618
|
-
experimental: record(string(), AssertObjectSchema).optional(),
|
|
24619
|
-
/**
|
|
24620
|
-
* Present if the client supports sampling from an LLM.
|
|
24621
|
-
*/
|
|
24622
|
-
sampling: object$1({
|
|
24623
|
-
/**
|
|
24624
|
-
* Present if the client supports context inclusion via includeContext parameter.
|
|
24625
|
-
* If not declared, servers SHOULD only use `includeContext: "none"` (or omit it).
|
|
24626
|
-
*/
|
|
24627
|
-
context: AssertObjectSchema.optional(),
|
|
24628
|
-
/**
|
|
24629
|
-
* Present if the client supports tool use via tools and toolChoice parameters.
|
|
24630
|
-
*/
|
|
24631
|
-
tools: AssertObjectSchema.optional()
|
|
24632
|
-
}).optional(),
|
|
24633
|
-
/**
|
|
24634
|
-
* Present if the client supports eliciting user input.
|
|
24635
|
-
*/
|
|
24636
|
-
elicitation: ElicitationCapabilitySchema.optional(),
|
|
24637
|
-
/**
|
|
24638
|
-
* Present if the client supports listing roots.
|
|
24639
|
-
*/
|
|
24640
|
-
roots: object$1({
|
|
24641
|
-
/**
|
|
24642
|
-
* Whether the client supports issuing notifications for changes to the roots list.
|
|
24643
|
-
*/
|
|
24644
|
-
listChanged: boolean().optional() }).optional(),
|
|
24645
|
-
/**
|
|
24646
|
-
* Present if the client supports task creation.
|
|
24647
|
-
*/
|
|
24648
|
-
tasks: ClientTasksCapabilitySchema.optional(),
|
|
24649
|
-
/**
|
|
24650
|
-
* Extensions that the client supports. Keys are extension identifiers (vendor-prefix/extension-name).
|
|
24651
|
-
*/
|
|
24652
|
-
extensions: record(string(), AssertObjectSchema).optional()
|
|
24653
|
-
});
|
|
24654
|
-
const InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
24655
|
-
/**
|
|
24656
|
-
* The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well.
|
|
24657
|
-
*/
|
|
24658
|
-
protocolVersion: string(),
|
|
24659
|
-
capabilities: ClientCapabilitiesSchema,
|
|
24660
|
-
clientInfo: ImplementationSchema
|
|
24661
|
-
});
|
|
24662
|
-
/**
|
|
24663
|
-
* This request is sent from the client to the server when it first connects, asking it to begin initialization.
|
|
24664
|
-
*/
|
|
24665
|
-
const InitializeRequestSchema = RequestSchema.extend({
|
|
24666
|
-
method: literal("initialize"),
|
|
24667
|
-
params: InitializeRequestParamsSchema
|
|
24668
|
-
});
|
|
24669
|
-
/**
|
|
24670
|
-
* Capabilities that a server may support. Known capabilities are defined here, in this schema, but this is not a closed set: any server can define its own, additional capabilities.
|
|
24671
|
-
*/
|
|
24672
|
-
const ServerCapabilitiesSchema = object$1({
|
|
24673
|
-
/**
|
|
24674
|
-
* Experimental, non-standard capabilities that the server supports.
|
|
24675
|
-
*/
|
|
24676
|
-
experimental: record(string(), AssertObjectSchema).optional(),
|
|
24677
|
-
/**
|
|
24678
|
-
* Present if the server supports sending log messages to the client.
|
|
24679
|
-
*/
|
|
24680
|
-
logging: AssertObjectSchema.optional(),
|
|
24681
|
-
/**
|
|
24682
|
-
* Present if the server supports sending completions to the client.
|
|
24683
|
-
*/
|
|
24684
|
-
completions: AssertObjectSchema.optional(),
|
|
24685
|
-
/**
|
|
24686
|
-
* Present if the server offers any prompt templates.
|
|
24687
|
-
*/
|
|
24688
|
-
prompts: object$1({
|
|
24689
|
-
/**
|
|
24690
|
-
* Whether this server supports issuing notifications for changes to the prompt list.
|
|
24691
|
-
*/
|
|
24692
|
-
listChanged: boolean().optional() }).optional(),
|
|
24693
|
-
/**
|
|
24694
|
-
* Present if the server offers any resources to read.
|
|
24695
|
-
*/
|
|
24696
|
-
resources: object$1({
|
|
24697
|
-
/**
|
|
24698
|
-
* Whether this server supports clients subscribing to resource updates.
|
|
24699
|
-
*/
|
|
24700
|
-
subscribe: boolean().optional(),
|
|
24701
|
-
/**
|
|
24702
|
-
* Whether this server supports issuing notifications for changes to the resource list.
|
|
24703
|
-
*/
|
|
24704
|
-
listChanged: boolean().optional()
|
|
24705
|
-
}).optional(),
|
|
24706
|
-
/**
|
|
24707
|
-
* Present if the server offers any tools to call.
|
|
24708
|
-
*/
|
|
24709
|
-
tools: object$1({
|
|
24710
|
-
/**
|
|
24711
|
-
* Whether this server supports issuing notifications for changes to the tool list.
|
|
24712
|
-
*/
|
|
24713
|
-
listChanged: boolean().optional() }).optional(),
|
|
24714
|
-
/**
|
|
24715
|
-
* Present if the server supports task creation.
|
|
24716
|
-
*/
|
|
24717
|
-
tasks: ServerTasksCapabilitySchema.optional(),
|
|
24718
|
-
/**
|
|
24719
|
-
* Extensions that the server supports. Keys are extension identifiers (vendor-prefix/extension-name).
|
|
24720
|
-
*/
|
|
24721
|
-
extensions: record(string(), AssertObjectSchema).optional()
|
|
24722
|
-
});
|
|
24723
|
-
/**
|
|
24724
|
-
* After receiving an initialize request from the client, the server sends this response.
|
|
24725
|
-
*/
|
|
24726
|
-
const InitializeResultSchema = ResultSchema.extend({
|
|
24727
|
-
/**
|
|
24728
|
-
* The version of the Model Context Protocol that the server wants to use. This may not match the version that the client requested. If the client cannot support this version, it MUST disconnect.
|
|
24729
|
-
*/
|
|
24730
|
-
protocolVersion: string(),
|
|
24731
|
-
capabilities: ServerCapabilitiesSchema,
|
|
24732
|
-
serverInfo: ImplementationSchema,
|
|
24733
|
-
/**
|
|
24734
|
-
* Instructions describing how to use the server and its features.
|
|
24735
|
-
*
|
|
24736
|
-
* This can be used by clients to improve the LLM's understanding of available tools, resources, etc. It can be thought of like a "hint" to the model. For example, this information MAY be added to the system prompt.
|
|
24737
|
-
*/
|
|
24738
|
-
instructions: string().optional()
|
|
24739
|
-
});
|
|
24740
|
-
/**
|
|
24741
|
-
* This notification is sent from the client to the server after initialization has finished.
|
|
24742
|
-
*/
|
|
24743
|
-
const InitializedNotificationSchema = NotificationSchema.extend({
|
|
24744
|
-
method: literal("notifications/initialized"),
|
|
24745
|
-
params: NotificationsParamsSchema.optional()
|
|
24746
|
-
});
|
|
24747
|
-
/**
|
|
24748
|
-
* A ping, issued by either the server or the client, to check that the other party is still alive. The receiver must promptly respond, or else may be disconnected.
|
|
24749
|
-
*/
|
|
24750
|
-
const PingRequestSchema = RequestSchema.extend({
|
|
24751
|
-
method: literal("ping"),
|
|
24752
|
-
params: BaseRequestParamsSchema.optional()
|
|
24753
|
-
});
|
|
24754
|
-
const ProgressSchema = object$1({
|
|
24755
|
-
/**
|
|
24756
|
-
* The progress thus far. This should increase every time progress is made, even if the total is unknown.
|
|
24757
|
-
*/
|
|
24758
|
-
progress: number(),
|
|
24759
|
-
/**
|
|
24760
|
-
* Total number of items to process (or total progress required), if known.
|
|
24761
|
-
*/
|
|
24762
|
-
total: optional(number()),
|
|
24763
|
-
/**
|
|
24764
|
-
* An optional message describing the current progress.
|
|
24765
|
-
*/
|
|
24766
|
-
message: optional(string())
|
|
24767
|
-
});
|
|
24768
|
-
const ProgressNotificationParamsSchema = object$1({
|
|
24769
|
-
...NotificationsParamsSchema.shape,
|
|
24770
|
-
...ProgressSchema.shape,
|
|
24771
|
-
/**
|
|
24772
|
-
* The progress token which was given in the initial request, used to associate this notification with the request that is proceeding.
|
|
24773
|
-
*/
|
|
24774
|
-
progressToken: ProgressTokenSchema
|
|
24775
|
-
});
|
|
24776
|
-
/**
|
|
24777
|
-
* An out-of-band notification used to inform the receiver of a progress update for a long-running request.
|
|
24778
|
-
*
|
|
24779
|
-
* @category notifications/progress
|
|
24780
|
-
*/
|
|
24781
|
-
const ProgressNotificationSchema = NotificationSchema.extend({
|
|
24782
|
-
method: literal("notifications/progress"),
|
|
24783
|
-
params: ProgressNotificationParamsSchema
|
|
24784
|
-
});
|
|
24785
|
-
const PaginatedRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
24786
|
-
/**
|
|
24787
|
-
* An opaque token representing the current pagination position.
|
|
24788
|
-
* If provided, the server should return results starting after this cursor.
|
|
24789
|
-
*/
|
|
24790
|
-
cursor: CursorSchema.optional() });
|
|
24791
|
-
const PaginatedRequestSchema = RequestSchema.extend({ params: PaginatedRequestParamsSchema.optional() });
|
|
24792
|
-
const PaginatedResultSchema = ResultSchema.extend({
|
|
24793
|
-
/**
|
|
24794
|
-
* An opaque token representing the pagination position after the last returned result.
|
|
24795
|
-
* If present, there may be more results available.
|
|
24796
|
-
*/
|
|
24797
|
-
nextCursor: CursorSchema.optional() });
|
|
24798
|
-
/**
|
|
24799
|
-
* The status of a task.
|
|
24800
|
-
* */
|
|
24801
|
-
const TaskStatusSchema = _enum([
|
|
24802
|
-
"working",
|
|
24803
|
-
"input_required",
|
|
24804
|
-
"completed",
|
|
24805
|
-
"failed",
|
|
24806
|
-
"cancelled"
|
|
24807
|
-
]);
|
|
24808
|
-
/**
|
|
24809
|
-
* A pollable state object associated with a request.
|
|
24810
|
-
*/
|
|
24811
|
-
const TaskSchema = object$1({
|
|
24812
|
-
taskId: string(),
|
|
24813
|
-
status: TaskStatusSchema,
|
|
24814
|
-
/**
|
|
24815
|
-
* Time in milliseconds to keep task results available after completion.
|
|
24816
|
-
* If null, the task has unlimited lifetime until manually cleaned up.
|
|
24817
|
-
*/
|
|
24818
|
-
ttl: union([number(), _null()]),
|
|
24819
|
-
/**
|
|
24820
|
-
* ISO 8601 timestamp when the task was created.
|
|
24821
|
-
*/
|
|
24822
|
-
createdAt: string(),
|
|
24823
|
-
/**
|
|
24824
|
-
* ISO 8601 timestamp when the task was last updated.
|
|
24825
|
-
*/
|
|
24826
|
-
lastUpdatedAt: string(),
|
|
24827
|
-
pollInterval: optional(number()),
|
|
24828
|
-
/**
|
|
24829
|
-
* Optional diagnostic message for failed tasks or other status information.
|
|
24830
|
-
*/
|
|
24831
|
-
statusMessage: optional(string())
|
|
24832
|
-
});
|
|
24833
|
-
/**
|
|
24834
|
-
* Result returned when a task is created, containing the task data wrapped in a task field.
|
|
24835
|
-
*/
|
|
24836
|
-
const CreateTaskResultSchema = ResultSchema.extend({ task: TaskSchema });
|
|
24837
|
-
/**
|
|
24838
|
-
* Parameters for task status notification.
|
|
24839
|
-
*/
|
|
24840
|
-
const TaskStatusNotificationParamsSchema = NotificationsParamsSchema.merge(TaskSchema);
|
|
24841
|
-
/**
|
|
24842
|
-
* A notification sent when a task's status changes.
|
|
24843
|
-
*/
|
|
24844
|
-
const TaskStatusNotificationSchema = NotificationSchema.extend({
|
|
24845
|
-
method: literal("notifications/tasks/status"),
|
|
24846
|
-
params: TaskStatusNotificationParamsSchema
|
|
24847
|
-
});
|
|
24848
|
-
/**
|
|
24849
|
-
* A request to get the state of a specific task.
|
|
24850
|
-
*/
|
|
24851
|
-
const GetTaskRequestSchema = RequestSchema.extend({
|
|
24852
|
-
method: literal("tasks/get"),
|
|
24853
|
-
params: BaseRequestParamsSchema.extend({ taskId: string() })
|
|
24854
|
-
});
|
|
24855
|
-
/**
|
|
24856
|
-
* The response to a tasks/get request.
|
|
24857
|
-
*/
|
|
24858
|
-
const GetTaskResultSchema = ResultSchema.merge(TaskSchema);
|
|
24859
|
-
/**
|
|
24860
|
-
* A request to get the result of a specific task.
|
|
24861
|
-
*/
|
|
24862
|
-
const GetTaskPayloadRequestSchema = RequestSchema.extend({
|
|
24863
|
-
method: literal("tasks/result"),
|
|
24864
|
-
params: BaseRequestParamsSchema.extend({ taskId: string() })
|
|
24865
|
-
});
|
|
24866
|
-
ResultSchema.loose();
|
|
24867
|
-
/**
|
|
24868
|
-
* A request to list tasks.
|
|
24869
|
-
*/
|
|
24870
|
-
const ListTasksRequestSchema = PaginatedRequestSchema.extend({ method: literal("tasks/list") });
|
|
24871
|
-
/**
|
|
24872
|
-
* The response to a tasks/list request.
|
|
24873
|
-
*/
|
|
24874
|
-
const ListTasksResultSchema = PaginatedResultSchema.extend({ tasks: array(TaskSchema) });
|
|
24875
|
-
/**
|
|
24876
|
-
* A request to cancel a specific task.
|
|
24877
|
-
*/
|
|
24878
|
-
const CancelTaskRequestSchema = RequestSchema.extend({
|
|
24879
|
-
method: literal("tasks/cancel"),
|
|
24880
|
-
params: BaseRequestParamsSchema.extend({ taskId: string() })
|
|
24881
|
-
});
|
|
24882
|
-
ResultSchema.merge(TaskSchema);
|
|
24883
|
-
/**
|
|
24884
|
-
* The contents of a specific resource or sub-resource.
|
|
24885
|
-
*/
|
|
24886
|
-
const ResourceContentsSchema = object$1({
|
|
24887
|
-
/**
|
|
24888
|
-
* The URI of this resource.
|
|
24889
|
-
*/
|
|
24890
|
-
uri: string(),
|
|
24891
|
-
/**
|
|
24892
|
-
* The MIME type of this resource, if known.
|
|
24893
|
-
*/
|
|
24894
|
-
mimeType: optional(string()),
|
|
24895
|
-
/**
|
|
24896
|
-
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
24897
|
-
* for notes on _meta usage.
|
|
24898
|
-
*/
|
|
24899
|
-
_meta: record(string(), unknown()).optional()
|
|
24900
|
-
});
|
|
24901
|
-
const TextResourceContentsSchema = ResourceContentsSchema.extend({
|
|
24902
|
-
/**
|
|
24903
|
-
* The text of the item. This must only be set if the item can actually be represented as text (not binary data).
|
|
24904
|
-
*/
|
|
24905
|
-
text: string() });
|
|
24906
|
-
/**
|
|
24907
|
-
* A Zod schema for validating Base64 strings that is more performant and
|
|
24908
|
-
* robust for very large inputs than the default regex-based check. It avoids
|
|
24909
|
-
* stack overflows by using the native `atob` function for validation.
|
|
24910
|
-
*/
|
|
24911
|
-
const Base64Schema = string().refine((val) => {
|
|
24912
|
-
try {
|
|
24913
|
-
atob(val);
|
|
24914
|
-
return true;
|
|
24915
|
-
} catch {
|
|
24916
|
-
return false;
|
|
24917
|
-
}
|
|
24918
|
-
}, { message: "Invalid Base64 string" });
|
|
24919
|
-
const BlobResourceContentsSchema = ResourceContentsSchema.extend({
|
|
24920
|
-
/**
|
|
24921
|
-
* A base64-encoded string representing the binary data of the item.
|
|
24922
|
-
*/
|
|
24923
|
-
blob: Base64Schema });
|
|
24924
|
-
/**
|
|
24925
|
-
* The sender or recipient of messages and data in a conversation.
|
|
24926
|
-
*/
|
|
24927
|
-
const RoleSchema = _enum(["user", "assistant"]);
|
|
24928
|
-
/**
|
|
24929
|
-
* Optional annotations providing clients additional context about a resource.
|
|
24930
|
-
*/
|
|
24931
|
-
const AnnotationsSchema = object$1({
|
|
24932
|
-
/**
|
|
24933
|
-
* Intended audience(s) for the resource.
|
|
24934
|
-
*/
|
|
24935
|
-
audience: array(RoleSchema).optional(),
|
|
24936
|
-
/**
|
|
24937
|
-
* Importance hint for the resource, from 0 (least) to 1 (most).
|
|
24938
|
-
*/
|
|
24939
|
-
priority: number().min(0).max(1).optional(),
|
|
24940
|
-
/**
|
|
24941
|
-
* ISO 8601 timestamp for the most recent modification.
|
|
24942
|
-
*/
|
|
24943
|
-
lastModified: datetime({ offset: true }).optional()
|
|
24944
|
-
});
|
|
24945
|
-
/**
|
|
24946
|
-
* A known resource that the server is capable of reading.
|
|
24947
|
-
*/
|
|
24948
|
-
const ResourceSchema = object$1({
|
|
24949
|
-
...BaseMetadataSchema.shape,
|
|
24950
|
-
...IconsSchema.shape,
|
|
24951
|
-
/**
|
|
24952
|
-
* The URI of this resource.
|
|
24953
|
-
*/
|
|
24954
|
-
uri: string(),
|
|
24955
|
-
/**
|
|
24956
|
-
* A description of what this resource represents.
|
|
24957
|
-
*
|
|
24958
|
-
* This can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a "hint" to the model.
|
|
24959
|
-
*/
|
|
24960
|
-
description: optional(string()),
|
|
24961
|
-
/**
|
|
24962
|
-
* The MIME type of this resource, if known.
|
|
24963
|
-
*/
|
|
24964
|
-
mimeType: optional(string()),
|
|
24965
|
-
/**
|
|
24966
|
-
* The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.
|
|
24967
|
-
*
|
|
24968
|
-
* This can be used by Hosts to display file sizes and estimate context window usage.
|
|
24969
|
-
*/
|
|
24970
|
-
size: optional(number()),
|
|
24971
|
-
/**
|
|
24972
|
-
* Optional annotations for the client.
|
|
24973
|
-
*/
|
|
24974
|
-
annotations: AnnotationsSchema.optional(),
|
|
24975
|
-
/**
|
|
24976
|
-
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
24977
|
-
* for notes on _meta usage.
|
|
24978
|
-
*/
|
|
24979
|
-
_meta: optional(looseObject({}))
|
|
24980
|
-
});
|
|
24981
|
-
/**
|
|
24982
|
-
* A template description for resources available on the server.
|
|
24983
|
-
*/
|
|
24984
|
-
const ResourceTemplateSchema = object$1({
|
|
24985
|
-
...BaseMetadataSchema.shape,
|
|
24986
|
-
...IconsSchema.shape,
|
|
24987
|
-
/**
|
|
24988
|
-
* A URI template (according to RFC 6570) that can be used to construct resource URIs.
|
|
24989
|
-
*/
|
|
24990
|
-
uriTemplate: string(),
|
|
24991
|
-
/**
|
|
24992
|
-
* A description of what this template is for.
|
|
24993
|
-
*
|
|
24994
|
-
* This can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a "hint" to the model.
|
|
24995
|
-
*/
|
|
24996
|
-
description: optional(string()),
|
|
24997
|
-
/**
|
|
24998
|
-
* The MIME type for all resources that match this template. This should only be included if all resources matching this template have the same type.
|
|
24999
|
-
*/
|
|
25000
|
-
mimeType: optional(string()),
|
|
25001
|
-
/**
|
|
25002
|
-
* Optional annotations for the client.
|
|
25003
|
-
*/
|
|
25004
|
-
annotations: AnnotationsSchema.optional(),
|
|
25005
|
-
/**
|
|
25006
|
-
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
25007
|
-
* for notes on _meta usage.
|
|
25008
|
-
*/
|
|
25009
|
-
_meta: optional(looseObject({}))
|
|
25010
|
-
});
|
|
25011
|
-
/**
|
|
25012
|
-
* Sent from the client to request a list of resources the server has.
|
|
25013
|
-
*/
|
|
25014
|
-
const ListResourcesRequestSchema = PaginatedRequestSchema.extend({ method: literal("resources/list") });
|
|
25015
|
-
/**
|
|
25016
|
-
* The server's response to a resources/list request from the client.
|
|
25017
|
-
*/
|
|
25018
|
-
const ListResourcesResultSchema = PaginatedResultSchema.extend({ resources: array(ResourceSchema) });
|
|
25019
|
-
/**
|
|
25020
|
-
* Sent from the client to request a list of resource templates the server has.
|
|
25021
|
-
*/
|
|
25022
|
-
const ListResourceTemplatesRequestSchema = PaginatedRequestSchema.extend({ method: literal("resources/templates/list") });
|
|
25023
|
-
/**
|
|
25024
|
-
* The server's response to a resources/templates/list request from the client.
|
|
25025
|
-
*/
|
|
25026
|
-
const ListResourceTemplatesResultSchema = PaginatedResultSchema.extend({ resourceTemplates: array(ResourceTemplateSchema) });
|
|
25027
|
-
const ResourceRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
25028
|
-
/**
|
|
25029
|
-
* The URI of the resource to read. The URI can use any protocol; it is up to the server how to interpret it.
|
|
25030
|
-
*
|
|
25031
|
-
* @format uri
|
|
25032
|
-
*/
|
|
25033
|
-
uri: string() });
|
|
25034
|
-
/**
|
|
25035
|
-
* Parameters for a `resources/read` request.
|
|
25036
|
-
*/
|
|
25037
|
-
const ReadResourceRequestParamsSchema = ResourceRequestParamsSchema;
|
|
25038
|
-
/**
|
|
25039
|
-
* Sent from the client to the server, to read a specific resource URI.
|
|
25040
|
-
*/
|
|
25041
|
-
const ReadResourceRequestSchema = RequestSchema.extend({
|
|
25042
|
-
method: literal("resources/read"),
|
|
25043
|
-
params: ReadResourceRequestParamsSchema
|
|
25044
|
-
});
|
|
25045
|
-
/**
|
|
25046
|
-
* The server's response to a resources/read request from the client.
|
|
25047
|
-
*/
|
|
25048
|
-
const ReadResourceResultSchema = ResultSchema.extend({ contents: array(union([TextResourceContentsSchema, BlobResourceContentsSchema])) });
|
|
25049
|
-
/**
|
|
25050
|
-
* An optional notification from the server to the client, informing it that the list of resources it can read from has changed. This may be issued by servers without any previous subscription from the client.
|
|
25051
|
-
*/
|
|
25052
|
-
const ResourceListChangedNotificationSchema = NotificationSchema.extend({
|
|
25053
|
-
method: literal("notifications/resources/list_changed"),
|
|
25054
|
-
params: NotificationsParamsSchema.optional()
|
|
25055
|
-
});
|
|
25056
|
-
const SubscribeRequestParamsSchema = ResourceRequestParamsSchema;
|
|
25057
|
-
/**
|
|
25058
|
-
* Sent from the client to request resources/updated notifications from the server whenever a particular resource changes.
|
|
25059
|
-
*/
|
|
25060
|
-
const SubscribeRequestSchema = RequestSchema.extend({
|
|
25061
|
-
method: literal("resources/subscribe"),
|
|
25062
|
-
params: SubscribeRequestParamsSchema
|
|
25063
|
-
});
|
|
25064
|
-
const UnsubscribeRequestParamsSchema = ResourceRequestParamsSchema;
|
|
25065
|
-
/**
|
|
25066
|
-
* Sent from the client to request cancellation of resources/updated notifications from the server. This should follow a previous resources/subscribe request.
|
|
25067
|
-
*/
|
|
25068
|
-
const UnsubscribeRequestSchema = RequestSchema.extend({
|
|
25069
|
-
method: literal("resources/unsubscribe"),
|
|
25070
|
-
params: UnsubscribeRequestParamsSchema
|
|
25071
|
-
});
|
|
25072
|
-
/**
|
|
25073
|
-
* Parameters for a `notifications/resources/updated` notification.
|
|
25074
|
-
*/
|
|
25075
|
-
const ResourceUpdatedNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
25076
|
-
/**
|
|
25077
|
-
* The URI of the resource that has been updated. This might be a sub-resource of the one that the client actually subscribed to.
|
|
25078
|
-
*/
|
|
25079
|
-
uri: string() });
|
|
25080
|
-
/**
|
|
25081
|
-
* A notification from the server to the client, informing it that a resource has changed and may need to be read again. This should only be sent if the client previously sent a resources/subscribe request.
|
|
25082
|
-
*/
|
|
25083
|
-
const ResourceUpdatedNotificationSchema = NotificationSchema.extend({
|
|
25084
|
-
method: literal("notifications/resources/updated"),
|
|
25085
|
-
params: ResourceUpdatedNotificationParamsSchema
|
|
25086
|
-
});
|
|
25087
|
-
/**
|
|
25088
|
-
* Describes an argument that a prompt can accept.
|
|
25089
|
-
*/
|
|
25090
|
-
const PromptArgumentSchema = object$1({
|
|
25091
|
-
/**
|
|
25092
|
-
* The name of the argument.
|
|
25093
|
-
*/
|
|
25094
|
-
name: string(),
|
|
25095
|
-
/**
|
|
25096
|
-
* A human-readable description of the argument.
|
|
25097
|
-
*/
|
|
25098
|
-
description: optional(string()),
|
|
25099
|
-
/**
|
|
25100
|
-
* Whether this argument must be provided.
|
|
25101
|
-
*/
|
|
25102
|
-
required: optional(boolean())
|
|
25103
|
-
});
|
|
25104
|
-
/**
|
|
25105
|
-
* A prompt or prompt template that the server offers.
|
|
25106
|
-
*/
|
|
25107
|
-
const PromptSchema$1 = object$1({
|
|
25108
|
-
...BaseMetadataSchema.shape,
|
|
25109
|
-
...IconsSchema.shape,
|
|
25110
|
-
/**
|
|
25111
|
-
* An optional description of what this prompt provides
|
|
25112
|
-
*/
|
|
25113
|
-
description: optional(string()),
|
|
25114
|
-
/**
|
|
25115
|
-
* A list of arguments to use for templating the prompt.
|
|
25116
|
-
*/
|
|
25117
|
-
arguments: optional(array(PromptArgumentSchema)),
|
|
25118
|
-
/**
|
|
25119
|
-
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
25120
|
-
* for notes on _meta usage.
|
|
25121
|
-
*/
|
|
25122
|
-
_meta: optional(looseObject({}))
|
|
25123
|
-
});
|
|
25124
|
-
/**
|
|
25125
|
-
* Sent from the client to request a list of prompts and prompt templates the server has.
|
|
25126
|
-
*/
|
|
25127
|
-
const ListPromptsRequestSchema = PaginatedRequestSchema.extend({ method: literal("prompts/list") });
|
|
25128
|
-
/**
|
|
25129
|
-
* The server's response to a prompts/list request from the client.
|
|
25130
|
-
*/
|
|
25131
|
-
const ListPromptsResultSchema = PaginatedResultSchema.extend({ prompts: array(PromptSchema$1) });
|
|
25132
|
-
/**
|
|
25133
|
-
* Parameters for a `prompts/get` request.
|
|
25134
|
-
*/
|
|
25135
|
-
const GetPromptRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
25136
|
-
/**
|
|
25137
|
-
* The name of the prompt or prompt template.
|
|
25138
|
-
*/
|
|
25139
|
-
name: string(),
|
|
25140
|
-
/**
|
|
25141
|
-
* Arguments to use for templating the prompt.
|
|
25142
|
-
*/
|
|
25143
|
-
arguments: record(string(), string()).optional()
|
|
25144
|
-
});
|
|
25145
|
-
/**
|
|
25146
|
-
* Used by the client to get a prompt provided by the server.
|
|
25147
|
-
*/
|
|
25148
|
-
const GetPromptRequestSchema = RequestSchema.extend({
|
|
25149
|
-
method: literal("prompts/get"),
|
|
25150
|
-
params: GetPromptRequestParamsSchema
|
|
25151
|
-
});
|
|
25152
|
-
/**
|
|
25153
|
-
* Text provided to or from an LLM.
|
|
25154
|
-
*/
|
|
25155
|
-
const TextContentSchema = object$1({
|
|
25156
|
-
type: literal("text"),
|
|
25157
|
-
/**
|
|
25158
|
-
* The text content of the message.
|
|
25159
|
-
*/
|
|
25160
|
-
text: string(),
|
|
25161
|
-
/**
|
|
25162
|
-
* Optional annotations for the client.
|
|
25163
|
-
*/
|
|
25164
|
-
annotations: AnnotationsSchema.optional(),
|
|
25165
|
-
/**
|
|
25166
|
-
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
25167
|
-
* for notes on _meta usage.
|
|
25168
|
-
*/
|
|
25169
|
-
_meta: record(string(), unknown()).optional()
|
|
25170
|
-
});
|
|
25171
|
-
/**
|
|
25172
|
-
* An image provided to or from an LLM.
|
|
25173
|
-
*/
|
|
25174
|
-
const ImageContentSchema = object$1({
|
|
25175
|
-
type: literal("image"),
|
|
25176
|
-
/**
|
|
25177
|
-
* The base64-encoded image data.
|
|
25178
|
-
*/
|
|
25179
|
-
data: Base64Schema,
|
|
25180
|
-
/**
|
|
25181
|
-
* The MIME type of the image. Different providers may support different image types.
|
|
25182
|
-
*/
|
|
25183
|
-
mimeType: string(),
|
|
25184
|
-
/**
|
|
25185
|
-
* Optional annotations for the client.
|
|
25186
|
-
*/
|
|
25187
|
-
annotations: AnnotationsSchema.optional(),
|
|
25188
|
-
/**
|
|
25189
|
-
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
25190
|
-
* for notes on _meta usage.
|
|
25191
|
-
*/
|
|
25192
|
-
_meta: record(string(), unknown()).optional()
|
|
25193
|
-
});
|
|
25194
|
-
/**
|
|
25195
|
-
* An Audio provided to or from an LLM.
|
|
25196
|
-
*/
|
|
25197
|
-
const AudioContentSchema = object$1({
|
|
25198
|
-
type: literal("audio"),
|
|
25199
|
-
/**
|
|
25200
|
-
* The base64-encoded audio data.
|
|
25201
|
-
*/
|
|
25202
|
-
data: Base64Schema,
|
|
25203
|
-
/**
|
|
25204
|
-
* The MIME type of the audio. Different providers may support different audio types.
|
|
25205
|
-
*/
|
|
25206
|
-
mimeType: string(),
|
|
25207
|
-
/**
|
|
25208
|
-
* Optional annotations for the client.
|
|
25209
|
-
*/
|
|
25210
|
-
annotations: AnnotationsSchema.optional(),
|
|
25211
|
-
/**
|
|
25212
|
-
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
25213
|
-
* for notes on _meta usage.
|
|
25214
|
-
*/
|
|
25215
|
-
_meta: record(string(), unknown()).optional()
|
|
25216
|
-
});
|
|
25217
|
-
/**
|
|
25218
|
-
* A tool call request from an assistant (LLM).
|
|
25219
|
-
* Represents the assistant's request to use a tool.
|
|
25220
|
-
*/
|
|
25221
|
-
const ToolUseContentSchema = object$1({
|
|
25222
|
-
type: literal("tool_use"),
|
|
25223
|
-
/**
|
|
25224
|
-
* The name of the tool to invoke.
|
|
25225
|
-
* Must match a tool name from the request's tools array.
|
|
25226
|
-
*/
|
|
25227
|
-
name: string(),
|
|
25228
|
-
/**
|
|
25229
|
-
* Unique identifier for this tool call.
|
|
25230
|
-
* Used to correlate with ToolResultContent in subsequent messages.
|
|
25231
|
-
*/
|
|
25232
|
-
id: string(),
|
|
25233
|
-
/**
|
|
25234
|
-
* Arguments to pass to the tool.
|
|
25235
|
-
* Must conform to the tool's inputSchema.
|
|
25236
|
-
*/
|
|
25237
|
-
input: record(string(), unknown()),
|
|
25238
|
-
/**
|
|
25239
|
-
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
25240
|
-
* for notes on _meta usage.
|
|
25241
|
-
*/
|
|
25242
|
-
_meta: record(string(), unknown()).optional()
|
|
25243
|
-
});
|
|
25244
|
-
/**
|
|
25245
|
-
* The contents of a resource, embedded into a prompt or tool call result.
|
|
25246
|
-
*/
|
|
25247
|
-
const EmbeddedResourceSchema = object$1({
|
|
25248
|
-
type: literal("resource"),
|
|
25249
|
-
resource: union([TextResourceContentsSchema, BlobResourceContentsSchema]),
|
|
25250
|
-
/**
|
|
25251
|
-
* Optional annotations for the client.
|
|
25252
|
-
*/
|
|
25253
|
-
annotations: AnnotationsSchema.optional(),
|
|
25254
|
-
/**
|
|
25255
|
-
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
25256
|
-
* for notes on _meta usage.
|
|
25257
|
-
*/
|
|
25258
|
-
_meta: record(string(), unknown()).optional()
|
|
25259
|
-
});
|
|
25260
|
-
/**
|
|
25261
|
-
* A content block that can be used in prompts and tool results.
|
|
25262
|
-
*/
|
|
25263
|
-
const ContentBlockSchema = union([
|
|
25264
|
-
TextContentSchema,
|
|
25265
|
-
ImageContentSchema,
|
|
25266
|
-
AudioContentSchema,
|
|
25267
|
-
ResourceSchema.extend({ type: literal("resource_link") }),
|
|
25268
|
-
EmbeddedResourceSchema
|
|
25269
|
-
]);
|
|
25270
|
-
/**
|
|
25271
|
-
* Describes a message returned as part of a prompt.
|
|
25272
|
-
*/
|
|
25273
|
-
const PromptMessageSchema = object$1({
|
|
25274
|
-
role: RoleSchema,
|
|
25275
|
-
content: ContentBlockSchema
|
|
25276
|
-
});
|
|
25277
|
-
/**
|
|
25278
|
-
* The server's response to a prompts/get request from the client.
|
|
25279
|
-
*/
|
|
25280
|
-
const GetPromptResultSchema = ResultSchema.extend({
|
|
25281
|
-
/**
|
|
25282
|
-
* An optional description for the prompt.
|
|
25283
|
-
*/
|
|
25284
|
-
description: string().optional(),
|
|
25285
|
-
messages: array(PromptMessageSchema)
|
|
25286
|
-
});
|
|
25287
|
-
/**
|
|
25288
|
-
* An optional notification from the server to the client, informing it that the list of prompts it offers has changed. This may be issued by servers without any previous subscription from the client.
|
|
25289
|
-
*/
|
|
25290
|
-
const PromptListChangedNotificationSchema = NotificationSchema.extend({
|
|
25291
|
-
method: literal("notifications/prompts/list_changed"),
|
|
25292
|
-
params: NotificationsParamsSchema.optional()
|
|
25293
|
-
});
|
|
25294
|
-
/**
|
|
25295
|
-
* Additional properties describing a Tool to clients.
|
|
25296
|
-
*
|
|
25297
|
-
* NOTE: all properties in ToolAnnotations are **hints**.
|
|
25298
|
-
* They are not guaranteed to provide a faithful description of
|
|
25299
|
-
* tool behavior (including descriptive properties like `title`).
|
|
25300
|
-
*
|
|
25301
|
-
* Clients should never make tool use decisions based on ToolAnnotations
|
|
25302
|
-
* received from untrusted servers.
|
|
25303
|
-
*/
|
|
25304
|
-
const ToolAnnotationsSchema = object$1({
|
|
25305
|
-
/**
|
|
25306
|
-
* A human-readable title for the tool.
|
|
25307
|
-
*/
|
|
25308
|
-
title: string().optional(),
|
|
25309
|
-
/**
|
|
25310
|
-
* If true, the tool does not modify its environment.
|
|
25311
|
-
*
|
|
25312
|
-
* Default: false
|
|
25313
|
-
*/
|
|
25314
|
-
readOnlyHint: boolean().optional(),
|
|
25315
|
-
/**
|
|
25316
|
-
* If true, the tool may perform destructive updates to its environment.
|
|
25317
|
-
* If false, the tool performs only additive updates.
|
|
25318
|
-
*
|
|
25319
|
-
* (This property is meaningful only when `readOnlyHint == false`)
|
|
25320
|
-
*
|
|
25321
|
-
* Default: true
|
|
25322
|
-
*/
|
|
25323
|
-
destructiveHint: boolean().optional(),
|
|
25324
|
-
/**
|
|
25325
|
-
* If true, calling the tool repeatedly with the same arguments
|
|
25326
|
-
* will have no additional effect on the its environment.
|
|
25327
|
-
*
|
|
25328
|
-
* (This property is meaningful only when `readOnlyHint == false`)
|
|
25329
|
-
*
|
|
25330
|
-
* Default: false
|
|
25331
|
-
*/
|
|
25332
|
-
idempotentHint: boolean().optional(),
|
|
25333
|
-
/**
|
|
25334
|
-
* If true, this tool may interact with an "open world" of external
|
|
25335
|
-
* entities. If false, the tool's domain of interaction is closed.
|
|
25336
|
-
* For example, the world of a web search tool is open, whereas that
|
|
25337
|
-
* of a memory tool is not.
|
|
25338
|
-
*
|
|
25339
|
-
* Default: true
|
|
25340
|
-
*/
|
|
25341
|
-
openWorldHint: boolean().optional()
|
|
25342
|
-
});
|
|
25343
|
-
/**
|
|
25344
|
-
* Execution-related properties for a tool.
|
|
25345
|
-
*/
|
|
25346
|
-
const ToolExecutionSchema = object$1({
|
|
25347
|
-
/**
|
|
25348
|
-
* Indicates the tool's preference for task-augmented execution.
|
|
25349
|
-
* - "required": Clients MUST invoke the tool as a task
|
|
25350
|
-
* - "optional": Clients MAY invoke the tool as a task or normal request
|
|
25351
|
-
* - "forbidden": Clients MUST NOT attempt to invoke the tool as a task
|
|
25352
|
-
*
|
|
25353
|
-
* If not present, defaults to "forbidden".
|
|
25354
|
-
*/
|
|
25355
|
-
taskSupport: _enum([
|
|
25356
|
-
"required",
|
|
25357
|
-
"optional",
|
|
25358
|
-
"forbidden"
|
|
25359
|
-
]).optional() });
|
|
25360
|
-
/**
|
|
25361
|
-
* Definition for a tool the client can call.
|
|
25362
|
-
*/
|
|
25363
|
-
const ToolSchema = object$1({
|
|
25364
|
-
...BaseMetadataSchema.shape,
|
|
25365
|
-
...IconsSchema.shape,
|
|
25366
|
-
/**
|
|
25367
|
-
* A human-readable description of the tool.
|
|
25368
|
-
*/
|
|
25369
|
-
description: string().optional(),
|
|
25370
|
-
/**
|
|
25371
|
-
* A JSON Schema 2020-12 object defining the expected parameters for the tool.
|
|
25372
|
-
* Must have type: 'object' at the root level per MCP spec.
|
|
25373
|
-
*/
|
|
25374
|
-
inputSchema: object$1({
|
|
25375
|
-
type: literal("object"),
|
|
25376
|
-
properties: record(string(), AssertObjectSchema).optional(),
|
|
25377
|
-
required: array(string()).optional()
|
|
25378
|
-
}).catchall(unknown()),
|
|
25379
|
-
/**
|
|
25380
|
-
* An optional JSON Schema 2020-12 object defining the structure of the tool's output
|
|
25381
|
-
* returned in the structuredContent field of a CallToolResult.
|
|
25382
|
-
* Must have type: 'object' at the root level per MCP spec.
|
|
25383
|
-
*/
|
|
25384
|
-
outputSchema: object$1({
|
|
25385
|
-
type: literal("object"),
|
|
25386
|
-
properties: record(string(), AssertObjectSchema).optional(),
|
|
25387
|
-
required: array(string()).optional()
|
|
25388
|
-
}).catchall(unknown()).optional(),
|
|
25389
|
-
/**
|
|
25390
|
-
* Optional additional tool information.
|
|
25391
|
-
*/
|
|
25392
|
-
annotations: ToolAnnotationsSchema.optional(),
|
|
25393
|
-
/**
|
|
25394
|
-
* Execution-related properties for this tool.
|
|
25395
|
-
*/
|
|
25396
|
-
execution: ToolExecutionSchema.optional(),
|
|
25397
|
-
/**
|
|
25398
|
-
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
25399
|
-
* for notes on _meta usage.
|
|
25400
|
-
*/
|
|
25401
|
-
_meta: record(string(), unknown()).optional()
|
|
25402
|
-
});
|
|
25403
|
-
/**
|
|
25404
|
-
* Sent from the client to request a list of tools the server has.
|
|
25405
|
-
*/
|
|
25406
|
-
const ListToolsRequestSchema = PaginatedRequestSchema.extend({ method: literal("tools/list") });
|
|
25407
|
-
/**
|
|
25408
|
-
* The server's response to a tools/list request from the client.
|
|
25409
|
-
*/
|
|
25410
|
-
const ListToolsResultSchema = PaginatedResultSchema.extend({ tools: array(ToolSchema) });
|
|
25411
|
-
/**
|
|
25412
|
-
* The server's response to a tool call.
|
|
25413
|
-
*/
|
|
25414
|
-
const CallToolResultSchema = ResultSchema.extend({
|
|
25415
|
-
/**
|
|
25416
|
-
* A list of content objects that represent the result of the tool call.
|
|
25417
|
-
*
|
|
25418
|
-
* If the Tool does not define an outputSchema, this field MUST be present in the result.
|
|
25419
|
-
* For backwards compatibility, this field is always present, but it may be empty.
|
|
25420
|
-
*/
|
|
25421
|
-
content: array(ContentBlockSchema).default([]),
|
|
25422
|
-
/**
|
|
25423
|
-
* An object containing structured tool output.
|
|
25424
|
-
*
|
|
25425
|
-
* If the Tool defines an outputSchema, this field MUST be present in the result, and contain a JSON object that matches the schema.
|
|
25426
|
-
*/
|
|
25427
|
-
structuredContent: record(string(), unknown()).optional(),
|
|
25428
|
-
/**
|
|
25429
|
-
* Whether the tool call ended in an error.
|
|
25430
|
-
*
|
|
25431
|
-
* If not set, this is assumed to be false (the call was successful).
|
|
25432
|
-
*
|
|
25433
|
-
* Any errors that originate from the tool SHOULD be reported inside the result
|
|
25434
|
-
* object, with `isError` set to true, _not_ as an MCP protocol-level error
|
|
25435
|
-
* response. Otherwise, the LLM would not be able to see that an error occurred
|
|
25436
|
-
* and self-correct.
|
|
25437
|
-
*
|
|
25438
|
-
* However, any errors in _finding_ the tool, an error indicating that the
|
|
25439
|
-
* server does not support tool calls, or any other exceptional conditions,
|
|
25440
|
-
* should be reported as an MCP error response.
|
|
25441
|
-
*/
|
|
25442
|
-
isError: boolean().optional()
|
|
25443
|
-
});
|
|
25444
|
-
CallToolResultSchema.or(ResultSchema.extend({ toolResult: unknown() }));
|
|
25445
|
-
/**
|
|
25446
|
-
* Parameters for a `tools/call` request.
|
|
25447
|
-
*/
|
|
25448
|
-
const CallToolRequestParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
25449
|
-
/**
|
|
25450
|
-
* The name of the tool to call.
|
|
25451
|
-
*/
|
|
25452
|
-
name: string(),
|
|
25453
|
-
/**
|
|
25454
|
-
* Arguments to pass to the tool.
|
|
25455
|
-
*/
|
|
25456
|
-
arguments: record(string(), unknown()).optional()
|
|
25457
|
-
});
|
|
25458
|
-
/**
|
|
25459
|
-
* Used by the client to invoke a tool provided by the server.
|
|
25460
|
-
*/
|
|
25461
|
-
const CallToolRequestSchema = RequestSchema.extend({
|
|
25462
|
-
method: literal("tools/call"),
|
|
25463
|
-
params: CallToolRequestParamsSchema
|
|
25464
|
-
});
|
|
25465
|
-
/**
|
|
25466
|
-
* An optional notification from the server to the client, informing it that the list of tools it offers has changed. This may be issued by servers without any previous subscription from the client.
|
|
25467
|
-
*/
|
|
25468
|
-
const ToolListChangedNotificationSchema = NotificationSchema.extend({
|
|
25469
|
-
method: literal("notifications/tools/list_changed"),
|
|
25470
|
-
params: NotificationsParamsSchema.optional()
|
|
25471
|
-
});
|
|
25472
|
-
object$1({
|
|
25473
|
-
/**
|
|
25474
|
-
* If true, the list will be refreshed automatically when a list changed notification is received.
|
|
25475
|
-
* The callback will be called with the updated list.
|
|
25476
|
-
*
|
|
25477
|
-
* If false, the callback will be called with null items, allowing manual refresh.
|
|
25478
|
-
*
|
|
25479
|
-
* @default true
|
|
25480
|
-
*/
|
|
25481
|
-
autoRefresh: boolean().default(true),
|
|
25482
|
-
/**
|
|
25483
|
-
* Debounce time in milliseconds for list changed notification processing.
|
|
25484
|
-
*
|
|
25485
|
-
* Multiple notifications received within this timeframe will only trigger one refresh.
|
|
25486
|
-
* Set to 0 to disable debouncing.
|
|
25487
|
-
*
|
|
25488
|
-
* @default 300
|
|
25489
|
-
*/
|
|
25490
|
-
debounceMs: number().int().nonnegative().default(300)
|
|
25491
|
-
});
|
|
25492
|
-
/**
|
|
25493
|
-
* The severity of a log message.
|
|
25494
|
-
*/
|
|
25495
|
-
const LoggingLevelSchema = _enum([
|
|
25496
|
-
"debug",
|
|
25497
|
-
"info",
|
|
25498
|
-
"notice",
|
|
25499
|
-
"warning",
|
|
25500
|
-
"error",
|
|
25501
|
-
"critical",
|
|
25502
|
-
"alert",
|
|
25503
|
-
"emergency"
|
|
25504
|
-
]);
|
|
25505
|
-
/**
|
|
25506
|
-
* Parameters for a `logging/setLevel` request.
|
|
25507
|
-
*/
|
|
25508
|
-
const SetLevelRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
25509
|
-
/**
|
|
25510
|
-
* The level of logging that the client wants to receive from the server. The server should send all logs at this level and higher (i.e., more severe) to the client as notifications/logging/message.
|
|
25511
|
-
*/
|
|
25512
|
-
level: LoggingLevelSchema });
|
|
25513
|
-
/**
|
|
25514
|
-
* A request from the client to the server, to enable or adjust logging.
|
|
25515
|
-
*/
|
|
25516
|
-
const SetLevelRequestSchema = RequestSchema.extend({
|
|
25517
|
-
method: literal("logging/setLevel"),
|
|
25518
|
-
params: SetLevelRequestParamsSchema
|
|
25519
|
-
});
|
|
25520
|
-
/**
|
|
25521
|
-
* Parameters for a `notifications/message` notification.
|
|
25522
|
-
*/
|
|
25523
|
-
const LoggingMessageNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
25524
|
-
/**
|
|
25525
|
-
* The severity of this log message.
|
|
25526
|
-
*/
|
|
25527
|
-
level: LoggingLevelSchema,
|
|
25528
|
-
/**
|
|
25529
|
-
* An optional name of the logger issuing this message.
|
|
25530
|
-
*/
|
|
25531
|
-
logger: string().optional(),
|
|
25532
|
-
/**
|
|
25533
|
-
* The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here.
|
|
25534
|
-
*/
|
|
25535
|
-
data: unknown()
|
|
25536
|
-
});
|
|
25537
|
-
/**
|
|
25538
|
-
* Notification of a log message passed from server to client. If no logging/setLevel request has been sent from the client, the server MAY decide which messages to send automatically.
|
|
25539
|
-
*/
|
|
25540
|
-
const LoggingMessageNotificationSchema = NotificationSchema.extend({
|
|
25541
|
-
method: literal("notifications/message"),
|
|
25542
|
-
params: LoggingMessageNotificationParamsSchema
|
|
25543
|
-
});
|
|
25544
|
-
/**
|
|
25545
|
-
* The server's preferences for model selection, requested of the client during sampling.
|
|
25546
|
-
*/
|
|
25547
|
-
const ModelPreferencesSchema = object$1({
|
|
25548
|
-
/**
|
|
25549
|
-
* Optional hints to use for model selection.
|
|
25550
|
-
*/
|
|
25551
|
-
hints: array(object$1({
|
|
25552
|
-
/**
|
|
25553
|
-
* A hint for a model name.
|
|
25554
|
-
*/
|
|
25555
|
-
name: string().optional() })).optional(),
|
|
25556
|
-
/**
|
|
25557
|
-
* How much to prioritize cost when selecting a model.
|
|
25558
|
-
*/
|
|
25559
|
-
costPriority: number().min(0).max(1).optional(),
|
|
25560
|
-
/**
|
|
25561
|
-
* How much to prioritize sampling speed (latency) when selecting a model.
|
|
25562
|
-
*/
|
|
25563
|
-
speedPriority: number().min(0).max(1).optional(),
|
|
25564
|
-
/**
|
|
25565
|
-
* How much to prioritize intelligence and capabilities when selecting a model.
|
|
25566
|
-
*/
|
|
25567
|
-
intelligencePriority: number().min(0).max(1).optional()
|
|
25568
|
-
});
|
|
25569
|
-
/**
|
|
25570
|
-
* Controls tool usage behavior in sampling requests.
|
|
25571
|
-
*/
|
|
25572
|
-
const ToolChoiceSchema = object$1({
|
|
25573
|
-
/**
|
|
25574
|
-
* Controls when tools are used:
|
|
25575
|
-
* - "auto": Model decides whether to use tools (default)
|
|
25576
|
-
* - "required": Model MUST use at least one tool before completing
|
|
25577
|
-
* - "none": Model MUST NOT use any tools
|
|
25578
|
-
*/
|
|
25579
|
-
mode: _enum([
|
|
25580
|
-
"auto",
|
|
25581
|
-
"required",
|
|
25582
|
-
"none"
|
|
25583
|
-
]).optional() });
|
|
25584
|
-
/**
|
|
25585
|
-
* The result of a tool execution, provided by the user (server).
|
|
25586
|
-
* Represents the outcome of invoking a tool requested via ToolUseContent.
|
|
25587
|
-
*/
|
|
25588
|
-
const ToolResultContentSchema = object$1({
|
|
25589
|
-
type: literal("tool_result"),
|
|
25590
|
-
toolUseId: string().describe("The unique identifier for the corresponding tool call."),
|
|
25591
|
-
content: array(ContentBlockSchema).default([]),
|
|
25592
|
-
structuredContent: object$1({}).loose().optional(),
|
|
25593
|
-
isError: boolean().optional(),
|
|
25594
|
-
/**
|
|
25595
|
-
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
25596
|
-
* for notes on _meta usage.
|
|
25597
|
-
*/
|
|
25598
|
-
_meta: record(string(), unknown()).optional()
|
|
25599
|
-
});
|
|
25600
|
-
/**
|
|
25601
|
-
* Basic content types for sampling responses (without tool use).
|
|
25602
|
-
* Used for backwards-compatible CreateMessageResult when tools are not used.
|
|
25603
|
-
*/
|
|
25604
|
-
const SamplingContentSchema = discriminatedUnion("type", [
|
|
25605
|
-
TextContentSchema,
|
|
25606
|
-
ImageContentSchema,
|
|
25607
|
-
AudioContentSchema
|
|
25608
|
-
]);
|
|
25609
|
-
/**
|
|
25610
|
-
* Content block types allowed in sampling messages.
|
|
25611
|
-
* This includes text, image, audio, tool use requests, and tool results.
|
|
25612
|
-
*/
|
|
25613
|
-
const SamplingMessageContentBlockSchema = discriminatedUnion("type", [
|
|
25614
|
-
TextContentSchema,
|
|
25615
|
-
ImageContentSchema,
|
|
25616
|
-
AudioContentSchema,
|
|
25617
|
-
ToolUseContentSchema,
|
|
25618
|
-
ToolResultContentSchema
|
|
25619
|
-
]);
|
|
25620
|
-
/**
|
|
25621
|
-
* Describes a message issued to or received from an LLM API.
|
|
25622
|
-
*/
|
|
25623
|
-
const SamplingMessageSchema = object$1({
|
|
25624
|
-
role: RoleSchema,
|
|
25625
|
-
content: union([SamplingMessageContentBlockSchema, array(SamplingMessageContentBlockSchema)]),
|
|
25626
|
-
/**
|
|
25627
|
-
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
25628
|
-
* for notes on _meta usage.
|
|
25629
|
-
*/
|
|
25630
|
-
_meta: record(string(), unknown()).optional()
|
|
25631
|
-
});
|
|
25632
|
-
/**
|
|
25633
|
-
* Parameters for a `sampling/createMessage` request.
|
|
25634
|
-
*/
|
|
25635
|
-
const CreateMessageRequestParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
25636
|
-
messages: array(SamplingMessageSchema),
|
|
25637
|
-
/**
|
|
25638
|
-
* The server's preferences for which model to select. The client MAY modify or omit this request.
|
|
25639
|
-
*/
|
|
25640
|
-
modelPreferences: ModelPreferencesSchema.optional(),
|
|
25641
|
-
/**
|
|
25642
|
-
* An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt.
|
|
25643
|
-
*/
|
|
25644
|
-
systemPrompt: string().optional(),
|
|
25645
|
-
/**
|
|
25646
|
-
* A request to include context from one or more MCP servers (including the caller), to be attached to the prompt.
|
|
25647
|
-
* The client MAY ignore this request.
|
|
25648
|
-
*
|
|
25649
|
-
* Default is "none". Values "thisServer" and "allServers" are soft-deprecated. Servers SHOULD only use these values if the client
|
|
25650
|
-
* declares ClientCapabilities.sampling.context. These values may be removed in future spec releases.
|
|
25651
|
-
*/
|
|
25652
|
-
includeContext: _enum([
|
|
25653
|
-
"none",
|
|
25654
|
-
"thisServer",
|
|
25655
|
-
"allServers"
|
|
25656
|
-
]).optional(),
|
|
25657
|
-
temperature: number().optional(),
|
|
25658
|
-
/**
|
|
25659
|
-
* The requested maximum number of tokens to sample (to prevent runaway completions).
|
|
25660
|
-
*
|
|
25661
|
-
* The client MAY choose to sample fewer tokens than the requested maximum.
|
|
25662
|
-
*/
|
|
25663
|
-
maxTokens: number().int(),
|
|
25664
|
-
stopSequences: array(string()).optional(),
|
|
25665
|
-
/**
|
|
25666
|
-
* Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific.
|
|
25667
|
-
*/
|
|
25668
|
-
metadata: AssertObjectSchema.optional(),
|
|
25669
|
-
/**
|
|
25670
|
-
* Tools that the model may use during generation.
|
|
25671
|
-
* The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.
|
|
25672
|
-
*/
|
|
25673
|
-
tools: array(ToolSchema).optional(),
|
|
25674
|
-
/**
|
|
25675
|
-
* Controls how the model uses tools.
|
|
25676
|
-
* The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.
|
|
25677
|
-
* Default is `{ mode: "auto" }`.
|
|
25678
|
-
*/
|
|
25679
|
-
toolChoice: ToolChoiceSchema.optional()
|
|
25680
|
-
});
|
|
25681
|
-
/**
|
|
25682
|
-
* A request from the server to sample an LLM via the client. The client has full discretion over which model to select. The client should also inform the user before beginning sampling, to allow them to inspect the request (human in the loop) and decide whether to approve it.
|
|
25683
|
-
*/
|
|
25684
|
-
const CreateMessageRequestSchema = RequestSchema.extend({
|
|
25685
|
-
method: literal("sampling/createMessage"),
|
|
25686
|
-
params: CreateMessageRequestParamsSchema
|
|
25687
|
-
});
|
|
25688
|
-
/**
|
|
25689
|
-
* The client's response to a sampling/create_message request from the server.
|
|
25690
|
-
* This is the backwards-compatible version that returns single content (no arrays).
|
|
25691
|
-
* Used when the request does not include tools.
|
|
25692
|
-
*/
|
|
25693
|
-
const CreateMessageResultSchema = ResultSchema.extend({
|
|
25694
|
-
/**
|
|
25695
|
-
* The name of the model that generated the message.
|
|
25696
|
-
*/
|
|
25697
|
-
model: string(),
|
|
25698
|
-
/**
|
|
25699
|
-
* The reason why sampling stopped, if known.
|
|
25700
|
-
*
|
|
25701
|
-
* Standard values:
|
|
25702
|
-
* - "endTurn": Natural end of the assistant's turn
|
|
25703
|
-
* - "stopSequence": A stop sequence was encountered
|
|
25704
|
-
* - "maxTokens": Maximum token limit was reached
|
|
25705
|
-
*
|
|
25706
|
-
* This field is an open string to allow for provider-specific stop reasons.
|
|
25707
|
-
*/
|
|
25708
|
-
stopReason: optional(_enum([
|
|
25709
|
-
"endTurn",
|
|
25710
|
-
"stopSequence",
|
|
25711
|
-
"maxTokens"
|
|
25712
|
-
]).or(string())),
|
|
25713
|
-
role: RoleSchema,
|
|
25714
|
-
/**
|
|
25715
|
-
* Response content. Single content block (text, image, or audio).
|
|
25716
|
-
*/
|
|
25717
|
-
content: SamplingContentSchema
|
|
25718
|
-
});
|
|
25719
|
-
/**
|
|
25720
|
-
* The client's response to a sampling/create_message request when tools were provided.
|
|
25721
|
-
* This version supports array content for tool use flows.
|
|
25722
|
-
*/
|
|
25723
|
-
const CreateMessageResultWithToolsSchema = ResultSchema.extend({
|
|
25724
|
-
/**
|
|
25725
|
-
* The name of the model that generated the message.
|
|
25726
|
-
*/
|
|
25727
|
-
model: string(),
|
|
25728
|
-
/**
|
|
25729
|
-
* The reason why sampling stopped, if known.
|
|
25730
|
-
*
|
|
25731
|
-
* Standard values:
|
|
25732
|
-
* - "endTurn": Natural end of the assistant's turn
|
|
25733
|
-
* - "stopSequence": A stop sequence was encountered
|
|
25734
|
-
* - "maxTokens": Maximum token limit was reached
|
|
25735
|
-
* - "toolUse": The model wants to use one or more tools
|
|
25736
|
-
*
|
|
25737
|
-
* This field is an open string to allow for provider-specific stop reasons.
|
|
25738
|
-
*/
|
|
25739
|
-
stopReason: optional(_enum([
|
|
25740
|
-
"endTurn",
|
|
25741
|
-
"stopSequence",
|
|
25742
|
-
"maxTokens",
|
|
25743
|
-
"toolUse"
|
|
25744
|
-
]).or(string())),
|
|
25745
|
-
role: RoleSchema,
|
|
25746
|
-
/**
|
|
25747
|
-
* Response content. May be a single block or array. May include ToolUseContent if stopReason is "toolUse".
|
|
25748
|
-
*/
|
|
25749
|
-
content: union([SamplingMessageContentBlockSchema, array(SamplingMessageContentBlockSchema)])
|
|
25750
|
-
});
|
|
25751
|
-
/**
|
|
25752
|
-
* Primitive schema definition for boolean fields.
|
|
25753
|
-
*/
|
|
25754
|
-
const BooleanSchemaSchema = object$1({
|
|
25755
|
-
type: literal("boolean"),
|
|
25756
|
-
title: string().optional(),
|
|
25757
|
-
description: string().optional(),
|
|
25758
|
-
default: boolean().optional()
|
|
25759
|
-
});
|
|
25760
|
-
/**
|
|
25761
|
-
* Primitive schema definition for string fields.
|
|
25762
|
-
*/
|
|
25763
|
-
const StringSchemaSchema = object$1({
|
|
25764
|
-
type: literal("string"),
|
|
25765
|
-
title: string().optional(),
|
|
25766
|
-
description: string().optional(),
|
|
25767
|
-
minLength: number().optional(),
|
|
25768
|
-
maxLength: number().optional(),
|
|
25769
|
-
format: _enum([
|
|
25770
|
-
"email",
|
|
25771
|
-
"uri",
|
|
25772
|
-
"date",
|
|
25773
|
-
"date-time"
|
|
25774
|
-
]).optional(),
|
|
25775
|
-
default: string().optional()
|
|
25776
|
-
});
|
|
25777
|
-
/**
|
|
25778
|
-
* Primitive schema definition for number fields.
|
|
25779
|
-
*/
|
|
25780
|
-
const NumberSchemaSchema = object$1({
|
|
25781
|
-
type: _enum(["number", "integer"]),
|
|
25782
|
-
title: string().optional(),
|
|
25783
|
-
description: string().optional(),
|
|
25784
|
-
minimum: number().optional(),
|
|
25785
|
-
maximum: number().optional(),
|
|
25786
|
-
default: number().optional()
|
|
25787
|
-
});
|
|
25788
|
-
/**
|
|
25789
|
-
* Schema for single-selection enumeration without display titles for options.
|
|
25790
|
-
*/
|
|
25791
|
-
const UntitledSingleSelectEnumSchemaSchema = object$1({
|
|
25792
|
-
type: literal("string"),
|
|
25793
|
-
title: string().optional(),
|
|
25794
|
-
description: string().optional(),
|
|
25795
|
-
enum: array(string()),
|
|
25796
|
-
default: string().optional()
|
|
25797
|
-
});
|
|
25798
|
-
/**
|
|
25799
|
-
* Schema for single-selection enumeration with display titles for each option.
|
|
25800
|
-
*/
|
|
25801
|
-
const TitledSingleSelectEnumSchemaSchema = object$1({
|
|
25802
|
-
type: literal("string"),
|
|
25803
|
-
title: string().optional(),
|
|
25804
|
-
description: string().optional(),
|
|
25805
|
-
oneOf: array(object$1({
|
|
25806
|
-
const: string(),
|
|
25807
|
-
title: string()
|
|
25808
|
-
})),
|
|
25809
|
-
default: string().optional()
|
|
25810
|
-
});
|
|
25811
|
-
/**
|
|
25812
|
-
* Union of all primitive schema definitions.
|
|
25813
|
-
*/
|
|
25814
|
-
const PrimitiveSchemaDefinitionSchema = union([
|
|
25815
|
-
union([
|
|
25816
|
-
object$1({
|
|
25817
|
-
type: literal("string"),
|
|
25818
|
-
title: string().optional(),
|
|
25819
|
-
description: string().optional(),
|
|
25820
|
-
enum: array(string()),
|
|
25821
|
-
enumNames: array(string()).optional(),
|
|
25822
|
-
default: string().optional()
|
|
25823
|
-
}),
|
|
25824
|
-
union([UntitledSingleSelectEnumSchemaSchema, TitledSingleSelectEnumSchemaSchema]),
|
|
25825
|
-
union([object$1({
|
|
25826
|
-
type: literal("array"),
|
|
25827
|
-
title: string().optional(),
|
|
25828
|
-
description: string().optional(),
|
|
25829
|
-
minItems: number().optional(),
|
|
25830
|
-
maxItems: number().optional(),
|
|
25831
|
-
items: object$1({
|
|
25832
|
-
type: literal("string"),
|
|
25833
|
-
enum: array(string())
|
|
25834
|
-
}),
|
|
25835
|
-
default: array(string()).optional()
|
|
25836
|
-
}), object$1({
|
|
25837
|
-
type: literal("array"),
|
|
25838
|
-
title: string().optional(),
|
|
25839
|
-
description: string().optional(),
|
|
25840
|
-
minItems: number().optional(),
|
|
25841
|
-
maxItems: number().optional(),
|
|
25842
|
-
items: object$1({ anyOf: array(object$1({
|
|
25843
|
-
const: string(),
|
|
25844
|
-
title: string()
|
|
25845
|
-
})) }),
|
|
25846
|
-
default: array(string()).optional()
|
|
25847
|
-
})])
|
|
25848
|
-
]),
|
|
25849
|
-
BooleanSchemaSchema,
|
|
25850
|
-
StringSchemaSchema,
|
|
25851
|
-
NumberSchemaSchema
|
|
25852
|
-
]);
|
|
25853
|
-
/**
|
|
25854
|
-
* The parameters for a request to elicit additional information from the user via the client.
|
|
25855
|
-
*/
|
|
25856
|
-
const ElicitRequestParamsSchema = union([TaskAugmentedRequestParamsSchema.extend({
|
|
25857
|
-
/**
|
|
25858
|
-
* The elicitation mode.
|
|
25859
|
-
*
|
|
25860
|
-
* Optional for backward compatibility. Clients MUST treat missing mode as "form".
|
|
25861
|
-
*/
|
|
25862
|
-
mode: literal("form").optional(),
|
|
25863
|
-
/**
|
|
25864
|
-
* The message to present to the user describing what information is being requested.
|
|
25865
|
-
*/
|
|
25866
|
-
message: string(),
|
|
25867
|
-
/**
|
|
25868
|
-
* A restricted subset of JSON Schema.
|
|
25869
|
-
* Only top-level properties are allowed, without nesting.
|
|
25870
|
-
*/
|
|
25871
|
-
requestedSchema: object$1({
|
|
25872
|
-
type: literal("object"),
|
|
25873
|
-
properties: record(string(), PrimitiveSchemaDefinitionSchema),
|
|
25874
|
-
required: array(string()).optional()
|
|
25875
|
-
})
|
|
25876
|
-
}), TaskAugmentedRequestParamsSchema.extend({
|
|
25877
|
-
/**
|
|
25878
|
-
* The elicitation mode.
|
|
25879
|
-
*/
|
|
25880
|
-
mode: literal("url"),
|
|
25881
|
-
/**
|
|
25882
|
-
* The message to present to the user explaining why the interaction is needed.
|
|
25883
|
-
*/
|
|
25884
|
-
message: string(),
|
|
25885
|
-
/**
|
|
25886
|
-
* The ID of the elicitation, which must be unique within the context of the server.
|
|
25887
|
-
* The client MUST treat this ID as an opaque value.
|
|
25888
|
-
*/
|
|
25889
|
-
elicitationId: string(),
|
|
25890
|
-
/**
|
|
25891
|
-
* The URL that the user should navigate to.
|
|
25892
|
-
*/
|
|
25893
|
-
url: string().url()
|
|
25894
|
-
})]);
|
|
25895
|
-
/**
|
|
25896
|
-
* A request from the server to elicit user input via the client.
|
|
25897
|
-
* The client should present the message and form fields to the user (form mode)
|
|
25898
|
-
* or navigate to a URL (URL mode).
|
|
25899
|
-
*/
|
|
25900
|
-
const ElicitRequestSchema = RequestSchema.extend({
|
|
25901
|
-
method: literal("elicitation/create"),
|
|
25902
|
-
params: ElicitRequestParamsSchema
|
|
25903
|
-
});
|
|
25904
|
-
/**
|
|
25905
|
-
* Parameters for a `notifications/elicitation/complete` notification.
|
|
25906
|
-
*
|
|
25907
|
-
* @category notifications/elicitation/complete
|
|
25908
|
-
*/
|
|
25909
|
-
const ElicitationCompleteNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
25910
|
-
/**
|
|
25911
|
-
* The ID of the elicitation that completed.
|
|
25912
|
-
*/
|
|
25913
|
-
elicitationId: string() });
|
|
25914
|
-
/**
|
|
25915
|
-
* A notification from the server to the client, informing it of a completion of an out-of-band elicitation request.
|
|
25916
|
-
*
|
|
25917
|
-
* @category notifications/elicitation/complete
|
|
25918
|
-
*/
|
|
25919
|
-
const ElicitationCompleteNotificationSchema = NotificationSchema.extend({
|
|
25920
|
-
method: literal("notifications/elicitation/complete"),
|
|
25921
|
-
params: ElicitationCompleteNotificationParamsSchema
|
|
25922
|
-
});
|
|
25923
|
-
/**
|
|
25924
|
-
* The client's response to an elicitation/create request from the server.
|
|
25925
|
-
*/
|
|
25926
|
-
const ElicitResultSchema = ResultSchema.extend({
|
|
25927
|
-
/**
|
|
25928
|
-
* The user action in response to the elicitation.
|
|
25929
|
-
* - "accept": User submitted the form/confirmed the action
|
|
25930
|
-
* - "decline": User explicitly decline the action
|
|
25931
|
-
* - "cancel": User dismissed without making an explicit choice
|
|
25932
|
-
*/
|
|
25933
|
-
action: _enum([
|
|
25934
|
-
"accept",
|
|
25935
|
-
"decline",
|
|
25936
|
-
"cancel"
|
|
25937
|
-
]),
|
|
25938
|
-
/**
|
|
25939
|
-
* The submitted form data, only present when action is "accept".
|
|
25940
|
-
* Contains values matching the requested schema.
|
|
25941
|
-
* Per MCP spec, content is "typically omitted" for decline/cancel actions.
|
|
25942
|
-
* We normalize null to undefined for leniency while maintaining type compatibility.
|
|
25943
|
-
*/
|
|
25944
|
-
content: preprocess((val) => val === null ? void 0 : val, record(string(), union([
|
|
25945
|
-
string(),
|
|
25946
|
-
number(),
|
|
25947
|
-
boolean(),
|
|
25948
|
-
array(string())
|
|
25949
|
-
])).optional())
|
|
25950
|
-
});
|
|
25951
|
-
/**
|
|
25952
|
-
* A reference to a resource or resource template definition.
|
|
25953
|
-
*/
|
|
25954
|
-
const ResourceTemplateReferenceSchema = object$1({
|
|
25955
|
-
type: literal("ref/resource"),
|
|
25956
|
-
/**
|
|
25957
|
-
* The URI or URI template of the resource.
|
|
25958
|
-
*/
|
|
25959
|
-
uri: string()
|
|
25960
|
-
});
|
|
25961
|
-
/**
|
|
25962
|
-
* Identifies a prompt.
|
|
25963
|
-
*/
|
|
25964
|
-
const PromptReferenceSchema = object$1({
|
|
25965
|
-
type: literal("ref/prompt"),
|
|
25966
|
-
/**
|
|
25967
|
-
* The name of the prompt or prompt template
|
|
25968
|
-
*/
|
|
25969
|
-
name: string()
|
|
25970
|
-
});
|
|
25971
|
-
/**
|
|
25972
|
-
* Parameters for a `completion/complete` request.
|
|
25973
|
-
*/
|
|
25974
|
-
const CompleteRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
25975
|
-
ref: union([PromptReferenceSchema, ResourceTemplateReferenceSchema]),
|
|
25976
|
-
/**
|
|
25977
|
-
* The argument's information
|
|
25978
|
-
*/
|
|
25979
|
-
argument: object$1({
|
|
25980
|
-
/**
|
|
25981
|
-
* The name of the argument
|
|
25982
|
-
*/
|
|
25983
|
-
name: string(),
|
|
25984
|
-
/**
|
|
25985
|
-
* The value of the argument to use for completion matching.
|
|
25986
|
-
*/
|
|
25987
|
-
value: string()
|
|
25988
|
-
}),
|
|
25989
|
-
context: object$1({
|
|
25990
|
-
/**
|
|
25991
|
-
* Previously-resolved variables in a URI template or prompt.
|
|
25992
|
-
*/
|
|
25993
|
-
arguments: record(string(), string()).optional() }).optional()
|
|
25994
|
-
});
|
|
25995
|
-
/**
|
|
25996
|
-
* A request from the client to the server, to ask for completion options.
|
|
25997
|
-
*/
|
|
25998
|
-
const CompleteRequestSchema = RequestSchema.extend({
|
|
25999
|
-
method: literal("completion/complete"),
|
|
26000
|
-
params: CompleteRequestParamsSchema
|
|
26001
|
-
});
|
|
26002
|
-
/**
|
|
26003
|
-
* The server's response to a completion/complete request
|
|
26004
|
-
*/
|
|
26005
|
-
const CompleteResultSchema = ResultSchema.extend({ completion: looseObject({
|
|
26006
|
-
/**
|
|
26007
|
-
* An array of completion values. Must not exceed 100 items.
|
|
26008
|
-
*/
|
|
26009
|
-
values: array(string()).max(100),
|
|
26010
|
-
/**
|
|
26011
|
-
* The total number of completion options available. This can exceed the number of values actually sent in the response.
|
|
26012
|
-
*/
|
|
26013
|
-
total: optional(number().int()),
|
|
26014
|
-
/**
|
|
26015
|
-
* Indicates whether there are additional completion options beyond those provided in the current response, even if the exact total is unknown.
|
|
26016
|
-
*/
|
|
26017
|
-
hasMore: optional(boolean())
|
|
26018
|
-
}) });
|
|
26019
|
-
/**
|
|
26020
|
-
* Represents a root directory or file that the server can operate on.
|
|
26021
|
-
*/
|
|
26022
|
-
const RootSchema = object$1({
|
|
26023
|
-
/**
|
|
26024
|
-
* The URI identifying the root. This *must* start with file:// for now.
|
|
26025
|
-
*/
|
|
26026
|
-
uri: string().startsWith("file://"),
|
|
26027
|
-
/**
|
|
26028
|
-
* An optional name for the root.
|
|
26029
|
-
*/
|
|
26030
|
-
name: string().optional(),
|
|
26031
|
-
/**
|
|
26032
|
-
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
26033
|
-
* for notes on _meta usage.
|
|
26034
|
-
*/
|
|
26035
|
-
_meta: record(string(), unknown()).optional()
|
|
26036
|
-
});
|
|
26037
|
-
/**
|
|
26038
|
-
* Sent from the server to request a list of root URIs from the client.
|
|
26039
|
-
*/
|
|
26040
|
-
const ListRootsRequestSchema = RequestSchema.extend({
|
|
26041
|
-
method: literal("roots/list"),
|
|
26042
|
-
params: BaseRequestParamsSchema.optional()
|
|
26043
|
-
});
|
|
26044
|
-
/**
|
|
26045
|
-
* The client's response to a roots/list request from the server.
|
|
26046
|
-
*/
|
|
26047
|
-
const ListRootsResultSchema = ResultSchema.extend({ roots: array(RootSchema) });
|
|
26048
|
-
/**
|
|
26049
|
-
* A notification from the client to the server, informing it that the list of roots has changed.
|
|
26050
|
-
*/
|
|
26051
|
-
const RootsListChangedNotificationSchema = NotificationSchema.extend({
|
|
26052
|
-
method: literal("notifications/roots/list_changed"),
|
|
26053
|
-
params: NotificationsParamsSchema.optional()
|
|
26054
|
-
});
|
|
26055
|
-
union([
|
|
26056
|
-
PingRequestSchema,
|
|
26057
|
-
InitializeRequestSchema,
|
|
26058
|
-
CompleteRequestSchema,
|
|
26059
|
-
SetLevelRequestSchema,
|
|
26060
|
-
GetPromptRequestSchema,
|
|
26061
|
-
ListPromptsRequestSchema,
|
|
26062
|
-
ListResourcesRequestSchema,
|
|
26063
|
-
ListResourceTemplatesRequestSchema,
|
|
26064
|
-
ReadResourceRequestSchema,
|
|
26065
|
-
SubscribeRequestSchema,
|
|
26066
|
-
UnsubscribeRequestSchema,
|
|
26067
|
-
CallToolRequestSchema,
|
|
26068
|
-
ListToolsRequestSchema,
|
|
26069
|
-
GetTaskRequestSchema,
|
|
26070
|
-
GetTaskPayloadRequestSchema,
|
|
26071
|
-
ListTasksRequestSchema,
|
|
26072
|
-
CancelTaskRequestSchema
|
|
26073
|
-
]);
|
|
26074
|
-
union([
|
|
26075
|
-
CancelledNotificationSchema,
|
|
26076
|
-
ProgressNotificationSchema,
|
|
26077
|
-
InitializedNotificationSchema,
|
|
26078
|
-
RootsListChangedNotificationSchema,
|
|
26079
|
-
TaskStatusNotificationSchema
|
|
26080
|
-
]);
|
|
26081
|
-
union([
|
|
26082
|
-
EmptyResultSchema,
|
|
26083
|
-
CreateMessageResultSchema,
|
|
26084
|
-
CreateMessageResultWithToolsSchema,
|
|
26085
|
-
ElicitResultSchema,
|
|
26086
|
-
ListRootsResultSchema,
|
|
26087
|
-
GetTaskResultSchema,
|
|
26088
|
-
ListTasksResultSchema,
|
|
26089
|
-
CreateTaskResultSchema
|
|
26090
|
-
]);
|
|
26091
|
-
union([
|
|
26092
|
-
PingRequestSchema,
|
|
26093
|
-
CreateMessageRequestSchema,
|
|
26094
|
-
ElicitRequestSchema,
|
|
26095
|
-
ListRootsRequestSchema,
|
|
26096
|
-
GetTaskRequestSchema,
|
|
26097
|
-
GetTaskPayloadRequestSchema,
|
|
26098
|
-
ListTasksRequestSchema,
|
|
26099
|
-
CancelTaskRequestSchema
|
|
26100
|
-
]);
|
|
26101
|
-
union([
|
|
26102
|
-
CancelledNotificationSchema,
|
|
26103
|
-
ProgressNotificationSchema,
|
|
26104
|
-
LoggingMessageNotificationSchema,
|
|
26105
|
-
ResourceUpdatedNotificationSchema,
|
|
26106
|
-
ResourceListChangedNotificationSchema,
|
|
26107
|
-
ToolListChangedNotificationSchema,
|
|
26108
|
-
PromptListChangedNotificationSchema,
|
|
26109
|
-
TaskStatusNotificationSchema,
|
|
26110
|
-
ElicitationCompleteNotificationSchema
|
|
26111
|
-
]);
|
|
26112
|
-
union([
|
|
26113
|
-
EmptyResultSchema,
|
|
26114
|
-
InitializeResultSchema,
|
|
26115
|
-
CompleteResultSchema,
|
|
26116
|
-
GetPromptResultSchema,
|
|
26117
|
-
ListPromptsResultSchema,
|
|
26118
|
-
ListResourcesResultSchema,
|
|
26119
|
-
ListResourceTemplatesResultSchema,
|
|
26120
|
-
ReadResourceResultSchema,
|
|
26121
|
-
CallToolResultSchema,
|
|
26122
|
-
ListToolsResultSchema,
|
|
26123
|
-
GetTaskResultSchema,
|
|
26124
|
-
ListTasksResultSchema,
|
|
26125
|
-
CreateTaskResultSchema
|
|
26126
|
-
]);
|
|
26127
|
-
//#endregion
|
|
26128
|
-
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/hono-mcp-server-sse-transport/0.0.7/d5ae5a23aa2b79db7055621f11a7cbc8d27f7caba1eeb308ab2cf5bcb1a8e5b8/node_modules/hono-mcp-server-sse-transport/build/sse.js
|
|
26129
|
-
const MAXIMUM_MESSAGE_SIZE = 4 * 1024 * 1024;
|
|
26130
|
-
var SSETransport = class {
|
|
26131
|
-
messageUrl;
|
|
26132
|
-
stream;
|
|
26133
|
-
_sessionId;
|
|
26134
|
-
onclose;
|
|
26135
|
-
onerror;
|
|
26136
|
-
onmessage;
|
|
26137
|
-
/**
|
|
26138
|
-
* Creates a new SSETransport, which will direct the MPC client to POST messages to messageUrl
|
|
26139
|
-
*/
|
|
26140
|
-
constructor(messageUrl, stream) {
|
|
26141
|
-
this.messageUrl = messageUrl;
|
|
26142
|
-
this.stream = stream;
|
|
26143
|
-
this._sessionId = crypto.randomUUID();
|
|
26144
|
-
this.stream.onAbort(() => {
|
|
26145
|
-
this.close();
|
|
26146
|
-
});
|
|
26147
|
-
}
|
|
26148
|
-
get sessionId() {
|
|
26149
|
-
return this._sessionId;
|
|
26150
|
-
}
|
|
26151
|
-
async start() {
|
|
26152
|
-
if (this.stream == null) throw new Error("Stream not initialized");
|
|
26153
|
-
if (this.stream.closed) throw new Error("SSE transport already closed!");
|
|
26154
|
-
await this.stream.writeSSE({
|
|
26155
|
-
event: "ping",
|
|
26156
|
-
data: ""
|
|
26157
|
-
});
|
|
26158
|
-
await this.stream.writeSSE({
|
|
26159
|
-
event: "endpoint",
|
|
26160
|
-
data: `${this.messageUrl}?sessionId=${this.sessionId}`
|
|
26161
|
-
});
|
|
26162
|
-
}
|
|
26163
|
-
async handlePostMessage(context) {
|
|
26164
|
-
if (this.stream?.closed == null) return context.text("SSE connection not established", 500);
|
|
26165
|
-
try {
|
|
26166
|
-
const contentType = context.req.header("content-type") || "";
|
|
26167
|
-
if (!contentType.includes("application/json")) throw new Error(`Unsupported content-type: ${contentType}`);
|
|
26168
|
-
const contentLength = Number.parseInt(context.req.header("content-length") || "0", 10);
|
|
26169
|
-
if (contentLength > MAXIMUM_MESSAGE_SIZE) throw new Error(`Request body too large: ${contentLength} bytes`);
|
|
26170
|
-
const body = await context.req.json();
|
|
26171
|
-
await this.handleMessage(body);
|
|
26172
|
-
return context.text("Accepted", 202);
|
|
26173
|
-
} catch (error) {
|
|
26174
|
-
this.onerror?.(error);
|
|
26175
|
-
return context.text("Error", 400);
|
|
26176
|
-
}
|
|
26177
|
-
}
|
|
26178
|
-
/**
|
|
26179
|
-
* Handle a client message, regardless of how it arrived. This can be used to inform the server of messages that arrive via a means different than HTTP POST.
|
|
26180
|
-
*/
|
|
26181
|
-
async handleMessage(message) {
|
|
26182
|
-
let parsedMessage;
|
|
26183
|
-
try {
|
|
26184
|
-
parsedMessage = JSONRPCMessageSchema.parse(message);
|
|
26185
|
-
} catch (error) {
|
|
26186
|
-
this.onerror?.(error);
|
|
26187
|
-
throw error;
|
|
26188
|
-
}
|
|
26189
|
-
this.onmessage?.(parsedMessage);
|
|
26190
|
-
}
|
|
26191
|
-
async close() {
|
|
26192
|
-
if (this.stream?.closed) this.stream.abort();
|
|
26193
|
-
}
|
|
26194
|
-
async send(message) {
|
|
26195
|
-
if (this.stream?.closed) throw new Error("Not connected");
|
|
26196
|
-
await this.stream.writeSSE({
|
|
26197
|
-
event: "message",
|
|
26198
|
-
data: JSON.stringify(message)
|
|
26199
|
-
});
|
|
26200
|
-
}
|
|
26201
|
-
};
|
|
26202
|
-
//#endregion
|
|
26203
|
-
//#region src/server/mrtrElicitation.ts
|
|
26204
|
-
/**
|
|
26205
|
-
* Elicitation on the 2026-07-28 protocol revision (multi-round-trip requests).
|
|
26206
|
-
*
|
|
26207
|
-
* The modern era has no server→client request channel, so `server.elicitInput()`
|
|
26208
|
-
* throws there by design. Instead, the `tools/call` handler must RETURN an
|
|
26209
|
-
* `input_required` result carrying the embedded elicitation request; the client
|
|
26210
|
-
* answers it locally and RETRIES the call with the response attached
|
|
26211
|
-
* (`inputResponses`). This module keeps the promise-shaped
|
|
26212
|
-
* `elicitation.sendRequest()` API tools already use by replaying the tool:
|
|
26213
|
-
*
|
|
26214
|
-
* 1. Each `sendRequest` call is assigned a deterministic sequence key.
|
|
26215
|
-
* 2. If the current (retried) request carries an answer for that key — either in
|
|
26216
|
-
* this round's `inputResponses` or in the accumulated `requestState` from
|
|
26217
|
-
* prior rounds — the promise resolves with it immediately.
|
|
26218
|
-
* 3. Otherwise a {@link ElicitationReplayInterrupt} is thrown; the `tools/call`
|
|
26219
|
-
* handler converts it into an {@link InputRequiredResult} return, and the
|
|
26220
|
-
* client's retry re-executes the tool from the top.
|
|
26221
|
-
*
|
|
26222
|
-
* Consequences tools must live with on the modern leg:
|
|
26223
|
-
* - Code before an unanswered elicitation re-executes on every round; keep side
|
|
26224
|
-
* effects idempotent or place them after the last elicitation.
|
|
26225
|
-
* - Elicitation order must be deterministic for a given input, since answers are
|
|
26226
|
-
* matched by call sequence.
|
|
26227
|
-
*/
|
|
26228
|
-
const ELICIT_KEY_PREFIX = "mastra_elicit_";
|
|
26229
|
-
/**
|
|
26230
|
-
* Thrown by the replay-based `sendRequest` when the current round carries no
|
|
26231
|
-
* answer for the elicitation. Never surfaces to tools or clients: the
|
|
26232
|
-
* `tools/call` handler converts it into an `input_required` result.
|
|
26233
|
-
*/
|
|
26234
|
-
var ElicitationReplayInterrupt = class extends Error {
|
|
26235
|
-
key;
|
|
26236
|
-
params;
|
|
26237
|
-
answered;
|
|
26238
|
-
constructor(key, params, answered) {
|
|
26239
|
-
super(`Elicitation '${key}' requires client input (multi-round-trip)`);
|
|
26240
|
-
this.key = key;
|
|
26241
|
-
this.params = params;
|
|
26242
|
-
this.answered = answered;
|
|
26243
|
-
this.name = "ElicitationReplayInterrupt";
|
|
26244
|
-
}
|
|
26245
|
-
};
|
|
26246
|
-
const isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26247
|
-
const looksLikeElicitResult = (value) => isPlainObject(value) && typeof value.action === "string";
|
|
26248
|
-
/**
|
|
26249
|
-
* Decodes the accumulated prior-round answers from the request's opaque
|
|
26250
|
-
* `requestState` echo. The state round-trips through the client, so it is
|
|
26251
|
-
* attacker-controlled input on re-entry — but its only content is the client's
|
|
26252
|
-
* own past elicitation answers, which are untrusted user input either way, so
|
|
26253
|
-
* tampering grants the client nothing it does not already control. Anything
|
|
26254
|
-
* that does not parse as a map of elicitation results is discarded.
|
|
26255
|
-
*/
|
|
26256
|
-
const decodePriorAnswers = (extra) => {
|
|
26257
|
-
const raw = extra.mcpReq.requestState();
|
|
26258
|
-
if (typeof raw !== "string" || raw.length === 0) return {};
|
|
26259
|
-
try {
|
|
26260
|
-
const parsed = JSON.parse(raw);
|
|
26261
|
-
if (!isPlainObject(parsed)) return {};
|
|
26262
|
-
const answers = {};
|
|
26263
|
-
for (const [key, value] of Object.entries(parsed)) if (key.startsWith(ELICIT_KEY_PREFIX) && looksLikeElicitResult(value)) answers[key] = value;
|
|
26264
|
-
return answers;
|
|
26265
|
-
} catch {
|
|
26266
|
-
return {};
|
|
26267
|
-
}
|
|
26268
|
-
};
|
|
26269
|
-
/** This round's bare responses that answer our elicitation keys. */
|
|
26270
|
-
const currentRoundAnswers = (extra) => {
|
|
26271
|
-
const answers = {};
|
|
26272
|
-
for (const [key, value] of Object.entries(extra.mcpReq.inputResponses ?? {})) if (key.startsWith(ELICIT_KEY_PREFIX) && looksLikeElicitResult(value)) answers[key] = value;
|
|
26273
|
-
return answers;
|
|
26274
|
-
};
|
|
26275
|
-
/**
|
|
26276
|
-
* Whether this request is served on the 2026-07-28 era. Modern clients always
|
|
26277
|
-
* attach the reserved per-request `_meta` envelope (the 2026 codec enforces the
|
|
26278
|
-
* required keys at dispatch); legacy requests never carry it.
|
|
26279
|
-
*/
|
|
26280
|
-
const isModernEraRequest = (extra) => extra.mcpReq.envelope !== void 0;
|
|
26281
|
-
/**
|
|
26282
|
-
* Builds the replay-based {@link ElicitationActions} for one modern-era tool
|
|
26283
|
-
* execution. Answers already provided by the client resolve immediately; the
|
|
26284
|
-
* first unanswered elicitation throws {@link ElicitationReplayInterrupt}.
|
|
26285
|
-
*
|
|
26286
|
-
* The interrupt is also reported through `onInterrupt` before it is thrown:
|
|
26287
|
-
* tool wrappers (e.g. Mastra's tool builder) re-wrap thrown errors, so the
|
|
26288
|
-
* `tools/call` handler cannot rely on `instanceof` on whatever escapes the
|
|
26289
|
-
* tool — the out-of-band capture is the authoritative signal.
|
|
26290
|
-
*/
|
|
26291
|
-
const createReplayElicitation = (extra, onInterrupt) => {
|
|
26292
|
-
const prior = decodePriorAnswers(extra);
|
|
26293
|
-
const current = currentRoundAnswers(extra);
|
|
26294
|
-
const answered = {
|
|
26295
|
-
...prior,
|
|
26296
|
-
...current
|
|
26297
|
-
};
|
|
26298
|
-
let sequence = 0;
|
|
26299
|
-
return { sendRequest: async (request) => {
|
|
26300
|
-
const key = `${ELICIT_KEY_PREFIX}${sequence++}`;
|
|
26301
|
-
const answer = answered[key];
|
|
26302
|
-
if (answer !== void 0) return answer;
|
|
26303
|
-
const interrupt = new ElicitationReplayInterrupt(key, request, answered);
|
|
26304
|
-
onInterrupt(interrupt);
|
|
26305
|
-
throw interrupt;
|
|
26306
|
-
} };
|
|
26307
|
-
};
|
|
26308
|
-
/**
|
|
26309
|
-
* Converts a caught {@link ElicitationReplayInterrupt} into the
|
|
26310
|
-
* `input_required` result the `tools/call` handler returns to the client.
|
|
26311
|
-
* Prior answers travel in `requestState` because each retry only carries the
|
|
26312
|
-
* current round's `inputResponses`.
|
|
26313
|
-
*/
|
|
26314
|
-
const replayInterruptToInputRequired = (interrupt) => {
|
|
26315
|
-
const params = {
|
|
26316
|
-
mode: "form",
|
|
26317
|
-
...interrupt.params
|
|
26318
|
-
};
|
|
26319
|
-
return {
|
|
26320
|
-
resultType: "input_required",
|
|
26321
|
-
inputRequests: { [interrupt.key]: {
|
|
26322
|
-
method: "elicitation/create",
|
|
26323
|
-
params
|
|
26324
|
-
} },
|
|
26325
|
-
...Object.keys(interrupt.answered).length > 0 ? { requestState: JSON.stringify(interrupt.answered) } : {}
|
|
26326
|
-
};
|
|
26327
|
-
};
|
|
26328
|
-
//#endregion
|
|
26329
|
-
//#region src/server/notificationBroadcast.ts
|
|
24394
|
+
const replayInterruptToInputRequired = (interrupt) => {
|
|
24395
|
+
const params = {
|
|
24396
|
+
mode: "form",
|
|
24397
|
+
...interrupt.params
|
|
24398
|
+
};
|
|
24399
|
+
return {
|
|
24400
|
+
resultType: "input_required",
|
|
24401
|
+
inputRequests: { [interrupt.key]: {
|
|
24402
|
+
method: "elicitation/create",
|
|
24403
|
+
params
|
|
24404
|
+
} },
|
|
24405
|
+
...Object.keys(interrupt.answered).length > 0 ? { requestState: JSON.stringify(interrupt.answered) } : {}
|
|
24406
|
+
};
|
|
24407
|
+
};
|
|
24408
|
+
//#endregion
|
|
24409
|
+
//#region src/server/notificationBroadcast.ts
|
|
26330
24410
|
/**
|
|
26331
24411
|
* Sends a notification to every active server instance (the main stdio/SSE
|
|
26332
24412
|
* instance plus each streamable HTTP session instance).
|
|
@@ -27234,7 +25314,7 @@ var MCPServer = class extends _mastra_core_mcp.MCPServerBase {
|
|
|
27234
25314
|
const toolSpec = {
|
|
27235
25315
|
name: tool.id || "unknown",
|
|
27236
25316
|
description: tool.description,
|
|
27237
|
-
inputSchema: this.
|
|
25317
|
+
inputSchema: this.convertInputSchema(tool.parameters)
|
|
27238
25318
|
};
|
|
27239
25319
|
if (tool.outputSchema) toolSpec.outputSchema = this.convertSchema(tool.outputSchema);
|
|
27240
25320
|
if (tool.mcp?.annotations) toolSpec.annotations = tool.mcp.annotations;
|
|
@@ -28506,6 +26586,12 @@ var MCPServer = class extends _mastra_core_mcp.MCPServerBase {
|
|
|
28506
26586
|
}
|
|
28507
26587
|
return jsonSchema;
|
|
28508
26588
|
}
|
|
26589
|
+
convertInputSchema(schema) {
|
|
26590
|
+
return this.convertSchema(schema) ?? {
|
|
26591
|
+
type: "object",
|
|
26592
|
+
properties: {}
|
|
26593
|
+
};
|
|
26594
|
+
}
|
|
28509
26595
|
/**
|
|
28510
26596
|
* Gets a list of all tools provided by this MCP server with their schemas.
|
|
28511
26597
|
*
|
|
@@ -28529,7 +26615,7 @@ var MCPServer = class extends _mastra_core_mcp.MCPServerBase {
|
|
|
28529
26615
|
id: toolId,
|
|
28530
26616
|
name: tool.id || toolId,
|
|
28531
26617
|
description: tool.description,
|
|
28532
|
-
inputSchema: this.
|
|
26618
|
+
inputSchema: this.convertInputSchema(tool.parameters),
|
|
28533
26619
|
outputSchema: this.convertSchema(tool.outputSchema),
|
|
28534
26620
|
toolType: tool.mcp?.toolType,
|
|
28535
26621
|
_meta: withMastraToolStrictMeta(tool.mcp?._meta, tool.strict)
|
|
@@ -28540,7 +26626,7 @@ var MCPServer = class extends _mastra_core_mcp.MCPServerBase {
|
|
|
28540
26626
|
id: toolId,
|
|
28541
26627
|
name: tool.id || toolId,
|
|
28542
26628
|
description: tool.description,
|
|
28543
|
-
inputSchema: this.
|
|
26629
|
+
inputSchema: this.convertInputSchema(tool.parameters),
|
|
28544
26630
|
outputSchema: this.convertSchema(tool.outputSchema),
|
|
28545
26631
|
toolType: tool.mcp?.toolType,
|
|
28546
26632
|
_meta: withMastraToolStrictMeta(tool.mcp?._meta, tool.strict)
|
|
@@ -28580,7 +26666,7 @@ var MCPServer = class extends _mastra_core_mcp.MCPServerBase {
|
|
|
28580
26666
|
return {
|
|
28581
26667
|
name: tool.id || toolId,
|
|
28582
26668
|
description: tool.description,
|
|
28583
|
-
inputSchema: this.
|
|
26669
|
+
inputSchema: this.convertInputSchema(tool.parameters),
|
|
28584
26670
|
outputSchema: this.convertSchema(tool.outputSchema),
|
|
28585
26671
|
toolType: tool.mcp?.toolType,
|
|
28586
26672
|
_meta: withMastraToolStrictMeta(tool.mcp?._meta, tool.strict)
|