@modelcontextprotocol/inspector 2.1.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +170 -23
- package/clients/cli/build/index.js +1696 -475
- package/clients/tui/build/index.js +4002 -715
- package/clients/tui/build/{undici-HXPKCIY3.js → undici-KNXAVD2F.js} +1225 -370
- package/clients/web/build/index.js +262 -59
- package/clients/web/build/{undici-HXPKCIY3.js → undici-KNXAVD2F.js} +1225 -370
- package/clients/web/dist/assets/index-CwhDusR3.js +237 -0
- package/clients/web/dist/assets/{prism-light-CCFFzO_n.js → prism-light-DBxbqjnM.js} +1 -1
- package/clients/web/dist/index.html +1 -1
- package/clients/web/static/sandbox_proxy.html +237 -0
- package/package.json +13 -14
- package/clients/web/dist/assets/index-CyPh2pEE.js +0 -300
|
@@ -83,9 +83,6 @@ function withConnectTimeout(settings, connectionTimeout) {
|
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
// ../../core/auth/node/secret-store.ts
|
|
87
|
-
import { AsyncEntry, findCredentialsAsync } from "@napi-rs/keyring";
|
|
88
|
-
|
|
89
86
|
// ../../core/auth/secret-fields.ts
|
|
90
87
|
var SECRET_FIELD_OAUTH_CLIENT_SECRET = "oauth-client-secret";
|
|
91
88
|
var SECRET_FIELD_IDP_CLIENT_SECRET = "idp-client-secret";
|
|
@@ -93,6 +90,41 @@ var envSecretField = (envKey) => `env:${envKey}`;
|
|
|
93
90
|
|
|
94
91
|
// ../../core/auth/node/secret-store.ts
|
|
95
92
|
var SERVICE_NAME = "mcp-inspector";
|
|
93
|
+
var keyringLoad;
|
|
94
|
+
var KeyringModuleShapeError = class extends Error {
|
|
95
|
+
constructor(detail, options) {
|
|
96
|
+
super(`@napi-rs/keyring loaded but ${detail}`, options);
|
|
97
|
+
this.name = "KeyringModuleShapeError";
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
var checkKeyringShape = (mod) => {
|
|
101
|
+
try {
|
|
102
|
+
if (typeof mod.AsyncEntry === "function" && typeof mod.findCredentialsAsync === "function") {
|
|
103
|
+
return { ok: true, mod };
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
ok: false,
|
|
107
|
+
err: new KeyringModuleShapeError(
|
|
108
|
+
"did not expose AsyncEntry / findCredentialsAsync"
|
|
109
|
+
)
|
|
110
|
+
};
|
|
111
|
+
} catch (err) {
|
|
112
|
+
return {
|
|
113
|
+
ok: false,
|
|
114
|
+
err: new KeyringModuleShapeError(
|
|
115
|
+
`its exports could not be read: ${err instanceof Error ? err.message : String(err)}`,
|
|
116
|
+
{ cause: err }
|
|
117
|
+
)
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
var loadKeyring = () => {
|
|
122
|
+
keyringLoad ??= import("@napi-rs/keyring").then(
|
|
123
|
+
checkKeyringShape,
|
|
124
|
+
(err) => ({ ok: false, err })
|
|
125
|
+
);
|
|
126
|
+
return keyringLoad;
|
|
127
|
+
};
|
|
96
128
|
function parseAccount(account) {
|
|
97
129
|
const idx = account.indexOf(":");
|
|
98
130
|
if (idx <= 0 || idx === account.length - 1) return null;
|
|
@@ -104,16 +136,31 @@ function parseAccount(account) {
|
|
|
104
136
|
var buildAccount = (serverId, field) => `${serverId}:${field}`;
|
|
105
137
|
var KeychainUnavailableError = class extends Error {
|
|
106
138
|
constructor(cause) {
|
|
139
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
107
140
|
super(
|
|
108
|
-
`OS keychain is not available.
|
|
141
|
+
`OS keychain is not available. ${hintFor(cause, message)} Underlying error: ${message}`
|
|
109
142
|
);
|
|
110
143
|
this.name = "KeychainUnavailableError";
|
|
111
144
|
}
|
|
112
145
|
};
|
|
146
|
+
var hintFor = (cause, message) => {
|
|
147
|
+
if (cause instanceof KeyringModuleShapeError) {
|
|
148
|
+
return `The @napi-rs/keyring package loaded but does not expose the API this build expects \u2014 most likely a version or packaging mismatch; reinstall the Inspector, and report this if it persists.`;
|
|
149
|
+
}
|
|
150
|
+
if (message.includes("Cannot find native binding")) {
|
|
151
|
+
return `The @napi-rs/keyring platform package for this OS is missing or unavailable \u2014 reinstall the Inspector (for npx, clear the npx cache under your npm cache directory first).`;
|
|
152
|
+
}
|
|
153
|
+
return `On Linux, install libsecret / gnome-keyring.`;
|
|
154
|
+
};
|
|
113
155
|
var KeyringSecretStore = class {
|
|
114
156
|
async get(serverId, field) {
|
|
115
|
-
const entry = new AsyncEntry(SERVICE_NAME, buildAccount(serverId, field));
|
|
116
157
|
try {
|
|
158
|
+
const keyring = await loadKeyring();
|
|
159
|
+
if (!keyring.ok) return null;
|
|
160
|
+
const entry = new keyring.mod.AsyncEntry(
|
|
161
|
+
SERVICE_NAME,
|
|
162
|
+
buildAccount(serverId, field)
|
|
163
|
+
);
|
|
117
164
|
const v2 = await entry.getPassword();
|
|
118
165
|
return v2 ?? null;
|
|
119
166
|
} catch {
|
|
@@ -121,16 +168,27 @@ var KeyringSecretStore = class {
|
|
|
121
168
|
}
|
|
122
169
|
}
|
|
123
170
|
async set(serverId, field, value) {
|
|
124
|
-
const entry = new AsyncEntry(SERVICE_NAME, buildAccount(serverId, field));
|
|
125
171
|
try {
|
|
172
|
+
const keyring = await loadKeyring();
|
|
173
|
+
if (!keyring.ok) throw new KeychainUnavailableError(keyring.err);
|
|
174
|
+
const entry = new keyring.mod.AsyncEntry(
|
|
175
|
+
SERVICE_NAME,
|
|
176
|
+
buildAccount(serverId, field)
|
|
177
|
+
);
|
|
126
178
|
await entry.setPassword(value);
|
|
127
179
|
} catch (err) {
|
|
180
|
+
if (err instanceof KeychainUnavailableError) throw err;
|
|
128
181
|
throw new KeychainUnavailableError(err);
|
|
129
182
|
}
|
|
130
183
|
}
|
|
131
184
|
async delete(serverId, field) {
|
|
132
|
-
const entry = new AsyncEntry(SERVICE_NAME, buildAccount(serverId, field));
|
|
133
185
|
try {
|
|
186
|
+
const keyring = await loadKeyring();
|
|
187
|
+
if (!keyring.ok) return;
|
|
188
|
+
const entry = new keyring.mod.AsyncEntry(
|
|
189
|
+
SERVICE_NAME,
|
|
190
|
+
buildAccount(serverId, field)
|
|
191
|
+
);
|
|
134
192
|
await entry.deleteCredential();
|
|
135
193
|
} catch {
|
|
136
194
|
}
|
|
@@ -138,7 +196,9 @@ var KeyringSecretStore = class {
|
|
|
138
196
|
async deleteAllForServer(serverId) {
|
|
139
197
|
let creds;
|
|
140
198
|
try {
|
|
141
|
-
|
|
199
|
+
const keyring = await loadKeyring();
|
|
200
|
+
if (!keyring.ok) return;
|
|
201
|
+
creds = await keyring.mod.findCredentialsAsync(SERVICE_NAME);
|
|
142
202
|
} catch {
|
|
143
203
|
return;
|
|
144
204
|
}
|
|
@@ -347,6 +407,60 @@ function cleanRoots(roots) {
|
|
|
347
407
|
function envRecordToPairs(env) {
|
|
348
408
|
return env ? Object.entries(env).map(([key, value]) => ({ key, value })) : [];
|
|
349
409
|
}
|
|
410
|
+
function envPairsToRecord(pairs) {
|
|
411
|
+
const out = {};
|
|
412
|
+
for (const { key, value } of pairs) {
|
|
413
|
+
if (key.trim() === "") continue;
|
|
414
|
+
out[key] = value;
|
|
415
|
+
}
|
|
416
|
+
return out;
|
|
417
|
+
}
|
|
418
|
+
function cleanAuthorizationParams(params) {
|
|
419
|
+
if (params === void 0) return void 0;
|
|
420
|
+
if (typeof params !== "object" || params === null || Array.isArray(params)) {
|
|
421
|
+
console.warn(
|
|
422
|
+
"Ignoring `oauth.authorizationParams`: expected an object of string values, got",
|
|
423
|
+
Array.isArray(params) ? "array" : typeof params
|
|
424
|
+
);
|
|
425
|
+
return void 0;
|
|
426
|
+
}
|
|
427
|
+
const out = {};
|
|
428
|
+
for (const [key, value] of Object.entries(params)) {
|
|
429
|
+
if (typeof value !== "string") {
|
|
430
|
+
console.warn(
|
|
431
|
+
`Dropping \`oauth.authorizationParams.${key}\`: expected a string value, got ${typeof value}.`
|
|
432
|
+
);
|
|
433
|
+
continue;
|
|
434
|
+
}
|
|
435
|
+
if (key.trim() === "") continue;
|
|
436
|
+
out[key] = value;
|
|
437
|
+
}
|
|
438
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
439
|
+
}
|
|
440
|
+
function oauthAuthorizationParamsFromSettings(settings) {
|
|
441
|
+
if (!settings.oauthAuthorizationParams) return void 0;
|
|
442
|
+
const record2 = envPairsToRecord(settings.oauthAuthorizationParams);
|
|
443
|
+
return Object.keys(record2).length > 0 ? record2 : void 0;
|
|
444
|
+
}
|
|
445
|
+
function cleanEndpointOverride(value, field) {
|
|
446
|
+
if (value === void 0) return void 0;
|
|
447
|
+
if (typeof value !== "string") {
|
|
448
|
+
console.warn(
|
|
449
|
+
`Ignoring \`oauth.${field}\`: expected a string, got ${typeof value}.`
|
|
450
|
+
);
|
|
451
|
+
return void 0;
|
|
452
|
+
}
|
|
453
|
+
return value.trim() || void 0;
|
|
454
|
+
}
|
|
455
|
+
function oauthEndpointOverridesFromSettings(settings) {
|
|
456
|
+
const authorizationUrl = settings.oauthAuthorizationUrl?.trim();
|
|
457
|
+
const tokenUrl = settings.oauthTokenUrl?.trim();
|
|
458
|
+
if (!authorizationUrl && !tokenUrl) return void 0;
|
|
459
|
+
return {
|
|
460
|
+
...authorizationUrl && { authorizationUrl },
|
|
461
|
+
...tokenUrl && { tokenUrl }
|
|
462
|
+
};
|
|
463
|
+
}
|
|
350
464
|
function storedFieldsToInspectorSettings(stored) {
|
|
351
465
|
const hasAny = stored.headers !== void 0 || stored.metadata !== void 0 || stored.connectionTimeout !== void 0 || stored.requestTimeout !== void 0 || stored.taskTtl !== void 0 || stored.autoRefreshOnListChanged !== void 0 || stored.paginatedLists !== void 0 || stored.advertisedExtensions !== void 0 || stored.maxFetchRequests !== void 0 || stored.oauth !== void 0 || stored.roots !== void 0 || stored.protocolEra !== void 0 || stored.modernLogLevel !== void 0 || stored.env !== void 0 || stored.cwd !== void 0;
|
|
352
466
|
if (!hasAny) return void 0;
|
|
@@ -384,6 +498,19 @@ function storedFieldsToInspectorSettings(stored) {
|
|
|
384
498
|
if (stored.oauth?.clientSecret)
|
|
385
499
|
settings.oauthClientSecret = stored.oauth.clientSecret;
|
|
386
500
|
if (stored.oauth?.scopes) settings.oauthScopes = stored.oauth.scopes;
|
|
501
|
+
const authorizationParams = cleanAuthorizationParams(
|
|
502
|
+
stored.oauth?.authorizationParams
|
|
503
|
+
);
|
|
504
|
+
if (authorizationParams) {
|
|
505
|
+
settings.oauthAuthorizationParams = envRecordToPairs(authorizationParams);
|
|
506
|
+
}
|
|
507
|
+
const authorizationUrl = cleanEndpointOverride(
|
|
508
|
+
stored.oauth?.authorizationUrl,
|
|
509
|
+
"authorizationUrl"
|
|
510
|
+
);
|
|
511
|
+
if (authorizationUrl) settings.oauthAuthorizationUrl = authorizationUrl;
|
|
512
|
+
const tokenUrl = cleanEndpointOverride(stored.oauth?.tokenUrl, "tokenUrl");
|
|
513
|
+
if (tokenUrl) settings.oauthTokenUrl = tokenUrl;
|
|
387
514
|
if (stored.oauth?.onInsufficientScope) {
|
|
388
515
|
settings.oauthOnInsufficientScope = stored.oauth.onInsufficientScope;
|
|
389
516
|
}
|
|
@@ -2479,7 +2606,10 @@ import {
|
|
|
2479
2606
|
ListToolsResultSchema,
|
|
2480
2607
|
ListResourcesResultSchema,
|
|
2481
2608
|
ListResourceTemplatesResultSchema,
|
|
2482
|
-
ListPromptsResultSchema
|
|
2609
|
+
ListPromptsResultSchema,
|
|
2610
|
+
ResourceSchema,
|
|
2611
|
+
ResourceTemplateSchema,
|
|
2612
|
+
PromptSchema
|
|
2483
2613
|
} from "@modelcontextprotocol/core";
|
|
2484
2614
|
import { AjvJsonSchemaValidator } from "@modelcontextprotocol/client/validators/ajv";
|
|
2485
2615
|
|
|
@@ -2499,16 +2629,322 @@ function validateToolOutput(provider, tool, result) {
|
|
|
2499
2629
|
}
|
|
2500
2630
|
}
|
|
2501
2631
|
|
|
2632
|
+
// ../../core/mcp/listSalvage.ts
|
|
2633
|
+
import { z as z2 } from "zod/v4";
|
|
2634
|
+
import { SdkError, SdkErrorCode } from "@modelcontextprotocol/client";
|
|
2635
|
+
import { ToolSchema } from "@modelcontextprotocol/core";
|
|
2636
|
+
var LIST_MAX_PAGES = 64;
|
|
2637
|
+
function listPaginationExceeded(method) {
|
|
2638
|
+
return new Error(
|
|
2639
|
+
`Salvage walk for ${method} exceeded ${LIST_MAX_PAGES} pages without the server's pagination converging`
|
|
2640
|
+
);
|
|
2641
|
+
}
|
|
2642
|
+
function isClientDecodeRejection(err) {
|
|
2643
|
+
return SdkError.isInstance(err) && (err.code === SdkErrorCode.InvalidResult || err.code === SdkErrorCode.UnsupportedResultType);
|
|
2644
|
+
}
|
|
2645
|
+
function isSalvageableRejection(err) {
|
|
2646
|
+
return SdkError.isInstance(err) && err.code === SdkErrorCode.InvalidResult;
|
|
2647
|
+
}
|
|
2648
|
+
function lenientListPageSchema(resultSchema, itemsKey) {
|
|
2649
|
+
return resultSchema.extend({ [itemsKey]: z2.array(z2.unknown()) });
|
|
2650
|
+
}
|
|
2651
|
+
function nextCursorOf(page) {
|
|
2652
|
+
if (typeof page !== "object" || page === null) return void 0;
|
|
2653
|
+
const value = page.nextCursor;
|
|
2654
|
+
return typeof value === "string" ? value : void 0;
|
|
2655
|
+
}
|
|
2656
|
+
var ModernResultEnvelopeSchema = z2.looseObject({
|
|
2657
|
+
resultType: z2.literal("complete"),
|
|
2658
|
+
// A non-negative INTEGER, matching the codec: `ttlMs: -1` or `0.5` is an
|
|
2659
|
+
// envelope violation the strict path rejects, and accepting it here on the
|
|
2660
|
+
// strength of an unrelated bad entry would hide it.
|
|
2661
|
+
ttlMs: z2.int().min(0),
|
|
2662
|
+
cacheScope: z2.enum(["public", "private"])
|
|
2663
|
+
});
|
|
2664
|
+
function rawItemsOf(page, itemsKey) {
|
|
2665
|
+
if (typeof page !== "object" || page === null) return void 0;
|
|
2666
|
+
const value = page[itemsKey];
|
|
2667
|
+
return Array.isArray(value) ? value : void 0;
|
|
2668
|
+
}
|
|
2669
|
+
function labelForRawItem(value) {
|
|
2670
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
2671
|
+
const record2 = value;
|
|
2672
|
+
for (const key of ["name", "uriTemplate", "uri", "title"]) {
|
|
2673
|
+
const candidate = record2[key];
|
|
2674
|
+
if (typeof candidate === "string" && candidate.length > 0) return candidate;
|
|
2675
|
+
}
|
|
2676
|
+
return void 0;
|
|
2677
|
+
}
|
|
2678
|
+
function describeIssues(error) {
|
|
2679
|
+
const [issue] = error.issues;
|
|
2680
|
+
if (!issue) return "did not match the expected shape";
|
|
2681
|
+
const path2 = issue.path.join(".");
|
|
2682
|
+
const detail = expectedDetail(issue);
|
|
2683
|
+
const message = detail ? `${issue.message} (${detail})` : issue.message;
|
|
2684
|
+
return path2.length > 0 ? `${path2}: ${message}` : message;
|
|
2685
|
+
}
|
|
2686
|
+
function expectedDetail(issue) {
|
|
2687
|
+
if (!("expected" in issue) || typeof issue.expected !== "string") {
|
|
2688
|
+
return void 0;
|
|
2689
|
+
}
|
|
2690
|
+
const detail = `expected ${issue.expected}`;
|
|
2691
|
+
return issue.message.includes(detail) ? void 0 : detail;
|
|
2692
|
+
}
|
|
2693
|
+
function salvageListItems({
|
|
2694
|
+
method,
|
|
2695
|
+
items,
|
|
2696
|
+
schema,
|
|
2697
|
+
startIndex = 0
|
|
2698
|
+
}) {
|
|
2699
|
+
const valid = [];
|
|
2700
|
+
const malformed = [];
|
|
2701
|
+
items.forEach((item, offset) => {
|
|
2702
|
+
const parsed = schema.safeParse(item);
|
|
2703
|
+
if (parsed.success) {
|
|
2704
|
+
valid.push(parsed.data);
|
|
2705
|
+
return;
|
|
2706
|
+
}
|
|
2707
|
+
const label = labelForRawItem(item);
|
|
2708
|
+
malformed.push({
|
|
2709
|
+
method,
|
|
2710
|
+
index: startIndex + offset,
|
|
2711
|
+
...label !== void 0 && { label },
|
|
2712
|
+
reason: describeIssues(parsed.error)
|
|
2713
|
+
});
|
|
2714
|
+
});
|
|
2715
|
+
return { valid, malformed };
|
|
2716
|
+
}
|
|
2717
|
+
function summarizeMalformed(malformed) {
|
|
2718
|
+
const [first] = malformed;
|
|
2719
|
+
if (!first) return "";
|
|
2720
|
+
const where = first.label ?? `index ${first.index}`;
|
|
2721
|
+
const rest = malformed.length > 1 ? ` (+${malformed.length - 1} more)` : "";
|
|
2722
|
+
return `Dropped ${malformed.length} malformed ${malformed.length === 1 ? "entry" : "entries"} \u2014 ${where}: ${first.reason}${rest}`;
|
|
2723
|
+
}
|
|
2724
|
+
function toolItemSchemaForEra(isModern) {
|
|
2725
|
+
return isModern ? eraToolItemSchema(ModernToolWireSchema, stripExecution) : eraToolItemSchema(LegacyToolWireSchema, (tool) => tool);
|
|
2726
|
+
}
|
|
2727
|
+
var LegacyToolWireSchema = ToolSchema.extend({
|
|
2728
|
+
outputSchema: ToolSchema.shape.inputSchema.optional()
|
|
2729
|
+
});
|
|
2730
|
+
var ModernToolWireSchema = ToolSchema.extend({
|
|
2731
|
+
inputSchema: z2.looseObject({
|
|
2732
|
+
type: z2.literal("object"),
|
|
2733
|
+
$schema: z2.string().optional()
|
|
2734
|
+
})
|
|
2735
|
+
});
|
|
2736
|
+
function stripExecution(tool) {
|
|
2737
|
+
if (tool.execution === void 0) return tool;
|
|
2738
|
+
const { execution: _execution, ...rest } = tool;
|
|
2739
|
+
return rest;
|
|
2740
|
+
}
|
|
2741
|
+
function eraToolItemSchema(wire, normalize) {
|
|
2742
|
+
return wire.transform((parsed) => normalize(parsed));
|
|
2743
|
+
}
|
|
2744
|
+
|
|
2502
2745
|
// ../../core/mcp/taskNotificationSchemas.ts
|
|
2503
2746
|
import { NotificationSchema } from "@modelcontextprotocol/core";
|
|
2504
|
-
import { z as
|
|
2747
|
+
import { z as z3 } from "zod/v4";
|
|
2505
2748
|
var TasksListChangedNotificationSchema = NotificationSchema.extend({
|
|
2506
|
-
method:
|
|
2507
|
-
params:
|
|
2749
|
+
method: z3.literal("notifications/tasks/list_changed"),
|
|
2750
|
+
params: z3.record(z3.string(), z3.unknown()).optional()
|
|
2508
2751
|
});
|
|
2509
2752
|
|
|
2510
|
-
// ../../core/mcp/
|
|
2753
|
+
// ../../core/mcp/uriTemplate.ts
|
|
2511
2754
|
import { UriTemplate } from "@modelcontextprotocol/client";
|
|
2755
|
+
var OPERATORS = ["+", "#", ".", "/", ";", "?", "&"];
|
|
2756
|
+
var NAMED_OPERATORS = /* @__PURE__ */ new Set([";", "?", "&"]);
|
|
2757
|
+
var VARCHAR = String.raw`(?:[A-Za-z0-9_]|%[0-9A-Fa-f]{2})`;
|
|
2758
|
+
var TOLERATED_VARCHAR = String.raw`[-~]`;
|
|
2759
|
+
function varnameGrammar(varchar) {
|
|
2760
|
+
return `${varchar}(?:\\.?${varchar})*`;
|
|
2761
|
+
}
|
|
2762
|
+
var MODIFIER = String.raw`(?:\*|:([1-9][0-9]{0,3}))?`;
|
|
2763
|
+
var CONFORMING_VARSPEC = new RegExp(
|
|
2764
|
+
`^(${varnameGrammar(VARCHAR)})${MODIFIER}$`
|
|
2765
|
+
);
|
|
2766
|
+
var TOLERATED_VARSPEC = new RegExp(
|
|
2767
|
+
`^(${varnameGrammar(`(?:${VARCHAR}|${TOLERATED_VARCHAR})`)})${MODIFIER}$`
|
|
2768
|
+
);
|
|
2769
|
+
function parseVarSpec(raw) {
|
|
2770
|
+
const conforming = CONFORMING_VARSPEC.exec(raw);
|
|
2771
|
+
const match = conforming ?? TOLERATED_VARSPEC.exec(raw);
|
|
2772
|
+
if (match === null) return "invalid";
|
|
2773
|
+
const [, name, maxLength] = match;
|
|
2774
|
+
return {
|
|
2775
|
+
name,
|
|
2776
|
+
...maxLength === void 0 ? {} : { maxLength: +maxLength },
|
|
2777
|
+
...conforming === null ? { conforming: false } : {}
|
|
2778
|
+
};
|
|
2779
|
+
}
|
|
2780
|
+
function parseUriTemplate(uriTemplate) {
|
|
2781
|
+
const parts = [];
|
|
2782
|
+
let literal2 = "";
|
|
2783
|
+
let i2 = 0;
|
|
2784
|
+
while (i2 < uriTemplate.length) {
|
|
2785
|
+
if (uriTemplate[i2] !== "{") {
|
|
2786
|
+
literal2 += uriTemplate[i2];
|
|
2787
|
+
i2 += 1;
|
|
2788
|
+
continue;
|
|
2789
|
+
}
|
|
2790
|
+
const end = uriTemplate.indexOf("}", i2);
|
|
2791
|
+
if (end === -1) {
|
|
2792
|
+
literal2 += uriTemplate.slice(i2);
|
|
2793
|
+
break;
|
|
2794
|
+
}
|
|
2795
|
+
if (literal2) {
|
|
2796
|
+
parts.push({ kind: "literal", text: literal2 });
|
|
2797
|
+
literal2 = "";
|
|
2798
|
+
}
|
|
2799
|
+
const body = uriTemplate.slice(i2 + 1, end);
|
|
2800
|
+
const operator = OPERATORS.find((op) => body.startsWith(op)) ?? "";
|
|
2801
|
+
const parsed = body.slice(operator.length).split(",").map(parseVarSpec);
|
|
2802
|
+
const varspecs = parsed.filter(
|
|
2803
|
+
(spec) => spec !== "invalid"
|
|
2804
|
+
);
|
|
2805
|
+
parts.push({
|
|
2806
|
+
kind: "expression",
|
|
2807
|
+
source: uriTemplate.slice(i2, end + 1),
|
|
2808
|
+
operator,
|
|
2809
|
+
varspecs,
|
|
2810
|
+
names: varspecs.map((spec) => spec.name),
|
|
2811
|
+
invalid: parsed.includes("invalid")
|
|
2812
|
+
});
|
|
2813
|
+
i2 = end + 1;
|
|
2814
|
+
}
|
|
2815
|
+
if (literal2) parts.push({ kind: "literal", text: literal2 });
|
|
2816
|
+
return parts;
|
|
2817
|
+
}
|
|
2818
|
+
function readValue(values, name) {
|
|
2819
|
+
return Object.hasOwn(values, name) ? values[name] : void 0;
|
|
2820
|
+
}
|
|
2821
|
+
var ALLOW_RESERVED = /[^A-Za-z0-9\-._~:/?#[\]@!$&'()*+,;=]/gu;
|
|
2822
|
+
function encodeLiteral(text) {
|
|
2823
|
+
return text.split(/([{}])/g).map(
|
|
2824
|
+
(chunk, index) => index % 2 === 1 ? chunk : encodeAllowReserved(chunk)
|
|
2825
|
+
).join("");
|
|
2826
|
+
}
|
|
2827
|
+
function encodeAllowReserved(value) {
|
|
2828
|
+
return value.split(/(%[0-9A-Fa-f]{2})/g).map(
|
|
2829
|
+
(chunk, index) => index % 2 === 1 ? chunk : chunk.replace(ALLOW_RESERVED, (char) => encodeURIComponent(char))
|
|
2830
|
+
).join("");
|
|
2831
|
+
}
|
|
2832
|
+
var FORCE_ENCODED = {
|
|
2833
|
+
"!": "%21",
|
|
2834
|
+
"'": "%27",
|
|
2835
|
+
"(": "%28",
|
|
2836
|
+
")": "%29",
|
|
2837
|
+
"*": "%2A"
|
|
2838
|
+
};
|
|
2839
|
+
function encodeUnreserved(value) {
|
|
2840
|
+
return encodeURIComponent(value).replace(
|
|
2841
|
+
/[!'()*]/g,
|
|
2842
|
+
(char) => FORCE_ENCODED[char]
|
|
2843
|
+
);
|
|
2844
|
+
}
|
|
2845
|
+
function allowsReserved(operator) {
|
|
2846
|
+
return operator === "+" || operator === "#";
|
|
2847
|
+
}
|
|
2848
|
+
function encodeValue(value, operator) {
|
|
2849
|
+
return allowsReserved(operator) ? encodeAllowReserved(value) : encodeUnreserved(value);
|
|
2850
|
+
}
|
|
2851
|
+
var CONTINUATION = String.raw`%[89AB][0-9A-F]`;
|
|
2852
|
+
var UTF8_SEQUENCE = [
|
|
2853
|
+
String.raw`(?:%F0%(?:9[0-9A-F]|[AB][0-9A-F])|%F[1-3]${CONTINUATION}|%F4%8[0-9A-F])${CONTINUATION}${CONTINUATION}`,
|
|
2854
|
+
String.raw`(?:%E0%[AB][0-9A-F]|%E[1-9ABCEF]${CONTINUATION}|%ED%[89][0-9A-F])${CONTINUATION}`,
|
|
2855
|
+
String.raw`%(?:C[2-9A-F]|D[0-9A-F])${CONTINUATION}`
|
|
2856
|
+
].join("|");
|
|
2857
|
+
var PREFIX_UNIT = new RegExp(`${UTF8_SEQUENCE}|%[0-9A-F]{2}|[\\s\\S]`, "giu");
|
|
2858
|
+
function prefixUnits(value) {
|
|
2859
|
+
return value.match(PREFIX_UNIT) ?? [];
|
|
2860
|
+
}
|
|
2861
|
+
function renderValue(value, spec, operator) {
|
|
2862
|
+
const truncated = spec.maxLength === void 0 ? value : prefixUnits(value).slice(0, spec.maxLength).join("");
|
|
2863
|
+
return encodeValue(truncated, operator);
|
|
2864
|
+
}
|
|
2865
|
+
function expandTemplateExpression(part, values) {
|
|
2866
|
+
const present = part.varspecs.flatMap((spec) => {
|
|
2867
|
+
const value = readValue(values, spec.name);
|
|
2868
|
+
return value === void 0 ? [] : [{ spec, value }];
|
|
2869
|
+
});
|
|
2870
|
+
if (present.length === 0) return "";
|
|
2871
|
+
const { operator } = part;
|
|
2872
|
+
if (NAMED_OPERATORS.has(operator)) {
|
|
2873
|
+
const pairs = present.map(({ spec, value }) => {
|
|
2874
|
+
const rendered2 = renderValue(value, spec, operator);
|
|
2875
|
+
return operator === ";" && rendered2.length === 0 ? spec.name : `${spec.name}=${rendered2}`;
|
|
2876
|
+
});
|
|
2877
|
+
return operator === ";" ? `;${pairs.join(";")}` : `${operator}${pairs.join("&")}`;
|
|
2878
|
+
}
|
|
2879
|
+
const rendered = present.map(
|
|
2880
|
+
({ spec, value }) => renderValue(value, spec, operator)
|
|
2881
|
+
);
|
|
2882
|
+
switch (operator) {
|
|
2883
|
+
case "#":
|
|
2884
|
+
return `#${rendered.join(",")}`;
|
|
2885
|
+
case ".":
|
|
2886
|
+
return `.${rendered.join(".")}`;
|
|
2887
|
+
case "/":
|
|
2888
|
+
return `/${rendered.join("/")}`;
|
|
2889
|
+
// "" and "+" — a bare comma-joined list, no prefix.
|
|
2890
|
+
default:
|
|
2891
|
+
return rendered.join(",");
|
|
2892
|
+
}
|
|
2893
|
+
}
|
|
2894
|
+
function expandParts(parts, values) {
|
|
2895
|
+
return parts.map(
|
|
2896
|
+
(part) => part.kind === "literal" ? encodeLiteral(part.text) : expandTemplateExpression(part, values)
|
|
2897
|
+
).join("");
|
|
2898
|
+
}
|
|
2899
|
+
function expandUriTemplateStrict(uriTemplate, values) {
|
|
2900
|
+
const sdk = sdkTemplateError(uriTemplate);
|
|
2901
|
+
if (sdk) throw new Error(sdk);
|
|
2902
|
+
const parts = parseUriTemplate(uriTemplate);
|
|
2903
|
+
const invalid = partsError(uriTemplate, parts);
|
|
2904
|
+
if (invalid) throw new Error(invalid);
|
|
2905
|
+
const tooLong = valueLengthError(values, declaredNames(parts));
|
|
2906
|
+
if (tooLong) throw new Error(tooLong);
|
|
2907
|
+
return expandParts(parts, values);
|
|
2908
|
+
}
|
|
2909
|
+
function sdkTemplateError(uriTemplate) {
|
|
2910
|
+
try {
|
|
2911
|
+
new UriTemplate(uriTemplate);
|
|
2912
|
+
return null;
|
|
2913
|
+
} catch (error) {
|
|
2914
|
+
return error instanceof Error ? error.message : String(error);
|
|
2915
|
+
}
|
|
2916
|
+
}
|
|
2917
|
+
function partsError(uriTemplate, parts) {
|
|
2918
|
+
const stray = parts.find(
|
|
2919
|
+
(part) => part.kind === "literal" && /[{}]/.test(part.text)
|
|
2920
|
+
);
|
|
2921
|
+
if (stray) {
|
|
2922
|
+
return `Unmatched brace in "${uriTemplate}" \u2014 an expression must be a complete {\u2026}.`;
|
|
2923
|
+
}
|
|
2924
|
+
const bad = parts.find((part) => part.kind === "expression" && part.invalid);
|
|
2925
|
+
if (bad) {
|
|
2926
|
+
return `Invalid RFC 6570 varspec in "${uriTemplate}": ${bad.kind === "expression" ? bad.source : ""} \u2014 each varspec must name a variable, optionally with an explode (*) or a 1-9999 prefix modifier.`;
|
|
2927
|
+
}
|
|
2928
|
+
return null;
|
|
2929
|
+
}
|
|
2930
|
+
var MAX_VALUE_LENGTH = 1e6;
|
|
2931
|
+
function valueLengthError(values, names) {
|
|
2932
|
+
const considered = names === void 0 ? Object.keys(values) : [...new Set(names)];
|
|
2933
|
+
for (const name of considered) {
|
|
2934
|
+
const value = readValue(values, name);
|
|
2935
|
+
if (value !== void 0 && value.length > MAX_VALUE_LENGTH) {
|
|
2936
|
+
return `The value for "${name}" exceeds the ${MAX_VALUE_LENGTH}-character limit.`;
|
|
2937
|
+
}
|
|
2938
|
+
}
|
|
2939
|
+
return null;
|
|
2940
|
+
}
|
|
2941
|
+
function declaredNames(parts) {
|
|
2942
|
+
return [
|
|
2943
|
+
...new Set(
|
|
2944
|
+
parts.flatMap((part) => part.kind === "expression" ? part.names : [])
|
|
2945
|
+
)
|
|
2946
|
+
];
|
|
2947
|
+
}
|
|
2512
2948
|
|
|
2513
2949
|
// ../../core/mcp/typedEventTarget.ts
|
|
2514
2950
|
var TypedEventGeneric = class extends CustomEvent {
|
|
@@ -2775,6 +3211,136 @@ var ToolCallCancelledError = class extends Error {
|
|
|
2775
3211
|
}
|
|
2776
3212
|
};
|
|
2777
3213
|
|
|
3214
|
+
// ../../core/auth/endpointOverrides.ts
|
|
3215
|
+
var OVERRIDE_FIELDS = {
|
|
3216
|
+
authorizationUrl: "authorization_endpoint",
|
|
3217
|
+
tokenUrl: "token_endpoint"
|
|
3218
|
+
};
|
|
3219
|
+
function oauthEndpointUrlError(value) {
|
|
3220
|
+
const trimmed = value.trim();
|
|
3221
|
+
if (trimmed === "") return void 0;
|
|
3222
|
+
let parsed;
|
|
3223
|
+
try {
|
|
3224
|
+
parsed = new URL(trimmed);
|
|
3225
|
+
} catch {
|
|
3226
|
+
return `"${trimmed}" is not an absolute URL.`;
|
|
3227
|
+
}
|
|
3228
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
3229
|
+
return `"${trimmed}" is not an http(s) URL.`;
|
|
3230
|
+
}
|
|
3231
|
+
if (parsed.username || parsed.password) {
|
|
3232
|
+
return "URL must not contain a username or password.";
|
|
3233
|
+
}
|
|
3234
|
+
return void 0;
|
|
3235
|
+
}
|
|
3236
|
+
function normalizeEndpointUrl(value, field) {
|
|
3237
|
+
if (value === void 0) return void 0;
|
|
3238
|
+
const trimmed = value.trim();
|
|
3239
|
+
if (trimmed === "") return void 0;
|
|
3240
|
+
const error = oauthEndpointUrlError(trimmed);
|
|
3241
|
+
if (error) {
|
|
3242
|
+
console.warn(`[oauth] Ignoring \`${field}\`: ${error}`);
|
|
3243
|
+
return void 0;
|
|
3244
|
+
}
|
|
3245
|
+
return trimmed;
|
|
3246
|
+
}
|
|
3247
|
+
function normalizeOAuthEndpointOverrides(overrides) {
|
|
3248
|
+
if (!overrides) return void 0;
|
|
3249
|
+
const authorizationUrl = normalizeEndpointUrl(
|
|
3250
|
+
overrides.authorizationUrl,
|
|
3251
|
+
"authorizationUrl"
|
|
3252
|
+
);
|
|
3253
|
+
const tokenUrl = normalizeEndpointUrl(overrides.tokenUrl, "tokenUrl");
|
|
3254
|
+
if (!authorizationUrl && !tokenUrl) return void 0;
|
|
3255
|
+
return {
|
|
3256
|
+
...authorizationUrl && { authorizationUrl },
|
|
3257
|
+
...tokenUrl && { tokenUrl }
|
|
3258
|
+
};
|
|
3259
|
+
}
|
|
3260
|
+
function isAuthorizationServerMetadata(value) {
|
|
3261
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
3262
|
+
return false;
|
|
3263
|
+
}
|
|
3264
|
+
const doc = value;
|
|
3265
|
+
if (typeof doc.issuer !== "string") return false;
|
|
3266
|
+
return typeof doc.authorization_endpoint === "string" || typeof doc.token_endpoint === "string";
|
|
3267
|
+
}
|
|
3268
|
+
function applyOAuthEndpointOverrides(metadata, overrides) {
|
|
3269
|
+
const patched = { ...metadata };
|
|
3270
|
+
for (const [key, field] of Object.entries(OVERRIDE_FIELDS)) {
|
|
3271
|
+
const override = overrides[key];
|
|
3272
|
+
if (override) patched[field] = override;
|
|
3273
|
+
}
|
|
3274
|
+
return patched;
|
|
3275
|
+
}
|
|
3276
|
+
var AS_METADATA_WELL_KNOWN_PATHS = [
|
|
3277
|
+
"/.well-known/oauth-authorization-server",
|
|
3278
|
+
"/.well-known/openid-configuration"
|
|
3279
|
+
];
|
|
3280
|
+
function requestUrlOf(input) {
|
|
3281
|
+
if (typeof input === "string") return input;
|
|
3282
|
+
if (input instanceof URL) return input.href;
|
|
3283
|
+
return input.url;
|
|
3284
|
+
}
|
|
3285
|
+
function isAuthorizationServerMetadataRequest(input) {
|
|
3286
|
+
const raw = requestUrlOf(input);
|
|
3287
|
+
let pathname;
|
|
3288
|
+
try {
|
|
3289
|
+
pathname = new URL(raw).pathname;
|
|
3290
|
+
} catch {
|
|
3291
|
+
pathname = raw;
|
|
3292
|
+
}
|
|
3293
|
+
return AS_METADATA_WELL_KNOWN_PATHS.some((path2) => pathname.includes(path2));
|
|
3294
|
+
}
|
|
3295
|
+
function isJsonDocumentResponse(contentType) {
|
|
3296
|
+
if (!contentType) return false;
|
|
3297
|
+
const mediaType = contentType.split(";")[0].trim().toLowerCase();
|
|
3298
|
+
return mediaType === "application/json" || mediaType.endsWith("+json");
|
|
3299
|
+
}
|
|
3300
|
+
function responseWithBody(response, body) {
|
|
3301
|
+
const headers = new Headers(response.headers);
|
|
3302
|
+
headers.delete("content-length");
|
|
3303
|
+
headers.delete("content-encoding");
|
|
3304
|
+
return new Response(body, {
|
|
3305
|
+
status: response.status,
|
|
3306
|
+
statusText: response.statusText,
|
|
3307
|
+
headers
|
|
3308
|
+
});
|
|
3309
|
+
}
|
|
3310
|
+
function withOAuthEndpointOverrides(fetchFn, getOverrides) {
|
|
3311
|
+
let lastKey;
|
|
3312
|
+
let lastNormalized;
|
|
3313
|
+
const resolveOverrides = () => {
|
|
3314
|
+
const raw = getOverrides();
|
|
3315
|
+
const key = JSON.stringify([raw?.authorizationUrl, raw?.tokenUrl]);
|
|
3316
|
+
if (key !== lastKey) {
|
|
3317
|
+
lastKey = key;
|
|
3318
|
+
lastNormalized = normalizeOAuthEndpointOverrides(raw);
|
|
3319
|
+
}
|
|
3320
|
+
return lastNormalized;
|
|
3321
|
+
};
|
|
3322
|
+
return async (input, init) => {
|
|
3323
|
+
const response = await fetchFn(input, init);
|
|
3324
|
+
const overrides = resolveOverrides();
|
|
3325
|
+
if (!overrides) return response;
|
|
3326
|
+
if (!isAuthorizationServerMetadataRequest(input)) return response;
|
|
3327
|
+
if (!response.ok) return response;
|
|
3328
|
+
if (!isJsonDocumentResponse(response.headers.get("content-type")))
|
|
3329
|
+
return response;
|
|
3330
|
+
let parsed;
|
|
3331
|
+
try {
|
|
3332
|
+
parsed = await response.clone().json();
|
|
3333
|
+
} catch {
|
|
3334
|
+
return response;
|
|
3335
|
+
}
|
|
3336
|
+
if (!isAuthorizationServerMetadata(parsed)) return response;
|
|
3337
|
+
return responseWithBody(
|
|
3338
|
+
response,
|
|
3339
|
+
JSON.stringify(applyOAuthEndpointOverrides(parsed, overrides))
|
|
3340
|
+
);
|
|
3341
|
+
};
|
|
3342
|
+
}
|
|
3343
|
+
|
|
2778
3344
|
// ../../core/logging/logger.ts
|
|
2779
3345
|
var noop = () => {
|
|
2780
3346
|
};
|
|
@@ -2794,6 +3360,41 @@ function createSilentLogger() {
|
|
|
2794
3360
|
}
|
|
2795
3361
|
var silentLogger = createSilentLogger();
|
|
2796
3362
|
|
|
3363
|
+
// ../../core/auth/authorizationParams.ts
|
|
3364
|
+
var RESERVED_AUTHORIZATION_PARAMS = [
|
|
3365
|
+
"client_id",
|
|
3366
|
+
"code_challenge",
|
|
3367
|
+
"code_challenge_method",
|
|
3368
|
+
"redirect_uri",
|
|
3369
|
+
"resource",
|
|
3370
|
+
"response_type",
|
|
3371
|
+
"scope",
|
|
3372
|
+
"state"
|
|
3373
|
+
];
|
|
3374
|
+
var RESERVED = new Set(RESERVED_AUTHORIZATION_PARAMS);
|
|
3375
|
+
function isReservedAuthorizationParam(key) {
|
|
3376
|
+
return RESERVED.has(key.trim().toLowerCase());
|
|
3377
|
+
}
|
|
3378
|
+
function applyAuthorizationParams(authorizationUrl, params) {
|
|
3379
|
+
if (!params) return authorizationUrl;
|
|
3380
|
+
const applicable = Object.entries(params).filter(([key]) => {
|
|
3381
|
+
if (key.trim() === "") return false;
|
|
3382
|
+
if (isReservedAuthorizationParam(key)) {
|
|
3383
|
+
console.warn(
|
|
3384
|
+
`[oauth] Ignoring reserved authorization parameter "${key.trim()}" \u2014 it is set by the authorization flow.`
|
|
3385
|
+
);
|
|
3386
|
+
return false;
|
|
3387
|
+
}
|
|
3388
|
+
return true;
|
|
3389
|
+
});
|
|
3390
|
+
if (applicable.length === 0) return authorizationUrl;
|
|
3391
|
+
const merged = new URL(authorizationUrl.href);
|
|
3392
|
+
for (const [key, value] of applicable) {
|
|
3393
|
+
merged.searchParams.set(key.trim(), value);
|
|
3394
|
+
}
|
|
3395
|
+
return merged;
|
|
3396
|
+
}
|
|
3397
|
+
|
|
2797
3398
|
// ../../core/auth/providers.ts
|
|
2798
3399
|
var MutableRedirectUrlProvider = class {
|
|
2799
3400
|
redirectUrl = "";
|
|
@@ -2829,12 +3430,15 @@ var BaseOAuthClientProvider = class {
|
|
|
2829
3430
|
redirectUrlProvider;
|
|
2830
3431
|
navigation;
|
|
2831
3432
|
clientMetadataUrl;
|
|
3433
|
+
/** Custom authorization-request parameters (#2018). Authorize URL only. */
|
|
3434
|
+
authorizationParams;
|
|
2832
3435
|
constructor(serverUrl, oauthConfig) {
|
|
2833
3436
|
this.serverUrl = serverUrl;
|
|
2834
3437
|
this.storage = oauthConfig.storage;
|
|
2835
3438
|
this.redirectUrlProvider = oauthConfig.redirectUrlProvider;
|
|
2836
3439
|
this.navigation = oauthConfig.navigation;
|
|
2837
3440
|
this.clientMetadataUrl = oauthConfig.clientMetadataUrl;
|
|
3441
|
+
this.authorizationParams = oauthConfig.authorizationParams;
|
|
2838
3442
|
}
|
|
2839
3443
|
/**
|
|
2840
3444
|
* Load persisted scope into {@link cachedScope} before SDK `auth()` (which
|
|
@@ -2941,6 +3545,27 @@ var BaseOAuthClientProvider = class {
|
|
|
2941
3545
|
});
|
|
2942
3546
|
}
|
|
2943
3547
|
redirectToAuthorization(authorizationUrl) {
|
|
3548
|
+
this.performAuthorizationRedirect(
|
|
3549
|
+
applyAuthorizationParams(authorizationUrl, this.authorizationParams)
|
|
3550
|
+
);
|
|
3551
|
+
}
|
|
3552
|
+
/**
|
|
3553
|
+
* Redirect to an authorize URL belonging to a **different** authorization
|
|
3554
|
+
* server than the one this provider was configured for, so the per-server
|
|
3555
|
+
* custom parameters (#2018) MUST NOT be applied.
|
|
3556
|
+
*
|
|
3557
|
+
* The only caller is the enterprise-managed (EMA) transport provider, which
|
|
3558
|
+
* discards the resource AS URL and sends the user to the enterprise IdP
|
|
3559
|
+
* instead. Parameters a user configured for their MCP server's authorization
|
|
3560
|
+
* server — a `kc_idp_hint`, an `audience` — are meaningless and potentially
|
|
3561
|
+
* flow-breaking on the IdP's, and appending them there would leak per-server
|
|
3562
|
+
* config across an authorization-server boundary.
|
|
3563
|
+
*/
|
|
3564
|
+
redirectToExternalAuthorization(authorizationUrl) {
|
|
3565
|
+
this.performAuthorizationRedirect(authorizationUrl);
|
|
3566
|
+
}
|
|
3567
|
+
/** Capture, announce, and navigate to a finished authorize URL. */
|
|
3568
|
+
performAuthorizationRedirect(authorizationUrl) {
|
|
2944
3569
|
this.capturedAuthUrl = authorizationUrl;
|
|
2945
3570
|
if (!this.suppressAuthorizationNavigation) {
|
|
2946
3571
|
if (this.eventTarget) {
|
|
@@ -3805,7 +4430,7 @@ var EmaTransportOAuthProvider = class {
|
|
|
3805
4430
|
async redirectToAuthorization(_authorizationUrl) {
|
|
3806
4431
|
const idpAuthorizationUrl = await startEmaIdpAuthorization(this.emaConfig);
|
|
3807
4432
|
this.inner.clearCapturedAuthUrl();
|
|
3808
|
-
this.inner.
|
|
4433
|
+
this.inner.redirectToExternalAuthorization(idpAuthorizationUrl);
|
|
3809
4434
|
}
|
|
3810
4435
|
saveCodeVerifier(codeVerifier) {
|
|
3811
4436
|
return this.inner.saveCodeVerifier(codeVerifier);
|
|
@@ -3922,6 +4547,30 @@ var OAuthManager = class {
|
|
|
3922
4547
|
getServerUrl() {
|
|
3923
4548
|
return this.params.getServerUrl();
|
|
3924
4549
|
}
|
|
4550
|
+
/**
|
|
4551
|
+
* The per-server authorization/token endpoint overrides, read live so a
|
|
4552
|
+
* `setOAuthConfig` between requests takes effect without rebuilding the
|
|
4553
|
+
* client's fetch. `InspectorClient` reads this from inside its fetch wrapper.
|
|
4554
|
+
* (#1906)
|
|
4555
|
+
*
|
|
4556
|
+
* Returns nothing under enterprise-managed authorization, for the same reason
|
|
4557
|
+
* `redirectToExternalAuthorization` skips the custom authorization parameters
|
|
4558
|
+
* (#2018): the EMA leg authorizes against the enterprise IdP, a *different*
|
|
4559
|
+
* authorization server, and its OIDC discovery runs through this same fetch
|
|
4560
|
+
* (`emaFlow` → `idpOidc`). Rewriting that document would point the IdP login —
|
|
4561
|
+
* or the IdP code/refresh-token exchange — at the resource server's
|
|
4562
|
+
* authorization server, which is both wrong and a way to leak an IdP
|
|
4563
|
+
* credential across an authorization-server boundary.
|
|
4564
|
+
*/
|
|
4565
|
+
getEndpointOverrides() {
|
|
4566
|
+
if (this.isEnterpriseManaged()) return void 0;
|
|
4567
|
+
const { authorizationUrl, tokenUrl } = this.oauthConfig;
|
|
4568
|
+
if (!authorizationUrl && !tokenUrl) return void 0;
|
|
4569
|
+
return {
|
|
4570
|
+
...authorizationUrl && { authorizationUrl },
|
|
4571
|
+
...tokenUrl && { tokenUrl }
|
|
4572
|
+
};
|
|
4573
|
+
}
|
|
3925
4574
|
/**
|
|
3926
4575
|
* Return the configured OAuth storage, throwing a clear error if it is
|
|
3927
4576
|
* absent. Used on the EMA re-mint/persist paths, which are only reached for
|
|
@@ -3945,7 +4594,12 @@ var OAuthManager = class {
|
|
|
3945
4594
|
storage: this.oauthConfig.storage,
|
|
3946
4595
|
redirectUrlProvider: this.oauthConfig.redirectUrlProvider,
|
|
3947
4596
|
navigation: this.oauthConfig.navigation,
|
|
3948
|
-
clientMetadataUrl: this.oauthConfig.clientMetadataUrl
|
|
4597
|
+
clientMetadataUrl: this.oauthConfig.clientMetadataUrl,
|
|
4598
|
+
// #2018: per-server custom authorization-request parameters. Carried on
|
|
4599
|
+
// the provider (not in OAuth storage like `scope`) — they are pure config
|
|
4600
|
+
// read from mcp.json, and nothing in the flow needs to persist or union
|
|
4601
|
+
// them.
|
|
4602
|
+
authorizationParams: this.oauthConfig.authorizationParams
|
|
3949
4603
|
});
|
|
3950
4604
|
provider.setEventTarget(this.params.getEventTarget());
|
|
3951
4605
|
await provider.prepareForAuth();
|
|
@@ -4629,6 +5283,7 @@ async function* parseSSE(reader) {
|
|
|
4629
5283
|
}
|
|
4630
5284
|
var RemoteClientTransport = class {
|
|
4631
5285
|
_sessionId = void 0;
|
|
5286
|
+
_protocolVersion = void 0;
|
|
4632
5287
|
eventStreamReader = null;
|
|
4633
5288
|
eventStreamAbort = null;
|
|
4634
5289
|
eventStreamConsumeTask = null;
|
|
@@ -4651,6 +5306,21 @@ var RemoteClientTransport = class {
|
|
|
4651
5306
|
getRemoteBackendSessionId() {
|
|
4652
5307
|
return this._sessionId;
|
|
4653
5308
|
}
|
|
5309
|
+
/**
|
|
5310
|
+
* The SDK Client calls this with the negotiated protocol version as soon as
|
|
5311
|
+
* `initialize` resolves — before it sends `notifications/initialized` — so an
|
|
5312
|
+
* HTTP transport can stamp `Mcp-Protocol-Version` on every later request.
|
|
5313
|
+
*
|
|
5314
|
+
* Here the real upstream transport lives on the backend, so we can only
|
|
5315
|
+
* record the version and forward it on the next `/api/mcp/send`, which
|
|
5316
|
+
* applies it to the upstream transport *before* sending. Because
|
|
5317
|
+
* `notifications/initialized` is that next send, it and everything after it
|
|
5318
|
+
* (including the standalone SSE GET and the session DELETE, both issued by
|
|
5319
|
+
* the upstream transport itself) carry the header (#1935).
|
|
5320
|
+
*/
|
|
5321
|
+
setProtocolVersion(version) {
|
|
5322
|
+
this._protocolVersion = version;
|
|
5323
|
+
}
|
|
4654
5324
|
/**
|
|
4655
5325
|
* Reattach to an existing remote backend session after a full-page OAuth
|
|
4656
5326
|
* redirect. Opens the SSE event stream without POST /connect.
|
|
@@ -5020,7 +5690,12 @@ var RemoteClientTransport = class {
|
|
|
5020
5690
|
},
|
|
5021
5691
|
// Forward per-send `Mcp-Param-*` headers (SEP-2243) for the backend to
|
|
5022
5692
|
// apply to the upstream send; the browser can't set them cross-origin.
|
|
5023
|
-
...options?.headers != null && { headers: options.headers }
|
|
5693
|
+
...options?.headers != null && { headers: options.headers },
|
|
5694
|
+
// Forward the negotiated protocol version so the backend's transport can
|
|
5695
|
+
// stamp `Mcp-Protocol-Version` on this and every later request (#1935).
|
|
5696
|
+
...this._protocolVersion !== void 0 && {
|
|
5697
|
+
protocolVersion: this._protocolVersion
|
|
5698
|
+
}
|
|
5024
5699
|
};
|
|
5025
5700
|
const res = await this.fetchFn(`${this.baseUrl}/api/mcp/send`, {
|
|
5026
5701
|
method: "POST",
|
|
@@ -5101,6 +5776,13 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
5101
5776
|
outputValidator = null;
|
|
5102
5777
|
transport = null;
|
|
5103
5778
|
baseTransport = null;
|
|
5779
|
+
// Correlation for `markResponseRejected` (#1953): the method of each
|
|
5780
|
+
// outbound request still awaiting a response, and — once one is answered —
|
|
5781
|
+
// the id of the most recently answered request per method. Entries are
|
|
5782
|
+
// dropped as responses arrive, so this holds at most one id per method
|
|
5783
|
+
// rather than growing with the session.
|
|
5784
|
+
outboundRequestMethods = /* @__PURE__ */ new Map();
|
|
5785
|
+
lastAnsweredRequestByMethod = /* @__PURE__ */ new Map();
|
|
5104
5786
|
/** True when the cached transport was built with an OAuth authProvider attached. */
|
|
5105
5787
|
transportHasAuthProvider = false;
|
|
5106
5788
|
/** Dedupes concurrent ambient auth challenges (reason + scopes). */
|
|
@@ -5143,6 +5825,11 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
5143
5825
|
// annotations (SEP-2243), recomputed on every aggregate tools refresh and
|
|
5144
5826
|
// surfaced so the Tools tab can show why a tool vanished (#1632).
|
|
5145
5827
|
excludedTools = [];
|
|
5828
|
+
// Entries the Inspector dropped from a list result because they failed the
|
|
5829
|
+
// spec schema for that primitive, keyed by list method. Populated only by the
|
|
5830
|
+
// salvage fallback in `listAllSalvaging` — empty against a conforming server
|
|
5831
|
+
// (#1909).
|
|
5832
|
+
malformedListItems = /* @__PURE__ */ new Map();
|
|
5146
5833
|
// The capabilities this Inspector client advertises to the server during the
|
|
5147
5834
|
// initialize handshake. Built once in setupClient() and snapshotted here so
|
|
5148
5835
|
// UI surfaces (Server Info modal) can display them without poking at the
|
|
@@ -5211,7 +5898,10 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
5211
5898
|
// `McpSubscription` whose filter's `resourceSubscriptions` mirrors
|
|
5212
5899
|
// `subscribedResources`; mutating the set re-lists (close old, open new), and
|
|
5213
5900
|
// an unexpected `"remote"` close re-lists (reconnect-by-re-listen — the stream
|
|
5214
|
-
// is not resumable). `null`
|
|
5901
|
+
// is not resumable). `null` on the legacy era, and on the modern era whenever
|
|
5902
|
+
// the filter is empty — which is *not* the same as "no URI subscribed": the
|
|
5903
|
+
// stream also carries the list-change opt-ins, so a tools-only server opens it
|
|
5904
|
+
// with no subscriptions at all (#1920).
|
|
5215
5905
|
modernSubscription = null;
|
|
5216
5906
|
// Monotonic guard so a stale re-list/reconnect (whose `listen()` or `closed`
|
|
5217
5907
|
// resolves after a newer refresh already started) can detect it lost the race
|
|
@@ -5318,6 +6008,10 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
5318
6008
|
resources: options.listChangedNotifications?.resources ?? true,
|
|
5319
6009
|
prompts: options.listChangedNotifications?.prompts ?? true
|
|
5320
6010
|
};
|
|
6011
|
+
this.fetchFn = withOAuthEndpointOverrides(
|
|
6012
|
+
this.fetchFn ?? fetch,
|
|
6013
|
+
() => this.oauthManager?.getEndpointOverrides()
|
|
6014
|
+
);
|
|
5321
6015
|
this.effectiveAuthFetch = this.buildEffectiveAuthFetch();
|
|
5322
6016
|
this.sessionId = options.sessionId;
|
|
5323
6017
|
if (options.oauth || options.environment.oauth) {
|
|
@@ -5345,6 +6039,11 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
5345
6039
|
});
|
|
5346
6040
|
}
|
|
5347
6041
|
const clientOptions = {
|
|
6042
|
+
// Bound the SDK's auto-aggregate with the SAME constant the #1909 salvage
|
|
6043
|
+
// re-walks use, so the strict path and its fallback cannot drift apart.
|
|
6044
|
+
// This is the SDK's own default today; setting it explicitly is what makes
|
|
6045
|
+
// the shared value a fact rather than a copied guess.
|
|
6046
|
+
listMaxPages: LIST_MAX_PAGES,
|
|
5348
6047
|
// Per-server protocol era (SEP §7.8), threaded from config via
|
|
5349
6048
|
// `eraToVersionNegotiation` and defaulted to `{ mode: "legacy" }` in the
|
|
5350
6049
|
// constructor. "legacy" keeps the wire byte-identical to a 2025 client;
|
|
@@ -5434,6 +6133,9 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
5434
6133
|
createMessageTrackingCallbacks() {
|
|
5435
6134
|
return {
|
|
5436
6135
|
trackRequest: (message, origin) => {
|
|
6136
|
+
if (origin === "client") {
|
|
6137
|
+
this.outboundRequestMethods.set(message.id, message.method);
|
|
6138
|
+
}
|
|
5437
6139
|
const entry = {
|
|
5438
6140
|
id: crypto.randomUUID(),
|
|
5439
6141
|
timestamp: /* @__PURE__ */ new Date(),
|
|
@@ -5444,6 +6146,14 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
5444
6146
|
this.dispatchTypedEvent("message", entry);
|
|
5445
6147
|
},
|
|
5446
6148
|
trackResponse: (message, origin) => {
|
|
6149
|
+
const responseId = message.id;
|
|
6150
|
+
if (origin === "server" && responseId !== void 0) {
|
|
6151
|
+
const method = this.outboundRequestMethods.get(responseId);
|
|
6152
|
+
this.outboundRequestMethods.delete(responseId);
|
|
6153
|
+
if (method !== void 0) {
|
|
6154
|
+
this.lastAnsweredRequestByMethod.set(method, responseId);
|
|
6155
|
+
}
|
|
6156
|
+
}
|
|
5447
6157
|
const entry = {
|
|
5448
6158
|
id: crypto.randomUUID(),
|
|
5449
6159
|
timestamp: /* @__PURE__ */ new Date(),
|
|
@@ -6001,6 +6711,16 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
6001
6711
|
this.clearReceiverTasks();
|
|
6002
6712
|
this.resetSubscriptionStream();
|
|
6003
6713
|
this.cancelledTaskIds.clear();
|
|
6714
|
+
this.outboundRequestMethods.clear();
|
|
6715
|
+
this.lastAnsweredRequestByMethod.clear();
|
|
6716
|
+
if (this.malformedListItems.size > 0) {
|
|
6717
|
+
this.malformedListItems.clear();
|
|
6718
|
+
this.dispatchTypedEvent("malformedListItemsChange", []);
|
|
6719
|
+
}
|
|
6720
|
+
if (this.excludedTools.length > 0) {
|
|
6721
|
+
this.excludedTools = [];
|
|
6722
|
+
this.dispatchTypedEvent("excludedToolsChange", []);
|
|
6723
|
+
}
|
|
6004
6724
|
for (const [, controller] of this.taskInputAbortControllers) {
|
|
6005
6725
|
controller.abort(new Error("Connection ended"));
|
|
6006
6726
|
}
|
|
@@ -6224,8 +6944,7 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
6224
6944
|
this.status = "connected";
|
|
6225
6945
|
this.dispatchTypedEvent("statusChange", this.status);
|
|
6226
6946
|
await this.fetchServerInfo();
|
|
6227
|
-
this.
|
|
6228
|
-
if (this.initialLoggingLevel && this.capabilities?.logging) {
|
|
6947
|
+
if (this.initialLoggingLevel && this.capabilities?.logging && this.protocolEra !== "modern") {
|
|
6229
6948
|
await this.client.setLoggingLevel(
|
|
6230
6949
|
this.initialLoggingLevel,
|
|
6231
6950
|
this.getRequestOptions()
|
|
@@ -6303,6 +7022,10 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
6303
7022
|
);
|
|
6304
7023
|
}
|
|
6305
7024
|
}
|
|
7025
|
+
await this.openModernListenStreamOnConnect();
|
|
7026
|
+
if (this.status === "connected" && !this.disconnecting) {
|
|
7027
|
+
this.dispatchTypedEvent("connect");
|
|
7028
|
+
}
|
|
6306
7029
|
} catch (error) {
|
|
6307
7030
|
if (!isConnectAuthRecoveryError(error)) {
|
|
6308
7031
|
this.status = "error";
|
|
@@ -6366,6 +7089,7 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
6366
7089
|
this.protocolEra = void 0;
|
|
6367
7090
|
this.discoverResult = void 0;
|
|
6368
7091
|
this.excludedTools = [];
|
|
7092
|
+
this.malformedListItems.clear();
|
|
6369
7093
|
this.modernLogLevel = void 0;
|
|
6370
7094
|
this.dispatchTypedEvent("pendingSamplesChange", this.pendingSamples);
|
|
6371
7095
|
this.dispatchTypedEvent(
|
|
@@ -6379,6 +7103,7 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
6379
7103
|
this.dispatchTypedEvent("protocolEraChange", this.protocolEra);
|
|
6380
7104
|
this.dispatchTypedEvent("discoverResultChange", this.discoverResult);
|
|
6381
7105
|
this.dispatchTypedEvent("excludedToolsChange", this.excludedTools);
|
|
7106
|
+
this.dispatchTypedEvent("malformedListItemsChange", []);
|
|
6382
7107
|
}
|
|
6383
7108
|
/**
|
|
6384
7109
|
* Returns a client proxy for use by AppRenderer / @mcp-ui. Delegates to the
|
|
@@ -6472,7 +7197,6 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
6472
7197
|
* `clientCapabilities` carrying the tasks extension). We reproduce it here.
|
|
6473
7198
|
*/
|
|
6474
7199
|
withModernTaskEnvelope(params) {
|
|
6475
|
-
const existingMeta = params._meta ?? {};
|
|
6476
7200
|
const clientCapabilities = {
|
|
6477
7201
|
...this.clientCapabilities,
|
|
6478
7202
|
// Force-stamp the tasks extension regardless of what the client
|
|
@@ -6484,6 +7208,26 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
6484
7208
|
[TASKS_EXTENSION_KEY]: {}
|
|
6485
7209
|
}
|
|
6486
7210
|
};
|
|
7211
|
+
return this.withModernEnvelope(params, clientCapabilities);
|
|
7212
|
+
}
|
|
7213
|
+
/**
|
|
7214
|
+
* Stamp the `_meta` envelope every raw-wire request needs on the modern leg:
|
|
7215
|
+
* the negotiated protocol version, the client identity, and the client
|
|
7216
|
+
* capabilities.
|
|
7217
|
+
*
|
|
7218
|
+
* Split out of {@link withModernTaskEnvelope} so the list-salvage re-walk
|
|
7219
|
+
* (#1909) can reuse it WITHOUT that method's force-stamped tasks extension —
|
|
7220
|
+
* a `tools/list` has no business claiming an extension the user may have
|
|
7221
|
+
* deliberately turned off (#1738).
|
|
7222
|
+
*
|
|
7223
|
+
* The NEGOTIATED protocol version is used so the envelope agrees with the
|
|
7224
|
+
* `MCP-Protocol-Version` header the transport stamps from the same source — a
|
|
7225
|
+
* future modern-family revision would negotiate a different string, and the
|
|
7226
|
+
* two must not disagree. The raw channel only runs on a connected modern
|
|
7227
|
+
* session, so this is always set; the constant is a defensive fallback.
|
|
7228
|
+
*/
|
|
7229
|
+
withModernEnvelope(params, clientCapabilities = this.clientCapabilities) {
|
|
7230
|
+
const existingMeta = params._meta ?? {};
|
|
6487
7231
|
const protocolVersion = this.getProtocolVersion() ?? MODERN_PROTOCOL_VERSION2;
|
|
6488
7232
|
return {
|
|
6489
7233
|
...params,
|
|
@@ -7080,7 +7824,11 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
7080
7824
|
const effectiveMeta = this.mergeMeta(metadata);
|
|
7081
7825
|
const params = {
|
|
7082
7826
|
...effectiveMeta ? { _meta: effectiveMeta } : {},
|
|
7083
|
-
|
|
7827
|
+
// `!== undefined`, not truthiness: "" is a valid cursor. Dropping it asks
|
|
7828
|
+
// for page one again — and `listToolsForScan` pairs this call with a
|
|
7829
|
+
// fallback that already preserves it, so the two legs of one scan page
|
|
7830
|
+
// would otherwise disagree about which page they fetched.
|
|
7831
|
+
...cursor !== void 0 && { cursor }
|
|
7084
7832
|
};
|
|
7085
7833
|
const response = await this.invokeMcpClient(
|
|
7086
7834
|
() => this.client.request(
|
|
@@ -7108,15 +7856,29 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
7108
7856
|
if (!this.client) {
|
|
7109
7857
|
throw new Error("Client is not connected");
|
|
7110
7858
|
}
|
|
7111
|
-
const
|
|
7112
|
-
|
|
7113
|
-
|
|
7114
|
-
|
|
7115
|
-
|
|
7116
|
-
|
|
7117
|
-
|
|
7859
|
+
const tools = await this.listAllSalvaging({
|
|
7860
|
+
method: "tools/list",
|
|
7861
|
+
itemsKey: "tools",
|
|
7862
|
+
resultSchema: ListToolsResultSchema,
|
|
7863
|
+
// Era-aware: the neutral `ToolSchema` is more permissive than the
|
|
7864
|
+
// negotiated era's wire schema — see `toolItemSchemaForEra`.
|
|
7865
|
+
itemSchema: toolItemSchemaForEra(this.isModernEra()),
|
|
7866
|
+
metadata: options?.metadata,
|
|
7867
|
+
finalize: (salvaged) => this.excludeInvalidXMcpHeaderTools(salvaged),
|
|
7868
|
+
aggregate: async () => [
|
|
7869
|
+
...(await this.client.listTools(
|
|
7870
|
+
this.aggregateListParams(options?.metadata),
|
|
7871
|
+
this.getCacheableRequestOptions(options?.cacheMode)
|
|
7872
|
+
)).tools
|
|
7873
|
+
]
|
|
7874
|
+
});
|
|
7875
|
+
await this.refreshExcludedTools(options?.metadata).catch((err) => {
|
|
7876
|
+
this.logger.warn(
|
|
7877
|
+
{ err },
|
|
7878
|
+
"Excluded-tools walk failed; the SEP-2243 excluded list may be incomplete"
|
|
7879
|
+
);
|
|
7118
7880
|
});
|
|
7119
|
-
return { tools
|
|
7881
|
+
return { tools };
|
|
7120
7882
|
}
|
|
7121
7883
|
/**
|
|
7122
7884
|
* Whether this connection excludes tools with invalid `x-mcp-header`
|
|
@@ -7127,6 +7889,222 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
7127
7889
|
excludesInvalidXMcpHeaderTools() {
|
|
7128
7890
|
return this.isModernEra() && this.getServerType() !== "stdio";
|
|
7129
7891
|
}
|
|
7892
|
+
/**
|
|
7893
|
+
* Mark the response that most recently answered `method` as rejected by the
|
|
7894
|
+
* client, so its Protocol entry shows why instead of rendering as a clean
|
|
7895
|
+
* success (#1953).
|
|
7896
|
+
*
|
|
7897
|
+
* The SDK gives no request id with a decode failure — `SdkError` carries the
|
|
7898
|
+
* method and nothing else — so the id is recovered by correlation: the last
|
|
7899
|
+
* response received for that method. That is exact rather than approximate,
|
|
7900
|
+
* because the SDK rejects synchronously while decoding the response (inside
|
|
7901
|
+
* the transport's `onmessage`) and the caller's `catch` runs in the very next
|
|
7902
|
+
* microtask. Delivering another response for the same method in that window
|
|
7903
|
+
* would take a macrotask (a socket read), which cannot interleave there.
|
|
7904
|
+
*
|
|
7905
|
+
* A no-op when nothing has answered `method` this session.
|
|
7906
|
+
*/
|
|
7907
|
+
markResponseRejected(method, reason) {
|
|
7908
|
+
const id = this.lastAnsweredRequestByMethod.get(method);
|
|
7909
|
+
if (id === void 0) return;
|
|
7910
|
+
this.dispatchTypedEvent("responseRejected", { id, reason });
|
|
7911
|
+
}
|
|
7912
|
+
/**
|
|
7913
|
+
* Put the method's response correlation back where it was before a salvage
|
|
7914
|
+
* re-walk, so a caller that goes on to mark the failure still marks the
|
|
7915
|
+
* ORIGINAL rejected response.
|
|
7916
|
+
*
|
|
7917
|
+
* The re-walk answers the same method, so on any rethrow path the map points
|
|
7918
|
+
* at a lenient page that succeeded. `ManagedListState.refresh()` catches the
|
|
7919
|
+
* rethrown error and calls `markResponseRejected(method, ...)`, which would
|
|
7920
|
+
* then stamp "Rejected by the Inspector" onto that page and leave the real
|
|
7921
|
+
* one rendering clean — the same misattribution the capture inside
|
|
7922
|
+
* `salvageList` exists to prevent, just one frame further out. Deleting when
|
|
7923
|
+
* nothing had answered before makes the outer mark a no-op rather than a lie.
|
|
7924
|
+
*/
|
|
7925
|
+
restoreResponseCorrelation(method, id) {
|
|
7926
|
+
if (id === void 0) this.lastAnsweredRequestByMethod.delete(method);
|
|
7927
|
+
else this.lastAnsweredRequestByMethod.set(method, id);
|
|
7928
|
+
}
|
|
7929
|
+
/** Every entry dropped from a list result as malformed, across methods (#1909). */
|
|
7930
|
+
getMalformedListItems() {
|
|
7931
|
+
return [...this.malformedListItems.values()].flat();
|
|
7932
|
+
}
|
|
7933
|
+
/**
|
|
7934
|
+
* Record (or clear) the malformed entries for one list method and notify.
|
|
7935
|
+
*
|
|
7936
|
+
* A no-op when the method had none and still has none, so the common case —
|
|
7937
|
+
* every conforming refresh, of which there are many — costs no event and no
|
|
7938
|
+
* re-render.
|
|
7939
|
+
*/
|
|
7940
|
+
setMalformedListItems(method, malformed) {
|
|
7941
|
+
const previous = this.malformedListItems.get(method) ?? [];
|
|
7942
|
+
if (previous.length === 0 && malformed.length === 0) return;
|
|
7943
|
+
if (malformed.length === 0) this.malformedListItems.delete(method);
|
|
7944
|
+
else this.malformedListItems.set(method, malformed);
|
|
7945
|
+
this.dispatchTypedEvent(
|
|
7946
|
+
"malformedListItemsChange",
|
|
7947
|
+
this.getMalformedListItems()
|
|
7948
|
+
);
|
|
7949
|
+
}
|
|
7950
|
+
/**
|
|
7951
|
+
* Run a list aggregate, falling back to a per-item salvage when the SDK
|
|
7952
|
+
* rejects the result it received (#1909).
|
|
7953
|
+
*
|
|
7954
|
+
* The strict aggregate runs first and unchanged, so a conforming server pays
|
|
7955
|
+
* nothing: no extra request, no extra parse, and the SDK's response cache
|
|
7956
|
+
* still serves it. Only an `InvalidResult` rejection — a response in hand
|
|
7957
|
+
* that failed validation — reaches {@link salvageList}; every other failure
|
|
7958
|
+
* (transport drop, timeout, server-sent error) rethrows untouched, because
|
|
7959
|
+
* re-listing would not produce anything to salvage.
|
|
7960
|
+
*/
|
|
7961
|
+
async listAllSalvaging({
|
|
7962
|
+
method,
|
|
7963
|
+
itemsKey,
|
|
7964
|
+
itemSchema,
|
|
7965
|
+
resultSchema,
|
|
7966
|
+
aggregate,
|
|
7967
|
+
metadata,
|
|
7968
|
+
finalize
|
|
7969
|
+
}) {
|
|
7970
|
+
try {
|
|
7971
|
+
const items = await this.invokeMcpClient(aggregate, { method });
|
|
7972
|
+
this.setMalformedListItems(method, []);
|
|
7973
|
+
return items;
|
|
7974
|
+
} catch (err) {
|
|
7975
|
+
if (!isSalvageableRejection(err)) throw err;
|
|
7976
|
+
const salvaged = await this.salvageList({
|
|
7977
|
+
method,
|
|
7978
|
+
itemsKey,
|
|
7979
|
+
itemSchema,
|
|
7980
|
+
resultSchema,
|
|
7981
|
+
metadata,
|
|
7982
|
+
err
|
|
7983
|
+
});
|
|
7984
|
+
return finalize ? finalize(salvaged) : salvaged;
|
|
7985
|
+
}
|
|
7986
|
+
}
|
|
7987
|
+
/**
|
|
7988
|
+
* Drop the tools the SDK would have excluded from `tools/list` for invalid
|
|
7989
|
+
* `x-mcp-header` annotations (SEP-2243).
|
|
7990
|
+
*
|
|
7991
|
+
* The strict aggregate is filtered by the SDK before we see it, so the
|
|
7992
|
+
* salvage path has to reapply the same rule itself: otherwise one ordinary
|
|
7993
|
+
* malformed tool anywhere in the list would trip the fallback and quietly
|
|
7994
|
+
* readmit every invalid-header tool alongside it — turning a rendering fix
|
|
7995
|
+
* into a spec violation. The dropped tools are still reported through
|
|
7996
|
+
* `refreshExcludedTools`, which lists them with their reason.
|
|
7997
|
+
*/
|
|
7998
|
+
excludeInvalidXMcpHeaderTools(tools) {
|
|
7999
|
+
if (!this.excludesInvalidXMcpHeaderTools()) return tools;
|
|
8000
|
+
return tools.filter(
|
|
8001
|
+
(tool) => scanXMcpHeaderDeclarations(tool.inputSchema).valid
|
|
8002
|
+
);
|
|
8003
|
+
}
|
|
8004
|
+
/**
|
|
8005
|
+
* Re-walk a list method with pagination validated but entries left raw, then
|
|
8006
|
+
* validate each entry on its own — keeping the good ones and reporting the
|
|
8007
|
+
* rest (#1909).
|
|
8008
|
+
*
|
|
8009
|
+
* Two deliberate properties:
|
|
8010
|
+
*
|
|
8011
|
+
* - **The original error wins when nothing is salvageable.** If every entry
|
|
8012
|
+
* validates here, the strict rejection was about something else (a
|
|
8013
|
+
* top-level field, an era codec decision), so there is no per-item story to
|
|
8014
|
+
* tell and swallowing it would hide a real failure. Rethrow the original.
|
|
8015
|
+
* - **A salvaged response is still a rejected response.** The Protocol entry
|
|
8016
|
+
* is marked (#1953) with what was dropped, so the wire truth survives even
|
|
8017
|
+
* though the list now renders.
|
|
8018
|
+
*
|
|
8019
|
+
* This walk is deliberately un-cached (it uses the raw per-page path), which
|
|
8020
|
+
* is fine: it only runs against a server that just returned a non-conforming
|
|
8021
|
+
* result.
|
|
8022
|
+
*/
|
|
8023
|
+
async salvageList({
|
|
8024
|
+
method,
|
|
8025
|
+
itemsKey,
|
|
8026
|
+
itemSchema,
|
|
8027
|
+
resultSchema,
|
|
8028
|
+
metadata,
|
|
8029
|
+
err
|
|
8030
|
+
}) {
|
|
8031
|
+
const pageSchema = lenientListPageSchema(resultSchema, itemsKey);
|
|
8032
|
+
const rejectedResponseId = this.lastAnsweredRequestByMethod.get(method);
|
|
8033
|
+
const valid = [];
|
|
8034
|
+
const malformed = [];
|
|
8035
|
+
const seenCursors = /* @__PURE__ */ new Set();
|
|
8036
|
+
let cursor;
|
|
8037
|
+
let pages = 0;
|
|
8038
|
+
try {
|
|
8039
|
+
do {
|
|
8040
|
+
if (pages >= LIST_MAX_PAGES) throw listPaginationExceeded(method);
|
|
8041
|
+
pages += 1;
|
|
8042
|
+
const effectiveMeta = this.mergeMeta(metadata);
|
|
8043
|
+
const params = {
|
|
8044
|
+
...effectiveMeta ? { _meta: effectiveMeta } : {},
|
|
8045
|
+
// `!== undefined`, not truthiness: "" is a valid cursor, and dropping it
|
|
8046
|
+
// would re-request page one and duplicate its entries until the
|
|
8047
|
+
// repeated-cursor guard below stopped the walk.
|
|
8048
|
+
...cursor !== void 0 && { cursor }
|
|
8049
|
+
};
|
|
8050
|
+
const page = await this.invokeMcpClient(
|
|
8051
|
+
() => this.isModernEra() ? this.rawWireRequest(
|
|
8052
|
+
method,
|
|
8053
|
+
this.withModernEnvelope(params),
|
|
8054
|
+
pageSchema
|
|
8055
|
+
) : this.client.request(
|
|
8056
|
+
{ method, params },
|
|
8057
|
+
pageSchema,
|
|
8058
|
+
this.getRequestOptions(metadata?.progressToken)
|
|
8059
|
+
),
|
|
8060
|
+
{ method }
|
|
8061
|
+
);
|
|
8062
|
+
if (this.isModernEra() && !ModernResultEnvelopeSchema.safeParse(page).success) {
|
|
8063
|
+
throw err;
|
|
8064
|
+
}
|
|
8065
|
+
const items = rawItemsOf(page, itemsKey);
|
|
8066
|
+
if (items === void 0) throw err;
|
|
8067
|
+
const salvaged = salvageListItems({
|
|
8068
|
+
method,
|
|
8069
|
+
items,
|
|
8070
|
+
schema: itemSchema,
|
|
8071
|
+
startIndex: valid.length + malformed.length
|
|
8072
|
+
});
|
|
8073
|
+
valid.push(...salvaged.valid);
|
|
8074
|
+
malformed.push(...salvaged.malformed);
|
|
8075
|
+
cursor = nextCursorOf(page);
|
|
8076
|
+
if (cursor !== void 0) {
|
|
8077
|
+
if (seenCursors.has(cursor)) break;
|
|
8078
|
+
seenCursors.add(cursor);
|
|
8079
|
+
}
|
|
8080
|
+
} while (cursor !== void 0);
|
|
8081
|
+
} catch (walkErr) {
|
|
8082
|
+
if (walkErr !== err) {
|
|
8083
|
+
this.logger.warn(
|
|
8084
|
+
{ err: walkErr, method },
|
|
8085
|
+
"Salvage re-walk failed; surfacing the original list error"
|
|
8086
|
+
);
|
|
8087
|
+
}
|
|
8088
|
+
this.restoreResponseCorrelation(method, rejectedResponseId);
|
|
8089
|
+
throw err;
|
|
8090
|
+
}
|
|
8091
|
+
if (malformed.length === 0) {
|
|
8092
|
+
this.restoreResponseCorrelation(method, rejectedResponseId);
|
|
8093
|
+
throw err;
|
|
8094
|
+
}
|
|
8095
|
+
if (rejectedResponseId !== void 0) {
|
|
8096
|
+
this.dispatchTypedEvent("responseRejected", {
|
|
8097
|
+
id: rejectedResponseId,
|
|
8098
|
+
reason: summarizeMalformed(malformed)
|
|
8099
|
+
});
|
|
8100
|
+
}
|
|
8101
|
+
this.setMalformedListItems(method, malformed);
|
|
8102
|
+
this.logger.warn(
|
|
8103
|
+
{ method, malformed },
|
|
8104
|
+
"Dropped malformed entries from a list result; the rest of the list was kept"
|
|
8105
|
+
);
|
|
8106
|
+
return valid;
|
|
8107
|
+
}
|
|
7130
8108
|
/** The current SEP-2243 excluded-tools set (empty on legacy/stdio). */
|
|
7131
8109
|
getExcludedTools() {
|
|
7132
8110
|
return this.excludedTools;
|
|
@@ -7145,8 +8123,11 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
7145
8123
|
if (this.excludesInvalidXMcpHeaderTools()) {
|
|
7146
8124
|
const seenCursors = /* @__PURE__ */ new Set();
|
|
7147
8125
|
let cursor;
|
|
8126
|
+
let pages = 0;
|
|
7148
8127
|
do {
|
|
7149
|
-
|
|
8128
|
+
if (pages >= LIST_MAX_PAGES) throw listPaginationExceeded("tools/list");
|
|
8129
|
+
pages += 1;
|
|
8130
|
+
const page = await this.listToolsForScan(cursor, metadata);
|
|
7150
8131
|
for (const tool of page.tools) {
|
|
7151
8132
|
const scan = scanXMcpHeaderDeclarations(tool.inputSchema);
|
|
7152
8133
|
if (!scan.valid) excluded.push({ tool, reason: scan.reason });
|
|
@@ -7162,6 +8143,90 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
7162
8143
|
this.dispatchTypedEvent("excludedToolsChange", excluded);
|
|
7163
8144
|
return excluded;
|
|
7164
8145
|
}
|
|
8146
|
+
/**
|
|
8147
|
+
* One page of the RAW `tools/list` for the SEP-2243 scan, tolerating a
|
|
8148
|
+
* malformed sibling entry (#1632 + #1909).
|
|
8149
|
+
*
|
|
8150
|
+
* The scan needs the unfiltered list, so it uses the strict single-page call
|
|
8151
|
+
* — but that call rejects the whole page when any entry is non-conforming,
|
|
8152
|
+
* which would blank the excluded set and leave a tool that vanished for an
|
|
8153
|
+
* invalid header with no explanation at all. That is the same failure #1909
|
|
8154
|
+
* is about, one level down. So on a decode rejection the page is re-fetched
|
|
8155
|
+
* leniently and scanned entry by entry.
|
|
8156
|
+
*
|
|
8157
|
+
* The malformed ones are not "excluded tools" and are not returned: they
|
|
8158
|
+
* describe THIS exchange, not the aggregate the Tools panel renders, so they
|
|
8159
|
+
* surface as the rejection reason on this response's own Protocol entry and
|
|
8160
|
+
* go no further (see `refreshExcludedTools`).
|
|
8161
|
+
*/
|
|
8162
|
+
async listToolsForScan(cursor, metadata) {
|
|
8163
|
+
try {
|
|
8164
|
+
return await this.listTools(cursor, metadata);
|
|
8165
|
+
} catch (err) {
|
|
8166
|
+
if (!isSalvageableRejection(err)) throw err;
|
|
8167
|
+
const rejectedResponseId = this.lastAnsweredRequestByMethod.get("tools/list");
|
|
8168
|
+
try {
|
|
8169
|
+
const effectiveMeta = this.mergeMeta(metadata);
|
|
8170
|
+
const params = {
|
|
8171
|
+
...effectiveMeta ? { _meta: effectiveMeta } : {},
|
|
8172
|
+
// See `salvageList`: "" is a valid cursor.
|
|
8173
|
+
...cursor !== void 0 && { cursor }
|
|
8174
|
+
};
|
|
8175
|
+
const pageSchema = lenientListPageSchema(
|
|
8176
|
+
ListToolsResultSchema,
|
|
8177
|
+
"tools"
|
|
8178
|
+
);
|
|
8179
|
+
const page = await this.invokeMcpClient(
|
|
8180
|
+
() => this.isModernEra() ? this.rawWireRequest(
|
|
8181
|
+
"tools/list",
|
|
8182
|
+
this.withModernEnvelope(params),
|
|
8183
|
+
pageSchema
|
|
8184
|
+
) : this.client.request(
|
|
8185
|
+
{ method: "tools/list", params },
|
|
8186
|
+
pageSchema,
|
|
8187
|
+
this.getRequestOptions(metadata?.progressToken)
|
|
8188
|
+
),
|
|
8189
|
+
{ method: "tools/list" }
|
|
8190
|
+
);
|
|
8191
|
+
if (this.isModernEra() && !ModernResultEnvelopeSchema.safeParse(page).success) {
|
|
8192
|
+
throw err;
|
|
8193
|
+
}
|
|
8194
|
+
const items = rawItemsOf(page, "tools");
|
|
8195
|
+
if (items === void 0) throw err;
|
|
8196
|
+
const { valid, malformed } = salvageListItems({
|
|
8197
|
+
method: "tools/list",
|
|
8198
|
+
items,
|
|
8199
|
+
schema: toolItemSchemaForEra(this.isModernEra())
|
|
8200
|
+
});
|
|
8201
|
+
if (rejectedResponseId !== void 0) {
|
|
8202
|
+
this.dispatchTypedEvent("responseRejected", {
|
|
8203
|
+
id: rejectedResponseId,
|
|
8204
|
+
reason: malformed.length > 0 ? summarizeMalformed(malformed) : err instanceof Error ? err.message : String(err)
|
|
8205
|
+
});
|
|
8206
|
+
}
|
|
8207
|
+
const nextCursor = nextCursorOf(page);
|
|
8208
|
+
return {
|
|
8209
|
+
tools: valid,
|
|
8210
|
+
...nextCursor !== void 0 && { nextCursor }
|
|
8211
|
+
};
|
|
8212
|
+
} catch (fallbackErr) {
|
|
8213
|
+
if (rejectedResponseId !== void 0) {
|
|
8214
|
+
this.dispatchTypedEvent("responseRejected", {
|
|
8215
|
+
id: rejectedResponseId,
|
|
8216
|
+
reason: err instanceof Error ? err.message : String(err)
|
|
8217
|
+
});
|
|
8218
|
+
}
|
|
8219
|
+
if (fallbackErr !== err) {
|
|
8220
|
+
this.logger.warn(
|
|
8221
|
+
{ err: fallbackErr },
|
|
8222
|
+
"Excluded-tools salvage re-fetch failed; surfacing the original list error"
|
|
8223
|
+
);
|
|
8224
|
+
}
|
|
8225
|
+
this.restoreResponseCorrelation("tools/list", rejectedResponseId);
|
|
8226
|
+
throw err;
|
|
8227
|
+
}
|
|
8228
|
+
}
|
|
8229
|
+
}
|
|
7165
8230
|
/**
|
|
7166
8231
|
* Call a tool. Caller must provide the Tool (e.g. from a state manager).
|
|
7167
8232
|
* @param tool The tool to call (use tool.name for the request)
|
|
@@ -7948,13 +9013,20 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
7948
9013
|
if (!this.client) {
|
|
7949
9014
|
throw new Error("Client is not connected");
|
|
7950
9015
|
}
|
|
7951
|
-
const
|
|
7952
|
-
|
|
7953
|
-
|
|
7954
|
-
|
|
7955
|
-
|
|
7956
|
-
|
|
7957
|
-
|
|
9016
|
+
const resources = await this.listAllSalvaging({
|
|
9017
|
+
method: "resources/list",
|
|
9018
|
+
itemsKey: "resources",
|
|
9019
|
+
resultSchema: ListResourcesResultSchema,
|
|
9020
|
+
itemSchema: ResourceSchema,
|
|
9021
|
+
metadata: options?.metadata,
|
|
9022
|
+
aggregate: async () => [
|
|
9023
|
+
...(await this.client.listResources(
|
|
9024
|
+
this.aggregateListParams(options?.metadata),
|
|
9025
|
+
this.getCacheableRequestOptions(options?.cacheMode)
|
|
9026
|
+
)).resources
|
|
9027
|
+
]
|
|
9028
|
+
});
|
|
9029
|
+
return { resources };
|
|
7958
9030
|
}
|
|
7959
9031
|
/**
|
|
7960
9032
|
* Read a resource by URI
|
|
@@ -8010,8 +9082,7 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
8010
9082
|
const uriTemplateString = uriTemplate;
|
|
8011
9083
|
let expandedUri;
|
|
8012
9084
|
try {
|
|
8013
|
-
|
|
8014
|
-
expandedUri = uriTemplate2.expand(params);
|
|
9085
|
+
expandedUri = expandUriTemplateStrict(uriTemplateString, params);
|
|
8015
9086
|
} catch (error) {
|
|
8016
9087
|
throw new Error(
|
|
8017
9088
|
`Failed to expand URI template "${uriTemplate}": ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -8073,14 +9144,20 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
8073
9144
|
if (!this.client) {
|
|
8074
9145
|
throw new Error("Client is not connected");
|
|
8075
9146
|
}
|
|
8076
|
-
const
|
|
8077
|
-
|
|
8078
|
-
|
|
8079
|
-
|
|
8080
|
-
|
|
8081
|
-
|
|
8082
|
-
|
|
8083
|
-
|
|
9147
|
+
const resourceTemplates = await this.listAllSalvaging({
|
|
9148
|
+
method: "resources/templates/list",
|
|
9149
|
+
itemsKey: "resourceTemplates",
|
|
9150
|
+
resultSchema: ListResourceTemplatesResultSchema,
|
|
9151
|
+
itemSchema: ResourceTemplateSchema,
|
|
9152
|
+
metadata: options?.metadata,
|
|
9153
|
+
aggregate: async () => [
|
|
9154
|
+
...(await this.client.listResourceTemplates(
|
|
9155
|
+
this.aggregateListParams(options?.metadata),
|
|
9156
|
+
this.getCacheableRequestOptions(options?.cacheMode)
|
|
9157
|
+
)).resourceTemplates
|
|
9158
|
+
]
|
|
9159
|
+
});
|
|
9160
|
+
return { resourceTemplates };
|
|
8084
9161
|
}
|
|
8085
9162
|
/**
|
|
8086
9163
|
* List available prompts with pagination support
|
|
@@ -8119,13 +9196,20 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
8119
9196
|
if (!this.client) {
|
|
8120
9197
|
throw new Error("Client is not connected");
|
|
8121
9198
|
}
|
|
8122
|
-
const
|
|
8123
|
-
|
|
8124
|
-
|
|
8125
|
-
|
|
8126
|
-
|
|
8127
|
-
|
|
8128
|
-
|
|
9199
|
+
const prompts = await this.listAllSalvaging({
|
|
9200
|
+
method: "prompts/list",
|
|
9201
|
+
itemsKey: "prompts",
|
|
9202
|
+
resultSchema: ListPromptsResultSchema,
|
|
9203
|
+
itemSchema: PromptSchema,
|
|
9204
|
+
metadata: options?.metadata,
|
|
9205
|
+
aggregate: async () => [
|
|
9206
|
+
...(await this.client.listPrompts(
|
|
9207
|
+
this.aggregateListParams(options?.metadata),
|
|
9208
|
+
this.getCacheableRequestOptions(options?.cacheMode)
|
|
9209
|
+
)).prompts
|
|
9210
|
+
]
|
|
9211
|
+
});
|
|
9212
|
+
return { prompts };
|
|
8129
9213
|
}
|
|
8130
9214
|
/**
|
|
8131
9215
|
* Get a prompt by name
|
|
@@ -8394,9 +9478,10 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
8394
9478
|
* opted-in notification type (SEP §7.4).
|
|
8395
9479
|
*/
|
|
8396
9480
|
buildSubscriptionFilter() {
|
|
8397
|
-
const filter = {
|
|
8398
|
-
|
|
8399
|
-
|
|
9481
|
+
const filter = {};
|
|
9482
|
+
if (this.subscribedResources.size > 0) {
|
|
9483
|
+
filter.resourceSubscriptions = Array.from(this.subscribedResources);
|
|
9484
|
+
}
|
|
8400
9485
|
if (this.listChangedNotifications.tools && this.capabilities?.tools?.listChanged) {
|
|
8401
9486
|
filter.toolsListChanged = true;
|
|
8402
9487
|
}
|
|
@@ -8408,6 +9493,74 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
8408
9493
|
}
|
|
8409
9494
|
return filter;
|
|
8410
9495
|
}
|
|
9496
|
+
/**
|
|
9497
|
+
* Whether the modern listen stream should be open: the built filter carries
|
|
9498
|
+
* something to listen for (#1920). Before #1920 this was "at least one URI is
|
|
9499
|
+
* subscribed", which made the stream unreachable on a server with no resources
|
|
9500
|
+
* — a tools-only server advertising `tools.listChanged` had no way to open it,
|
|
9501
|
+
* so `notifications/tools/list_changed` could never arrive. The filter already
|
|
9502
|
+
* modelled the list-change opt-ins; only the trigger was narrower than the
|
|
9503
|
+
* filter it built. This matches the SDK's own `ClientOptions.listChanged`
|
|
9504
|
+
* auto-open, which opens whenever the effective (config ∩ capability)
|
|
9505
|
+
* intersection is non-empty.
|
|
9506
|
+
*
|
|
9507
|
+
* Note this is deliberately *not* the same predicate as the stream state's
|
|
9508
|
+
* `active` — see `modernStreamActive()`.
|
|
9509
|
+
*/
|
|
9510
|
+
wantsModernStream() {
|
|
9511
|
+
const filter = this.buildSubscriptionFilter();
|
|
9512
|
+
return (filter.resourceSubscriptions?.length ?? 0) > 0 || filter.toolsListChanged === true || filter.resourcesListChanged === true || filter.promptsListChanged === true;
|
|
9513
|
+
}
|
|
9514
|
+
/**
|
|
9515
|
+
* Whether the stream state reports `active` — i.e. whether the *Subscriptions*
|
|
9516
|
+
* UI has a stream to describe. That is a narrower question than
|
|
9517
|
+
* `wantsModernStream()`: `ResourceSubscriptionStreamState` drives the
|
|
9518
|
+
* Subscriptions section's badge, so a stream open purely for list-change
|
|
9519
|
+
* notifications (no subscribed URI) has nothing to report there and stays
|
|
9520
|
+
* `active: false` (#1920). Keeping the two apart also preserves the invariant
|
|
9521
|
+
* the rest of this file is written against — an empty subscribed set is never
|
|
9522
|
+
* announced alongside an `active` stream.
|
|
9523
|
+
*/
|
|
9524
|
+
modernStreamActive() {
|
|
9525
|
+
return this.subscribedResources.size > 0;
|
|
9526
|
+
}
|
|
9527
|
+
/**
|
|
9528
|
+
* Open the modern listen stream at the end of a successful connect, when the
|
|
9529
|
+
* filter is non-empty (#1920). Only the list-change opt-ins can make it
|
|
9530
|
+
* non-empty here — the subscribed set is emptied by `resetSessionState()` on
|
|
9531
|
+
* the way in — so this is exactly the "server advertises a listChanged the
|
|
9532
|
+
* Inspector wants" case that had no trigger before.
|
|
9533
|
+
*
|
|
9534
|
+
* A failure is not allowed to fail the connect: the handshake succeeded and
|
|
9535
|
+
* every request-scoped feature works without this stream. It is reported the
|
|
9536
|
+
* way a lost stream is — hand it to the reconnect machinery, which retries
|
|
9537
|
+
* with backoff and settles on `"ended"` past the cap.
|
|
9538
|
+
*
|
|
9539
|
+
* Gated on the same generation test as `subscribeToResource` — see the long
|
|
9540
|
+
* comment there. The `connect` event has deliberately *not* been dispatched
|
|
9541
|
+
* yet (that is the point of running here), so a list-state consumer is not the
|
|
9542
|
+
* risk; what is, is anything else that bumps the generation while this
|
|
9543
|
+
* `listen()` is in flight. `statusChange` has already fired, and any
|
|
9544
|
+
* concurrent call on this instance qualifies: a `subscribeToResource` from a
|
|
9545
|
+
* caller restoring subscriptions, or a `disconnect()` — whose
|
|
9546
|
+
* `resetSubscriptionStream` bumps the generation too, making a reconcile here
|
|
9547
|
+
* arm a reconnect for a session that is already gone.
|
|
9548
|
+
*/
|
|
9549
|
+
async openModernListenStreamOnConnect() {
|
|
9550
|
+
if (!this.isModernEra() || !this.wantsModernStream()) return;
|
|
9551
|
+
const generationBefore = this.modernListenGeneration;
|
|
9552
|
+
try {
|
|
9553
|
+
await this.refreshModernSubscription();
|
|
9554
|
+
} catch (error) {
|
|
9555
|
+
this.logger.error(
|
|
9556
|
+
{ error },
|
|
9557
|
+
"Failed to open the modern subscriptions/listen stream on connect"
|
|
9558
|
+
);
|
|
9559
|
+
if (this.modernListenGeneration === generationBefore + 1) {
|
|
9560
|
+
this.reconcileModernStreamStateAfterFailedRefresh();
|
|
9561
|
+
}
|
|
9562
|
+
}
|
|
9563
|
+
}
|
|
8411
9564
|
/** Cancel a pending reconnect re-listen, if any (#1630). */
|
|
8412
9565
|
clearModernReconnectTimer() {
|
|
8413
9566
|
if (this.modernReconnectTimer !== void 0) {
|
|
@@ -8417,9 +9570,10 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
8417
9570
|
}
|
|
8418
9571
|
/**
|
|
8419
9572
|
* (Re-)establish the modern `subscriptions/listen` stream to match the current
|
|
8420
|
-
*
|
|
8421
|
-
*
|
|
8422
|
-
*
|
|
9573
|
+
* filter (#1630). Because the stream is not resumable, every filter change
|
|
9574
|
+
* re-lists: the existing stream is closed and a fresh `listen()` opened. With
|
|
9575
|
+
* an empty filter — no subscribed URIs *and* no enabled list-change opt-in the
|
|
9576
|
+
* server advertises — the stream is left closed (#1920).
|
|
8423
9577
|
*
|
|
8424
9578
|
* `modernListenGeneration` guards against races — if a newer refresh starts
|
|
8425
9579
|
* while this one awaits its acknowledgement, the just-opened stream is
|
|
@@ -8437,7 +9591,7 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
8437
9591
|
if (previous) {
|
|
8438
9592
|
await closeSubscriptionBestEffort(previous);
|
|
8439
9593
|
}
|
|
8440
|
-
if (this.
|
|
9594
|
+
if (!this.wantsModernStream()) {
|
|
8441
9595
|
this.setModernStreamState(INACTIVE_SUBSCRIPTION_STREAM_STATE);
|
|
8442
9596
|
return;
|
|
8443
9597
|
}
|
|
@@ -8452,7 +9606,7 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
8452
9606
|
this.modernSubscription = subscription;
|
|
8453
9607
|
this.modernReconnectAttempts = 0;
|
|
8454
9608
|
this.setModernStreamState({
|
|
8455
|
-
active:
|
|
9609
|
+
active: this.modernStreamActive(),
|
|
8456
9610
|
status: "acknowledged",
|
|
8457
9611
|
honoredUris: subscription.honoredFilter.resourceSubscriptions ?? []
|
|
8458
9612
|
});
|
|
@@ -8483,10 +9637,10 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
8483
9637
|
return;
|
|
8484
9638
|
}
|
|
8485
9639
|
this.modernSubscription = null;
|
|
8486
|
-
const shouldReconnect = reason === "remote" && !isTerminalStatus(this.status) && this.
|
|
9640
|
+
const shouldReconnect = reason === "remote" && !isTerminalStatus(this.status) && this.wantsModernStream();
|
|
8487
9641
|
if (!shouldReconnect) {
|
|
8488
9642
|
this.setModernStreamState({
|
|
8489
|
-
active: this.
|
|
9643
|
+
active: this.modernStreamActive(),
|
|
8490
9644
|
status: "ended",
|
|
8491
9645
|
honoredUris: []
|
|
8492
9646
|
});
|
|
@@ -8500,10 +9654,11 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
8500
9654
|
* refresh owns the state as well as the filter — so both call sites gate on
|
|
8501
9655
|
* the generation first.
|
|
8502
9656
|
*
|
|
8503
|
-
* The
|
|
8504
|
-
*
|
|
8505
|
-
*
|
|
8506
|
-
*
|
|
9657
|
+
* The two branches are the empty and non-empty *filter* (#1920) — which is
|
|
9658
|
+
* "nothing subscribed" only when no list-change opt-in is live. The empty case
|
|
9659
|
+
* is the ordinary one: nothing to listen for, no stream, inactive. The
|
|
9660
|
+
* non-empty one exists because a failed re-listen leaves `modernSubscription`
|
|
9661
|
+
* null with the filter still wanting a stream, and nothing else will notice: the reconnect machinery is reachable only from a stream that closed
|
|
8507
9662
|
* or a reconnect that failed, and neither happened here. Left alone, the state
|
|
8508
9663
|
* keeps whatever the last success (or the optimistic `"connecting"`) wrote — a
|
|
8509
9664
|
* badge that will never change over subscriptions the server may never have
|
|
@@ -8511,17 +9666,17 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
8511
9666
|
* Subscribe early-returns on the URI already being in the set).
|
|
8512
9667
|
*
|
|
8513
9668
|
* So it reconnects rather than settling for an honest-but-dead `"ended"`:
|
|
8514
|
-
* every other route to "stream gone,
|
|
9669
|
+
* every other route to "stream gone, filter live" either expects the close or
|
|
8515
9670
|
* has exhausted the retry cap, and this is the one that has made no attempt
|
|
8516
9671
|
* at all. `scheduleModernReconnect` fits as-is — a user-initiated refresh
|
|
8517
9672
|
* already reset `modernReconnectAttempts`, so it starts at the base delay; the
|
|
8518
|
-
* timer bails on a terminal status or an emptied
|
|
9673
|
+
* timer bails on a terminal status or an emptied filter; and past the cap
|
|
8519
9674
|
* `onModernReconnectFailed` lands on the same `"ended"` badge. The state
|
|
8520
9675
|
* therefore becomes true or ends after a real attempt. The caller still sees
|
|
8521
9676
|
* its error either way — the retry is about the subscriptions, not the call.
|
|
8522
9677
|
*/
|
|
8523
9678
|
reconcileModernStreamStateAfterFailedRefresh() {
|
|
8524
|
-
if (this.
|
|
9679
|
+
if (!this.wantsModernStream()) {
|
|
8525
9680
|
this.setModernStreamState(INACTIVE_SUBSCRIPTION_STREAM_STATE);
|
|
8526
9681
|
return;
|
|
8527
9682
|
}
|
|
@@ -8535,7 +9690,7 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
8535
9690
|
*/
|
|
8536
9691
|
scheduleModernReconnect() {
|
|
8537
9692
|
this.setModernStreamState({
|
|
8538
|
-
active:
|
|
9693
|
+
active: this.modernStreamActive(),
|
|
8539
9694
|
status: "reconnecting",
|
|
8540
9695
|
honoredUris: []
|
|
8541
9696
|
});
|
|
@@ -8546,7 +9701,7 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
8546
9701
|
this.clearModernReconnectTimer();
|
|
8547
9702
|
this.modernReconnectTimer = setTimeout(() => {
|
|
8548
9703
|
this.modernReconnectTimer = void 0;
|
|
8549
|
-
if (isTerminalStatus(this.status) || this.
|
|
9704
|
+
if (isTerminalStatus(this.status) || !this.wantsModernStream()) {
|
|
8550
9705
|
return;
|
|
8551
9706
|
}
|
|
8552
9707
|
this.refreshModernSubscription(true).catch(
|
|
@@ -8561,9 +9716,9 @@ var InspectorClient = class _InspectorClient extends InspectorClientEventTarget
|
|
|
8561
9716
|
*/
|
|
8562
9717
|
onModernReconnectFailed() {
|
|
8563
9718
|
this.modernReconnectAttempts += 1;
|
|
8564
|
-
if (this.modernReconnectAttempts > MODERN_RECONNECT_MAX_ATTEMPTS || isTerminalStatus(this.status) || this.
|
|
9719
|
+
if (this.modernReconnectAttempts > MODERN_RECONNECT_MAX_ATTEMPTS || isTerminalStatus(this.status) || !this.wantsModernStream()) {
|
|
8565
9720
|
this.setModernStreamState({
|
|
8566
|
-
active: this.
|
|
9721
|
+
active: this.modernStreamActive(),
|
|
8567
9722
|
status: "ended",
|
|
8568
9723
|
honoredUris: []
|
|
8569
9724
|
});
|
|
@@ -9216,6 +10371,11 @@ var ManagedListState = class extends TypedEventTarget {
|
|
|
9216
10371
|
unsubscribe = null;
|
|
9217
10372
|
_metadata = void 0;
|
|
9218
10373
|
listChanged = false;
|
|
10374
|
+
// The last fetch's failure, kept as observable state so a load that fails
|
|
10375
|
+
// (a transport error, or a result the SDK codec rejects as invalid) is
|
|
10376
|
+
// rendered by the list panel instead of vanishing into an unhandled
|
|
10377
|
+
// rejection — which read as "this server has no tools" (#1953).
|
|
10378
|
+
error = null;
|
|
9219
10379
|
config;
|
|
9220
10380
|
// Debounce a burst of `list_changed` notifications into a single
|
|
9221
10381
|
// refresh (or one indicator light) once it settles.
|
|
@@ -9234,7 +10394,8 @@ var ManagedListState = class extends TypedEventTarget {
|
|
|
9234
10394
|
if (this.config.deferWhenPaginated && this.client?.getServerSettings()?.paginatedLists) {
|
|
9235
10395
|
return;
|
|
9236
10396
|
}
|
|
9237
|
-
void this.refresh()
|
|
10397
|
+
void this.refresh().catch(() => {
|
|
10398
|
+
});
|
|
9238
10399
|
};
|
|
9239
10400
|
const onListChanged = () => {
|
|
9240
10401
|
if (this.listChangedTimer !== null) clearTimeout(this.listChangedTimer);
|
|
@@ -9252,6 +10413,7 @@ var ManagedListState = class extends TypedEventTarget {
|
|
|
9252
10413
|
this.items = [];
|
|
9253
10414
|
this.dispatchChange();
|
|
9254
10415
|
this.setListChanged(false);
|
|
10416
|
+
this.setError(null);
|
|
9255
10417
|
}
|
|
9256
10418
|
};
|
|
9257
10419
|
this.client.addEventListener("connect", onConnect);
|
|
@@ -9293,7 +10455,8 @@ var ManagedListState = class extends TypedEventTarget {
|
|
|
9293
10455
|
const settings = this.client?.getServerSettings();
|
|
9294
10456
|
const skipAggregate = this.config.deferWhenPaginated && settings?.paginatedLists;
|
|
9295
10457
|
if (!skipAggregate && settings?.autoRefreshOnListChanged) {
|
|
9296
|
-
await this.refresh(void 0, "refresh")
|
|
10458
|
+
await this.refresh(void 0, "refresh").catch(() => {
|
|
10459
|
+
});
|
|
9297
10460
|
} else if (this.config.supportsIndicator) {
|
|
9298
10461
|
this.setListChanged(true);
|
|
9299
10462
|
}
|
|
@@ -9335,6 +10498,18 @@ var ManagedListState = class extends TypedEventTarget {
|
|
|
9335
10498
|
this.listChanged = value;
|
|
9336
10499
|
this.emit("listChangedChange", value);
|
|
9337
10500
|
}
|
|
10501
|
+
/** The last fetch's failure, or `null` when the last fetch succeeded. */
|
|
10502
|
+
getError() {
|
|
10503
|
+
return this.error;
|
|
10504
|
+
}
|
|
10505
|
+
// Compared by identity rather than message: two distinct failures with the
|
|
10506
|
+
// same text are still two events, and a re-render on a repeat failure is
|
|
10507
|
+
// cheap next to silently coalescing them.
|
|
10508
|
+
setError(value) {
|
|
10509
|
+
if (this.error === value) return;
|
|
10510
|
+
this.error = value;
|
|
10511
|
+
this.emit("errorChange", value);
|
|
10512
|
+
}
|
|
9338
10513
|
setMetadata(metadata) {
|
|
9339
10514
|
this._metadata = metadata;
|
|
9340
10515
|
}
|
|
@@ -9343,9 +10518,29 @@ var ManagedListState = class extends TypedEventTarget {
|
|
|
9343
10518
|
* this fetch: `undefined` (the connect-time load) uses the default `'use'`;
|
|
9344
10519
|
* a user-initiated or auto refresh passes `'refresh'` to force a
|
|
9345
10520
|
* cache-bypassing round trip and re-store the fresh aggregate.
|
|
10521
|
+
*
|
|
10522
|
+
* A failure is recorded as observable state (`getError`) AND re-thrown: the
|
|
10523
|
+
* state drives the panel's error rendering, while the rejection is what the
|
|
10524
|
+
* caller's auth-recovery wrapper keys off to detect a 401 and start a
|
|
10525
|
+
* re-authorization. Callers with nobody to await them (the connect-time load,
|
|
10526
|
+
* the `list_changed` auto-refresh) catch it explicitly (#1953).
|
|
9346
10527
|
*/
|
|
9347
10528
|
async refresh(metadata, cacheMode) {
|
|
9348
|
-
|
|
10529
|
+
let next;
|
|
10530
|
+
try {
|
|
10531
|
+
next = await this.fetchItems(metadata, cacheMode);
|
|
10532
|
+
} catch (err) {
|
|
10533
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
10534
|
+
this.setError(error);
|
|
10535
|
+
if (isClientDecodeRejection(err)) {
|
|
10536
|
+
this.client?.markResponseRejected?.(
|
|
10537
|
+
this.config.listMethod,
|
|
10538
|
+
error.message
|
|
10539
|
+
);
|
|
10540
|
+
}
|
|
10541
|
+
throw err;
|
|
10542
|
+
}
|
|
10543
|
+
this.setError(null);
|
|
9349
10544
|
if (next === null) return this.getItems();
|
|
9350
10545
|
this.applyItems(next);
|
|
9351
10546
|
return this.getItems();
|
|
@@ -9384,6 +10579,7 @@ var ManagedListState = class extends TypedEventTarget {
|
|
|
9384
10579
|
var ManagedToolsState = class extends ManagedListState {
|
|
9385
10580
|
constructor(client, debounceMs = DEFAULT_LIST_CHANGED_DEBOUNCE_MS) {
|
|
9386
10581
|
super(client, {
|
|
10582
|
+
listMethod: "tools/list",
|
|
9387
10583
|
changeEvent: "toolsChange",
|
|
9388
10584
|
listChangedEvent: "toolsListChanged",
|
|
9389
10585
|
capabilityKey: "tools",
|
|
@@ -9445,6 +10641,20 @@ var MessageLogState = class extends TypedEventTarget {
|
|
|
9445
10641
|
}
|
|
9446
10642
|
pushEntry(entry);
|
|
9447
10643
|
};
|
|
10644
|
+
const onResponseRejected = (event) => {
|
|
10645
|
+
const { id, reason } = event.detail;
|
|
10646
|
+
for (let i2 = this.messages.length - 1; i2 >= 0; i2--) {
|
|
10647
|
+
const entry = this.messages[i2];
|
|
10648
|
+
const entryId = entry.message.id;
|
|
10649
|
+
if (entryId !== id) continue;
|
|
10650
|
+
if (entry.direction === "notification") continue;
|
|
10651
|
+
if (entry.direction === "request" && !entry.response) continue;
|
|
10652
|
+
entry.clientError = reason;
|
|
10653
|
+
this.dispatchTypedEvent("message", entry);
|
|
10654
|
+
this.dispatchTypedEvent("messagesChange", this.getMessages());
|
|
10655
|
+
return;
|
|
10656
|
+
}
|
|
10657
|
+
};
|
|
9448
10658
|
const onStatusChange = () => {
|
|
9449
10659
|
if (isTerminalStatus(this.client?.getStatus())) {
|
|
9450
10660
|
this.messages = [];
|
|
@@ -9453,10 +10663,12 @@ var MessageLogState = class extends TypedEventTarget {
|
|
|
9453
10663
|
}
|
|
9454
10664
|
};
|
|
9455
10665
|
this.client.addEventListener("message", onMessage);
|
|
10666
|
+
this.client.addEventListener("responseRejected", onResponseRejected);
|
|
9456
10667
|
this.client.addEventListener("statusChange", onStatusChange);
|
|
9457
10668
|
this.unsubscribe = () => {
|
|
9458
10669
|
if (this.client) {
|
|
9459
10670
|
this.client.removeEventListener("message", onMessage);
|
|
10671
|
+
this.client.removeEventListener("responseRejected", onResponseRejected);
|
|
9460
10672
|
this.client.removeEventListener("statusChange", onStatusChange);
|
|
9461
10673
|
}
|
|
9462
10674
|
this.client = null;
|
|
@@ -9502,6 +10714,7 @@ var MessageLogState = class extends TypedEventTarget {
|
|
|
9502
10714
|
var ManagedResourcesState = class extends ManagedListState {
|
|
9503
10715
|
constructor(client, debounceMs = DEFAULT_LIST_CHANGED_DEBOUNCE_MS) {
|
|
9504
10716
|
super(client, {
|
|
10717
|
+
listMethod: "resources/list",
|
|
9505
10718
|
changeEvent: "resourcesChange",
|
|
9506
10719
|
listChangedEvent: "resourcesListChanged",
|
|
9507
10720
|
capabilityKey: "resources",
|
|
@@ -9523,6 +10736,7 @@ var ManagedResourcesState = class extends ManagedListState {
|
|
|
9523
10736
|
var ManagedResourceTemplatesState = class extends ManagedListState {
|
|
9524
10737
|
constructor(client, debounceMs = DEFAULT_LIST_CHANGED_DEBOUNCE_MS) {
|
|
9525
10738
|
super(client, {
|
|
10739
|
+
listMethod: "resources/templates/list",
|
|
9526
10740
|
changeEvent: "resourceTemplatesChange",
|
|
9527
10741
|
listChangedEvent: "resourceTemplatesListChanged",
|
|
9528
10742
|
// Templates are gated on the broader `resources` capability.
|
|
@@ -9550,6 +10764,7 @@ var ManagedResourceTemplatesState = class extends ManagedListState {
|
|
|
9550
10764
|
var ManagedPromptsState = class extends ManagedListState {
|
|
9551
10765
|
constructor(client, debounceMs = DEFAULT_LIST_CHANGED_DEBOUNCE_MS) {
|
|
9552
10766
|
super(client, {
|
|
10767
|
+
listMethod: "prompts/list",
|
|
9553
10768
|
changeEvent: "promptsChange",
|
|
9554
10769
|
listChangedEvent: "promptsListChanged",
|
|
9555
10770
|
capabilityKey: "prompts",
|
|
@@ -9758,29 +10973,29 @@ var ManagedRequestorTasksState = class extends TypedEventTarget {
|
|
|
9758
10973
|
};
|
|
9759
10974
|
|
|
9760
10975
|
// ../../node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
|
|
9761
|
-
import * as
|
|
10976
|
+
import * as z4 from "zod/v4";
|
|
9762
10977
|
var RELATED_TASK_META_KEY4 = "io.modelcontextprotocol/related-task";
|
|
9763
10978
|
var JSONRPC_VERSION = "2.0";
|
|
9764
|
-
var AssertObjectSchema =
|
|
9765
|
-
var ProgressTokenSchema =
|
|
9766
|
-
var CursorSchema =
|
|
9767
|
-
var TaskCreationParamsSchema =
|
|
10979
|
+
var AssertObjectSchema = z4.custom((v2) => v2 !== null && (typeof v2 === "object" || typeof v2 === "function"));
|
|
10980
|
+
var ProgressTokenSchema = z4.union([z4.string(), z4.number().int()]);
|
|
10981
|
+
var CursorSchema = z4.string();
|
|
10982
|
+
var TaskCreationParamsSchema = z4.looseObject({
|
|
9768
10983
|
/**
|
|
9769
10984
|
* Requested duration in milliseconds to retain task from creation.
|
|
9770
10985
|
*/
|
|
9771
|
-
ttl:
|
|
10986
|
+
ttl: z4.number().optional(),
|
|
9772
10987
|
/**
|
|
9773
10988
|
* Time in milliseconds to wait between task status requests.
|
|
9774
10989
|
*/
|
|
9775
|
-
pollInterval:
|
|
10990
|
+
pollInterval: z4.number().optional()
|
|
9776
10991
|
});
|
|
9777
|
-
var TaskMetadataSchema =
|
|
9778
|
-
ttl:
|
|
10992
|
+
var TaskMetadataSchema = z4.object({
|
|
10993
|
+
ttl: z4.number().optional()
|
|
9779
10994
|
});
|
|
9780
|
-
var RelatedTaskMetadataSchema =
|
|
9781
|
-
taskId:
|
|
10995
|
+
var RelatedTaskMetadataSchema = z4.object({
|
|
10996
|
+
taskId: z4.string()
|
|
9782
10997
|
});
|
|
9783
|
-
var RequestMetaSchema =
|
|
10998
|
+
var RequestMetaSchema = z4.looseObject({
|
|
9784
10999
|
/**
|
|
9785
11000
|
* 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.
|
|
9786
11001
|
*/
|
|
@@ -9790,7 +11005,7 @@ var RequestMetaSchema = z3.looseObject({
|
|
|
9790
11005
|
*/
|
|
9791
11006
|
[RELATED_TASK_META_KEY4]: RelatedTaskMetadataSchema.optional()
|
|
9792
11007
|
});
|
|
9793
|
-
var BaseRequestParamsSchema =
|
|
11008
|
+
var BaseRequestParamsSchema = z4.object({
|
|
9794
11009
|
/**
|
|
9795
11010
|
* See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
|
|
9796
11011
|
*/
|
|
@@ -9807,40 +11022,40 @@ var TaskAugmentedRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
|
9807
11022
|
*/
|
|
9808
11023
|
task: TaskMetadataSchema.optional()
|
|
9809
11024
|
});
|
|
9810
|
-
var RequestSchema =
|
|
9811
|
-
method:
|
|
11025
|
+
var RequestSchema = z4.object({
|
|
11026
|
+
method: z4.string(),
|
|
9812
11027
|
params: BaseRequestParamsSchema.loose().optional()
|
|
9813
11028
|
});
|
|
9814
|
-
var NotificationsParamsSchema =
|
|
11029
|
+
var NotificationsParamsSchema = z4.object({
|
|
9815
11030
|
/**
|
|
9816
11031
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
9817
11032
|
* for notes on _meta usage.
|
|
9818
11033
|
*/
|
|
9819
11034
|
_meta: RequestMetaSchema.optional()
|
|
9820
11035
|
});
|
|
9821
|
-
var NotificationSchema2 =
|
|
9822
|
-
method:
|
|
11036
|
+
var NotificationSchema2 = z4.object({
|
|
11037
|
+
method: z4.string(),
|
|
9823
11038
|
params: NotificationsParamsSchema.loose().optional()
|
|
9824
11039
|
});
|
|
9825
|
-
var ResultSchema =
|
|
11040
|
+
var ResultSchema = z4.looseObject({
|
|
9826
11041
|
/**
|
|
9827
11042
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
9828
11043
|
* for notes on _meta usage.
|
|
9829
11044
|
*/
|
|
9830
11045
|
_meta: RequestMetaSchema.optional()
|
|
9831
11046
|
});
|
|
9832
|
-
var RequestIdSchema =
|
|
9833
|
-
var JSONRPCRequestSchema =
|
|
9834
|
-
jsonrpc:
|
|
11047
|
+
var RequestIdSchema = z4.union([z4.string(), z4.number().int()]);
|
|
11048
|
+
var JSONRPCRequestSchema = z4.object({
|
|
11049
|
+
jsonrpc: z4.literal(JSONRPC_VERSION),
|
|
9835
11050
|
id: RequestIdSchema,
|
|
9836
11051
|
...RequestSchema.shape
|
|
9837
11052
|
}).strict();
|
|
9838
|
-
var JSONRPCNotificationSchema =
|
|
9839
|
-
jsonrpc:
|
|
11053
|
+
var JSONRPCNotificationSchema = z4.object({
|
|
11054
|
+
jsonrpc: z4.literal(JSONRPC_VERSION),
|
|
9840
11055
|
...NotificationSchema2.shape
|
|
9841
11056
|
}).strict();
|
|
9842
|
-
var JSONRPCResultResponseSchema =
|
|
9843
|
-
jsonrpc:
|
|
11057
|
+
var JSONRPCResultResponseSchema = z4.object({
|
|
11058
|
+
jsonrpc: z4.literal(JSONRPC_VERSION),
|
|
9844
11059
|
id: RequestIdSchema,
|
|
9845
11060
|
result: ResultSchema
|
|
9846
11061
|
}).strict();
|
|
@@ -9855,31 +11070,31 @@ var ErrorCode;
|
|
|
9855
11070
|
ErrorCode2[ErrorCode2["InternalError"] = -32603] = "InternalError";
|
|
9856
11071
|
ErrorCode2[ErrorCode2["UrlElicitationRequired"] = -32042] = "UrlElicitationRequired";
|
|
9857
11072
|
})(ErrorCode || (ErrorCode = {}));
|
|
9858
|
-
var JSONRPCErrorResponseSchema =
|
|
9859
|
-
jsonrpc:
|
|
11073
|
+
var JSONRPCErrorResponseSchema = z4.object({
|
|
11074
|
+
jsonrpc: z4.literal(JSONRPC_VERSION),
|
|
9860
11075
|
id: RequestIdSchema.optional(),
|
|
9861
|
-
error:
|
|
11076
|
+
error: z4.object({
|
|
9862
11077
|
/**
|
|
9863
11078
|
* The error type that occurred.
|
|
9864
11079
|
*/
|
|
9865
|
-
code:
|
|
11080
|
+
code: z4.number().int(),
|
|
9866
11081
|
/**
|
|
9867
11082
|
* A short description of the error. The message SHOULD be limited to a concise single sentence.
|
|
9868
11083
|
*/
|
|
9869
|
-
message:
|
|
11084
|
+
message: z4.string(),
|
|
9870
11085
|
/**
|
|
9871
11086
|
* Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
|
|
9872
11087
|
*/
|
|
9873
|
-
data:
|
|
11088
|
+
data: z4.unknown().optional()
|
|
9874
11089
|
})
|
|
9875
11090
|
}).strict();
|
|
9876
|
-
var JSONRPCMessageSchema =
|
|
11091
|
+
var JSONRPCMessageSchema = z4.union([
|
|
9877
11092
|
JSONRPCRequestSchema,
|
|
9878
11093
|
JSONRPCNotificationSchema,
|
|
9879
11094
|
JSONRPCResultResponseSchema,
|
|
9880
11095
|
JSONRPCErrorResponseSchema
|
|
9881
11096
|
]);
|
|
9882
|
-
var JSONRPCResponseSchema =
|
|
11097
|
+
var JSONRPCResponseSchema = z4.union([JSONRPCResultResponseSchema, JSONRPCErrorResponseSchema]);
|
|
9883
11098
|
var EmptyResultSchema2 = ResultSchema.strict();
|
|
9884
11099
|
var CancelledNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
9885
11100
|
/**
|
|
@@ -9891,28 +11106,28 @@ var CancelledNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
|
9891
11106
|
/**
|
|
9892
11107
|
* An optional string describing the reason for the cancellation. This MAY be logged or presented to the user.
|
|
9893
11108
|
*/
|
|
9894
|
-
reason:
|
|
11109
|
+
reason: z4.string().optional()
|
|
9895
11110
|
});
|
|
9896
11111
|
var CancelledNotificationSchema = NotificationSchema2.extend({
|
|
9897
|
-
method:
|
|
11112
|
+
method: z4.literal("notifications/cancelled"),
|
|
9898
11113
|
params: CancelledNotificationParamsSchema
|
|
9899
11114
|
});
|
|
9900
|
-
var IconSchema =
|
|
11115
|
+
var IconSchema = z4.object({
|
|
9901
11116
|
/**
|
|
9902
11117
|
* URL or data URI for the icon.
|
|
9903
11118
|
*/
|
|
9904
|
-
src:
|
|
11119
|
+
src: z4.string(),
|
|
9905
11120
|
/**
|
|
9906
11121
|
* Optional MIME type for the icon.
|
|
9907
11122
|
*/
|
|
9908
|
-
mimeType:
|
|
11123
|
+
mimeType: z4.string().optional(),
|
|
9909
11124
|
/**
|
|
9910
11125
|
* Optional array of strings that specify sizes at which the icon can be used.
|
|
9911
11126
|
* Each string should be in WxH format (e.g., `"48x48"`, `"96x96"`) or `"any"` for scalable formats like SVG.
|
|
9912
11127
|
*
|
|
9913
11128
|
* If not provided, the client should assume that the icon can be used at any size.
|
|
9914
11129
|
*/
|
|
9915
|
-
sizes:
|
|
11130
|
+
sizes: z4.array(z4.string()).optional(),
|
|
9916
11131
|
/**
|
|
9917
11132
|
* Optional specifier for the theme this icon is designed for. `light` indicates
|
|
9918
11133
|
* the icon is designed to be used with a light background, and `dark` indicates
|
|
@@ -9920,9 +11135,9 @@ var IconSchema = z3.object({
|
|
|
9920
11135
|
*
|
|
9921
11136
|
* If not provided, the client should assume the icon can be used with any theme.
|
|
9922
11137
|
*/
|
|
9923
|
-
theme:
|
|
11138
|
+
theme: z4.enum(["light", "dark"]).optional()
|
|
9924
11139
|
});
|
|
9925
|
-
var IconsSchema =
|
|
11140
|
+
var IconsSchema = z4.object({
|
|
9926
11141
|
/**
|
|
9927
11142
|
* Optional set of sized icons that the client can display in a user interface.
|
|
9928
11143
|
*
|
|
@@ -9934,11 +11149,11 @@ var IconsSchema = z3.object({
|
|
|
9934
11149
|
* - `image/svg+xml` - SVG images (scalable but requires security precautions)
|
|
9935
11150
|
* - `image/webp` - WebP images (modern, efficient format)
|
|
9936
11151
|
*/
|
|
9937
|
-
icons:
|
|
11152
|
+
icons: z4.array(IconSchema).optional()
|
|
9938
11153
|
});
|
|
9939
|
-
var BaseMetadataSchema =
|
|
11154
|
+
var BaseMetadataSchema = z4.object({
|
|
9940
11155
|
/** Intended for programmatic or logical use, but used as a display name in past specs or fallback */
|
|
9941
|
-
name:
|
|
11156
|
+
name: z4.string(),
|
|
9942
11157
|
/**
|
|
9943
11158
|
* Intended for UI and end-user contexts — optimized to be human-readable and easily understood,
|
|
9944
11159
|
* even by those unfamiliar with domain-specific terminology.
|
|
@@ -9947,16 +11162,16 @@ var BaseMetadataSchema = z3.object({
|
|
|
9947
11162
|
* where `annotations.title` should be given precedence over using `name`,
|
|
9948
11163
|
* if present).
|
|
9949
11164
|
*/
|
|
9950
|
-
title:
|
|
11165
|
+
title: z4.string().optional()
|
|
9951
11166
|
});
|
|
9952
11167
|
var ImplementationSchema = BaseMetadataSchema.extend({
|
|
9953
11168
|
...BaseMetadataSchema.shape,
|
|
9954
11169
|
...IconsSchema.shape,
|
|
9955
|
-
version:
|
|
11170
|
+
version: z4.string(),
|
|
9956
11171
|
/**
|
|
9957
11172
|
* An optional URL of the website for this implementation.
|
|
9958
11173
|
*/
|
|
9959
|
-
websiteUrl:
|
|
11174
|
+
websiteUrl: z4.string().optional(),
|
|
9960
11175
|
/**
|
|
9961
11176
|
* An optional human-readable description of what this implementation does.
|
|
9962
11177
|
*
|
|
@@ -9964,23 +11179,23 @@ var ImplementationSchema = BaseMetadataSchema.extend({
|
|
|
9964
11179
|
* and capabilities. For example, a server might describe the types of resources
|
|
9965
11180
|
* or tools it provides, while a client might describe its intended use case.
|
|
9966
11181
|
*/
|
|
9967
|
-
description:
|
|
11182
|
+
description: z4.string().optional()
|
|
9968
11183
|
});
|
|
9969
|
-
var FormElicitationCapabilitySchema =
|
|
9970
|
-
applyDefaults:
|
|
9971
|
-
}),
|
|
9972
|
-
var ElicitationCapabilitySchema =
|
|
11184
|
+
var FormElicitationCapabilitySchema = z4.intersection(z4.object({
|
|
11185
|
+
applyDefaults: z4.boolean().optional()
|
|
11186
|
+
}), z4.record(z4.string(), z4.unknown()));
|
|
11187
|
+
var ElicitationCapabilitySchema = z4.preprocess((value) => {
|
|
9973
11188
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
9974
11189
|
if (Object.keys(value).length === 0) {
|
|
9975
11190
|
return { form: {} };
|
|
9976
11191
|
}
|
|
9977
11192
|
}
|
|
9978
11193
|
return value;
|
|
9979
|
-
},
|
|
11194
|
+
}, z4.intersection(z4.object({
|
|
9980
11195
|
form: FormElicitationCapabilitySchema.optional(),
|
|
9981
11196
|
url: AssertObjectSchema.optional()
|
|
9982
|
-
}),
|
|
9983
|
-
var ClientTasksCapabilitySchema =
|
|
11197
|
+
}), z4.record(z4.string(), z4.unknown()).optional()));
|
|
11198
|
+
var ClientTasksCapabilitySchema = z4.looseObject({
|
|
9984
11199
|
/**
|
|
9985
11200
|
* Present if the client supports listing tasks.
|
|
9986
11201
|
*/
|
|
@@ -9992,22 +11207,22 @@ var ClientTasksCapabilitySchema = z3.looseObject({
|
|
|
9992
11207
|
/**
|
|
9993
11208
|
* Capabilities for task creation on specific request types.
|
|
9994
11209
|
*/
|
|
9995
|
-
requests:
|
|
11210
|
+
requests: z4.looseObject({
|
|
9996
11211
|
/**
|
|
9997
11212
|
* Task support for sampling requests.
|
|
9998
11213
|
*/
|
|
9999
|
-
sampling:
|
|
11214
|
+
sampling: z4.looseObject({
|
|
10000
11215
|
createMessage: AssertObjectSchema.optional()
|
|
10001
11216
|
}).optional(),
|
|
10002
11217
|
/**
|
|
10003
11218
|
* Task support for elicitation requests.
|
|
10004
11219
|
*/
|
|
10005
|
-
elicitation:
|
|
11220
|
+
elicitation: z4.looseObject({
|
|
10006
11221
|
create: AssertObjectSchema.optional()
|
|
10007
11222
|
}).optional()
|
|
10008
11223
|
}).optional()
|
|
10009
11224
|
});
|
|
10010
|
-
var ServerTasksCapabilitySchema =
|
|
11225
|
+
var ServerTasksCapabilitySchema = z4.looseObject({
|
|
10011
11226
|
/**
|
|
10012
11227
|
* Present if the server supports listing tasks.
|
|
10013
11228
|
*/
|
|
@@ -10019,24 +11234,24 @@ var ServerTasksCapabilitySchema = z3.looseObject({
|
|
|
10019
11234
|
/**
|
|
10020
11235
|
* Capabilities for task creation on specific request types.
|
|
10021
11236
|
*/
|
|
10022
|
-
requests:
|
|
11237
|
+
requests: z4.looseObject({
|
|
10023
11238
|
/**
|
|
10024
11239
|
* Task support for tool requests.
|
|
10025
11240
|
*/
|
|
10026
|
-
tools:
|
|
11241
|
+
tools: z4.looseObject({
|
|
10027
11242
|
call: AssertObjectSchema.optional()
|
|
10028
11243
|
}).optional()
|
|
10029
11244
|
}).optional()
|
|
10030
11245
|
});
|
|
10031
|
-
var ClientCapabilitiesSchema =
|
|
11246
|
+
var ClientCapabilitiesSchema = z4.object({
|
|
10032
11247
|
/**
|
|
10033
11248
|
* Experimental, non-standard capabilities that the client supports.
|
|
10034
11249
|
*/
|
|
10035
|
-
experimental:
|
|
11250
|
+
experimental: z4.record(z4.string(), AssertObjectSchema).optional(),
|
|
10036
11251
|
/**
|
|
10037
11252
|
* Present if the client supports sampling from an LLM.
|
|
10038
11253
|
*/
|
|
10039
|
-
sampling:
|
|
11254
|
+
sampling: z4.object({
|
|
10040
11255
|
/**
|
|
10041
11256
|
* Present if the client supports context inclusion via includeContext parameter.
|
|
10042
11257
|
* If not declared, servers SHOULD only use `includeContext: "none"` (or omit it).
|
|
@@ -10054,11 +11269,11 @@ var ClientCapabilitiesSchema = z3.object({
|
|
|
10054
11269
|
/**
|
|
10055
11270
|
* Present if the client supports listing roots.
|
|
10056
11271
|
*/
|
|
10057
|
-
roots:
|
|
11272
|
+
roots: z4.object({
|
|
10058
11273
|
/**
|
|
10059
11274
|
* Whether the client supports issuing notifications for changes to the roots list.
|
|
10060
11275
|
*/
|
|
10061
|
-
listChanged:
|
|
11276
|
+
listChanged: z4.boolean().optional()
|
|
10062
11277
|
}).optional(),
|
|
10063
11278
|
/**
|
|
10064
11279
|
* Present if the client supports task creation.
|
|
@@ -10067,25 +11282,25 @@ var ClientCapabilitiesSchema = z3.object({
|
|
|
10067
11282
|
/**
|
|
10068
11283
|
* Extensions that the client supports. Keys are extension identifiers (vendor-prefix/extension-name).
|
|
10069
11284
|
*/
|
|
10070
|
-
extensions:
|
|
11285
|
+
extensions: z4.record(z4.string(), AssertObjectSchema).optional()
|
|
10071
11286
|
});
|
|
10072
11287
|
var InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
10073
11288
|
/**
|
|
10074
11289
|
* The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well.
|
|
10075
11290
|
*/
|
|
10076
|
-
protocolVersion:
|
|
11291
|
+
protocolVersion: z4.string(),
|
|
10077
11292
|
capabilities: ClientCapabilitiesSchema,
|
|
10078
11293
|
clientInfo: ImplementationSchema
|
|
10079
11294
|
});
|
|
10080
11295
|
var InitializeRequestSchema = RequestSchema.extend({
|
|
10081
|
-
method:
|
|
11296
|
+
method: z4.literal("initialize"),
|
|
10082
11297
|
params: InitializeRequestParamsSchema
|
|
10083
11298
|
});
|
|
10084
|
-
var ServerCapabilitiesSchema =
|
|
11299
|
+
var ServerCapabilitiesSchema = z4.object({
|
|
10085
11300
|
/**
|
|
10086
11301
|
* Experimental, non-standard capabilities that the server supports.
|
|
10087
11302
|
*/
|
|
10088
|
-
experimental:
|
|
11303
|
+
experimental: z4.record(z4.string(), AssertObjectSchema).optional(),
|
|
10089
11304
|
/**
|
|
10090
11305
|
* Present if the server supports sending log messages to the client.
|
|
10091
11306
|
*/
|
|
@@ -10097,33 +11312,33 @@ var ServerCapabilitiesSchema = z3.object({
|
|
|
10097
11312
|
/**
|
|
10098
11313
|
* Present if the server offers any prompt templates.
|
|
10099
11314
|
*/
|
|
10100
|
-
prompts:
|
|
11315
|
+
prompts: z4.object({
|
|
10101
11316
|
/**
|
|
10102
11317
|
* Whether this server supports issuing notifications for changes to the prompt list.
|
|
10103
11318
|
*/
|
|
10104
|
-
listChanged:
|
|
11319
|
+
listChanged: z4.boolean().optional()
|
|
10105
11320
|
}).optional(),
|
|
10106
11321
|
/**
|
|
10107
11322
|
* Present if the server offers any resources to read.
|
|
10108
11323
|
*/
|
|
10109
|
-
resources:
|
|
11324
|
+
resources: z4.object({
|
|
10110
11325
|
/**
|
|
10111
11326
|
* Whether this server supports clients subscribing to resource updates.
|
|
10112
11327
|
*/
|
|
10113
|
-
subscribe:
|
|
11328
|
+
subscribe: z4.boolean().optional(),
|
|
10114
11329
|
/**
|
|
10115
11330
|
* Whether this server supports issuing notifications for changes to the resource list.
|
|
10116
11331
|
*/
|
|
10117
|
-
listChanged:
|
|
11332
|
+
listChanged: z4.boolean().optional()
|
|
10118
11333
|
}).optional(),
|
|
10119
11334
|
/**
|
|
10120
11335
|
* Present if the server offers any tools to call.
|
|
10121
11336
|
*/
|
|
10122
|
-
tools:
|
|
11337
|
+
tools: z4.object({
|
|
10123
11338
|
/**
|
|
10124
11339
|
* Whether this server supports issuing notifications for changes to the tool list.
|
|
10125
11340
|
*/
|
|
10126
|
-
listChanged:
|
|
11341
|
+
listChanged: z4.boolean().optional()
|
|
10127
11342
|
}).optional(),
|
|
10128
11343
|
/**
|
|
10129
11344
|
* Present if the server supports task creation.
|
|
@@ -10132,13 +11347,13 @@ var ServerCapabilitiesSchema = z3.object({
|
|
|
10132
11347
|
/**
|
|
10133
11348
|
* Extensions that the server supports. Keys are extension identifiers (vendor-prefix/extension-name).
|
|
10134
11349
|
*/
|
|
10135
|
-
extensions:
|
|
11350
|
+
extensions: z4.record(z4.string(), AssertObjectSchema).optional()
|
|
10136
11351
|
});
|
|
10137
11352
|
var InitializeResultSchema = ResultSchema.extend({
|
|
10138
11353
|
/**
|
|
10139
11354
|
* 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.
|
|
10140
11355
|
*/
|
|
10141
|
-
protocolVersion:
|
|
11356
|
+
protocolVersion: z4.string(),
|
|
10142
11357
|
capabilities: ServerCapabilitiesSchema,
|
|
10143
11358
|
serverInfo: ImplementationSchema,
|
|
10144
11359
|
/**
|
|
@@ -10146,31 +11361,31 @@ var InitializeResultSchema = ResultSchema.extend({
|
|
|
10146
11361
|
*
|
|
10147
11362
|
* 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.
|
|
10148
11363
|
*/
|
|
10149
|
-
instructions:
|
|
11364
|
+
instructions: z4.string().optional()
|
|
10150
11365
|
});
|
|
10151
11366
|
var InitializedNotificationSchema = NotificationSchema2.extend({
|
|
10152
|
-
method:
|
|
11367
|
+
method: z4.literal("notifications/initialized"),
|
|
10153
11368
|
params: NotificationsParamsSchema.optional()
|
|
10154
11369
|
});
|
|
10155
11370
|
var PingRequestSchema = RequestSchema.extend({
|
|
10156
|
-
method:
|
|
11371
|
+
method: z4.literal("ping"),
|
|
10157
11372
|
params: BaseRequestParamsSchema.optional()
|
|
10158
11373
|
});
|
|
10159
|
-
var ProgressSchema =
|
|
11374
|
+
var ProgressSchema = z4.object({
|
|
10160
11375
|
/**
|
|
10161
11376
|
* The progress thus far. This should increase every time progress is made, even if the total is unknown.
|
|
10162
11377
|
*/
|
|
10163
|
-
progress:
|
|
11378
|
+
progress: z4.number(),
|
|
10164
11379
|
/**
|
|
10165
11380
|
* Total number of items to process (or total progress required), if known.
|
|
10166
11381
|
*/
|
|
10167
|
-
total:
|
|
11382
|
+
total: z4.optional(z4.number()),
|
|
10168
11383
|
/**
|
|
10169
11384
|
* An optional message describing the current progress.
|
|
10170
11385
|
*/
|
|
10171
|
-
message:
|
|
11386
|
+
message: z4.optional(z4.string())
|
|
10172
11387
|
});
|
|
10173
|
-
var ProgressNotificationParamsSchema =
|
|
11388
|
+
var ProgressNotificationParamsSchema = z4.object({
|
|
10174
11389
|
...NotificationsParamsSchema.shape,
|
|
10175
11390
|
...ProgressSchema.shape,
|
|
10176
11391
|
/**
|
|
@@ -10179,7 +11394,7 @@ var ProgressNotificationParamsSchema = z3.object({
|
|
|
10179
11394
|
progressToken: ProgressTokenSchema
|
|
10180
11395
|
});
|
|
10181
11396
|
var ProgressNotificationSchema = NotificationSchema2.extend({
|
|
10182
|
-
method:
|
|
11397
|
+
method: z4.literal("notifications/progress"),
|
|
10183
11398
|
params: ProgressNotificationParamsSchema
|
|
10184
11399
|
});
|
|
10185
11400
|
var PaginatedRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
@@ -10199,86 +11414,86 @@ var PaginatedResultSchema = ResultSchema.extend({
|
|
|
10199
11414
|
*/
|
|
10200
11415
|
nextCursor: CursorSchema.optional()
|
|
10201
11416
|
});
|
|
10202
|
-
var TaskStatusSchema =
|
|
10203
|
-
var TaskSchema =
|
|
10204
|
-
taskId:
|
|
11417
|
+
var TaskStatusSchema = z4.enum(["working", "input_required", "completed", "failed", "cancelled"]);
|
|
11418
|
+
var TaskSchema = z4.object({
|
|
11419
|
+
taskId: z4.string(),
|
|
10205
11420
|
status: TaskStatusSchema,
|
|
10206
11421
|
/**
|
|
10207
11422
|
* Time in milliseconds to keep task results available after completion.
|
|
10208
11423
|
* If null, the task has unlimited lifetime until manually cleaned up.
|
|
10209
11424
|
*/
|
|
10210
|
-
ttl:
|
|
11425
|
+
ttl: z4.union([z4.number(), z4.null()]),
|
|
10211
11426
|
/**
|
|
10212
11427
|
* ISO 8601 timestamp when the task was created.
|
|
10213
11428
|
*/
|
|
10214
|
-
createdAt:
|
|
11429
|
+
createdAt: z4.string(),
|
|
10215
11430
|
/**
|
|
10216
11431
|
* ISO 8601 timestamp when the task was last updated.
|
|
10217
11432
|
*/
|
|
10218
|
-
lastUpdatedAt:
|
|
10219
|
-
pollInterval:
|
|
11433
|
+
lastUpdatedAt: z4.string(),
|
|
11434
|
+
pollInterval: z4.optional(z4.number()),
|
|
10220
11435
|
/**
|
|
10221
11436
|
* Optional diagnostic message for failed tasks or other status information.
|
|
10222
11437
|
*/
|
|
10223
|
-
statusMessage:
|
|
11438
|
+
statusMessage: z4.optional(z4.string())
|
|
10224
11439
|
});
|
|
10225
11440
|
var CreateTaskResultSchema2 = ResultSchema.extend({
|
|
10226
11441
|
task: TaskSchema
|
|
10227
11442
|
});
|
|
10228
11443
|
var TaskStatusNotificationParamsSchema = NotificationsParamsSchema.merge(TaskSchema);
|
|
10229
11444
|
var TaskStatusNotificationSchema2 = NotificationSchema2.extend({
|
|
10230
|
-
method:
|
|
11445
|
+
method: z4.literal("notifications/tasks/status"),
|
|
10231
11446
|
params: TaskStatusNotificationParamsSchema
|
|
10232
11447
|
});
|
|
10233
11448
|
var GetTaskRequestSchema2 = RequestSchema.extend({
|
|
10234
|
-
method:
|
|
11449
|
+
method: z4.literal("tasks/get"),
|
|
10235
11450
|
params: BaseRequestParamsSchema.extend({
|
|
10236
|
-
taskId:
|
|
11451
|
+
taskId: z4.string()
|
|
10237
11452
|
})
|
|
10238
11453
|
});
|
|
10239
11454
|
var GetTaskResultSchema2 = ResultSchema.merge(TaskSchema);
|
|
10240
11455
|
var GetTaskPayloadRequestSchema2 = RequestSchema.extend({
|
|
10241
|
-
method:
|
|
11456
|
+
method: z4.literal("tasks/result"),
|
|
10242
11457
|
params: BaseRequestParamsSchema.extend({
|
|
10243
|
-
taskId:
|
|
11458
|
+
taskId: z4.string()
|
|
10244
11459
|
})
|
|
10245
11460
|
});
|
|
10246
11461
|
var GetTaskPayloadResultSchema = ResultSchema.loose();
|
|
10247
11462
|
var ListTasksRequestSchema2 = PaginatedRequestSchema.extend({
|
|
10248
|
-
method:
|
|
11463
|
+
method: z4.literal("tasks/list")
|
|
10249
11464
|
});
|
|
10250
11465
|
var ListTasksResultSchema2 = PaginatedResultSchema.extend({
|
|
10251
|
-
tasks:
|
|
11466
|
+
tasks: z4.array(TaskSchema)
|
|
10252
11467
|
});
|
|
10253
11468
|
var CancelTaskRequestSchema2 = RequestSchema.extend({
|
|
10254
|
-
method:
|
|
11469
|
+
method: z4.literal("tasks/cancel"),
|
|
10255
11470
|
params: BaseRequestParamsSchema.extend({
|
|
10256
|
-
taskId:
|
|
11471
|
+
taskId: z4.string()
|
|
10257
11472
|
})
|
|
10258
11473
|
});
|
|
10259
11474
|
var CancelTaskResultSchema2 = ResultSchema.merge(TaskSchema);
|
|
10260
|
-
var ResourceContentsSchema =
|
|
11475
|
+
var ResourceContentsSchema = z4.object({
|
|
10261
11476
|
/**
|
|
10262
11477
|
* The URI of this resource.
|
|
10263
11478
|
*/
|
|
10264
|
-
uri:
|
|
11479
|
+
uri: z4.string(),
|
|
10265
11480
|
/**
|
|
10266
11481
|
* The MIME type of this resource, if known.
|
|
10267
11482
|
*/
|
|
10268
|
-
mimeType:
|
|
11483
|
+
mimeType: z4.optional(z4.string()),
|
|
10269
11484
|
/**
|
|
10270
11485
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
10271
11486
|
* for notes on _meta usage.
|
|
10272
11487
|
*/
|
|
10273
|
-
_meta:
|
|
11488
|
+
_meta: z4.record(z4.string(), z4.unknown()).optional()
|
|
10274
11489
|
});
|
|
10275
11490
|
var TextResourceContentsSchema = ResourceContentsSchema.extend({
|
|
10276
11491
|
/**
|
|
10277
11492
|
* The text of the item. This must only be set if the item can actually be represented as text (not binary data).
|
|
10278
11493
|
*/
|
|
10279
|
-
text:
|
|
11494
|
+
text: z4.string()
|
|
10280
11495
|
});
|
|
10281
|
-
var Base64Schema =
|
|
11496
|
+
var Base64Schema = z4.string().refine((val) => {
|
|
10282
11497
|
try {
|
|
10283
11498
|
atob(val);
|
|
10284
11499
|
return true;
|
|
@@ -10292,44 +11507,44 @@ var BlobResourceContentsSchema = ResourceContentsSchema.extend({
|
|
|
10292
11507
|
*/
|
|
10293
11508
|
blob: Base64Schema
|
|
10294
11509
|
});
|
|
10295
|
-
var RoleSchema =
|
|
10296
|
-
var AnnotationsSchema =
|
|
11510
|
+
var RoleSchema = z4.enum(["user", "assistant"]);
|
|
11511
|
+
var AnnotationsSchema = z4.object({
|
|
10297
11512
|
/**
|
|
10298
11513
|
* Intended audience(s) for the resource.
|
|
10299
11514
|
*/
|
|
10300
|
-
audience:
|
|
11515
|
+
audience: z4.array(RoleSchema).optional(),
|
|
10301
11516
|
/**
|
|
10302
11517
|
* Importance hint for the resource, from 0 (least) to 1 (most).
|
|
10303
11518
|
*/
|
|
10304
|
-
priority:
|
|
11519
|
+
priority: z4.number().min(0).max(1).optional(),
|
|
10305
11520
|
/**
|
|
10306
11521
|
* ISO 8601 timestamp for the most recent modification.
|
|
10307
11522
|
*/
|
|
10308
|
-
lastModified:
|
|
11523
|
+
lastModified: z4.iso.datetime({ offset: true }).optional()
|
|
10309
11524
|
});
|
|
10310
|
-
var
|
|
11525
|
+
var ResourceSchema2 = z4.object({
|
|
10311
11526
|
...BaseMetadataSchema.shape,
|
|
10312
11527
|
...IconsSchema.shape,
|
|
10313
11528
|
/**
|
|
10314
11529
|
* The URI of this resource.
|
|
10315
11530
|
*/
|
|
10316
|
-
uri:
|
|
11531
|
+
uri: z4.string(),
|
|
10317
11532
|
/**
|
|
10318
11533
|
* A description of what this resource represents.
|
|
10319
11534
|
*
|
|
10320
11535
|
* 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.
|
|
10321
11536
|
*/
|
|
10322
|
-
description:
|
|
11537
|
+
description: z4.optional(z4.string()),
|
|
10323
11538
|
/**
|
|
10324
11539
|
* The MIME type of this resource, if known.
|
|
10325
11540
|
*/
|
|
10326
|
-
mimeType:
|
|
11541
|
+
mimeType: z4.optional(z4.string()),
|
|
10327
11542
|
/**
|
|
10328
11543
|
* The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.
|
|
10329
11544
|
*
|
|
10330
11545
|
* This can be used by Hosts to display file sizes and estimate context window usage.
|
|
10331
11546
|
*/
|
|
10332
|
-
size:
|
|
11547
|
+
size: z4.optional(z4.number()),
|
|
10333
11548
|
/**
|
|
10334
11549
|
* Optional annotations for the client.
|
|
10335
11550
|
*/
|
|
@@ -10338,25 +11553,25 @@ var ResourceSchema = z3.object({
|
|
|
10338
11553
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
10339
11554
|
* for notes on _meta usage.
|
|
10340
11555
|
*/
|
|
10341
|
-
_meta:
|
|
11556
|
+
_meta: z4.optional(z4.looseObject({}))
|
|
10342
11557
|
});
|
|
10343
|
-
var
|
|
11558
|
+
var ResourceTemplateSchema2 = z4.object({
|
|
10344
11559
|
...BaseMetadataSchema.shape,
|
|
10345
11560
|
...IconsSchema.shape,
|
|
10346
11561
|
/**
|
|
10347
11562
|
* A URI template (according to RFC 6570) that can be used to construct resource URIs.
|
|
10348
11563
|
*/
|
|
10349
|
-
uriTemplate:
|
|
11564
|
+
uriTemplate: z4.string(),
|
|
10350
11565
|
/**
|
|
10351
11566
|
* A description of what this template is for.
|
|
10352
11567
|
*
|
|
10353
11568
|
* 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.
|
|
10354
11569
|
*/
|
|
10355
|
-
description:
|
|
11570
|
+
description: z4.optional(z4.string()),
|
|
10356
11571
|
/**
|
|
10357
11572
|
* 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.
|
|
10358
11573
|
*/
|
|
10359
|
-
mimeType:
|
|
11574
|
+
mimeType: z4.optional(z4.string()),
|
|
10360
11575
|
/**
|
|
10361
11576
|
* Optional annotations for the client.
|
|
10362
11577
|
*/
|
|
@@ -10365,19 +11580,19 @@ var ResourceTemplateSchema = z3.object({
|
|
|
10365
11580
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
10366
11581
|
* for notes on _meta usage.
|
|
10367
11582
|
*/
|
|
10368
|
-
_meta:
|
|
11583
|
+
_meta: z4.optional(z4.looseObject({}))
|
|
10369
11584
|
});
|
|
10370
11585
|
var ListResourcesRequestSchema = PaginatedRequestSchema.extend({
|
|
10371
|
-
method:
|
|
11586
|
+
method: z4.literal("resources/list")
|
|
10372
11587
|
});
|
|
10373
11588
|
var ListResourcesResultSchema2 = PaginatedResultSchema.extend({
|
|
10374
|
-
resources:
|
|
11589
|
+
resources: z4.array(ResourceSchema2)
|
|
10375
11590
|
});
|
|
10376
11591
|
var ListResourceTemplatesRequestSchema = PaginatedRequestSchema.extend({
|
|
10377
|
-
method:
|
|
11592
|
+
method: z4.literal("resources/templates/list")
|
|
10378
11593
|
});
|
|
10379
11594
|
var ListResourceTemplatesResultSchema2 = PaginatedResultSchema.extend({
|
|
10380
|
-
resourceTemplates:
|
|
11595
|
+
resourceTemplates: z4.array(ResourceTemplateSchema2)
|
|
10381
11596
|
});
|
|
10382
11597
|
var ResourceRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
10383
11598
|
/**
|
|
@@ -10385,97 +11600,97 @@ var ResourceRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
|
10385
11600
|
*
|
|
10386
11601
|
* @format uri
|
|
10387
11602
|
*/
|
|
10388
|
-
uri:
|
|
11603
|
+
uri: z4.string()
|
|
10389
11604
|
});
|
|
10390
11605
|
var ReadResourceRequestParamsSchema = ResourceRequestParamsSchema;
|
|
10391
11606
|
var ReadResourceRequestSchema = RequestSchema.extend({
|
|
10392
|
-
method:
|
|
11607
|
+
method: z4.literal("resources/read"),
|
|
10393
11608
|
params: ReadResourceRequestParamsSchema
|
|
10394
11609
|
});
|
|
10395
11610
|
var ReadResourceResultSchema2 = ResultSchema.extend({
|
|
10396
|
-
contents:
|
|
11611
|
+
contents: z4.array(z4.union([TextResourceContentsSchema, BlobResourceContentsSchema]))
|
|
10397
11612
|
});
|
|
10398
11613
|
var ResourceListChangedNotificationSchema = NotificationSchema2.extend({
|
|
10399
|
-
method:
|
|
11614
|
+
method: z4.literal("notifications/resources/list_changed"),
|
|
10400
11615
|
params: NotificationsParamsSchema.optional()
|
|
10401
11616
|
});
|
|
10402
11617
|
var SubscribeRequestParamsSchema = ResourceRequestParamsSchema;
|
|
10403
11618
|
var SubscribeRequestSchema = RequestSchema.extend({
|
|
10404
|
-
method:
|
|
11619
|
+
method: z4.literal("resources/subscribe"),
|
|
10405
11620
|
params: SubscribeRequestParamsSchema
|
|
10406
11621
|
});
|
|
10407
11622
|
var UnsubscribeRequestParamsSchema = ResourceRequestParamsSchema;
|
|
10408
11623
|
var UnsubscribeRequestSchema = RequestSchema.extend({
|
|
10409
|
-
method:
|
|
11624
|
+
method: z4.literal("resources/unsubscribe"),
|
|
10410
11625
|
params: UnsubscribeRequestParamsSchema
|
|
10411
11626
|
});
|
|
10412
11627
|
var ResourceUpdatedNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
10413
11628
|
/**
|
|
10414
11629
|
* The URI of the resource that has been updated. This might be a sub-resource of the one that the client actually subscribed to.
|
|
10415
11630
|
*/
|
|
10416
|
-
uri:
|
|
11631
|
+
uri: z4.string()
|
|
10417
11632
|
});
|
|
10418
11633
|
var ResourceUpdatedNotificationSchema = NotificationSchema2.extend({
|
|
10419
|
-
method:
|
|
11634
|
+
method: z4.literal("notifications/resources/updated"),
|
|
10420
11635
|
params: ResourceUpdatedNotificationParamsSchema
|
|
10421
11636
|
});
|
|
10422
|
-
var PromptArgumentSchema =
|
|
11637
|
+
var PromptArgumentSchema = z4.object({
|
|
10423
11638
|
/**
|
|
10424
11639
|
* The name of the argument.
|
|
10425
11640
|
*/
|
|
10426
|
-
name:
|
|
11641
|
+
name: z4.string(),
|
|
10427
11642
|
/**
|
|
10428
11643
|
* A human-readable description of the argument.
|
|
10429
11644
|
*/
|
|
10430
|
-
description:
|
|
11645
|
+
description: z4.optional(z4.string()),
|
|
10431
11646
|
/**
|
|
10432
11647
|
* Whether this argument must be provided.
|
|
10433
11648
|
*/
|
|
10434
|
-
required:
|
|
11649
|
+
required: z4.optional(z4.boolean())
|
|
10435
11650
|
});
|
|
10436
|
-
var
|
|
11651
|
+
var PromptSchema2 = z4.object({
|
|
10437
11652
|
...BaseMetadataSchema.shape,
|
|
10438
11653
|
...IconsSchema.shape,
|
|
10439
11654
|
/**
|
|
10440
11655
|
* An optional description of what this prompt provides
|
|
10441
11656
|
*/
|
|
10442
|
-
description:
|
|
11657
|
+
description: z4.optional(z4.string()),
|
|
10443
11658
|
/**
|
|
10444
11659
|
* A list of arguments to use for templating the prompt.
|
|
10445
11660
|
*/
|
|
10446
|
-
arguments:
|
|
11661
|
+
arguments: z4.optional(z4.array(PromptArgumentSchema)),
|
|
10447
11662
|
/**
|
|
10448
11663
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
10449
11664
|
* for notes on _meta usage.
|
|
10450
11665
|
*/
|
|
10451
|
-
_meta:
|
|
11666
|
+
_meta: z4.optional(z4.looseObject({}))
|
|
10452
11667
|
});
|
|
10453
11668
|
var ListPromptsRequestSchema = PaginatedRequestSchema.extend({
|
|
10454
|
-
method:
|
|
11669
|
+
method: z4.literal("prompts/list")
|
|
10455
11670
|
});
|
|
10456
11671
|
var ListPromptsResultSchema2 = PaginatedResultSchema.extend({
|
|
10457
|
-
prompts:
|
|
11672
|
+
prompts: z4.array(PromptSchema2)
|
|
10458
11673
|
});
|
|
10459
11674
|
var GetPromptRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
10460
11675
|
/**
|
|
10461
11676
|
* The name of the prompt or prompt template.
|
|
10462
11677
|
*/
|
|
10463
|
-
name:
|
|
11678
|
+
name: z4.string(),
|
|
10464
11679
|
/**
|
|
10465
11680
|
* Arguments to use for templating the prompt.
|
|
10466
11681
|
*/
|
|
10467
|
-
arguments:
|
|
11682
|
+
arguments: z4.record(z4.string(), z4.string()).optional()
|
|
10468
11683
|
});
|
|
10469
11684
|
var GetPromptRequestSchema = RequestSchema.extend({
|
|
10470
|
-
method:
|
|
11685
|
+
method: z4.literal("prompts/get"),
|
|
10471
11686
|
params: GetPromptRequestParamsSchema
|
|
10472
11687
|
});
|
|
10473
|
-
var TextContentSchema =
|
|
10474
|
-
type:
|
|
11688
|
+
var TextContentSchema = z4.object({
|
|
11689
|
+
type: z4.literal("text"),
|
|
10475
11690
|
/**
|
|
10476
11691
|
* The text content of the message.
|
|
10477
11692
|
*/
|
|
10478
|
-
text:
|
|
11693
|
+
text: z4.string(),
|
|
10479
11694
|
/**
|
|
10480
11695
|
* Optional annotations for the client.
|
|
10481
11696
|
*/
|
|
@@ -10484,10 +11699,10 @@ var TextContentSchema = z3.object({
|
|
|
10484
11699
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
10485
11700
|
* for notes on _meta usage.
|
|
10486
11701
|
*/
|
|
10487
|
-
_meta:
|
|
11702
|
+
_meta: z4.record(z4.string(), z4.unknown()).optional()
|
|
10488
11703
|
});
|
|
10489
|
-
var ImageContentSchema =
|
|
10490
|
-
type:
|
|
11704
|
+
var ImageContentSchema = z4.object({
|
|
11705
|
+
type: z4.literal("image"),
|
|
10491
11706
|
/**
|
|
10492
11707
|
* The base64-encoded image data.
|
|
10493
11708
|
*/
|
|
@@ -10495,7 +11710,7 @@ var ImageContentSchema = z3.object({
|
|
|
10495
11710
|
/**
|
|
10496
11711
|
* The MIME type of the image. Different providers may support different image types.
|
|
10497
11712
|
*/
|
|
10498
|
-
mimeType:
|
|
11713
|
+
mimeType: z4.string(),
|
|
10499
11714
|
/**
|
|
10500
11715
|
* Optional annotations for the client.
|
|
10501
11716
|
*/
|
|
@@ -10504,10 +11719,10 @@ var ImageContentSchema = z3.object({
|
|
|
10504
11719
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
10505
11720
|
* for notes on _meta usage.
|
|
10506
11721
|
*/
|
|
10507
|
-
_meta:
|
|
11722
|
+
_meta: z4.record(z4.string(), z4.unknown()).optional()
|
|
10508
11723
|
});
|
|
10509
|
-
var AudioContentSchema =
|
|
10510
|
-
type:
|
|
11724
|
+
var AudioContentSchema = z4.object({
|
|
11725
|
+
type: z4.literal("audio"),
|
|
10511
11726
|
/**
|
|
10512
11727
|
* The base64-encoded audio data.
|
|
10513
11728
|
*/
|
|
@@ -10515,7 +11730,7 @@ var AudioContentSchema = z3.object({
|
|
|
10515
11730
|
/**
|
|
10516
11731
|
* The MIME type of the audio. Different providers may support different audio types.
|
|
10517
11732
|
*/
|
|
10518
|
-
mimeType:
|
|
11733
|
+
mimeType: z4.string(),
|
|
10519
11734
|
/**
|
|
10520
11735
|
* Optional annotations for the client.
|
|
10521
11736
|
*/
|
|
@@ -10524,34 +11739,34 @@ var AudioContentSchema = z3.object({
|
|
|
10524
11739
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
10525
11740
|
* for notes on _meta usage.
|
|
10526
11741
|
*/
|
|
10527
|
-
_meta:
|
|
11742
|
+
_meta: z4.record(z4.string(), z4.unknown()).optional()
|
|
10528
11743
|
});
|
|
10529
|
-
var ToolUseContentSchema =
|
|
10530
|
-
type:
|
|
11744
|
+
var ToolUseContentSchema = z4.object({
|
|
11745
|
+
type: z4.literal("tool_use"),
|
|
10531
11746
|
/**
|
|
10532
11747
|
* The name of the tool to invoke.
|
|
10533
11748
|
* Must match a tool name from the request's tools array.
|
|
10534
11749
|
*/
|
|
10535
|
-
name:
|
|
11750
|
+
name: z4.string(),
|
|
10536
11751
|
/**
|
|
10537
11752
|
* Unique identifier for this tool call.
|
|
10538
11753
|
* Used to correlate with ToolResultContent in subsequent messages.
|
|
10539
11754
|
*/
|
|
10540
|
-
id:
|
|
11755
|
+
id: z4.string(),
|
|
10541
11756
|
/**
|
|
10542
11757
|
* Arguments to pass to the tool.
|
|
10543
11758
|
* Must conform to the tool's inputSchema.
|
|
10544
11759
|
*/
|
|
10545
|
-
input:
|
|
11760
|
+
input: z4.record(z4.string(), z4.unknown()),
|
|
10546
11761
|
/**
|
|
10547
11762
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
10548
11763
|
* for notes on _meta usage.
|
|
10549
11764
|
*/
|
|
10550
|
-
_meta:
|
|
11765
|
+
_meta: z4.record(z4.string(), z4.unknown()).optional()
|
|
10551
11766
|
});
|
|
10552
|
-
var EmbeddedResourceSchema =
|
|
10553
|
-
type:
|
|
10554
|
-
resource:
|
|
11767
|
+
var EmbeddedResourceSchema = z4.object({
|
|
11768
|
+
type: z4.literal("resource"),
|
|
11769
|
+
resource: z4.union([TextResourceContentsSchema, BlobResourceContentsSchema]),
|
|
10555
11770
|
/**
|
|
10556
11771
|
* Optional annotations for the client.
|
|
10557
11772
|
*/
|
|
@@ -10560,19 +11775,19 @@ var EmbeddedResourceSchema = z3.object({
|
|
|
10560
11775
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
10561
11776
|
* for notes on _meta usage.
|
|
10562
11777
|
*/
|
|
10563
|
-
_meta:
|
|
11778
|
+
_meta: z4.record(z4.string(), z4.unknown()).optional()
|
|
10564
11779
|
});
|
|
10565
|
-
var ResourceLinkSchema =
|
|
10566
|
-
type:
|
|
11780
|
+
var ResourceLinkSchema = ResourceSchema2.extend({
|
|
11781
|
+
type: z4.literal("resource_link")
|
|
10567
11782
|
});
|
|
10568
|
-
var ContentBlockSchema =
|
|
11783
|
+
var ContentBlockSchema = z4.union([
|
|
10569
11784
|
TextContentSchema,
|
|
10570
11785
|
ImageContentSchema,
|
|
10571
11786
|
AudioContentSchema,
|
|
10572
11787
|
ResourceLinkSchema,
|
|
10573
11788
|
EmbeddedResourceSchema
|
|
10574
11789
|
]);
|
|
10575
|
-
var PromptMessageSchema =
|
|
11790
|
+
var PromptMessageSchema = z4.object({
|
|
10576
11791
|
role: RoleSchema,
|
|
10577
11792
|
content: ContentBlockSchema
|
|
10578
11793
|
});
|
|
@@ -10580,24 +11795,24 @@ var GetPromptResultSchema2 = ResultSchema.extend({
|
|
|
10580
11795
|
/**
|
|
10581
11796
|
* An optional description for the prompt.
|
|
10582
11797
|
*/
|
|
10583
|
-
description:
|
|
10584
|
-
messages:
|
|
11798
|
+
description: z4.string().optional(),
|
|
11799
|
+
messages: z4.array(PromptMessageSchema)
|
|
10585
11800
|
});
|
|
10586
11801
|
var PromptListChangedNotificationSchema = NotificationSchema2.extend({
|
|
10587
|
-
method:
|
|
11802
|
+
method: z4.literal("notifications/prompts/list_changed"),
|
|
10588
11803
|
params: NotificationsParamsSchema.optional()
|
|
10589
11804
|
});
|
|
10590
|
-
var ToolAnnotationsSchema =
|
|
11805
|
+
var ToolAnnotationsSchema = z4.object({
|
|
10591
11806
|
/**
|
|
10592
11807
|
* A human-readable title for the tool.
|
|
10593
11808
|
*/
|
|
10594
|
-
title:
|
|
11809
|
+
title: z4.string().optional(),
|
|
10595
11810
|
/**
|
|
10596
11811
|
* If true, the tool does not modify its environment.
|
|
10597
11812
|
*
|
|
10598
11813
|
* Default: false
|
|
10599
11814
|
*/
|
|
10600
|
-
readOnlyHint:
|
|
11815
|
+
readOnlyHint: z4.boolean().optional(),
|
|
10601
11816
|
/**
|
|
10602
11817
|
* If true, the tool may perform destructive updates to its environment.
|
|
10603
11818
|
* If false, the tool performs only additive updates.
|
|
@@ -10606,7 +11821,7 @@ var ToolAnnotationsSchema = z3.object({
|
|
|
10606
11821
|
*
|
|
10607
11822
|
* Default: true
|
|
10608
11823
|
*/
|
|
10609
|
-
destructiveHint:
|
|
11824
|
+
destructiveHint: z4.boolean().optional(),
|
|
10610
11825
|
/**
|
|
10611
11826
|
* If true, calling the tool repeatedly with the same arguments
|
|
10612
11827
|
* will have no additional effect on the its environment.
|
|
@@ -10615,7 +11830,7 @@ var ToolAnnotationsSchema = z3.object({
|
|
|
10615
11830
|
*
|
|
10616
11831
|
* Default: false
|
|
10617
11832
|
*/
|
|
10618
|
-
idempotentHint:
|
|
11833
|
+
idempotentHint: z4.boolean().optional(),
|
|
10619
11834
|
/**
|
|
10620
11835
|
* If true, this tool may interact with an "open world" of external
|
|
10621
11836
|
* entities. If false, the tool's domain of interaction is closed.
|
|
@@ -10624,9 +11839,9 @@ var ToolAnnotationsSchema = z3.object({
|
|
|
10624
11839
|
*
|
|
10625
11840
|
* Default: true
|
|
10626
11841
|
*/
|
|
10627
|
-
openWorldHint:
|
|
11842
|
+
openWorldHint: z4.boolean().optional()
|
|
10628
11843
|
});
|
|
10629
|
-
var ToolExecutionSchema =
|
|
11844
|
+
var ToolExecutionSchema = z4.object({
|
|
10630
11845
|
/**
|
|
10631
11846
|
* Indicates the tool's preference for task-augmented execution.
|
|
10632
11847
|
* - "required": Clients MUST invoke the tool as a task
|
|
@@ -10635,34 +11850,34 @@ var ToolExecutionSchema = z3.object({
|
|
|
10635
11850
|
*
|
|
10636
11851
|
* If not present, defaults to "forbidden".
|
|
10637
11852
|
*/
|
|
10638
|
-
taskSupport:
|
|
11853
|
+
taskSupport: z4.enum(["required", "optional", "forbidden"]).optional()
|
|
10639
11854
|
});
|
|
10640
|
-
var
|
|
11855
|
+
var ToolSchema2 = z4.object({
|
|
10641
11856
|
...BaseMetadataSchema.shape,
|
|
10642
11857
|
...IconsSchema.shape,
|
|
10643
11858
|
/**
|
|
10644
11859
|
* A human-readable description of the tool.
|
|
10645
11860
|
*/
|
|
10646
|
-
description:
|
|
11861
|
+
description: z4.string().optional(),
|
|
10647
11862
|
/**
|
|
10648
11863
|
* A JSON Schema 2020-12 object defining the expected parameters for the tool.
|
|
10649
11864
|
* Must have type: 'object' at the root level per MCP spec.
|
|
10650
11865
|
*/
|
|
10651
|
-
inputSchema:
|
|
10652
|
-
type:
|
|
10653
|
-
properties:
|
|
10654
|
-
required:
|
|
10655
|
-
}).catchall(
|
|
11866
|
+
inputSchema: z4.object({
|
|
11867
|
+
type: z4.literal("object"),
|
|
11868
|
+
properties: z4.record(z4.string(), AssertObjectSchema).optional(),
|
|
11869
|
+
required: z4.array(z4.string()).optional()
|
|
11870
|
+
}).catchall(z4.unknown()),
|
|
10656
11871
|
/**
|
|
10657
11872
|
* An optional JSON Schema 2020-12 object defining the structure of the tool's output
|
|
10658
11873
|
* returned in the structuredContent field of a CallToolResult.
|
|
10659
11874
|
* Must have type: 'object' at the root level per MCP spec.
|
|
10660
11875
|
*/
|
|
10661
|
-
outputSchema:
|
|
10662
|
-
type:
|
|
10663
|
-
properties:
|
|
10664
|
-
required:
|
|
10665
|
-
}).catchall(
|
|
11876
|
+
outputSchema: z4.object({
|
|
11877
|
+
type: z4.literal("object"),
|
|
11878
|
+
properties: z4.record(z4.string(), AssertObjectSchema).optional(),
|
|
11879
|
+
required: z4.array(z4.string()).optional()
|
|
11880
|
+
}).catchall(z4.unknown()).optional(),
|
|
10666
11881
|
/**
|
|
10667
11882
|
* Optional additional tool information.
|
|
10668
11883
|
*/
|
|
@@ -10675,13 +11890,13 @@ var ToolSchema = z3.object({
|
|
|
10675
11890
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
10676
11891
|
* for notes on _meta usage.
|
|
10677
11892
|
*/
|
|
10678
|
-
_meta:
|
|
11893
|
+
_meta: z4.record(z4.string(), z4.unknown()).optional()
|
|
10679
11894
|
});
|
|
10680
11895
|
var ListToolsRequestSchema = PaginatedRequestSchema.extend({
|
|
10681
|
-
method:
|
|
11896
|
+
method: z4.literal("tools/list")
|
|
10682
11897
|
});
|
|
10683
11898
|
var ListToolsResultSchema2 = PaginatedResultSchema.extend({
|
|
10684
|
-
tools:
|
|
11899
|
+
tools: z4.array(ToolSchema2)
|
|
10685
11900
|
});
|
|
10686
11901
|
var CallToolResultSchema2 = ResultSchema.extend({
|
|
10687
11902
|
/**
|
|
@@ -10690,13 +11905,13 @@ var CallToolResultSchema2 = ResultSchema.extend({
|
|
|
10690
11905
|
* If the Tool does not define an outputSchema, this field MUST be present in the result.
|
|
10691
11906
|
* For backwards compatibility, this field is always present, but it may be empty.
|
|
10692
11907
|
*/
|
|
10693
|
-
content:
|
|
11908
|
+
content: z4.array(ContentBlockSchema).default([]),
|
|
10694
11909
|
/**
|
|
10695
11910
|
* An object containing structured tool output.
|
|
10696
11911
|
*
|
|
10697
11912
|
* If the Tool defines an outputSchema, this field MUST be present in the result, and contain a JSON object that matches the schema.
|
|
10698
11913
|
*/
|
|
10699
|
-
structuredContent:
|
|
11914
|
+
structuredContent: z4.record(z4.string(), z4.unknown()).optional(),
|
|
10700
11915
|
/**
|
|
10701
11916
|
* Whether the tool call ended in an error.
|
|
10702
11917
|
*
|
|
@@ -10711,30 +11926,30 @@ var CallToolResultSchema2 = ResultSchema.extend({
|
|
|
10711
11926
|
* server does not support tool calls, or any other exceptional conditions,
|
|
10712
11927
|
* should be reported as an MCP error response.
|
|
10713
11928
|
*/
|
|
10714
|
-
isError:
|
|
11929
|
+
isError: z4.boolean().optional()
|
|
10715
11930
|
});
|
|
10716
11931
|
var CompatibilityCallToolResultSchema = CallToolResultSchema2.or(ResultSchema.extend({
|
|
10717
|
-
toolResult:
|
|
11932
|
+
toolResult: z4.unknown()
|
|
10718
11933
|
}));
|
|
10719
11934
|
var CallToolRequestParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
10720
11935
|
/**
|
|
10721
11936
|
* The name of the tool to call.
|
|
10722
11937
|
*/
|
|
10723
|
-
name:
|
|
11938
|
+
name: z4.string(),
|
|
10724
11939
|
/**
|
|
10725
11940
|
* Arguments to pass to the tool.
|
|
10726
11941
|
*/
|
|
10727
|
-
arguments:
|
|
11942
|
+
arguments: z4.record(z4.string(), z4.unknown()).optional()
|
|
10728
11943
|
});
|
|
10729
11944
|
var CallToolRequestSchema = RequestSchema.extend({
|
|
10730
|
-
method:
|
|
11945
|
+
method: z4.literal("tools/call"),
|
|
10731
11946
|
params: CallToolRequestParamsSchema
|
|
10732
11947
|
});
|
|
10733
11948
|
var ToolListChangedNotificationSchema = NotificationSchema2.extend({
|
|
10734
|
-
method:
|
|
11949
|
+
method: z4.literal("notifications/tools/list_changed"),
|
|
10735
11950
|
params: NotificationsParamsSchema.optional()
|
|
10736
11951
|
});
|
|
10737
|
-
var ListChangedOptionsBaseSchema =
|
|
11952
|
+
var ListChangedOptionsBaseSchema = z4.object({
|
|
10738
11953
|
/**
|
|
10739
11954
|
* If true, the list will be refreshed automatically when a list changed notification is received.
|
|
10740
11955
|
* The callback will be called with the updated list.
|
|
@@ -10743,7 +11958,7 @@ var ListChangedOptionsBaseSchema = z3.object({
|
|
|
10743
11958
|
*
|
|
10744
11959
|
* @default true
|
|
10745
11960
|
*/
|
|
10746
|
-
autoRefresh:
|
|
11961
|
+
autoRefresh: z4.boolean().default(true),
|
|
10747
11962
|
/**
|
|
10748
11963
|
* Debounce time in milliseconds for list changed notification processing.
|
|
10749
11964
|
*
|
|
@@ -10752,9 +11967,9 @@ var ListChangedOptionsBaseSchema = z3.object({
|
|
|
10752
11967
|
*
|
|
10753
11968
|
* @default 300
|
|
10754
11969
|
*/
|
|
10755
|
-
debounceMs:
|
|
11970
|
+
debounceMs: z4.number().int().nonnegative().default(300)
|
|
10756
11971
|
});
|
|
10757
|
-
var LoggingLevelSchema =
|
|
11972
|
+
var LoggingLevelSchema = z4.enum(["debug", "info", "notice", "warning", "error", "critical", "alert", "emergency"]);
|
|
10758
11973
|
var SetLevelRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
10759
11974
|
/**
|
|
10760
11975
|
* 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.
|
|
@@ -10762,7 +11977,7 @@ var SetLevelRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
|
10762
11977
|
level: LoggingLevelSchema
|
|
10763
11978
|
});
|
|
10764
11979
|
var SetLevelRequestSchema = RequestSchema.extend({
|
|
10765
|
-
method:
|
|
11980
|
+
method: z4.literal("logging/setLevel"),
|
|
10766
11981
|
params: SetLevelRequestParamsSchema
|
|
10767
11982
|
});
|
|
10768
11983
|
var LoggingMessageNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
@@ -10773,80 +11988,80 @@ var LoggingMessageNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
|
10773
11988
|
/**
|
|
10774
11989
|
* An optional name of the logger issuing this message.
|
|
10775
11990
|
*/
|
|
10776
|
-
logger:
|
|
11991
|
+
logger: z4.string().optional(),
|
|
10777
11992
|
/**
|
|
10778
11993
|
* The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here.
|
|
10779
11994
|
*/
|
|
10780
|
-
data:
|
|
11995
|
+
data: z4.unknown()
|
|
10781
11996
|
});
|
|
10782
11997
|
var LoggingMessageNotificationSchema = NotificationSchema2.extend({
|
|
10783
|
-
method:
|
|
11998
|
+
method: z4.literal("notifications/message"),
|
|
10784
11999
|
params: LoggingMessageNotificationParamsSchema
|
|
10785
12000
|
});
|
|
10786
|
-
var ModelHintSchema =
|
|
12001
|
+
var ModelHintSchema = z4.object({
|
|
10787
12002
|
/**
|
|
10788
12003
|
* A hint for a model name.
|
|
10789
12004
|
*/
|
|
10790
|
-
name:
|
|
12005
|
+
name: z4.string().optional()
|
|
10791
12006
|
});
|
|
10792
|
-
var ModelPreferencesSchema =
|
|
12007
|
+
var ModelPreferencesSchema = z4.object({
|
|
10793
12008
|
/**
|
|
10794
12009
|
* Optional hints to use for model selection.
|
|
10795
12010
|
*/
|
|
10796
|
-
hints:
|
|
12011
|
+
hints: z4.array(ModelHintSchema).optional(),
|
|
10797
12012
|
/**
|
|
10798
12013
|
* How much to prioritize cost when selecting a model.
|
|
10799
12014
|
*/
|
|
10800
|
-
costPriority:
|
|
12015
|
+
costPriority: z4.number().min(0).max(1).optional(),
|
|
10801
12016
|
/**
|
|
10802
12017
|
* How much to prioritize sampling speed (latency) when selecting a model.
|
|
10803
12018
|
*/
|
|
10804
|
-
speedPriority:
|
|
12019
|
+
speedPriority: z4.number().min(0).max(1).optional(),
|
|
10805
12020
|
/**
|
|
10806
12021
|
* How much to prioritize intelligence and capabilities when selecting a model.
|
|
10807
12022
|
*/
|
|
10808
|
-
intelligencePriority:
|
|
12023
|
+
intelligencePriority: z4.number().min(0).max(1).optional()
|
|
10809
12024
|
});
|
|
10810
|
-
var ToolChoiceSchema =
|
|
12025
|
+
var ToolChoiceSchema = z4.object({
|
|
10811
12026
|
/**
|
|
10812
12027
|
* Controls when tools are used:
|
|
10813
12028
|
* - "auto": Model decides whether to use tools (default)
|
|
10814
12029
|
* - "required": Model MUST use at least one tool before completing
|
|
10815
12030
|
* - "none": Model MUST NOT use any tools
|
|
10816
12031
|
*/
|
|
10817
|
-
mode:
|
|
12032
|
+
mode: z4.enum(["auto", "required", "none"]).optional()
|
|
10818
12033
|
});
|
|
10819
|
-
var ToolResultContentSchema =
|
|
10820
|
-
type:
|
|
10821
|
-
toolUseId:
|
|
10822
|
-
content:
|
|
10823
|
-
structuredContent:
|
|
10824
|
-
isError:
|
|
12034
|
+
var ToolResultContentSchema = z4.object({
|
|
12035
|
+
type: z4.literal("tool_result"),
|
|
12036
|
+
toolUseId: z4.string().describe("The unique identifier for the corresponding tool call."),
|
|
12037
|
+
content: z4.array(ContentBlockSchema).default([]),
|
|
12038
|
+
structuredContent: z4.object({}).loose().optional(),
|
|
12039
|
+
isError: z4.boolean().optional(),
|
|
10825
12040
|
/**
|
|
10826
12041
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
10827
12042
|
* for notes on _meta usage.
|
|
10828
12043
|
*/
|
|
10829
|
-
_meta:
|
|
12044
|
+
_meta: z4.record(z4.string(), z4.unknown()).optional()
|
|
10830
12045
|
});
|
|
10831
|
-
var SamplingContentSchema =
|
|
10832
|
-
var SamplingMessageContentBlockSchema =
|
|
12046
|
+
var SamplingContentSchema = z4.discriminatedUnion("type", [TextContentSchema, ImageContentSchema, AudioContentSchema]);
|
|
12047
|
+
var SamplingMessageContentBlockSchema = z4.discriminatedUnion("type", [
|
|
10833
12048
|
TextContentSchema,
|
|
10834
12049
|
ImageContentSchema,
|
|
10835
12050
|
AudioContentSchema,
|
|
10836
12051
|
ToolUseContentSchema,
|
|
10837
12052
|
ToolResultContentSchema
|
|
10838
12053
|
]);
|
|
10839
|
-
var SamplingMessageSchema =
|
|
12054
|
+
var SamplingMessageSchema = z4.object({
|
|
10840
12055
|
role: RoleSchema,
|
|
10841
|
-
content:
|
|
12056
|
+
content: z4.union([SamplingMessageContentBlockSchema, z4.array(SamplingMessageContentBlockSchema)]),
|
|
10842
12057
|
/**
|
|
10843
12058
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
10844
12059
|
* for notes on _meta usage.
|
|
10845
12060
|
*/
|
|
10846
|
-
_meta:
|
|
12061
|
+
_meta: z4.record(z4.string(), z4.unknown()).optional()
|
|
10847
12062
|
});
|
|
10848
12063
|
var CreateMessageRequestParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
10849
|
-
messages:
|
|
12064
|
+
messages: z4.array(SamplingMessageSchema),
|
|
10850
12065
|
/**
|
|
10851
12066
|
* The server's preferences for which model to select. The client MAY modify or omit this request.
|
|
10852
12067
|
*/
|
|
@@ -10854,7 +12069,7 @@ var CreateMessageRequestParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
|
10854
12069
|
/**
|
|
10855
12070
|
* An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt.
|
|
10856
12071
|
*/
|
|
10857
|
-
systemPrompt:
|
|
12072
|
+
systemPrompt: z4.string().optional(),
|
|
10858
12073
|
/**
|
|
10859
12074
|
* A request to include context from one or more MCP servers (including the caller), to be attached to the prompt.
|
|
10860
12075
|
* The client MAY ignore this request.
|
|
@@ -10862,15 +12077,15 @@ var CreateMessageRequestParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
|
10862
12077
|
* Default is "none". Values "thisServer" and "allServers" are soft-deprecated. Servers SHOULD only use these values if the client
|
|
10863
12078
|
* declares ClientCapabilities.sampling.context. These values may be removed in future spec releases.
|
|
10864
12079
|
*/
|
|
10865
|
-
includeContext:
|
|
10866
|
-
temperature:
|
|
12080
|
+
includeContext: z4.enum(["none", "thisServer", "allServers"]).optional(),
|
|
12081
|
+
temperature: z4.number().optional(),
|
|
10867
12082
|
/**
|
|
10868
12083
|
* The requested maximum number of tokens to sample (to prevent runaway completions).
|
|
10869
12084
|
*
|
|
10870
12085
|
* The client MAY choose to sample fewer tokens than the requested maximum.
|
|
10871
12086
|
*/
|
|
10872
|
-
maxTokens:
|
|
10873
|
-
stopSequences:
|
|
12087
|
+
maxTokens: z4.number().int(),
|
|
12088
|
+
stopSequences: z4.array(z4.string()).optional(),
|
|
10874
12089
|
/**
|
|
10875
12090
|
* Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific.
|
|
10876
12091
|
*/
|
|
@@ -10879,7 +12094,7 @@ var CreateMessageRequestParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
|
10879
12094
|
* Tools that the model may use during generation.
|
|
10880
12095
|
* The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.
|
|
10881
12096
|
*/
|
|
10882
|
-
tools:
|
|
12097
|
+
tools: z4.array(ToolSchema2).optional(),
|
|
10883
12098
|
/**
|
|
10884
12099
|
* Controls how the model uses tools.
|
|
10885
12100
|
* The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.
|
|
@@ -10888,14 +12103,14 @@ var CreateMessageRequestParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
|
10888
12103
|
toolChoice: ToolChoiceSchema.optional()
|
|
10889
12104
|
});
|
|
10890
12105
|
var CreateMessageRequestSchema = RequestSchema.extend({
|
|
10891
|
-
method:
|
|
12106
|
+
method: z4.literal("sampling/createMessage"),
|
|
10892
12107
|
params: CreateMessageRequestParamsSchema
|
|
10893
12108
|
});
|
|
10894
12109
|
var CreateMessageResultSchema = ResultSchema.extend({
|
|
10895
12110
|
/**
|
|
10896
12111
|
* The name of the model that generated the message.
|
|
10897
12112
|
*/
|
|
10898
|
-
model:
|
|
12113
|
+
model: z4.string(),
|
|
10899
12114
|
/**
|
|
10900
12115
|
* The reason why sampling stopped, if known.
|
|
10901
12116
|
*
|
|
@@ -10906,7 +12121,7 @@ var CreateMessageResultSchema = ResultSchema.extend({
|
|
|
10906
12121
|
*
|
|
10907
12122
|
* This field is an open string to allow for provider-specific stop reasons.
|
|
10908
12123
|
*/
|
|
10909
|
-
stopReason:
|
|
12124
|
+
stopReason: z4.optional(z4.enum(["endTurn", "stopSequence", "maxTokens"]).or(z4.string())),
|
|
10910
12125
|
role: RoleSchema,
|
|
10911
12126
|
/**
|
|
10912
12127
|
* Response content. Single content block (text, image, or audio).
|
|
@@ -10917,7 +12132,7 @@ var CreateMessageResultWithToolsSchema = ResultSchema.extend({
|
|
|
10917
12132
|
/**
|
|
10918
12133
|
* The name of the model that generated the message.
|
|
10919
12134
|
*/
|
|
10920
|
-
model:
|
|
12135
|
+
model: z4.string(),
|
|
10921
12136
|
/**
|
|
10922
12137
|
* The reason why sampling stopped, if known.
|
|
10923
12138
|
*
|
|
@@ -10929,144 +12144,144 @@ var CreateMessageResultWithToolsSchema = ResultSchema.extend({
|
|
|
10929
12144
|
*
|
|
10930
12145
|
* This field is an open string to allow for provider-specific stop reasons.
|
|
10931
12146
|
*/
|
|
10932
|
-
stopReason:
|
|
12147
|
+
stopReason: z4.optional(z4.enum(["endTurn", "stopSequence", "maxTokens", "toolUse"]).or(z4.string())),
|
|
10933
12148
|
role: RoleSchema,
|
|
10934
12149
|
/**
|
|
10935
12150
|
* Response content. May be a single block or array. May include ToolUseContent if stopReason is "toolUse".
|
|
10936
12151
|
*/
|
|
10937
|
-
content:
|
|
10938
|
-
});
|
|
10939
|
-
var BooleanSchemaSchema =
|
|
10940
|
-
type:
|
|
10941
|
-
title:
|
|
10942
|
-
description:
|
|
10943
|
-
default:
|
|
10944
|
-
});
|
|
10945
|
-
var StringSchemaSchema =
|
|
10946
|
-
type:
|
|
10947
|
-
title:
|
|
10948
|
-
description:
|
|
10949
|
-
minLength:
|
|
10950
|
-
maxLength:
|
|
10951
|
-
format:
|
|
10952
|
-
default:
|
|
10953
|
-
});
|
|
10954
|
-
var NumberSchemaSchema =
|
|
10955
|
-
type:
|
|
10956
|
-
title:
|
|
10957
|
-
description:
|
|
10958
|
-
minimum:
|
|
10959
|
-
maximum:
|
|
10960
|
-
default:
|
|
10961
|
-
});
|
|
10962
|
-
var UntitledSingleSelectEnumSchemaSchema =
|
|
10963
|
-
type:
|
|
10964
|
-
title:
|
|
10965
|
-
description:
|
|
10966
|
-
enum:
|
|
10967
|
-
default:
|
|
10968
|
-
});
|
|
10969
|
-
var TitledSingleSelectEnumSchemaSchema =
|
|
10970
|
-
type:
|
|
10971
|
-
title:
|
|
10972
|
-
description:
|
|
10973
|
-
oneOf:
|
|
10974
|
-
const:
|
|
10975
|
-
title:
|
|
12152
|
+
content: z4.union([SamplingMessageContentBlockSchema, z4.array(SamplingMessageContentBlockSchema)])
|
|
12153
|
+
});
|
|
12154
|
+
var BooleanSchemaSchema = z4.object({
|
|
12155
|
+
type: z4.literal("boolean"),
|
|
12156
|
+
title: z4.string().optional(),
|
|
12157
|
+
description: z4.string().optional(),
|
|
12158
|
+
default: z4.boolean().optional()
|
|
12159
|
+
});
|
|
12160
|
+
var StringSchemaSchema = z4.object({
|
|
12161
|
+
type: z4.literal("string"),
|
|
12162
|
+
title: z4.string().optional(),
|
|
12163
|
+
description: z4.string().optional(),
|
|
12164
|
+
minLength: z4.number().optional(),
|
|
12165
|
+
maxLength: z4.number().optional(),
|
|
12166
|
+
format: z4.enum(["email", "uri", "date", "date-time"]).optional(),
|
|
12167
|
+
default: z4.string().optional()
|
|
12168
|
+
});
|
|
12169
|
+
var NumberSchemaSchema = z4.object({
|
|
12170
|
+
type: z4.enum(["number", "integer"]),
|
|
12171
|
+
title: z4.string().optional(),
|
|
12172
|
+
description: z4.string().optional(),
|
|
12173
|
+
minimum: z4.number().optional(),
|
|
12174
|
+
maximum: z4.number().optional(),
|
|
12175
|
+
default: z4.number().optional()
|
|
12176
|
+
});
|
|
12177
|
+
var UntitledSingleSelectEnumSchemaSchema = z4.object({
|
|
12178
|
+
type: z4.literal("string"),
|
|
12179
|
+
title: z4.string().optional(),
|
|
12180
|
+
description: z4.string().optional(),
|
|
12181
|
+
enum: z4.array(z4.string()),
|
|
12182
|
+
default: z4.string().optional()
|
|
12183
|
+
});
|
|
12184
|
+
var TitledSingleSelectEnumSchemaSchema = z4.object({
|
|
12185
|
+
type: z4.literal("string"),
|
|
12186
|
+
title: z4.string().optional(),
|
|
12187
|
+
description: z4.string().optional(),
|
|
12188
|
+
oneOf: z4.array(z4.object({
|
|
12189
|
+
const: z4.string(),
|
|
12190
|
+
title: z4.string()
|
|
10976
12191
|
})),
|
|
10977
|
-
default:
|
|
10978
|
-
});
|
|
10979
|
-
var LegacyTitledEnumSchemaSchema =
|
|
10980
|
-
type:
|
|
10981
|
-
title:
|
|
10982
|
-
description:
|
|
10983
|
-
enum:
|
|
10984
|
-
enumNames:
|
|
10985
|
-
default:
|
|
10986
|
-
});
|
|
10987
|
-
var SingleSelectEnumSchemaSchema =
|
|
10988
|
-
var UntitledMultiSelectEnumSchemaSchema =
|
|
10989
|
-
type:
|
|
10990
|
-
title:
|
|
10991
|
-
description:
|
|
10992
|
-
minItems:
|
|
10993
|
-
maxItems:
|
|
10994
|
-
items:
|
|
10995
|
-
type:
|
|
10996
|
-
enum:
|
|
12192
|
+
default: z4.string().optional()
|
|
12193
|
+
});
|
|
12194
|
+
var LegacyTitledEnumSchemaSchema = z4.object({
|
|
12195
|
+
type: z4.literal("string"),
|
|
12196
|
+
title: z4.string().optional(),
|
|
12197
|
+
description: z4.string().optional(),
|
|
12198
|
+
enum: z4.array(z4.string()),
|
|
12199
|
+
enumNames: z4.array(z4.string()).optional(),
|
|
12200
|
+
default: z4.string().optional()
|
|
12201
|
+
});
|
|
12202
|
+
var SingleSelectEnumSchemaSchema = z4.union([UntitledSingleSelectEnumSchemaSchema, TitledSingleSelectEnumSchemaSchema]);
|
|
12203
|
+
var UntitledMultiSelectEnumSchemaSchema = z4.object({
|
|
12204
|
+
type: z4.literal("array"),
|
|
12205
|
+
title: z4.string().optional(),
|
|
12206
|
+
description: z4.string().optional(),
|
|
12207
|
+
minItems: z4.number().optional(),
|
|
12208
|
+
maxItems: z4.number().optional(),
|
|
12209
|
+
items: z4.object({
|
|
12210
|
+
type: z4.literal("string"),
|
|
12211
|
+
enum: z4.array(z4.string())
|
|
10997
12212
|
}),
|
|
10998
|
-
default:
|
|
10999
|
-
});
|
|
11000
|
-
var TitledMultiSelectEnumSchemaSchema =
|
|
11001
|
-
type:
|
|
11002
|
-
title:
|
|
11003
|
-
description:
|
|
11004
|
-
minItems:
|
|
11005
|
-
maxItems:
|
|
11006
|
-
items:
|
|
11007
|
-
anyOf:
|
|
11008
|
-
const:
|
|
11009
|
-
title:
|
|
12213
|
+
default: z4.array(z4.string()).optional()
|
|
12214
|
+
});
|
|
12215
|
+
var TitledMultiSelectEnumSchemaSchema = z4.object({
|
|
12216
|
+
type: z4.literal("array"),
|
|
12217
|
+
title: z4.string().optional(),
|
|
12218
|
+
description: z4.string().optional(),
|
|
12219
|
+
minItems: z4.number().optional(),
|
|
12220
|
+
maxItems: z4.number().optional(),
|
|
12221
|
+
items: z4.object({
|
|
12222
|
+
anyOf: z4.array(z4.object({
|
|
12223
|
+
const: z4.string(),
|
|
12224
|
+
title: z4.string()
|
|
11010
12225
|
}))
|
|
11011
12226
|
}),
|
|
11012
|
-
default:
|
|
12227
|
+
default: z4.array(z4.string()).optional()
|
|
11013
12228
|
});
|
|
11014
|
-
var MultiSelectEnumSchemaSchema =
|
|
11015
|
-
var EnumSchemaSchema =
|
|
11016
|
-
var PrimitiveSchemaDefinitionSchema =
|
|
12229
|
+
var MultiSelectEnumSchemaSchema = z4.union([UntitledMultiSelectEnumSchemaSchema, TitledMultiSelectEnumSchemaSchema]);
|
|
12230
|
+
var EnumSchemaSchema = z4.union([LegacyTitledEnumSchemaSchema, SingleSelectEnumSchemaSchema, MultiSelectEnumSchemaSchema]);
|
|
12231
|
+
var PrimitiveSchemaDefinitionSchema = z4.union([EnumSchemaSchema, BooleanSchemaSchema, StringSchemaSchema, NumberSchemaSchema]);
|
|
11017
12232
|
var ElicitRequestFormParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
11018
12233
|
/**
|
|
11019
12234
|
* The elicitation mode.
|
|
11020
12235
|
*
|
|
11021
12236
|
* Optional for backward compatibility. Clients MUST treat missing mode as "form".
|
|
11022
12237
|
*/
|
|
11023
|
-
mode:
|
|
12238
|
+
mode: z4.literal("form").optional(),
|
|
11024
12239
|
/**
|
|
11025
12240
|
* The message to present to the user describing what information is being requested.
|
|
11026
12241
|
*/
|
|
11027
|
-
message:
|
|
12242
|
+
message: z4.string(),
|
|
11028
12243
|
/**
|
|
11029
12244
|
* A restricted subset of JSON Schema.
|
|
11030
12245
|
* Only top-level properties are allowed, without nesting.
|
|
11031
12246
|
*/
|
|
11032
|
-
requestedSchema:
|
|
11033
|
-
type:
|
|
11034
|
-
properties:
|
|
11035
|
-
required:
|
|
12247
|
+
requestedSchema: z4.object({
|
|
12248
|
+
type: z4.literal("object"),
|
|
12249
|
+
properties: z4.record(z4.string(), PrimitiveSchemaDefinitionSchema),
|
|
12250
|
+
required: z4.array(z4.string()).optional()
|
|
11036
12251
|
})
|
|
11037
12252
|
});
|
|
11038
12253
|
var ElicitRequestURLParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
11039
12254
|
/**
|
|
11040
12255
|
* The elicitation mode.
|
|
11041
12256
|
*/
|
|
11042
|
-
mode:
|
|
12257
|
+
mode: z4.literal("url"),
|
|
11043
12258
|
/**
|
|
11044
12259
|
* The message to present to the user explaining why the interaction is needed.
|
|
11045
12260
|
*/
|
|
11046
|
-
message:
|
|
12261
|
+
message: z4.string(),
|
|
11047
12262
|
/**
|
|
11048
12263
|
* The ID of the elicitation, which must be unique within the context of the server.
|
|
11049
12264
|
* The client MUST treat this ID as an opaque value.
|
|
11050
12265
|
*/
|
|
11051
|
-
elicitationId:
|
|
12266
|
+
elicitationId: z4.string(),
|
|
11052
12267
|
/**
|
|
11053
12268
|
* The URL that the user should navigate to.
|
|
11054
12269
|
*/
|
|
11055
|
-
url:
|
|
12270
|
+
url: z4.string().url()
|
|
11056
12271
|
});
|
|
11057
|
-
var ElicitRequestParamsSchema =
|
|
12272
|
+
var ElicitRequestParamsSchema = z4.union([ElicitRequestFormParamsSchema, ElicitRequestURLParamsSchema]);
|
|
11058
12273
|
var ElicitRequestSchema = RequestSchema.extend({
|
|
11059
|
-
method:
|
|
12274
|
+
method: z4.literal("elicitation/create"),
|
|
11060
12275
|
params: ElicitRequestParamsSchema
|
|
11061
12276
|
});
|
|
11062
12277
|
var ElicitationCompleteNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
11063
12278
|
/**
|
|
11064
12279
|
* The ID of the elicitation that completed.
|
|
11065
12280
|
*/
|
|
11066
|
-
elicitationId:
|
|
12281
|
+
elicitationId: z4.string()
|
|
11067
12282
|
});
|
|
11068
12283
|
var ElicitationCompleteNotificationSchema = NotificationSchema2.extend({
|
|
11069
|
-
method:
|
|
12284
|
+
method: z4.literal("notifications/elicitation/complete"),
|
|
11070
12285
|
params: ElicitationCompleteNotificationParamsSchema
|
|
11071
12286
|
});
|
|
11072
12287
|
var ElicitResultSchema = ResultSchema.extend({
|
|
@@ -11076,98 +12291,98 @@ var ElicitResultSchema = ResultSchema.extend({
|
|
|
11076
12291
|
* - "decline": User explicitly decline the action
|
|
11077
12292
|
* - "cancel": User dismissed without making an explicit choice
|
|
11078
12293
|
*/
|
|
11079
|
-
action:
|
|
12294
|
+
action: z4.enum(["accept", "decline", "cancel"]),
|
|
11080
12295
|
/**
|
|
11081
12296
|
* The submitted form data, only present when action is "accept".
|
|
11082
12297
|
* Contains values matching the requested schema.
|
|
11083
12298
|
* Per MCP spec, content is "typically omitted" for decline/cancel actions.
|
|
11084
12299
|
* We normalize null to undefined for leniency while maintaining type compatibility.
|
|
11085
12300
|
*/
|
|
11086
|
-
content:
|
|
12301
|
+
content: z4.preprocess((val) => val === null ? void 0 : val, z4.record(z4.string(), z4.union([z4.string(), z4.number(), z4.boolean(), z4.array(z4.string())])).optional())
|
|
11087
12302
|
});
|
|
11088
|
-
var ResourceTemplateReferenceSchema =
|
|
11089
|
-
type:
|
|
12303
|
+
var ResourceTemplateReferenceSchema = z4.object({
|
|
12304
|
+
type: z4.literal("ref/resource"),
|
|
11090
12305
|
/**
|
|
11091
12306
|
* The URI or URI template of the resource.
|
|
11092
12307
|
*/
|
|
11093
|
-
uri:
|
|
12308
|
+
uri: z4.string()
|
|
11094
12309
|
});
|
|
11095
|
-
var PromptReferenceSchema =
|
|
11096
|
-
type:
|
|
12310
|
+
var PromptReferenceSchema = z4.object({
|
|
12311
|
+
type: z4.literal("ref/prompt"),
|
|
11097
12312
|
/**
|
|
11098
12313
|
* The name of the prompt or prompt template
|
|
11099
12314
|
*/
|
|
11100
|
-
name:
|
|
12315
|
+
name: z4.string()
|
|
11101
12316
|
});
|
|
11102
12317
|
var CompleteRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
11103
|
-
ref:
|
|
12318
|
+
ref: z4.union([PromptReferenceSchema, ResourceTemplateReferenceSchema]),
|
|
11104
12319
|
/**
|
|
11105
12320
|
* The argument's information
|
|
11106
12321
|
*/
|
|
11107
|
-
argument:
|
|
12322
|
+
argument: z4.object({
|
|
11108
12323
|
/**
|
|
11109
12324
|
* The name of the argument
|
|
11110
12325
|
*/
|
|
11111
|
-
name:
|
|
12326
|
+
name: z4.string(),
|
|
11112
12327
|
/**
|
|
11113
12328
|
* The value of the argument to use for completion matching.
|
|
11114
12329
|
*/
|
|
11115
|
-
value:
|
|
12330
|
+
value: z4.string()
|
|
11116
12331
|
}),
|
|
11117
|
-
context:
|
|
12332
|
+
context: z4.object({
|
|
11118
12333
|
/**
|
|
11119
12334
|
* Previously-resolved variables in a URI template or prompt.
|
|
11120
12335
|
*/
|
|
11121
|
-
arguments:
|
|
12336
|
+
arguments: z4.record(z4.string(), z4.string()).optional()
|
|
11122
12337
|
}).optional()
|
|
11123
12338
|
});
|
|
11124
12339
|
var CompleteRequestSchema = RequestSchema.extend({
|
|
11125
|
-
method:
|
|
12340
|
+
method: z4.literal("completion/complete"),
|
|
11126
12341
|
params: CompleteRequestParamsSchema
|
|
11127
12342
|
});
|
|
11128
12343
|
var CompleteResultSchema = ResultSchema.extend({
|
|
11129
|
-
completion:
|
|
12344
|
+
completion: z4.looseObject({
|
|
11130
12345
|
/**
|
|
11131
12346
|
* An array of completion values. Must not exceed 100 items.
|
|
11132
12347
|
*/
|
|
11133
|
-
values:
|
|
12348
|
+
values: z4.array(z4.string()).max(100),
|
|
11134
12349
|
/**
|
|
11135
12350
|
* The total number of completion options available. This can exceed the number of values actually sent in the response.
|
|
11136
12351
|
*/
|
|
11137
|
-
total:
|
|
12352
|
+
total: z4.optional(z4.number().int()),
|
|
11138
12353
|
/**
|
|
11139
12354
|
* Indicates whether there are additional completion options beyond those provided in the current response, even if the exact total is unknown.
|
|
11140
12355
|
*/
|
|
11141
|
-
hasMore:
|
|
12356
|
+
hasMore: z4.optional(z4.boolean())
|
|
11142
12357
|
})
|
|
11143
12358
|
});
|
|
11144
|
-
var RootSchema =
|
|
12359
|
+
var RootSchema = z4.object({
|
|
11145
12360
|
/**
|
|
11146
12361
|
* The URI identifying the root. This *must* start with file:// for now.
|
|
11147
12362
|
*/
|
|
11148
|
-
uri:
|
|
12363
|
+
uri: z4.string().startsWith("file://"),
|
|
11149
12364
|
/**
|
|
11150
12365
|
* An optional name for the root.
|
|
11151
12366
|
*/
|
|
11152
|
-
name:
|
|
12367
|
+
name: z4.string().optional(),
|
|
11153
12368
|
/**
|
|
11154
12369
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
11155
12370
|
* for notes on _meta usage.
|
|
11156
12371
|
*/
|
|
11157
|
-
_meta:
|
|
12372
|
+
_meta: z4.record(z4.string(), z4.unknown()).optional()
|
|
11158
12373
|
});
|
|
11159
12374
|
var ListRootsRequestSchema = RequestSchema.extend({
|
|
11160
|
-
method:
|
|
12375
|
+
method: z4.literal("roots/list"),
|
|
11161
12376
|
params: BaseRequestParamsSchema.optional()
|
|
11162
12377
|
});
|
|
11163
12378
|
var ListRootsResultSchema = ResultSchema.extend({
|
|
11164
|
-
roots:
|
|
12379
|
+
roots: z4.array(RootSchema)
|
|
11165
12380
|
});
|
|
11166
12381
|
var RootsListChangedNotificationSchema = NotificationSchema2.extend({
|
|
11167
|
-
method:
|
|
12382
|
+
method: z4.literal("notifications/roots/list_changed"),
|
|
11168
12383
|
params: NotificationsParamsSchema.optional()
|
|
11169
12384
|
});
|
|
11170
|
-
var ClientRequestSchema =
|
|
12385
|
+
var ClientRequestSchema = z4.union([
|
|
11171
12386
|
PingRequestSchema,
|
|
11172
12387
|
InitializeRequestSchema,
|
|
11173
12388
|
CompleteRequestSchema,
|
|
@@ -11186,14 +12401,14 @@ var ClientRequestSchema = z3.union([
|
|
|
11186
12401
|
ListTasksRequestSchema2,
|
|
11187
12402
|
CancelTaskRequestSchema2
|
|
11188
12403
|
]);
|
|
11189
|
-
var ClientNotificationSchema =
|
|
12404
|
+
var ClientNotificationSchema = z4.union([
|
|
11190
12405
|
CancelledNotificationSchema,
|
|
11191
12406
|
ProgressNotificationSchema,
|
|
11192
12407
|
InitializedNotificationSchema,
|
|
11193
12408
|
RootsListChangedNotificationSchema,
|
|
11194
12409
|
TaskStatusNotificationSchema2
|
|
11195
12410
|
]);
|
|
11196
|
-
var ClientResultSchema =
|
|
12411
|
+
var ClientResultSchema = z4.union([
|
|
11197
12412
|
EmptyResultSchema2,
|
|
11198
12413
|
CreateMessageResultSchema,
|
|
11199
12414
|
CreateMessageResultWithToolsSchema,
|
|
@@ -11203,7 +12418,7 @@ var ClientResultSchema = z3.union([
|
|
|
11203
12418
|
ListTasksResultSchema2,
|
|
11204
12419
|
CreateTaskResultSchema2
|
|
11205
12420
|
]);
|
|
11206
|
-
var ServerRequestSchema =
|
|
12421
|
+
var ServerRequestSchema = z4.union([
|
|
11207
12422
|
PingRequestSchema,
|
|
11208
12423
|
CreateMessageRequestSchema,
|
|
11209
12424
|
ElicitRequestSchema,
|
|
@@ -11213,7 +12428,7 @@ var ServerRequestSchema = z3.union([
|
|
|
11213
12428
|
ListTasksRequestSchema2,
|
|
11214
12429
|
CancelTaskRequestSchema2
|
|
11215
12430
|
]);
|
|
11216
|
-
var ServerNotificationSchema =
|
|
12431
|
+
var ServerNotificationSchema = z4.union([
|
|
11217
12432
|
CancelledNotificationSchema,
|
|
11218
12433
|
ProgressNotificationSchema,
|
|
11219
12434
|
LoggingMessageNotificationSchema,
|
|
@@ -11224,7 +12439,7 @@ var ServerNotificationSchema = z3.union([
|
|
|
11224
12439
|
TaskStatusNotificationSchema2,
|
|
11225
12440
|
ElicitationCompleteNotificationSchema
|
|
11226
12441
|
]);
|
|
11227
|
-
var ServerResultSchema =
|
|
12442
|
+
var ServerResultSchema = z4.union([
|
|
11228
12443
|
EmptyResultSchema2,
|
|
11229
12444
|
InitializeResultSchema,
|
|
11230
12445
|
CompleteResultSchema,
|
|
@@ -11297,7 +12512,7 @@ var O = Q.object({ connectDomains: Q.array(Q.string()).optional().describe(`Orig
|
|
|
11297
12512
|
|
|
11298
12513
|
- Maps to CSP \`connect-src\` directive
|
|
11299
12514
|
- Empty or omitted \u2192 no network connections (secure default)`), resourceDomains: Q.array(Q.string()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted \u2192 no network resources (secure default)"), frameDomains: Q.array(Q.string()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted \u2192 no nested iframes allowed (`frame-src 'none'`)"), baseUriDomains: Q.array(Q.string()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted \u2192 only same origin allowed (`base-uri 'self'`)") });
|
|
11300
|
-
var
|
|
12515
|
+
var z5 = Q.object({ camera: Q.object({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."), microphone: Q.object({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."), geolocation: Q.object({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."), clipboardWrite: Q.object({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.") });
|
|
11301
12516
|
var H = Q.object({ method: Q.literal("ui/notifications/size-changed"), params: Q.object({ width: Q.number().optional().describe("New width in pixels."), height: Q.number().optional().describe("New height in pixels.") }) });
|
|
11302
12517
|
var R = Q.object({ method: Q.literal("ui/notifications/tool-input"), params: Q.object({ arguments: Q.record(Q.string(), Q.unknown().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.") }) });
|
|
11303
12518
|
var T = Q.object({ method: Q.literal("ui/notifications/tool-input-partial"), params: Q.object({ arguments: Q.record(Q.string(), Q.unknown().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).") }) });
|
|
@@ -11308,10 +12523,10 @@ var C = Q.object({ method: Q.literal("ui/resource-teardown"), params: Q.object({
|
|
|
11308
12523
|
var S = Q.record(Q.string(), Q.unknown());
|
|
11309
12524
|
var F = Q.object({ text: Q.object({}).optional().describe("Host supports text content blocks."), image: Q.object({}).optional().describe("Host supports image content blocks."), audio: Q.object({}).optional().describe("Host supports audio content blocks."), resource: Q.object({}).optional().describe("Host supports resource content blocks."), resourceLink: Q.object({}).optional().describe("Host supports resource link content blocks."), structuredContent: Q.object({}).optional().describe("Host supports structured content.") });
|
|
11310
12525
|
var q = Q.object({ method: Q.literal("ui/notifications/request-teardown"), params: Q.object({}).optional() });
|
|
11311
|
-
var t = Q.object({ experimental: Q.
|
|
11312
|
-
var a = Q.object({ experimental: Q.
|
|
12526
|
+
var t = Q.object({ experimental: Q.record(Q.string(), Q.record(Q.string(), Q.any()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."), openLinks: Q.object({}).optional().describe("Host supports opening external URLs."), downloadFile: Q.object({}).optional().describe("Host supports file downloads via ui/download-file."), serverTools: Q.object({ listChanged: Q.boolean().optional().describe("Host supports tools/list_changed notifications.") }).optional().describe("Host can proxy tool calls to the MCP server."), serverResources: Q.object({ listChanged: Q.boolean().optional().describe("Host supports resources/list_changed notifications.") }).optional().describe("Host can proxy resource reads to the MCP server."), logging: Q.object({}).optional().describe("Host accepts log messages."), sandbox: Q.object({ permissions: z5.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."), csp: O.optional().describe("CSP domains approved by the host.") }).optional().describe("Sandbox configuration applied by the host."), updateModelContext: F.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."), message: F.optional().describe("Host supports receiving content messages (ui/message) from the view."), sampling: Q.object({ tools: Q.object({}).optional().describe("Host supports tool use via `tools` and `toolChoice` parameters.") }).optional().describe("Host supports LLM sampling (sampling/createMessage) from the view.\nMirrors the MCP `ClientCapabilities.sampling` shape so hosts can pass it through.") });
|
|
12527
|
+
var a = Q.object({ experimental: Q.record(Q.string(), Q.record(Q.string(), Q.any()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."), tools: Q.object({ listChanged: Q.boolean().optional().describe("App supports tools/list_changed notifications.") }).optional().describe("App exposes MCP-style tools that the host can call."), availableDisplayModes: Q.array(B).optional().describe("Display modes the app supports.") });
|
|
11313
12528
|
var y = Q.object({ method: Q.literal("ui/notifications/initialized"), params: Q.object({}).optional() });
|
|
11314
|
-
var TQ = Q.object({ csp: O.optional().describe("Content Security Policy configuration for UI resources."), permissions:
|
|
12529
|
+
var TQ = Q.object({ csp: O.optional().describe("Content Security Policy configuration for UI resources."), permissions: z5.optional().describe("Sandbox permissions requested by the UI resource."), domain: Q.string().optional().describe(`Dedicated origin for view sandbox.
|
|
11315
12530
|
|
|
11316
12531
|
Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
|
|
11317
12532
|
|
|
@@ -11335,9 +12550,9 @@ var MQ = Q.object({ resourceUri: Q.string().optional(), visibility: Q.array(e).o
|
|
|
11335
12550
|
var OX = Q.object({ mimeTypes: Q.array(Q.string()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.') });
|
|
11336
12551
|
var f = Q.object({ method: Q.literal("ui/download-file"), params: Q.object({ contents: Q.array(Q.union([EmbeddedResourceSchema, ResourceLinkSchema])).describe("Resource contents to download \u2014 embedded (inline data) or linked (host fetches). Uses standard MCP resource types.") }) });
|
|
11337
12552
|
var k = Q.object({ method: Q.literal("ui/message"), params: Q.object({ role: Q.literal("user").describe('Message role, currently only "user" is supported.'), content: Q.array(ContentBlockSchema).describe("Message content blocks (text, image, etc.).") }) });
|
|
11338
|
-
var CQ = Q.object({ method: Q.literal("ui/notifications/sandbox-resource-ready"), params: Q.object({ html: Q.string().describe("HTML content to load into the inner iframe."), sandbox: Q.string().optional().describe("Optional override for the inner iframe's sandbox attribute."), csp: O.optional().describe("CSP configuration from resource metadata."), permissions:
|
|
12553
|
+
var CQ = Q.object({ method: Q.literal("ui/notifications/sandbox-resource-ready"), params: Q.object({ html: Q.string().describe("HTML content to load into the inner iframe."), sandbox: Q.string().optional().describe("Optional override for the inner iframe's sandbox attribute."), csp: O.optional().describe("CSP configuration from resource metadata."), permissions: z5.optional().describe("Sandbox permissions from resource metadata.") }) });
|
|
11339
12554
|
var v = Q.object({ method: Q.literal("ui/notifications/tool-result"), params: CallToolResultSchema2.describe("Standard MCP tool execution result.") });
|
|
11340
|
-
var x = Q.object({ toolInfo: Q.object({ id: RequestIdSchema.optional().describe("JSON-RPC id of the tools/call request."), tool:
|
|
12555
|
+
var x = Q.object({ toolInfo: Q.object({ id: RequestIdSchema.optional().describe("JSON-RPC id of the tools/call request."), tool: ToolSchema2.describe("Tool definition including name, inputSchema, etc.") }).optional().describe("Metadata of the tool call that instantiated this App."), theme: r.optional().describe("Current color theme preference."), styles: s.optional().describe("Style configuration for theming the app."), displayMode: B.optional().describe("How the UI is currently displayed."), availableDisplayModes: Q.array(B).optional().describe("Display modes the host supports."), containerDimensions: Q.union([Q.object({ height: Q.number().describe("Fixed container height in pixels.") }), Q.object({ maxHeight: Q.union([Q.number(), Q.undefined()]).optional().describe("Maximum container height in pixels.") })]).and(Q.union([Q.object({ width: Q.number().describe("Fixed container width in pixels.") }), Q.object({ maxWidth: Q.union([Q.number(), Q.undefined()]).optional().describe("Maximum container width in pixels.") })])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
11341
12556
|
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`), locale: Q.string().optional().describe("User's language and region preference in BCP 47 format."), timeZone: Q.string().optional().describe("User's timezone in IANA format."), userAgent: Q.string().optional().describe("Host application identifier."), platform: Q.union([Q.literal("web"), Q.literal("desktop"), Q.literal("mobile")]).optional().describe("Platform type for responsive design decisions."), deviceCapabilities: Q.object({ touch: Q.boolean().optional().describe("Whether the device supports touch input."), hover: Q.boolean().optional().describe("Whether the device supports hover interactions.") }).optional().describe("Device input capabilities."), safeAreaInsets: Q.object({ top: Q.number().describe("Top safe area inset in pixels."), right: Q.number().describe("Right safe area inset in pixels."), bottom: Q.number().describe("Bottom safe area inset in pixels."), left: Q.number().describe("Left safe area inset in pixels.") }).optional().describe("Mobile safe area boundaries in pixels.") }).passthrough();
|
|
11342
12557
|
var b = Q.object({ method: Q.literal("ui/notifications/host-context-changed"), params: x.describe("Partial context update containing only changed fields.") });
|
|
11343
12558
|
var d = Q.object({ method: Q.literal("ui/update-model-context"), params: Q.object({ content: Q.array(ContentBlockSchema).optional().describe("Context content blocks (text, image, etc.)."), structuredContent: Q.record(Q.string(), Q.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.") }) });
|
|
@@ -12143,7 +13358,7 @@ function createCliOAuthNavigation(options = {}) {
|
|
|
12143
13358
|
}
|
|
12144
13359
|
|
|
12145
13360
|
// ../../core/client/config-parse.ts
|
|
12146
|
-
import { z as
|
|
13361
|
+
import { z as z6 } from "zod";
|
|
12147
13362
|
function isAbsoluteHttpUrl(value) {
|
|
12148
13363
|
let url;
|
|
12149
13364
|
try {
|
|
@@ -12160,11 +13375,11 @@ function isRealHost(hostname) {
|
|
|
12160
13375
|
const labels = hostname.split(".");
|
|
12161
13376
|
return labels.length >= 2 && labels.every((label) => label !== "");
|
|
12162
13377
|
}
|
|
12163
|
-
var HttpUrlStringSchema =
|
|
13378
|
+
var HttpUrlStringSchema = z6.string().min(1).superRefine((val, ctx) => {
|
|
12164
13379
|
const trimmed = val.trim();
|
|
12165
13380
|
if (!isAbsoluteHttpUrl(trimmed)) {
|
|
12166
13381
|
ctx.addIssue({
|
|
12167
|
-
code:
|
|
13382
|
+
code: z6.ZodIssueCode.custom,
|
|
12168
13383
|
message: `Invalid URL: "${trimmed}" \u2014 must be an http(s) URL (e.g. https://idp.example.com)`
|
|
12169
13384
|
});
|
|
12170
13385
|
}
|
|
@@ -12196,7 +13411,7 @@ function refineCimdMetadataUrl(val, ctx, required) {
|
|
|
12196
13411
|
if (trimmed === "") {
|
|
12197
13412
|
if (required) {
|
|
12198
13413
|
ctx.addIssue({
|
|
12199
|
-
code:
|
|
13414
|
+
code: z6.ZodIssueCode.custom,
|
|
12200
13415
|
message: "CIMD client metadata URL is required when CIMD is enabled"
|
|
12201
13416
|
});
|
|
12202
13417
|
}
|
|
@@ -12205,25 +13420,25 @@ function refineCimdMetadataUrl(val, ctx, required) {
|
|
|
12205
13420
|
const error = getCimdClientMetadataUrlError(trimmed);
|
|
12206
13421
|
if (error) {
|
|
12207
13422
|
ctx.addIssue({
|
|
12208
|
-
code:
|
|
13423
|
+
code: z6.ZodIssueCode.custom,
|
|
12209
13424
|
message: error
|
|
12210
13425
|
});
|
|
12211
13426
|
}
|
|
12212
13427
|
}
|
|
12213
|
-
var CimdConfigSchema =
|
|
12214
|
-
enabled:
|
|
12215
|
-
clientMetadataUrl:
|
|
13428
|
+
var CimdConfigSchema = z6.object({
|
|
13429
|
+
enabled: z6.boolean(),
|
|
13430
|
+
clientMetadataUrl: z6.string()
|
|
12216
13431
|
}).superRefine((data, ctx) => {
|
|
12217
13432
|
refineCimdMetadataUrl(data.clientMetadataUrl, ctx, data.enabled === true);
|
|
12218
13433
|
});
|
|
12219
|
-
var EnterpriseManagedAuthIdpConfigSchema =
|
|
13434
|
+
var EnterpriseManagedAuthIdpConfigSchema = z6.object({
|
|
12220
13435
|
issuer: HttpUrlStringSchema,
|
|
12221
|
-
clientId:
|
|
12222
|
-
clientSecret:
|
|
13436
|
+
clientId: z6.string().min(1),
|
|
13437
|
+
clientSecret: z6.string().optional()
|
|
12223
13438
|
});
|
|
12224
|
-
var ClientConfigSchema =
|
|
12225
|
-
enterpriseManagedAuth:
|
|
12226
|
-
enabled:
|
|
13439
|
+
var ClientConfigSchema = z6.object({
|
|
13440
|
+
enterpriseManagedAuth: z6.object({
|
|
13441
|
+
enabled: z6.boolean().optional(),
|
|
12227
13442
|
idp: EnterpriseManagedAuthIdpConfigSchema
|
|
12228
13443
|
}).optional(),
|
|
12229
13444
|
cimd: CimdConfigSchema.optional()
|
|
@@ -12370,7 +13585,9 @@ function isOAuthCapableServerConfig(config) {
|
|
|
12370
13585
|
function buildRunnerClientAuthOptions(clientConfig, savedSettings, cliOverrides) {
|
|
12371
13586
|
const activeIdp = getActiveEnterpriseManagedAuthIdp(clientConfig);
|
|
12372
13587
|
const activeCimdUrl = getActiveCimdClientMetadataUrl(clientConfig);
|
|
12373
|
-
const
|
|
13588
|
+
const serverAuthorizationParams = savedSettings ? oauthAuthorizationParamsFromSettings(savedSettings) : void 0;
|
|
13589
|
+
const serverEndpointOverrides = savedSettings ? oauthEndpointOverridesFromSettings(savedSettings) : void 0;
|
|
13590
|
+
const oauthFromServer = savedSettings && (savedSettings.oauthClientId || savedSettings.oauthClientSecret || savedSettings.oauthScopes || serverAuthorizationParams || serverEndpointOverrides || savedSettings.enterpriseManaged) ? {
|
|
12374
13591
|
...savedSettings.oauthClientId && {
|
|
12375
13592
|
clientId: savedSettings.oauthClientId
|
|
12376
13593
|
},
|
|
@@ -12380,6 +13597,10 @@ function buildRunnerClientAuthOptions(clientConfig, savedSettings, cliOverrides)
|
|
|
12380
13597
|
...savedSettings.oauthScopes && {
|
|
12381
13598
|
scope: savedSettings.oauthScopes
|
|
12382
13599
|
},
|
|
13600
|
+
...serverAuthorizationParams && {
|
|
13601
|
+
authorizationParams: serverAuthorizationParams
|
|
13602
|
+
},
|
|
13603
|
+
...serverEndpointOverrides,
|
|
12383
13604
|
...savedSettings.enterpriseManaged && {
|
|
12384
13605
|
enterpriseManaged: true
|
|
12385
13606
|
}
|