@prefecthq/fastmcp-ts 1.7.3 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.cjs +448 -162
- package/dist/cli/index.cjs.map +1 -1
- package/dist/client.js +4 -4
- package/dist/client.js.map +1 -1
- package/dist/server.d.ts +71 -3
- package/dist/server.js +161 -22
- package/dist/server.js.map +1 -1
- package/package.json +4 -4
package/dist/cli/index.cjs
CHANGED
|
@@ -1180,8 +1180,8 @@ var init_version = __esm({
|
|
|
1180
1180
|
async run({ args }) {
|
|
1181
1181
|
if (args.json) setJsonMode(true);
|
|
1182
1182
|
const data = {
|
|
1183
|
-
fastmcp: "1.
|
|
1184
|
-
"mcp-sdk": "2.
|
|
1183
|
+
fastmcp: "1.8.1",
|
|
1184
|
+
"mcp-sdk": "2.3.1",
|
|
1185
1185
|
node: process.version,
|
|
1186
1186
|
platform: `${process.platform} ${process.arch}`
|
|
1187
1187
|
};
|
|
@@ -8965,10 +8965,10 @@ var init_v4 = __esm({
|
|
|
8965
8965
|
}
|
|
8966
8966
|
});
|
|
8967
8967
|
|
|
8968
|
-
// node_modules/@modelcontextprotocol/core/dist/auth-
|
|
8968
|
+
// node_modules/@modelcontextprotocol/core/dist/auth-BNDyLTqp.mjs
|
|
8969
8969
|
var LATEST_PROTOCOL_VERSION, SUPPORTED_PROTOCOL_VERSIONS, RELATED_TASK_META_KEY, PROTOCOL_VERSION_META_KEY, CLIENT_INFO_META_KEY, SERVER_INFO_META_KEY, CLIENT_CAPABILITIES_META_KEY, SUBSCRIPTION_ID_META_KEY, LOG_LEVEL_META_KEY, JSONRPC_VERSION, JSONValueSchema, JSONObjectSchema, JSONArraySchema, ProgressTokenSchema, CursorSchema, TaskMetadataSchema, RelatedTaskMetadataSchema, RequestMetaSchema, BaseRequestParamsSchema, TaskAugmentedRequestParamsSchema, RequestSchema, NotificationsParamsSchema, NotificationSchema, ResultMetaObjectSchema, ResultSchema, RequestIdSchema, JSONRPCRequestSchema, JSONRPCNotificationSchema, JSONRPCResultResponseSchema, JSONRPCErrorResponseSchema, JSONRPCMessageSchema, JSONRPCResponseSchema, EmptyResultSchema, CancelledNotificationParamsSchema, CancelledNotificationSchema, IconSchema, IconsSchema, BaseMetadataSchema, ImplementationSchema, FormElicitationCapabilitySchema, ElicitationCapabilitySchema, ClientTasksCapabilitySchema, ServerTasksCapabilitySchema, ClientCapabilitiesSchema, InitializeRequestParamsSchema, InitializeRequestSchema, ServerCapabilitiesSchema, InitializeResultSchema, InitializedNotificationSchema, DiscoverRequestSchema, DiscoverResultSchema, PingRequestSchema, ProgressSchema, ProgressNotificationParamsSchema, ProgressNotificationSchema, PaginatedRequestParamsSchema, PaginatedRequestSchema, PaginatedResultSchema, ResourceContentsSchema, TextResourceContentsSchema, Base64Schema, BlobResourceContentsSchema, RoleSchema, AnnotationsSchema, ResourceSchema, ResourceTemplateSchema, ListResourcesRequestSchema, ListResourcesResultSchema, ListResourceTemplatesRequestSchema, ListResourceTemplatesResultSchema, ResourceRequestParamsSchema, ReadResourceRequestParamsSchema, ReadResourceRequestSchema, ReadResourceResultSchema, ResourceListChangedNotificationSchema, SubscribeRequestParamsSchema, SubscribeRequestSchema, UnsubscribeRequestParamsSchema, UnsubscribeRequestSchema, SubscriptionFilterSchema, SubscriptionsListenRequestParamsSchema, SubscriptionsListenRequestSchema, SubscriptionsAcknowledgedNotificationParamsSchema, SubscriptionsAcknowledgedNotificationSchema, SubscriptionsListenResultMetaSchema, SubscriptionsListenResultSchema, ResourceUpdatedNotificationParamsSchema, ResourceUpdatedNotificationSchema, PromptArgumentSchema, PromptSchema, ListPromptsRequestSchema, ListPromptsResultSchema, GetPromptRequestParamsSchema, GetPromptRequestSchema, TextContentSchema, ImageContentSchema, AudioContentSchema, ToolUseContentSchema, EmbeddedResourceSchema, ResourceLinkSchema, ContentBlockSchema, PromptMessageSchema, GetPromptResultSchema, PromptListChangedNotificationSchema, ToolAnnotationsSchema, ToolExecutionSchema, ToolSchema, ListToolsRequestSchema, ListToolsResultSchema, CallToolResultSchema, CompatibilityCallToolResultSchema, CallToolRequestParamsSchema, CallToolRequestSchema, ToolListChangedNotificationSchema, ListChangedOptionsBaseSchema, LoggingLevelSchema, SetLevelRequestParamsSchema, SetLevelRequestSchema, LoggingMessageNotificationParamsSchema, LoggingMessageNotificationSchema, ModelHintSchema, ModelPreferencesSchema, ToolChoiceSchema, ToolResultContentSchema, SamplingContentSchema, SamplingMessageContentBlockSchema, SamplingMessageSchema, CreateMessageRequestParamsSchema, CreateMessageRequestSchema, CreateMessageResultSchema, CreateMessageResultWithToolsSchema, BooleanSchemaSchema, StringSchemaSchema, NumberSchemaSchema, UntitledSingleSelectEnumSchemaSchema, TitledSingleSelectEnumSchemaSchema, LegacyTitledEnumSchemaSchema, SingleSelectEnumSchemaSchema, UntitledMultiSelectEnumSchemaSchema, TitledMultiSelectEnumSchemaSchema, MultiSelectEnumSchemaSchema, EnumSchemaSchema, PrimitiveSchemaDefinitionSchema, ElicitRequestFormParamsSchema, ElicitRequestURLParamsSchema, ElicitRequestParamsSchema, ElicitRequestSchema, ElicitationCompleteNotificationParamsSchema, ElicitationCompleteNotificationSchema, ElicitResultSchema, ResourceTemplateReferenceSchema, PromptReferenceSchema, CompleteRequestParamsSchema, CompleteRequestSchema, CompleteResultSchema, RootSchema, ListRootsRequestSchema, ListRootsResultSchema, RootsListChangedNotificationSchema, TaskCreationParamsSchema, TaskStatusSchema, TaskSchema, CreateTaskResultSchema, TaskStatusNotificationParamsSchema, TaskStatusNotificationSchema, GetTaskRequestSchema, GetTaskResultSchema, GetTaskPayloadRequestSchema, GetTaskPayloadResultSchema, ListTasksRequestSchema, ListTasksResultSchema, CancelTaskRequestSchema, CancelTaskResultSchema, ClientRequestSchema, ClientNotificationSchema, ClientResultSchema, ServerRequestSchema, ServerNotificationSchema, ServerResultSchema, SafeUrlSchema, OAuthProtectedResourceMetadataSchema, OAuthMetadataSchema, OpenIdProviderMetadataSchema, OpenIdProviderDiscoveryMetadataSchema, OAuthTokensSchema, IdJagTokenExchangeResponseSchema, OAuthErrorResponseSchema, OptionalSafeUrlSchema, OAuthClientMetadataSchema, OAuthClientInformationSchema, OAuthClientInformationFullSchema, OAuthClientRegistrationErrorSchema, OAuthTokenRevocationRequestSchema;
|
|
8970
|
-
var
|
|
8971
|
-
"node_modules/@modelcontextprotocol/core/dist/auth-
|
|
8970
|
+
var init_auth_BNDyLTqp = __esm({
|
|
8971
|
+
"node_modules/@modelcontextprotocol/core/dist/auth-BNDyLTqp.mjs"() {
|
|
8972
8972
|
"use strict";
|
|
8973
8973
|
init_v4();
|
|
8974
8974
|
LATEST_PROTOCOL_VERSION = "2025-11-25";
|
|
@@ -9807,7 +9807,8 @@ var init_auth_CUe6YdwF = __esm({
|
|
|
9807
9807
|
introspection_endpoint_auth_signing_alg_values_supported: array(string2()).optional(),
|
|
9808
9808
|
code_challenge_methods_supported: array(string2()).optional(),
|
|
9809
9809
|
client_id_metadata_document_supported: boolean2().optional(),
|
|
9810
|
-
authorization_response_iss_parameter_supported: boolean2().optional().catch(void 0)
|
|
9810
|
+
authorization_response_iss_parameter_supported: boolean2().optional().catch(void 0),
|
|
9811
|
+
dpop_signing_alg_values_supported: array(string2()).optional()
|
|
9811
9812
|
});
|
|
9812
9813
|
OpenIdProviderMetadataSchema = looseObject({
|
|
9813
9814
|
issuer: string2(),
|
|
@@ -9858,7 +9859,8 @@ var init_auth_CUe6YdwF = __esm({
|
|
|
9858
9859
|
token_type: string2(),
|
|
9859
9860
|
expires_in: coerce_exports.number().optional(),
|
|
9860
9861
|
scope: string2().optional(),
|
|
9861
|
-
refresh_token: string2().optional()
|
|
9862
|
+
refresh_token: string2().optional(),
|
|
9863
|
+
issuer: string2().optional().catch(void 0)
|
|
9862
9864
|
}).strip();
|
|
9863
9865
|
IdJagTokenExchangeResponseSchema = object({
|
|
9864
9866
|
issued_token_type: literal("urn:ietf:params:oauth:token-type:id-jag"),
|
|
@@ -9896,7 +9898,8 @@ var init_auth_CUe6YdwF = __esm({
|
|
|
9896
9898
|
client_id: string2(),
|
|
9897
9899
|
client_secret: string2().optional(),
|
|
9898
9900
|
client_id_issued_at: number2().optional(),
|
|
9899
|
-
client_secret_expires_at: number2().optional()
|
|
9901
|
+
client_secret_expires_at: number2().optional(),
|
|
9902
|
+
issuer: string2().optional().catch(void 0)
|
|
9900
9903
|
}).strip();
|
|
9901
9904
|
OAuthClientInformationFullSchema = OAuthClientMetadataSchema.merge(OAuthClientInformationSchema);
|
|
9902
9905
|
OAuthClientRegistrationErrorSchema = object({
|
|
@@ -9914,11 +9917,11 @@ var init_auth_CUe6YdwF = __esm({
|
|
|
9914
9917
|
var init_internal = __esm({
|
|
9915
9918
|
"node_modules/@modelcontextprotocol/core/dist/internal.mjs"() {
|
|
9916
9919
|
"use strict";
|
|
9917
|
-
|
|
9920
|
+
init_auth_BNDyLTqp();
|
|
9918
9921
|
}
|
|
9919
9922
|
});
|
|
9920
9923
|
|
|
9921
|
-
// node_modules/@modelcontextprotocol/client/dist/src-
|
|
9924
|
+
// node_modules/@modelcontextprotocol/client/dist/src-WCy6ifGf.mjs
|
|
9922
9925
|
function stampErrorBrands(instance, ctor) {
|
|
9923
9926
|
const brands = /* @__PURE__ */ new Set();
|
|
9924
9927
|
let current = ctor;
|
|
@@ -9949,6 +9952,12 @@ function resourceUrlFromServerUrl(url2) {
|
|
|
9949
9952
|
resourceURL.hash = "";
|
|
9950
9953
|
return resourceURL;
|
|
9951
9954
|
}
|
|
9955
|
+
function withoutIssuer(body) {
|
|
9956
|
+
if (typeof body !== "object" || body === null || Array.isArray(body)) return body;
|
|
9957
|
+
const copy = { ...body };
|
|
9958
|
+
delete copy.issuer;
|
|
9959
|
+
return copy;
|
|
9960
|
+
}
|
|
9952
9961
|
function checkResourceAllowed({ requestedResource, configuredResource }) {
|
|
9953
9962
|
const requested = typeof requestedResource === "string" ? new URL(requestedResource) : new URL(requestedResource.href);
|
|
9954
9963
|
const configured = typeof configuredResource === "string" ? new URL(configuredResource) : new URL(configuredResource.href);
|
|
@@ -10980,7 +10989,7 @@ function getRequestSchema(method) {
|
|
|
10980
10989
|
function getNotificationSchema(method) {
|
|
10981
10990
|
return hasNotificationMethod2025(method) ? registryMaps().notificationSchemas[method] : void 0;
|
|
10982
10991
|
}
|
|
10983
|
-
function isPlainObject$
|
|
10992
|
+
function isPlainObject$5(value) {
|
|
10984
10993
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
10985
10994
|
}
|
|
10986
10995
|
function triState$1(schema, raw) {
|
|
@@ -10999,7 +11008,7 @@ function triState$1(schema, raw) {
|
|
|
10999
11008
|
};
|
|
11000
11009
|
}
|
|
11001
11010
|
function toolNeedsLegacyWrap(t2) {
|
|
11002
|
-
return isPlainObject$
|
|
11011
|
+
return isPlainObject$5(t2) && isPlainObject$5(t2["outputSchema"]) && isNonObjectJsonSchemaRoot(t2["outputSchema"]);
|
|
11003
11012
|
}
|
|
11004
11013
|
function toNeutralResult(value) {
|
|
11005
11014
|
return value;
|
|
@@ -11873,7 +11882,8 @@ function build() {
|
|
|
11873
11882
|
ListResourceTemplatesResultResponseSchema: wireResultResponse(ListResourceTemplatesResultSchema$1),
|
|
11874
11883
|
ReadResourceResultResponseSchema: wireResultResponse(union([ReadResourceResultSchema$1, InputRequiredResultSchema])),
|
|
11875
11884
|
CompleteResultResponseSchema: wireResultResponse(CompleteResultSchema$1),
|
|
11876
|
-
DiscoverResultResponseSchema: wireResultResponse(DiscoverResultSchema$1)
|
|
11885
|
+
DiscoverResultResponseSchema: wireResultResponse(DiscoverResultSchema$1),
|
|
11886
|
+
SubscriptionsListenResultResponseSchema: wireResultResponse(SubscriptionsListenResultSchema$1)
|
|
11877
11887
|
};
|
|
11878
11888
|
}
|
|
11879
11889
|
function buildSchemas2026() {
|
|
@@ -11915,7 +11925,7 @@ function fillCacheFields(method, result) {
|
|
|
11915
11925
|
delete filled[RESULT_CACHE_HINT_FALLBACK];
|
|
11916
11926
|
return filled;
|
|
11917
11927
|
}
|
|
11918
|
-
function isPlainObject$
|
|
11928
|
+
function isPlainObject$4(value) {
|
|
11919
11929
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
11920
11930
|
}
|
|
11921
11931
|
function stampServerInfoMeta(result, serverInfo) {
|
|
@@ -11925,7 +11935,7 @@ function stampServerInfoMeta(result, serverInfo) {
|
|
|
11925
11935
|
...result,
|
|
11926
11936
|
_meta: { [SERVER_INFO_META_KEY]: serverInfo }
|
|
11927
11937
|
};
|
|
11928
|
-
if (!isPlainObject$
|
|
11938
|
+
if (!isPlainObject$4(meta3)) return result;
|
|
11929
11939
|
if (meta3[SERVER_INFO_META_KEY] !== void 0) return result;
|
|
11930
11940
|
return {
|
|
11931
11941
|
...result,
|
|
@@ -11999,7 +12009,7 @@ function getResultSchema2026(method) {
|
|
|
11999
12009
|
function getNotificationSchema2026(method) {
|
|
12000
12010
|
return hasNotificationMethod2026(method) ? buildSchemas2026().notificationSchemas2026[method] : void 0;
|
|
12001
12011
|
}
|
|
12002
|
-
function isPlainObject$
|
|
12012
|
+
function isPlainObject$3(value) {
|
|
12003
12013
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
12004
12014
|
}
|
|
12005
12015
|
function triState(schema, raw) {
|
|
@@ -12028,14 +12038,14 @@ function enforceDeletedFields(method, result) {
|
|
|
12028
12038
|
return next;
|
|
12029
12039
|
};
|
|
12030
12040
|
const tools = result.tools;
|
|
12031
|
-
if (method === "tools/list" && Array.isArray(tools) && tools.some((tool) => isPlainObject$
|
|
12032
|
-
if (!isPlainObject$
|
|
12041
|
+
if (method === "tools/list" && Array.isArray(tools) && tools.some((tool) => isPlainObject$3(tool) && "execution" in tool)) copy().tools = tools.map((tool) => {
|
|
12042
|
+
if (!isPlainObject$3(tool) || !("execution" in tool)) return tool;
|
|
12033
12043
|
const rest = { ...tool };
|
|
12034
12044
|
delete rest["execution"];
|
|
12035
12045
|
return rest;
|
|
12036
12046
|
});
|
|
12037
12047
|
const capabilities = result.capabilities;
|
|
12038
|
-
if (isPlainObject$
|
|
12048
|
+
if (isPlainObject$3(capabilities) && "tasks" in capabilities) {
|
|
12039
12049
|
const rest = { ...capabilities };
|
|
12040
12050
|
delete rest["tasks"];
|
|
12041
12051
|
copy().capabilities = rest;
|
|
@@ -12071,6 +12081,9 @@ function isSpecRequestMethod(method) {
|
|
|
12071
12081
|
function isSpecNotificationMethod(method) {
|
|
12072
12082
|
return ALL_CODECS.some((codec2) => codec2.hasNotificationMethod(method));
|
|
12073
12083
|
}
|
|
12084
|
+
function isExtensionReusedRequestMethod(method) {
|
|
12085
|
+
return method === "tasks/get" || method === "tasks/cancel";
|
|
12086
|
+
}
|
|
12074
12087
|
function scanXMcpHeaderDeclarations(inputSchema) {
|
|
12075
12088
|
const declarations = [];
|
|
12076
12089
|
const seenLower = /* @__PURE__ */ new Map();
|
|
@@ -12169,6 +12182,18 @@ function buildMcpParamHeaders(declarations, args) {
|
|
|
12169
12182
|
}
|
|
12170
12183
|
return out;
|
|
12171
12184
|
}
|
|
12185
|
+
function mcpNameSource(method, params) {
|
|
12186
|
+
const field = Object.hasOwn(MCP_NAME_HEADER_SOURCE, method) ? MCP_NAME_HEADER_SOURCE[method] : void 0;
|
|
12187
|
+
if (field === void 0) return;
|
|
12188
|
+
const raw = isPlainObject$2(params) ? params[field] : void 0;
|
|
12189
|
+
return {
|
|
12190
|
+
field,
|
|
12191
|
+
value: typeof raw === "string" ? raw : void 0
|
|
12192
|
+
};
|
|
12193
|
+
}
|
|
12194
|
+
function isPlainObject$2(value) {
|
|
12195
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
12196
|
+
}
|
|
12172
12197
|
function parseSchema(schema, data) {
|
|
12173
12198
|
return safeParse2(schema, data);
|
|
12174
12199
|
}
|
|
@@ -12649,7 +12674,8 @@ function manualInputRequiredValue(decoded) {
|
|
|
12649
12674
|
return {
|
|
12650
12675
|
resultType: "input_required",
|
|
12651
12676
|
inputRequests: decoded.inputRequests,
|
|
12652
|
-
...decoded.requestState !== void 0 && { requestState: decoded.requestState }
|
|
12677
|
+
...decoded.requestState !== void 0 && { requestState: decoded.requestState },
|
|
12678
|
+
...decoded._meta !== void 0 && { _meta: decoded._meta }
|
|
12653
12679
|
};
|
|
12654
12680
|
}
|
|
12655
12681
|
function mediaTypeEssence(header) {
|
|
@@ -12687,9 +12713,61 @@ function createFetchWithInit(baseFetch = fetch, baseInit) {
|
|
|
12687
12713
|
});
|
|
12688
12714
|
};
|
|
12689
12715
|
}
|
|
12690
|
-
|
|
12691
|
-
|
|
12692
|
-
"
|
|
12716
|
+
function isWithinOrigin(from, to) {
|
|
12717
|
+
if (from.protocol === to.protocol && from.host === to.host) return true;
|
|
12718
|
+
return from.protocol === "http:" && to.protocol === "https:" && from.hostname === to.hostname && !from.port && !to.port;
|
|
12719
|
+
}
|
|
12720
|
+
function redirectTarget(url2, response) {
|
|
12721
|
+
const location = REDIRECT_STATUSES.has(response.status) ? response.headers?.get("location") : void 0;
|
|
12722
|
+
if (!location) return void 0;
|
|
12723
|
+
try {
|
|
12724
|
+
return new URL(location, url2);
|
|
12725
|
+
} catch {
|
|
12726
|
+
return;
|
|
12727
|
+
}
|
|
12728
|
+
}
|
|
12729
|
+
function fetchLeavingRedirects(baseFetch) {
|
|
12730
|
+
const copy = (url2, init) => baseFetch(url2, init);
|
|
12731
|
+
leftToFetch.add(copy);
|
|
12732
|
+
return copy;
|
|
12733
|
+
}
|
|
12734
|
+
function fetchWithinOrigin(baseFetch) {
|
|
12735
|
+
if (leftToFetch.has(baseFetch)) return baseFetch;
|
|
12736
|
+
return async (url2, init) => {
|
|
12737
|
+
if (init?.redirect === "error" || init?.redirect === "manual") return baseFetch(url2, init);
|
|
12738
|
+
const method = (init?.method ?? "GET").toUpperCase();
|
|
12739
|
+
let current = url2;
|
|
12740
|
+
for (let followed = 0; ; followed++) {
|
|
12741
|
+
const response = await baseFetch(current, {
|
|
12742
|
+
...init,
|
|
12743
|
+
redirect: "manual"
|
|
12744
|
+
});
|
|
12745
|
+
const target = redirectTarget(current, response);
|
|
12746
|
+
if (!target || followed === MAX_REDIRECTS) return response;
|
|
12747
|
+
const from = new URL(current);
|
|
12748
|
+
const keepsMethod = method === "GET" || response.status === 307 || response.status === 308;
|
|
12749
|
+
const keepsUserinfo = !(target.username || target.password) || target.username === from.username && target.password === from.password;
|
|
12750
|
+
if (!keepsMethod || !keepsUserinfo || !isWithinOrigin(from, target)) return response;
|
|
12751
|
+
await response.text?.().catch(() => {
|
|
12752
|
+
});
|
|
12753
|
+
current = target;
|
|
12754
|
+
}
|
|
12755
|
+
};
|
|
12756
|
+
}
|
|
12757
|
+
function unfollowedRedirect(url2, response) {
|
|
12758
|
+
if (response.type === "opaqueredirect") return "Redirect not followed: this runtime does not expose where it points";
|
|
12759
|
+
const target = redirectTarget(response.url || url2, response);
|
|
12760
|
+
if (!target) return void 0;
|
|
12761
|
+
target.username = target.password = target.search = target.hash = "";
|
|
12762
|
+
if (target.protocol === "http:" && new URL(response.url || url2).protocol === "https:") {
|
|
12763
|
+
target.protocol = "https:";
|
|
12764
|
+
return `Redirect from https to plain http not followed; try ${target.href} as the endpoint`;
|
|
12765
|
+
}
|
|
12766
|
+
return `Redirect to ${target.href} not followed; use that URL as the endpoint if it is the intended server`;
|
|
12767
|
+
}
|
|
12768
|
+
var BRANDS, OAuthErrorCode, OAuthError, SdkErrorCode, SdkError, SdkHttpError, FIRST_MODERN_PROTOCOL_VERSION, SUPPORTED_MODERN_PROTOCOL_VERSIONS, TOOL_RESULT_FOREIGN_FAMILY_KEYS, memo$1, REF_REWRITE_DATA_POSITION_KEYS, REF_REWRITE_NAME_MAP_KEYS, requestMethodKeys$1, notificationMethodKeys$1, resultMethodKeys, maps$1, rev2025RequestMethods, rev2025NotificationMethods, NOT_IN_ERA$1, rev2025Codec, memo, CACHEABLE_RESULT_METHODS, RESULT_CACHE_HINT_FALLBACK, ProtocolErrorCode, ProtocolError, ResourceNotFoundError, UrlElicitationRequiredError, UnsupportedProtocolVersionError, MissingRequiredClientCapabilityError, DEFAULT_CACHE_TTL_MS, DEFAULT_CACHE_SCOPE, EXTENDED_RESULT_TYPE_METHODS, INPUT_REQUEST_METHODS_2026, maps, requestMethodKeys, notificationMethodKeys, rev2026RequestMethods, rev2026NotificationMethods, NOT_IN_ERA, REQUIRED_ENVELOPE_KEYS, rev2026Codec, wireResultSchemasMemo, MODERN_WIRE_REVISION, ALL_CODECS, schemas_exports3, isJSONRPCRequest, isJSONRPCNotification, isJSONRPCResultResponse, isJSONRPCErrorResponse, isInputRequiredResult, isInitializeRequest, isInitializedNotification, MCP_PARAM_HEADER_PREFIX, X_MCP_HEADER_KEY, RFC9110_TOKEN, PERMITTED_X_MCP_HEADER_TYPES, NON_REACHABLE_SUBSCHEMA_KEYWORDS, OBJECT_VALUED_SUBSCHEMA_KEYWORDS, BASE64_SENTINEL_PREFIX, BASE64_SENTINEL_SUFFIX, HEADER_MISMATCH_ERROR_CODE, INBOUND_VALIDATION_LADDER, LADDER_ERROR_HTTP_STATUS, MCP_NAME_HEADER_SOURCE, warnedZodFallback, JSON_SCHEMA_CONVERSION_TARGET, DATETIME_FRACTION_DIGITS, ANNOTATION_ONLY_JSON_SCHEMA_KEYWORDS, ROOT_KEYS, PROPERTY_KEYS_BY_TYPE, SUPPORTED_STRING_FORMATS, inputRequired, DEFAULT_INPUT_REQUIRED_AUTO_FULFILL, DEFAULT_INPUT_REQUIRED_MAX_ROUNDS, REQUEST_STATE_ONLY_LEG_PACING_MS, SPEC_SCHEMA_KEYS, authSchemas, _specTypeSchemas, _isSpecType, specTypeSchemas, isSpecType, DEFAULT_REQUEST_TIMEOUT_MSEC, RESERVED_ENVELOPE_META_KEYS, RETRY_PARAMS_KEYS, NO_REQUEST_STATE, writeNegotiatedProtocolVersion, Protocol, require_content_type, import_content_type, STDIO_DEFAULT_MAX_BUFFER_SIZE, ReadBuffer, REDIRECT_STATUSES, MAX_REDIRECTS, leftToFetch, InMemoryTransport;
|
|
12769
|
+
var init_src_WCy6ifGf = __esm({
|
|
12770
|
+
"node_modules/@modelcontextprotocol/client/dist/src-WCy6ifGf.mjs"() {
|
|
12693
12771
|
"use strict";
|
|
12694
12772
|
init_chunk_Br0eD_fh();
|
|
12695
12773
|
init_dialects_BOhdv1Fc();
|
|
@@ -12715,6 +12793,8 @@ var init_src_D_zzAWoS = __esm({
|
|
|
12715
12793
|
OAuthErrorCode$1["InvalidRedirectUri"] = "invalid_redirect_uri";
|
|
12716
12794
|
OAuthErrorCode$1["InsufficientScope"] = "insufficient_scope";
|
|
12717
12795
|
OAuthErrorCode$1["InvalidTarget"] = "invalid_target";
|
|
12796
|
+
OAuthErrorCode$1["InvalidDpopProof"] = "invalid_dpop_proof";
|
|
12797
|
+
OAuthErrorCode$1["UseDpopNonce"] = "use_dpop_nonce";
|
|
12718
12798
|
return OAuthErrorCode$1;
|
|
12719
12799
|
})({});
|
|
12720
12800
|
OAuthError = class OAuthError2 extends Error {
|
|
@@ -12804,8 +12884,18 @@ var init_src_D_zzAWoS = __esm({
|
|
|
12804
12884
|
if (typeof this !== "function") throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");
|
|
12805
12885
|
return brandedHasInstance(this, value);
|
|
12806
12886
|
}
|
|
12807
|
-
|
|
12808
|
-
|
|
12887
|
+
/**
|
|
12888
|
+
* @param code - Stable string code identifying the failure ({@linkcode SdkErrorCode}).
|
|
12889
|
+
* @param message - Human-readable description.
|
|
12890
|
+
* @param data - Optional structured payload (for example the HTTP status carried by
|
|
12891
|
+
* {@linkcode SdkHttpError}). Opaque to the SDK: a `cause` key inside `data` is not
|
|
12892
|
+
* promoted to `Error.cause`.
|
|
12893
|
+
* @param options - Standard `ErrorOptions`, forwarded to `Error`. Pass the underlying
|
|
12894
|
+
* failure as `{ cause }` so it is reachable through the `Error.cause` chain that
|
|
12895
|
+
* loggers and error trackers walk.
|
|
12896
|
+
*/
|
|
12897
|
+
constructor(code, message, data, options) {
|
|
12898
|
+
super(message, options);
|
|
12809
12899
|
this.code = code;
|
|
12810
12900
|
this.data = data;
|
|
12811
12901
|
this.name = "SdkError";
|
|
@@ -12816,8 +12906,11 @@ var init_src_D_zzAWoS = __esm({
|
|
|
12816
12906
|
static {
|
|
12817
12907
|
Object.defineProperty(this, "mcpBrand", { value: "mcp.SdkHttpError" });
|
|
12818
12908
|
}
|
|
12819
|
-
|
|
12820
|
-
|
|
12909
|
+
/**
|
|
12910
|
+
* @param options - Standard `ErrorOptions`, forwarded to `Error` (see {@linkcode SdkError}).
|
|
12911
|
+
*/
|
|
12912
|
+
constructor(code, message, data, options) {
|
|
12913
|
+
super(code, message, data, options);
|
|
12821
12914
|
this.name = "SdkHttpError";
|
|
12822
12915
|
}
|
|
12823
12916
|
get status() {
|
|
@@ -12936,7 +13029,7 @@ var init_src_D_zzAWoS = __esm({
|
|
|
12936
13029
|
};
|
|
12937
13030
|
},
|
|
12938
13031
|
decodeResult(_method, raw) {
|
|
12939
|
-
if (isPlainObject$
|
|
13032
|
+
if (isPlainObject$5(raw) && "resultType" in raw) {
|
|
12940
13033
|
const stripped = { ...raw };
|
|
12941
13034
|
delete stripped["resultType"];
|
|
12942
13035
|
return {
|
|
@@ -13177,7 +13270,7 @@ var init_src_D_zzAWoS = __esm({
|
|
|
13177
13270
|
projectCallToolResult: (result) => appendTextFallbackForNonObject(result),
|
|
13178
13271
|
inputRequestSchema: getInputRequestSchema2026,
|
|
13179
13272
|
decodeResult(method, raw) {
|
|
13180
|
-
if (!isPlainObject$
|
|
13273
|
+
if (!isPlainObject$3(raw)) return {
|
|
13181
13274
|
kind: "invalid",
|
|
13182
13275
|
error: new SdkError(SdkErrorCode.InvalidResult, `Invalid result for ${method}: not an object`, { method })
|
|
13183
13276
|
};
|
|
@@ -13198,8 +13291,10 @@ var init_src_D_zzAWoS = __esm({
|
|
|
13198
13291
|
};
|
|
13199
13292
|
if (rawResultType === "input_required") {
|
|
13200
13293
|
const rawInputRequests = raw["inputRequests"];
|
|
13201
|
-
const inputRequests = isPlainObject$
|
|
13294
|
+
const inputRequests = isPlainObject$3(rawInputRequests) ? rawInputRequests : {};
|
|
13202
13295
|
const requestState = raw["requestState"];
|
|
13296
|
+
const metaParse = raw["_meta"] === void 0 ? void 0 : buildSchemas2026().ResultMetaSchema.safeParse(raw["_meta"]);
|
|
13297
|
+
const meta3 = metaParse?.success ? metaParse.data : void 0;
|
|
13203
13298
|
if (Object.keys(inputRequests).length === 0 && typeof requestState !== "string") return {
|
|
13204
13299
|
kind: "invalid",
|
|
13205
13300
|
error: new SdkError(SdkErrorCode.InvalidResult, `Invalid result for ${method}: input_required carries neither inputRequests nor requestState (every input_required result must include at least one of the two)`, {
|
|
@@ -13210,7 +13305,8 @@ var init_src_D_zzAWoS = __esm({
|
|
|
13210
13305
|
return {
|
|
13211
13306
|
kind: "input_required",
|
|
13212
13307
|
inputRequests,
|
|
13213
|
-
...typeof requestState === "string" && { requestState }
|
|
13308
|
+
...typeof requestState === "string" && { requestState },
|
|
13309
|
+
...meta3 !== void 0 && { _meta: meta3 }
|
|
13214
13310
|
};
|
|
13215
13311
|
}
|
|
13216
13312
|
if (rawResultType !== "complete") return {
|
|
@@ -13520,7 +13616,7 @@ var init_src_D_zzAWoS = __esm({
|
|
|
13520
13616
|
evaluatedAt: "pre-dispatch",
|
|
13521
13617
|
codes: [HEADER_MISMATCH_ERROR_CODE],
|
|
13522
13618
|
conformance: ["http-header-validation"],
|
|
13523
|
-
rationale: "SEP-2243 standard `Mcp-Method` / `Mcp-Name` headers \u2014 presence, sentinel decoding, and `Mcp-Name` \u2194 body cross-check \u2014 are validated by the HTTP entry on a modern-classified request after the supported-revision gate and before dispatch. The classifier\u2019s own header-mismatch cells (protocol-version, `Mcp-Method` mismatch) stay on the edge `era-classification` rung; this rung carries the entry-layer presence/`Mcp-Name` half. Evaluated before the capability gate, the factory call, and the `Mcp-Param-*` rung so a request that fails several rungs is answered by the standard-header rung first. The documented order (after method-registry 5 and request-params 6) is NOT the observed precedence: serveModern evaluates this rung immediately after the supported-revision gate, so a request that also fails a dispatch rung is answered here before the dispatch rungs (5\u20136) are consulted."
|
|
13619
|
+
rationale: "SEP-2243 standard `MCP-Protocol-Version` / `Mcp-Method` / `Mcp-Name` headers \u2014 presence, sentinel decoding, and `Mcp-Name` \u2194 body cross-check \u2014 are validated by the HTTP entry on a modern-classified request after the supported-revision gate and before dispatch. The spec requires `MCP-Protocol-Version` and `Mcp-Method` on every modern *request* POST (`Mcp-Name` only for the methods that mirror `params.name` / `params.uri` / `params.taskId`, see `MCP_NAME_HEADER_SOURCE`) and names them in that order, so a request missing several is answered by the earliest. Notification POSTs are exempt: the presence half runs on requests only, so a modern-enveloped notification is dispatched even with no standard headers at all. The classifier\u2019s own header-mismatch cells (protocol-version, `Mcp-Method` mismatch) stay on the edge `era-classification` rung; this rung carries the entry-layer presence/`Mcp-Name` half \u2014 including the missing `MCP-Protocol-Version` cell, which cannot live on the edge rung without breaking body-primary classification. Evaluated before the capability gate, the factory call, and the `Mcp-Param-*` rung so a request that fails several rungs is answered by the standard-header rung first. The documented order (after method-registry 5 and request-params 6) is NOT the observed precedence: serveModern evaluates this rung immediately after the supported-revision gate, so a request that also fails a dispatch rung is answered here before the dispatch rungs (5\u20136) are consulted."
|
|
13524
13620
|
},
|
|
13525
13621
|
{
|
|
13526
13622
|
rung: "client-capabilities",
|
|
@@ -13547,6 +13643,14 @@ var init_src_D_zzAWoS = __esm({
|
|
|
13547
13643
|
[ProtocolErrorCode.MissingRequiredClientCapability]: 400,
|
|
13548
13644
|
[HEADER_MISMATCH_ERROR_CODE]: 400
|
|
13549
13645
|
};
|
|
13646
|
+
MCP_NAME_HEADER_SOURCE = {
|
|
13647
|
+
"tools/call": "name",
|
|
13648
|
+
"prompts/get": "name",
|
|
13649
|
+
"resources/read": "uri",
|
|
13650
|
+
"tasks/get": "taskId",
|
|
13651
|
+
"tasks/update": "taskId",
|
|
13652
|
+
"tasks/cancel": "taskId"
|
|
13653
|
+
};
|
|
13550
13654
|
warnedZodFallback = false;
|
|
13551
13655
|
JSON_SCHEMA_CONVERSION_TARGET = "draft-2020-12";
|
|
13552
13656
|
DATETIME_FRACTION_DIGITS = /\\\.\\d\{(\d+)\}/;
|
|
@@ -13802,6 +13906,8 @@ var init_src_D_zzAWoS = __esm({
|
|
|
13802
13906
|
_transport;
|
|
13803
13907
|
_requestMessageId = 0;
|
|
13804
13908
|
_requestHandlers = /* @__PURE__ */ new Map();
|
|
13909
|
+
/** Methods registered with an explicit schema; the era gate in `_onrequest` reads it for the Tasks extension names. */
|
|
13910
|
+
_customSchemaRequestMethods = /* @__PURE__ */ new Set();
|
|
13805
13911
|
_requestHandlerAbortControllers = /* @__PURE__ */ new Map();
|
|
13806
13912
|
_notificationHandlers = /* @__PURE__ */ new Map();
|
|
13807
13913
|
_responseHandlers = /* @__PURE__ */ new Map();
|
|
@@ -13938,7 +14044,7 @@ var init_src_D_zzAWoS = __esm({
|
|
|
13938
14044
|
return this._requestHandlers.get(method);
|
|
13939
14045
|
}
|
|
13940
14046
|
async _oncancel(notification) {
|
|
13941
|
-
if (
|
|
14047
|
+
if (notification.params.requestId === void 0) return;
|
|
13942
14048
|
this._requestHandlerAbortControllers.get(notification.params.requestId)?.abort(notification.params.reason);
|
|
13943
14049
|
}
|
|
13944
14050
|
_setupTimeout(messageId, timeout, maxTotalTimeout, onTimeout, resetTimeoutOnProgress = false) {
|
|
@@ -14085,7 +14191,7 @@ var init_src_D_zzAWoS = __esm({
|
|
|
14085
14191
|
return;
|
|
14086
14192
|
}
|
|
14087
14193
|
}
|
|
14088
|
-
if (isSpecRequestMethod(request.method) && !codec2.hasRequestMethod(request.method)) {
|
|
14194
|
+
if (isSpecRequestMethod(request.method) && !codec2.hasRequestMethod(request.method) && !(isExtensionReusedRequestMethod(request.method) && this._customSchemaRequestMethods.has(request.method))) {
|
|
14089
14195
|
sendErrorResponse(ProtocolErrorCode.MethodNotFound, "Method not found");
|
|
14090
14196
|
return;
|
|
14091
14197
|
}
|
|
@@ -14218,8 +14324,11 @@ var init_src_D_zzAWoS = __esm({
|
|
|
14218
14324
|
}
|
|
14219
14325
|
request(request, schemaOrOptions, maybeOptions) {
|
|
14220
14326
|
const codec2 = this._resolveOutboundCodec(request.method);
|
|
14327
|
+
if (isStandardSchema(schemaOrOptions)) {
|
|
14328
|
+
if (!isExtensionReusedRequestMethod(request.method)) this._assertOutboundRequestInEra(codec2, request.method);
|
|
14329
|
+
return this._requestWithSchemaViaCodec(codec2, request, schemaOrOptions, maybeOptions);
|
|
14330
|
+
}
|
|
14221
14331
|
this._assertOutboundRequestInEra(codec2, request.method);
|
|
14222
|
-
if (isStandardSchema(schemaOrOptions)) return this._requestWithSchemaViaCodec(codec2, request, schemaOrOptions, maybeOptions);
|
|
14223
14332
|
const validate2 = codecResultValidator(codec2, request.method);
|
|
14224
14333
|
if (validate2 === void 0) throw new TypeError(`'${request.method}' is not a spec method; pass a result schema as the second argument to request().`);
|
|
14225
14334
|
return this._requestWithSchemaViaCodec(codec2, request, validate2, schemaOrOptions);
|
|
@@ -14337,19 +14446,20 @@ var init_src_D_zzAWoS = __esm({
|
|
|
14337
14446
|
const cancel = (reason) => {
|
|
14338
14447
|
if (responseReceived) return;
|
|
14339
14448
|
this._progressHandlers.delete(messageId);
|
|
14340
|
-
if (requestAbort === void 0)
|
|
14341
|
-
|
|
14342
|
-
|
|
14343
|
-
|
|
14344
|
-
|
|
14345
|
-
|
|
14346
|
-
|
|
14347
|
-
|
|
14348
|
-
|
|
14349
|
-
|
|
14350
|
-
|
|
14351
|
-
|
|
14352
|
-
|
|
14449
|
+
if (requestAbort === void 0) {
|
|
14450
|
+
if (request.method !== "initialize") this._transport?.send(this._envelopeOutbound({
|
|
14451
|
+
jsonrpc: "2.0",
|
|
14452
|
+
method: "notifications/cancelled",
|
|
14453
|
+
params: {
|
|
14454
|
+
requestId: messageId,
|
|
14455
|
+
reason: String(reason)
|
|
14456
|
+
}
|
|
14457
|
+
}), {
|
|
14458
|
+
relatedRequestId,
|
|
14459
|
+
resumptionToken,
|
|
14460
|
+
onresumptiontoken
|
|
14461
|
+
}).catch((error2) => this._onerror(/* @__PURE__ */ new Error(`Failed to send cancellation: ${error2}`)));
|
|
14462
|
+
} else requestAbort.abort();
|
|
14353
14463
|
reject(reason instanceof SdkError ? reason : new SdkError(SdkErrorCode.RequestTimeout, String(reason)));
|
|
14354
14464
|
};
|
|
14355
14465
|
this._responseHandlers.set(messageId, (response) => {
|
|
@@ -14411,7 +14521,7 @@ var init_src_D_zzAWoS = __esm({
|
|
|
14411
14521
|
* Emits a notification, which is a one-way message that does not expect a response.
|
|
14412
14522
|
*/
|
|
14413
14523
|
async notification(notification, options) {
|
|
14414
|
-
return this._notificationViaCodec(this._resolveOutboundCodec(notification.method), notification, options);
|
|
14524
|
+
return await this._notificationViaCodec(this._resolveOutboundCodec(notification.method), notification, options);
|
|
14415
14525
|
}
|
|
14416
14526
|
/**
|
|
14417
14527
|
* The notification funnel proper, keyed by the resolved era codec —
|
|
@@ -14429,7 +14539,7 @@ var init_src_D_zzAWoS = __esm({
|
|
|
14429
14539
|
jsonrpc: "2.0",
|
|
14430
14540
|
...notification
|
|
14431
14541
|
});
|
|
14432
|
-
if ((this._options?.debouncedNotificationMethods ?? []).includes(notification.method) && !notification.params &&
|
|
14542
|
+
if ((this._options?.debouncedNotificationMethods ?? []).includes(notification.method) && !notification.params && options?.relatedRequestId === void 0) {
|
|
14433
14543
|
if (this._pendingDebouncedNotifications.has(notification.method)) return;
|
|
14434
14544
|
this._pendingDebouncedNotifications.add(notification.method);
|
|
14435
14545
|
Promise.resolve().then(() => {
|
|
@@ -14462,6 +14572,8 @@ var init_src_D_zzAWoS = __esm({
|
|
|
14462
14572
|
return maybeHandler(parsed.data, ctx);
|
|
14463
14573
|
};
|
|
14464
14574
|
else throw new TypeError("setRequestHandler: handler is required");
|
|
14575
|
+
if (typeof schemasOrHandler === "function") this._customSchemaRequestMethods.delete(method);
|
|
14576
|
+
else this._customSchemaRequestMethods.add(method);
|
|
14465
14577
|
this._requestHandlers.set(method, this._wrapHandler(method, stored));
|
|
14466
14578
|
}
|
|
14467
14579
|
/**
|
|
@@ -14491,6 +14603,7 @@ var init_src_D_zzAWoS = __esm({
|
|
|
14491
14603
|
*/
|
|
14492
14604
|
removeRequestHandler(method) {
|
|
14493
14605
|
this._requestHandlers.delete(method);
|
|
14606
|
+
this._customSchemaRequestMethods.delete(method);
|
|
14494
14607
|
}
|
|
14495
14608
|
/**
|
|
14496
14609
|
* Asserts that a request handler has not already been set for the given method, in preparation for a new one being automatically installed.
|
|
@@ -14604,6 +14717,15 @@ var init_src_D_zzAWoS = __esm({
|
|
|
14604
14717
|
this._buffer = void 0;
|
|
14605
14718
|
}
|
|
14606
14719
|
};
|
|
14720
|
+
REDIRECT_STATUSES = /* @__PURE__ */ new Set([
|
|
14721
|
+
301,
|
|
14722
|
+
302,
|
|
14723
|
+
303,
|
|
14724
|
+
307,
|
|
14725
|
+
308
|
|
14726
|
+
]);
|
|
14727
|
+
MAX_REDIRECTS = 5;
|
|
14728
|
+
leftToFetch = /* @__PURE__ */ new WeakSet();
|
|
14607
14729
|
InMemoryTransport = class InMemoryTransport2 {
|
|
14608
14730
|
_otherTransport;
|
|
14609
14731
|
_messageQueue = [];
|
|
@@ -22216,10 +22338,13 @@ var init_stream = __esm({
|
|
|
22216
22338
|
|
|
22217
22339
|
// node_modules/@modelcontextprotocol/client/dist/index.mjs
|
|
22218
22340
|
function discardIfIssuerMismatch(stored, issuer, opts) {
|
|
22219
|
-
if (stored
|
|
22220
|
-
if (stored.issuer
|
|
22341
|
+
if (!stored) return void 0;
|
|
22342
|
+
if (typeof stored.issuer !== "string") {
|
|
22221
22343
|
if (opts?.canPersistStamp !== false) console.warn("[mcp-sdk] SEP-2352: stored OAuth credential has no 'issuer' stamp (pre-upgrade storage or provider not round-tripping the value). SEP-2352 isolation is inactive for this read; ensure your provider round-trips the issuer field.");
|
|
22222
|
-
return stored
|
|
22344
|
+
return stored.issuer === void 0 ? stored : {
|
|
22345
|
+
...stored,
|
|
22346
|
+
issuer: void 0
|
|
22347
|
+
};
|
|
22223
22348
|
}
|
|
22224
22349
|
return issuersMatch(stored.issuer, issuer) ? stored : void 0;
|
|
22225
22350
|
}
|
|
@@ -22346,7 +22471,7 @@ function applyPublicAuth(clientId, params) {
|
|
|
22346
22471
|
params.set("client_id", clientId);
|
|
22347
22472
|
}
|
|
22348
22473
|
function isLoopbackHost(hostname3) {
|
|
22349
|
-
return hostname3 === "localhost" || hostname3 === "127.0.0.1" || hostname3 === "[::1]" || hostname3 === "::1";
|
|
22474
|
+
return hostname3 === "localhost" || hostname3.endsWith(".localhost") || hostname3 === "127.0.0.1" || hostname3 === "[::1]" || hostname3 === "::1";
|
|
22350
22475
|
}
|
|
22351
22476
|
function assertSecureTokenEndpoint(tokenEndpoint) {
|
|
22352
22477
|
const url2 = new URL(String(tokenEndpoint));
|
|
@@ -22385,16 +22510,22 @@ async function parseErrorResponse(input) {
|
|
|
22385
22510
|
return new OAuthError(OAuthErrorCode.ServerError, errorMessage);
|
|
22386
22511
|
}
|
|
22387
22512
|
}
|
|
22513
|
+
function warnCredentialInvalidation(provider, error2, invalidated) {
|
|
22514
|
+
const action = provider.invalidateCredentials === void 0 ? `retrying authorization without discarding the stored ${invalidated} (provider implements no invalidateCredentials())` : `invalidating the stored ${invalidated} and retrying authorization`;
|
|
22515
|
+
console.warn(`[mcp-sdk] OAuth ${JSON.stringify(error2.code)} \u2014 ${action}. Cause: ${JSON.stringify(error2.message)}`);
|
|
22516
|
+
}
|
|
22388
22517
|
async function auth(provider, options) {
|
|
22389
22518
|
try {
|
|
22390
22519
|
return await authInternal(provider, options);
|
|
22391
22520
|
} catch (error2) {
|
|
22392
22521
|
if (error2 instanceof OAuthError) {
|
|
22393
22522
|
if (error2.code === OAuthErrorCode.InvalidClient || error2.code === OAuthErrorCode.UnauthorizedClient) {
|
|
22523
|
+
warnCredentialInvalidation(provider, error2, "client credentials and tokens");
|
|
22394
22524
|
await provider.invalidateCredentials?.("client");
|
|
22395
22525
|
await provider.invalidateCredentials?.("tokens");
|
|
22396
22526
|
return await authInternal(provider, options);
|
|
22397
|
-
} else if (error2.code === OAuthErrorCode.InvalidGrant) {
|
|
22527
|
+
} else if (error2.code === OAuthErrorCode.InvalidGrant || error2.code === OAuthErrorCode.InvalidDpopProof) {
|
|
22528
|
+
warnCredentialInvalidation(provider, error2, "tokens");
|
|
22398
22529
|
await provider.invalidateCredentials?.("tokens");
|
|
22399
22530
|
return await authInternal(provider, options);
|
|
22400
22531
|
}
|
|
@@ -22462,8 +22593,9 @@ async function authInternal(provider, { serverUrl, authorizationCode, iss, scope
|
|
|
22462
22593
|
} else if (!issuersMatch(recordedIssuer, issuer)) throw new AuthorizationServerMismatchError(recordedIssuer, issuer);
|
|
22463
22594
|
}
|
|
22464
22595
|
if (freshDiscoveryState) await provider.saveDiscoveryState?.(freshDiscoveryState);
|
|
22465
|
-
const
|
|
22466
|
-
|
|
22596
|
+
const selectedResource = await selectResourceURL(serverUrl, provider, resourceMetadata);
|
|
22597
|
+
const resource = selectedResource && resourceMetadata && !provider.validateResourceURL ? resourceMetadata.resource : selectedResource;
|
|
22598
|
+
if (resource) await provider.saveResourceUrl?.(resourceIndicatorToString(resource));
|
|
22467
22599
|
const resolvedScope = determineScope({
|
|
22468
22600
|
requestedScope: scope,
|
|
22469
22601
|
resourceMetadata,
|
|
@@ -22534,24 +22666,30 @@ async function authInternal(provider, { serverUrl, authorizationCode, iss, scope
|
|
|
22534
22666
|
};
|
|
22535
22667
|
await provider.saveTokens(tokens, infoCtx);
|
|
22536
22668
|
}
|
|
22537
|
-
if (tokens?.refresh_token && !forceReauthorization)
|
|
22538
|
-
|
|
22539
|
-
|
|
22540
|
-
|
|
22541
|
-
|
|
22542
|
-
|
|
22543
|
-
|
|
22544
|
-
|
|
22545
|
-
|
|
22546
|
-
|
|
22547
|
-
|
|
22548
|
-
|
|
22549
|
-
}
|
|
22550
|
-
|
|
22551
|
-
|
|
22552
|
-
|
|
22553
|
-
|
|
22554
|
-
|
|
22669
|
+
if (tokens?.refresh_token && !forceReauthorization) {
|
|
22670
|
+
let newTokens;
|
|
22671
|
+
try {
|
|
22672
|
+
newTokens = await refreshAuthorization(authorizationServerUrl, {
|
|
22673
|
+
metadata,
|
|
22674
|
+
clientInformation,
|
|
22675
|
+
refreshToken: tokens.refresh_token,
|
|
22676
|
+
resource,
|
|
22677
|
+
addClientAuthentication: provider.addClientAuthentication,
|
|
22678
|
+
dpop: await provider.dpop?.(),
|
|
22679
|
+
fetchFn
|
|
22680
|
+
});
|
|
22681
|
+
} catch (error2) {
|
|
22682
|
+
if (error2 instanceof InsecureTokenEndpointError) throw error2;
|
|
22683
|
+
if (!(error2 instanceof OAuthError) || error2.code === OAuthErrorCode.ServerError) console.warn(`[mcp-sdk] Could not refresh OAuth tokens; falling back to a new authorization request. Cause: ${JSON.stringify(error2 instanceof Error ? error2.message : String(error2))}`);
|
|
22684
|
+
else throw error2;
|
|
22685
|
+
}
|
|
22686
|
+
if (newTokens) {
|
|
22687
|
+
await provider.saveTokens({
|
|
22688
|
+
...newTokens,
|
|
22689
|
+
issuer
|
|
22690
|
+
}, infoCtx);
|
|
22691
|
+
return "AUTHORIZED";
|
|
22692
|
+
}
|
|
22555
22693
|
}
|
|
22556
22694
|
const state = provider.state ? await provider.state() : void 0;
|
|
22557
22695
|
const { authorizationUrl, codeVerifier } = await startAuthorization(authorizationServerUrl, {
|
|
@@ -22592,7 +22730,7 @@ function extractWWWAuthenticateParams(res) {
|
|
|
22592
22730
|
const authenticateHeader = res.headers.get("WWW-Authenticate");
|
|
22593
22731
|
if (!authenticateHeader) return {};
|
|
22594
22732
|
const [type, scheme] = authenticateHeader.split(" ");
|
|
22595
|
-
if (type
|
|
22733
|
+
if (!type || !RECOGNIZED_CHALLENGE_SCHEMES.has(type.toLowerCase()) || !scheme) return {};
|
|
22596
22734
|
const resourceMetadataMatch = extractFieldFromWwwAuth(res, "resource_metadata") || void 0;
|
|
22597
22735
|
let resourceMetadataUrl;
|
|
22598
22736
|
if (resourceMetadataMatch) try {
|
|
@@ -22638,12 +22776,13 @@ async function discoverOAuthProtectedResourceMetadata(serverUrl, opts, fetchFn =
|
|
|
22638
22776
|
return OAuthProtectedResourceMetadataSchema.parse(await response.json());
|
|
22639
22777
|
}
|
|
22640
22778
|
async function fetchWithCorsRetry(url2, headers, fetchFn = fetch) {
|
|
22779
|
+
const withinOrigin = fetchWithinOrigin(fetchFn);
|
|
22641
22780
|
try {
|
|
22642
|
-
return await
|
|
22781
|
+
return await withinOrigin(url2, { headers });
|
|
22643
22782
|
} catch (error2) {
|
|
22644
22783
|
if (!(error2 instanceof TypeError) || !CORS_IS_POSSIBLE) throw error2;
|
|
22645
22784
|
if (headers) try {
|
|
22646
|
-
return await
|
|
22785
|
+
return await withinOrigin(url2, {});
|
|
22647
22786
|
} catch (retryError) {
|
|
22648
22787
|
if (!(retryError instanceof TypeError)) throw retryError;
|
|
22649
22788
|
return;
|
|
@@ -22661,7 +22800,7 @@ async function tryMetadataDiscovery(url2, protocolVersion, fetchFn = fetch) {
|
|
|
22661
22800
|
function shouldAttemptFallback(response, pathname) {
|
|
22662
22801
|
if (!response) return true;
|
|
22663
22802
|
if (pathname === "/") return false;
|
|
22664
|
-
return response.
|
|
22803
|
+
return !response.ok && response.status < 500 || response.status === 502;
|
|
22665
22804
|
}
|
|
22666
22805
|
async function discoverMetadataWithFallback(serverUrl, wellKnownType, fetchFn, opts) {
|
|
22667
22806
|
const issuer = new URL(serverUrl);
|
|
@@ -22718,7 +22857,7 @@ async function discoverAuthorizationServerMetadata(authorizationServerUrl, { fet
|
|
|
22718
22857
|
if (!response.ok) {
|
|
22719
22858
|
await response.text?.().catch(() => {
|
|
22720
22859
|
});
|
|
22721
|
-
if (response.status
|
|
22860
|
+
if (response.status < 500 || response.status === 502) continue;
|
|
22722
22861
|
throw new Error(`HTTP ${response.status} trying to load ${type === "oauth" ? "OAuth" : "OpenID provider"} metadata from ${endpointUrl}`);
|
|
22723
22862
|
}
|
|
22724
22863
|
const parsed = type === "oauth" ? OAuthMetadataSchema.parse(await response.json()) : OpenIdProviderDiscoveryMetadataSchema.parse(await response.json());
|
|
@@ -22749,6 +22888,9 @@ async function discoverOAuthServerInfo(serverUrl, opts) {
|
|
|
22749
22888
|
resourceMetadata
|
|
22750
22889
|
};
|
|
22751
22890
|
}
|
|
22891
|
+
function resourceIndicatorToString(resource) {
|
|
22892
|
+
return typeof resource === "string" ? resource : resource.href;
|
|
22893
|
+
}
|
|
22752
22894
|
async function startAuthorization(authorizationServerUrl, { metadata, clientInformation, redirectUrl, scope, state, resource }) {
|
|
22753
22895
|
let authorizationUrl;
|
|
22754
22896
|
if (metadata) {
|
|
@@ -22767,7 +22909,7 @@ async function startAuthorization(authorizationServerUrl, { metadata, clientInfo
|
|
|
22767
22909
|
if (state) authorizationUrl.searchParams.set("state", state);
|
|
22768
22910
|
if (scope) authorizationUrl.searchParams.set("scope", scope);
|
|
22769
22911
|
if (scope?.split(" ").includes("offline_access")) authorizationUrl.searchParams.append("prompt", "consent");
|
|
22770
|
-
if (resource) authorizationUrl.searchParams.set("resource", resource
|
|
22912
|
+
if (resource) authorizationUrl.searchParams.set("resource", resourceIndicatorToString(resource));
|
|
22771
22913
|
return {
|
|
22772
22914
|
authorizationUrl,
|
|
22773
22915
|
codeVerifier
|
|
@@ -22781,30 +22923,46 @@ function prepareAuthorizationCodeRequest(authorizationCode, codeVerifier, redire
|
|
|
22781
22923
|
redirect_uri: String(redirectUri)
|
|
22782
22924
|
});
|
|
22783
22925
|
}
|
|
22784
|
-
async function executeTokenRequest(authorizationServerUrl, { metadata, tokenRequestParams, clientInformation, addClientAuthentication, resource, fetchFn }) {
|
|
22926
|
+
async function executeTokenRequest(authorizationServerUrl, { metadata, tokenRequestParams, clientInformation, addClientAuthentication, resource, dpop, fetchFn }) {
|
|
22785
22927
|
const tokenUrl = assertSecureTokenEndpoint(metadata?.token_endpoint ?? new URL("/token", authorizationServerUrl));
|
|
22786
22928
|
const headers = new Headers({
|
|
22787
22929
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
22788
22930
|
Accept: "application/json"
|
|
22789
22931
|
});
|
|
22790
|
-
if (resource) tokenRequestParams.set("resource", resource
|
|
22791
|
-
if (addClientAuthentication)
|
|
22792
|
-
|
|
22793
|
-
|
|
22794
|
-
|
|
22795
|
-
|
|
22796
|
-
|
|
22797
|
-
|
|
22932
|
+
if (resource) tokenRequestParams.set("resource", resourceIndicatorToString(resource));
|
|
22933
|
+
if (!addClientAuthentication && clientInformation) applyClientAuthentication(selectClientAuthMethod(clientInformation, metadata?.token_endpoint_auth_methods_supported ?? []), clientInformation, headers, tokenRequestParams);
|
|
22934
|
+
const requestOnce = async () => {
|
|
22935
|
+
const requestHeaders = new Headers(headers);
|
|
22936
|
+
if (addClientAuthentication) await addClientAuthentication(requestHeaders, tokenRequestParams, tokenUrl, metadata);
|
|
22937
|
+
if (dpop) requestHeaders.set("DPoP", await dpop.buildProof({
|
|
22938
|
+
htm: "POST",
|
|
22939
|
+
htu: tokenUrl
|
|
22940
|
+
}));
|
|
22941
|
+
return fetchWithinOrigin(fetchFn ?? fetch)(tokenUrl, {
|
|
22942
|
+
method: "POST",
|
|
22943
|
+
headers: requestHeaders,
|
|
22944
|
+
body: tokenRequestParams
|
|
22945
|
+
});
|
|
22946
|
+
};
|
|
22947
|
+
let response = await requestOnce();
|
|
22948
|
+
if (dpop && response.status === 400) {
|
|
22949
|
+
if ((await response.clone().json().catch(() => {
|
|
22950
|
+
}))?.error === OAuthErrorCode.UseDpopNonce) {
|
|
22951
|
+
dpop.observeNonce(response, tokenUrl);
|
|
22952
|
+
response = await requestOnce();
|
|
22953
|
+
}
|
|
22954
|
+
}
|
|
22955
|
+
dpop?.observeNonce(response, tokenUrl);
|
|
22798
22956
|
if (!response.ok) throw await parseErrorResponse(response);
|
|
22799
22957
|
const json2 = await response.json();
|
|
22800
22958
|
try {
|
|
22801
|
-
return OAuthTokensSchema.parse(json2);
|
|
22959
|
+
return OAuthTokensSchema.parse(withoutIssuer(json2));
|
|
22802
22960
|
} catch (parseError) {
|
|
22803
22961
|
if (typeof json2 === "object" && json2 !== null && "error" in json2) throw await parseErrorResponse(JSON.stringify(json2));
|
|
22804
22962
|
throw parseError;
|
|
22805
22963
|
}
|
|
22806
22964
|
}
|
|
22807
|
-
async function refreshAuthorization(authorizationServerUrl, { metadata, clientInformation, refreshToken, resource, addClientAuthentication, fetchFn }) {
|
|
22965
|
+
async function refreshAuthorization(authorizationServerUrl, { metadata, clientInformation, refreshToken, resource, addClientAuthentication, dpop, fetchFn }) {
|
|
22808
22966
|
return {
|
|
22809
22967
|
refresh_token: refreshToken,
|
|
22810
22968
|
...await executeTokenRequest(authorizationServerUrl, {
|
|
@@ -22816,6 +22974,7 @@ async function refreshAuthorization(authorizationServerUrl, { metadata, clientIn
|
|
|
22816
22974
|
clientInformation,
|
|
22817
22975
|
addClientAuthentication,
|
|
22818
22976
|
resource,
|
|
22977
|
+
dpop,
|
|
22819
22978
|
fetchFn
|
|
22820
22979
|
})
|
|
22821
22980
|
};
|
|
@@ -22826,6 +22985,14 @@ async function fetchToken(provider, authorizationServerUrl, { metadata, resource
|
|
|
22826
22985
|
expectedIssuer: metadata?.issuer,
|
|
22827
22986
|
issParameterSupported: isIssParameterSupported(metadata)
|
|
22828
22987
|
});
|
|
22988
|
+
const issuer = metadata?.issuer ?? String(authorizationServerUrl);
|
|
22989
|
+
const readClientInformation = async () => {
|
|
22990
|
+
const rawClientInfo = await provider.clientInformation({ issuer });
|
|
22991
|
+
const checked = discardIfIssuerMismatch(rawClientInfo, issuer, { canPersistStamp: false });
|
|
22992
|
+
if (rawClientInfo && checked === void 0) throw new AuthorizationServerMismatchError(String(rawClientInfo.issuer), issuer);
|
|
22993
|
+
return checked;
|
|
22994
|
+
};
|
|
22995
|
+
let clientInformation = await readClientInformation();
|
|
22829
22996
|
const effectiveScope = scope ?? provider.clientMetadata.scope;
|
|
22830
22997
|
let tokenRequestParams;
|
|
22831
22998
|
if (provider.prepareTokenRequest) tokenRequestParams = await provider.prepareTokenRequest(effectiveScope);
|
|
@@ -22834,13 +23001,14 @@ async function fetchToken(provider, authorizationServerUrl, { metadata, resource
|
|
|
22834
23001
|
if (!provider.redirectUrl) throw new Error("redirectUrl is required for authorization_code flow");
|
|
22835
23002
|
tokenRequestParams = prepareAuthorizationCodeRequest(authorizationCode, await provider.codeVerifier(), provider.redirectUrl);
|
|
22836
23003
|
}
|
|
22837
|
-
|
|
23004
|
+
clientInformation ??= await readClientInformation();
|
|
22838
23005
|
return executeTokenRequest(authorizationServerUrl, {
|
|
22839
23006
|
metadata,
|
|
22840
23007
|
tokenRequestParams,
|
|
22841
|
-
clientInformation
|
|
23008
|
+
clientInformation,
|
|
22842
23009
|
addClientAuthentication: provider.addClientAuthentication,
|
|
22843
23010
|
resource,
|
|
23011
|
+
dpop: await provider.dpop?.(),
|
|
22844
23012
|
fetchFn
|
|
22845
23013
|
});
|
|
22846
23014
|
}
|
|
@@ -22854,7 +23022,7 @@ async function registerClient(authorizationServerUrl, { metadata, clientMetadata
|
|
|
22854
23022
|
...clientMetadata,
|
|
22855
23023
|
...scope === void 0 ? {} : { scope }
|
|
22856
23024
|
};
|
|
22857
|
-
const response = await (fetchFn ?? fetch)(registrationUrl, {
|
|
23025
|
+
const response = await fetchWithinOrigin(fetchFn ?? fetch)(registrationUrl, {
|
|
22858
23026
|
method: "POST",
|
|
22859
23027
|
headers: { "Content-Type": "application/json" },
|
|
22860
23028
|
body: JSON.stringify(submittedMetadata)
|
|
@@ -22864,7 +23032,7 @@ async function registerClient(authorizationServerUrl, { metadata, clientMetadata
|
|
|
22864
23032
|
body: await response.text(),
|
|
22865
23033
|
submittedMetadata
|
|
22866
23034
|
});
|
|
22867
|
-
return OAuthClientInformationFullSchema.parse(await response.json());
|
|
23035
|
+
return OAuthClientInformationFullSchema.parse(withoutIssuer(await response.json()));
|
|
22868
23036
|
}
|
|
22869
23037
|
function keyOf(key) {
|
|
22870
23038
|
return `${key.method}\0${JSON.stringify([key.partition ?? "", key.params ?? ""])}`;
|
|
@@ -22905,6 +23073,11 @@ function classifyProbeOutcome(outcome, context) {
|
|
|
22905
23073
|
return classifyHttpError(outcome, context);
|
|
22906
23074
|
case "network-error":
|
|
22907
23075
|
return classifyNetworkError(outcome.error, context);
|
|
23076
|
+
case "unusable-reply":
|
|
23077
|
+
return {
|
|
23078
|
+
kind: "error",
|
|
23079
|
+
error: new SdkError(SdkErrorCode.EraNegotiationFailed, `Version negotiation probe failed: the server answered with an unusable reply (${describeError(outcome.error)})`, { cause: outcome.error }, { cause: outcome.error })
|
|
23080
|
+
};
|
|
22908
23081
|
case "auth-required":
|
|
22909
23082
|
return {
|
|
22910
23083
|
kind: "error",
|
|
@@ -22996,7 +23169,7 @@ function classifyNetworkError(error2, context) {
|
|
|
22996
23169
|
if (context.environment === "browser" && isOpaqueFetchTypeError(error2)) return { kind: "legacy" };
|
|
22997
23170
|
return {
|
|
22998
23171
|
kind: "error",
|
|
22999
|
-
error: new SdkError(SdkErrorCode.EraNegotiationFailed, `Version negotiation probe failed: ${describeError(error2)}`, { cause: error2 })
|
|
23172
|
+
error: new SdkError(SdkErrorCode.EraNegotiationFailed, `Version negotiation probe failed: ${describeError(error2)}`, { cause: error2 }, { cause: error2 })
|
|
23000
23173
|
};
|
|
23001
23174
|
}
|
|
23002
23175
|
function isOpaqueFetchTypeError(error2) {
|
|
@@ -23079,6 +23252,10 @@ function buildProbeRequest(id, protocolVersion, clientInfo, capabilities) {
|
|
|
23079
23252
|
}) }
|
|
23080
23253
|
};
|
|
23081
23254
|
}
|
|
23255
|
+
function isUnusableReplyError(error2) {
|
|
23256
|
+
if (error2 instanceof SdkError && error2.code === SdkErrorCode.ClientHttpUnexpectedContent) return true;
|
|
23257
|
+
return error2 instanceof Error && error2.name === "SyntaxError";
|
|
23258
|
+
}
|
|
23082
23259
|
function normalizeReply(reply, timeoutMs) {
|
|
23083
23260
|
switch (reply.kind) {
|
|
23084
23261
|
case "response":
|
|
@@ -23104,6 +23281,10 @@ function normalizeReply(reply, timeoutMs) {
|
|
|
23104
23281
|
statusText: error2.data.statusText
|
|
23105
23282
|
};
|
|
23106
23283
|
}
|
|
23284
|
+
if (isUnusableReplyError(error2)) return {
|
|
23285
|
+
kind: "unusable-reply",
|
|
23286
|
+
error: error2
|
|
23287
|
+
};
|
|
23107
23288
|
return {
|
|
23108
23289
|
kind: "network-error",
|
|
23109
23290
|
error: error2
|
|
@@ -23268,6 +23449,14 @@ function validatePrior(prior) {
|
|
|
23268
23449
|
}
|
|
23269
23450
|
throw new SdkError(SdkErrorCode.EraNegotiationFailed, "connect({ prior }): unrecognized prior \u2014 expected { kind: 'modern', discover } or { kind: 'legacy' }");
|
|
23270
23451
|
}
|
|
23452
|
+
function hasDpopChallenge(wwwAuthenticate) {
|
|
23453
|
+
return /(?:^|,)\s*dpop(?:\s|$|,)/i.test(wwwAuthenticate);
|
|
23454
|
+
}
|
|
23455
|
+
function isDpopNonceChallenge(response) {
|
|
23456
|
+
if (response.status !== 401) return false;
|
|
23457
|
+
const wwwAuthenticate = response.headers.get("www-authenticate") ?? "";
|
|
23458
|
+
return hasDpopChallenge(wwwAuthenticate) && /use_dpop_nonce/i.test(wwwAuthenticate);
|
|
23459
|
+
}
|
|
23271
23460
|
function anySignal(a2, b) {
|
|
23272
23461
|
if (typeof AbortSignal.any === "function") return AbortSignal.any([a2, b]);
|
|
23273
23462
|
const controller = new AbortController();
|
|
@@ -23289,11 +23478,11 @@ function anySignal(a2, b) {
|
|
|
23289
23478
|
b.addEventListener("abort", onB, { once: true });
|
|
23290
23479
|
return controller.signal;
|
|
23291
23480
|
}
|
|
23292
|
-
var OAuthClientFlowError, IssuerMismatchError, RegistrationRejectedError, InsecureTokenEndpointError, AuthorizationServerMismatchError, InsufficientScopeError, UnauthorizedError, AUTHORIZATION_CODE_RESPONSE_TYPE, AUTHORIZATION_CODE_CHALLENGE_METHOD, CAP_EXEMPT_METHODS, InMemoryResponseCacheStore, MAX_CACHE_TTL_MS, ClientResponseCache, AUTH_SEAM, UNSUPPORTED_PROTOCOL_VERSION, NOT_PROBE_RECOGNIZED, DEFAULT_VERSION_NEGOTIATION_MODE, ProbeWindow, pendingSpentCloseGuards, LIST_CHANGED_EVICTIONS, DEFAULT_LIST_MAX_PAGES, Client, SseError, SSEClientTransport, DEFAULT_MAX_STEP_UP_RETRIES, DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS, RESERVED_REQUEST_HEADER_NAMES, StreamableHTTPClientTransport;
|
|
23481
|
+
var OAuthClientFlowError, IssuerMismatchError, RegistrationRejectedError, InsecureTokenEndpointError, AuthorizationServerMismatchError, InsufficientScopeError, UnauthorizedError, AUTHORIZATION_CODE_RESPONSE_TYPE, AUTHORIZATION_CODE_CHALLENGE_METHOD, RECOGNIZED_CHALLENGE_SCHEMES, CAP_EXEMPT_METHODS, InMemoryResponseCacheStore, MAX_CACHE_TTL_MS, ClientResponseCache, AUTH_SEAM, UNSUPPORTED_PROTOCOL_VERSION, NOT_PROBE_RECOGNIZED, DEFAULT_VERSION_NEGOTIATION_MODE, ProbeWindow, pendingSpentCloseGuards, LIST_CHANGED_EVICTIONS, DEFAULT_LIST_MAX_PAGES, Client, withDpop, withDpopFromProvider, SseError, SSEClientTransport, DEFAULT_MAX_STEP_UP_RETRIES, DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS, RESERVED_REQUEST_HEADER_NAMES, StreamableHTTPClientTransport;
|
|
23293
23482
|
var init_dist4 = __esm({
|
|
23294
23483
|
"node_modules/@modelcontextprotocol/client/dist/index.mjs"() {
|
|
23295
23484
|
"use strict";
|
|
23296
|
-
|
|
23485
|
+
init_src_WCy6ifGf();
|
|
23297
23486
|
init_shimsNode();
|
|
23298
23487
|
init_index_node();
|
|
23299
23488
|
init_dist3();
|
|
@@ -23365,7 +23554,7 @@ var init_dist4 = __esm({
|
|
|
23365
23554
|
/** The token endpoint URL that was rejected. */
|
|
23366
23555
|
tokenEndpoint;
|
|
23367
23556
|
constructor(tokenEndpoint) {
|
|
23368
|
-
super(`Refusing to send credentials to non-https token endpoint '${tokenEndpoint}'. OAuth token requests MUST use TLS (localhost / 127.0.0.1 / ::1 are exempt).`);
|
|
23557
|
+
super(`Refusing to send credentials to non-https token endpoint '${tokenEndpoint}'. OAuth token requests MUST use TLS (localhost / *.localhost / 127.0.0.1 / ::1 are exempt).`);
|
|
23369
23558
|
this.tokenEndpoint = tokenEndpoint;
|
|
23370
23559
|
}
|
|
23371
23560
|
};
|
|
@@ -23374,7 +23563,7 @@ var init_dist4 = __esm({
|
|
|
23374
23563
|
Object.defineProperty(this, "mcpBrand", { value: "mcp.AuthorizationServerMismatchError" });
|
|
23375
23564
|
}
|
|
23376
23565
|
constructor(recordedIssuer, currentIssuer) {
|
|
23377
|
-
super(`Authorization server
|
|
23566
|
+
super(`Authorization server mismatch: credentials are bound to ${JSON.stringify(recordedIssuer)} but this call resolved ${JSON.stringify(currentIssuer)}; refusing to present them to a different authorization server`);
|
|
23378
23567
|
this.recordedIssuer = recordedIssuer;
|
|
23379
23568
|
this.currentIssuer = currentIssuer;
|
|
23380
23569
|
}
|
|
@@ -23424,6 +23613,7 @@ var init_dist4 = __esm({
|
|
|
23424
23613
|
};
|
|
23425
23614
|
AUTHORIZATION_CODE_RESPONSE_TYPE = "code";
|
|
23426
23615
|
AUTHORIZATION_CODE_CHALLENGE_METHOD = "S256";
|
|
23616
|
+
RECOGNIZED_CHALLENGE_SCHEMES = /* @__PURE__ */ new Set(["bearer", "dpop"]);
|
|
23427
23617
|
CAP_EXEMPT_METHODS = /* @__PURE__ */ new Set([
|
|
23428
23618
|
"tools/list",
|
|
23429
23619
|
"prompts/list",
|
|
@@ -24640,7 +24830,7 @@ var init_dist4 = __esm({
|
|
|
24640
24830
|
}, options);
|
|
24641
24831
|
const hit = await this._serveFromCache("prompts/list", void 0, options);
|
|
24642
24832
|
if (hit !== void 0) return hit;
|
|
24643
|
-
return this._listAllPages("prompts/list", params, options, (
|
|
24833
|
+
return this._listAllPages("prompts/list", params, options, (r2) => r2.prompts);
|
|
24644
24834
|
}
|
|
24645
24835
|
/**
|
|
24646
24836
|
* Lists available resources.
|
|
@@ -24679,7 +24869,7 @@ var init_dist4 = __esm({
|
|
|
24679
24869
|
}, options);
|
|
24680
24870
|
const hit = await this._serveFromCache("resources/list", void 0, options);
|
|
24681
24871
|
if (hit !== void 0) return hit;
|
|
24682
|
-
return this._listAllPages("resources/list", params, options, (
|
|
24872
|
+
return this._listAllPages("resources/list", params, options, (r2) => r2.resources);
|
|
24683
24873
|
}
|
|
24684
24874
|
/**
|
|
24685
24875
|
* Lists available resource URI templates for dynamic resources.
|
|
@@ -24704,7 +24894,7 @@ var init_dist4 = __esm({
|
|
|
24704
24894
|
}, options);
|
|
24705
24895
|
const hit = await this._serveFromCache("resources/templates/list", void 0, options);
|
|
24706
24896
|
if (hit !== void 0) return hit;
|
|
24707
|
-
return this._listAllPages("resources/templates/list", params, options, (
|
|
24897
|
+
return this._listAllPages("resources/templates/list", params, options, (r2) => r2.resourceTemplates);
|
|
24708
24898
|
}
|
|
24709
24899
|
/**
|
|
24710
24900
|
* Walk every page of a paginated list verb, aggregate, and write ONE
|
|
@@ -24712,8 +24902,7 @@ var init_dist4 = __esm({
|
|
|
24712
24902
|
* methods' no-`cursor` auto-aggregate path. Page 1's result object is
|
|
24713
24903
|
* mutated in place (its items array is extended; `nextCursor` is
|
|
24714
24904
|
* cleared); page-1 metadata (`ttlMs`, `cacheScope`, `_meta`) is preserved.
|
|
24715
|
-
* A `nextCursor`
|
|
24716
|
-
* non-converging server, mcp.d's `drainList` guard);
|
|
24905
|
+
* A page with the same items and `nextCursor` as the previous page ends the walk;
|
|
24717
24906
|
* {@linkcode ClientOptions.listMaxPages} is a hard cap — hitting it
|
|
24718
24907
|
* throws, so a partial aggregate is never cached. The
|
|
24719
24908
|
* captured-generation guard skips the write when a `list_changed` landed
|
|
@@ -24728,7 +24917,7 @@ var init_dist4 = __esm({
|
|
|
24728
24917
|
* trace context) supplied to the public `list*()` reaches every wire
|
|
24729
24918
|
* request the walk issues.
|
|
24730
24919
|
*/
|
|
24731
|
-
async _listAllPages(method, baseParams, options,
|
|
24920
|
+
async _listAllPages(method, baseParams, options, items, finalize2) {
|
|
24732
24921
|
const bypass = options?.cacheMode === "bypass";
|
|
24733
24922
|
const generation = this._cache.captureGeneration(method);
|
|
24734
24923
|
const acc = await this.request({
|
|
@@ -24736,14 +24925,13 @@ var init_dist4 = __esm({
|
|
|
24736
24925
|
...baseParams && { params: { ...baseParams } }
|
|
24737
24926
|
}, options);
|
|
24738
24927
|
let cursor3 = acc.nextCursor;
|
|
24739
|
-
|
|
24928
|
+
let previous = acc;
|
|
24740
24929
|
let pages = 1;
|
|
24741
|
-
while (cursor3 !== void 0
|
|
24930
|
+
while (cursor3 !== void 0) {
|
|
24742
24931
|
if (this._listMaxPages !== 0 && pages >= this._listMaxPages) throw new SdkError(SdkErrorCode.ListPaginationExceeded, `${method}: exceeded listMaxPages (${this._listMaxPages}); server pagination did not terminate`, {
|
|
24743
24932
|
method,
|
|
24744
24933
|
listMaxPages: this._listMaxPages
|
|
24745
24934
|
});
|
|
24746
|
-
seen.add(cursor3);
|
|
24747
24935
|
const page = await this.request({
|
|
24748
24936
|
method,
|
|
24749
24937
|
params: {
|
|
@@ -24751,7 +24939,9 @@ var init_dist4 = __esm({
|
|
|
24751
24939
|
cursor: cursor3
|
|
24752
24940
|
}
|
|
24753
24941
|
}, options);
|
|
24754
|
-
|
|
24942
|
+
if (page.nextCursor === cursor3 && JSON.stringify(items(page)) === JSON.stringify(items(previous))) break;
|
|
24943
|
+
items(acc).push(...items(page));
|
|
24944
|
+
previous = page;
|
|
24755
24945
|
cursor3 = page.nextCursor;
|
|
24756
24946
|
pages++;
|
|
24757
24947
|
}
|
|
@@ -25015,19 +25205,22 @@ var init_dist4 = __esm({
|
|
|
25015
25205
|
notifications: filter
|
|
25016
25206
|
}
|
|
25017
25207
|
};
|
|
25208
|
+
const routeSendFailure = (error2) => {
|
|
25209
|
+
settle({
|
|
25210
|
+
cause: "remote",
|
|
25211
|
+
error: error2 instanceof Error ? error2 : new Error(String(error2))
|
|
25212
|
+
});
|
|
25213
|
+
};
|
|
25018
25214
|
try {
|
|
25019
|
-
|
|
25215
|
+
this.transport.send(jsonrpcRequest, {
|
|
25020
25216
|
requestSignal: requestAbort.signal,
|
|
25021
25217
|
onRequestStreamEnd: () => settle({
|
|
25022
25218
|
cause: "remote",
|
|
25023
25219
|
error: /* @__PURE__ */ new Error("subscriptions/listen: stream ended")
|
|
25024
25220
|
})
|
|
25025
|
-
});
|
|
25221
|
+
}).catch(routeSendFailure);
|
|
25026
25222
|
} catch (error2) {
|
|
25027
|
-
|
|
25028
|
-
cause: "remote",
|
|
25029
|
-
error: error2 instanceof Error ? error2 : new Error(String(error2))
|
|
25030
|
-
});
|
|
25223
|
+
routeSendFailure(error2);
|
|
25031
25224
|
}
|
|
25032
25225
|
return {
|
|
25033
25226
|
honoredFilter: await opening,
|
|
@@ -25279,7 +25472,7 @@ var init_dist4 = __esm({
|
|
|
25279
25472
|
}
|
|
25280
25473
|
const hit = await this._serveFromCache("tools/list", void 0, options);
|
|
25281
25474
|
if (hit !== void 0) return hit;
|
|
25282
|
-
return this._listAllPages("tools/list", params, options, (
|
|
25475
|
+
return this._listAllPages("tools/list", params, options, (r2) => r2.tools, (acc) => this._excludeInvalidXMcpHeaderTools(acc));
|
|
25283
25476
|
}
|
|
25284
25477
|
/**
|
|
25285
25478
|
* SEP-2243 (protocol revision 2026-07-28): a Streamable HTTP client MUST
|
|
@@ -25350,6 +25543,55 @@ var init_dist4 = __esm({
|
|
|
25350
25543
|
return this.notification({ method: "notifications/roots/list_changed" });
|
|
25351
25544
|
}
|
|
25352
25545
|
};
|
|
25546
|
+
withDpop = (session, getToken) => (next) => {
|
|
25547
|
+
const resolveSession = typeof session === "function" ? session : () => session;
|
|
25548
|
+
return async (input, init) => {
|
|
25549
|
+
const method = (init?.method ?? "GET").toUpperCase();
|
|
25550
|
+
const url2 = new URL(input.toString());
|
|
25551
|
+
const activeSession = await resolveSession();
|
|
25552
|
+
if (!activeSession) return next(input, init);
|
|
25553
|
+
const makeRequest = async () => {
|
|
25554
|
+
const accessToken = await getToken();
|
|
25555
|
+
if (!accessToken) return next(input, init);
|
|
25556
|
+
const headers = new Headers(init?.headers);
|
|
25557
|
+
const proof = await activeSession.buildProof({
|
|
25558
|
+
htm: method,
|
|
25559
|
+
htu: url2,
|
|
25560
|
+
accessToken
|
|
25561
|
+
});
|
|
25562
|
+
headers.set("Authorization", `DPoP ${accessToken}`);
|
|
25563
|
+
headers.set("DPoP", proof);
|
|
25564
|
+
return next(input, {
|
|
25565
|
+
...init,
|
|
25566
|
+
headers
|
|
25567
|
+
});
|
|
25568
|
+
};
|
|
25569
|
+
let response = await makeRequest();
|
|
25570
|
+
if (isDpopNonceChallenge(response) && response.headers.has("dpop-nonce")) {
|
|
25571
|
+
activeSession.observeNonce(response, url2);
|
|
25572
|
+
await response.text?.().catch(() => {
|
|
25573
|
+
});
|
|
25574
|
+
response = await makeRequest();
|
|
25575
|
+
}
|
|
25576
|
+
activeSession.observeNonce(response, url2);
|
|
25577
|
+
return response;
|
|
25578
|
+
};
|
|
25579
|
+
};
|
|
25580
|
+
withDpopFromProvider = (provider) => withDpop(async () => {
|
|
25581
|
+
try {
|
|
25582
|
+
return await provider.dpop?.();
|
|
25583
|
+
} catch (error2) {
|
|
25584
|
+
throw markAuthSeamEscape(error2);
|
|
25585
|
+
}
|
|
25586
|
+
}, async () => {
|
|
25587
|
+
let tokens;
|
|
25588
|
+
try {
|
|
25589
|
+
tokens = await provider.tokens();
|
|
25590
|
+
} catch (error2) {
|
|
25591
|
+
throw markAuthSeamEscape(error2);
|
|
25592
|
+
}
|
|
25593
|
+
return tokens?.token_type?.toLowerCase() === "dpop" ? tokens.access_token : void 0;
|
|
25594
|
+
});
|
|
25353
25595
|
SseError = class extends Error {
|
|
25354
25596
|
static {
|
|
25355
25597
|
Object.defineProperty(this, "mcpBrand", { value: "mcp.SseError" });
|
|
@@ -25391,6 +25633,8 @@ var init_dist4 = __esm({
|
|
|
25391
25633
|
_skipIssuerMetadataValidation;
|
|
25392
25634
|
_fetch;
|
|
25393
25635
|
_fetchWithInit;
|
|
25636
|
+
_redirectPolicy;
|
|
25637
|
+
_dpop;
|
|
25394
25638
|
_protocolVersion;
|
|
25395
25639
|
onclose;
|
|
25396
25640
|
onerror;
|
|
@@ -25402,32 +25646,46 @@ var init_dist4 = __esm({
|
|
|
25402
25646
|
this._eventSourceInit = opts?.eventSourceInit;
|
|
25403
25647
|
this._requestInit = opts?.requestInit;
|
|
25404
25648
|
this._skipIssuerMetadataValidation = opts?.skipIssuerMetadataValidation;
|
|
25649
|
+
this._fetch = opts?.fetch;
|
|
25405
25650
|
if (isOAuthClientProvider(opts?.authProvider)) {
|
|
25406
25651
|
this._oauthProvider = opts.authProvider;
|
|
25407
25652
|
this._authProvider = adaptOAuthProvider(opts.authProvider, { skipIssuerMetadataValidation: opts.skipIssuerMetadataValidation });
|
|
25653
|
+
if (opts.authProvider.dpop) {
|
|
25654
|
+
this._dpop = withDpopFromProvider(opts.authProvider);
|
|
25655
|
+
this._fetch = this._dpop(opts.fetch ?? fetch);
|
|
25656
|
+
}
|
|
25408
25657
|
} else this._authProvider = opts?.authProvider;
|
|
25409
|
-
this.
|
|
25658
|
+
this._redirectPolicy = opts?.redirectPolicy;
|
|
25410
25659
|
this._fetchWithInit = createFetchWithInit(opts?.fetch, opts?.requestInit);
|
|
25660
|
+
if (this._redirectPolicy === "follow") this._fetchWithInit = fetchLeavingRedirects(this._fetchWithInit);
|
|
25411
25661
|
}
|
|
25412
25662
|
_last401Response;
|
|
25663
|
+
_connectAuthRetried = false;
|
|
25664
|
+
/** `baseFetch` with redirects handled as `redirectPolicy` says. */
|
|
25665
|
+
_redirects(baseFetch) {
|
|
25666
|
+
return this._redirectPolicy === "follow" ? baseFetch : fetchWithinOrigin(baseFetch);
|
|
25667
|
+
}
|
|
25668
|
+
/** Error text for a redirect `response` that was not followed, or `undefined` for any other response. */
|
|
25669
|
+
_unfollowedRedirect(url2, response) {
|
|
25670
|
+
const text = this._redirectPolicy === "follow" ? void 0 : unfollowedRedirect(url2, response);
|
|
25671
|
+
return text && `${text} (redirectPolicy: 'same-origin')`;
|
|
25672
|
+
}
|
|
25413
25673
|
async _commonHeaders() {
|
|
25414
|
-
const headers =
|
|
25674
|
+
const headers = new Headers(this._requestInit?.headers || void 0);
|
|
25415
25675
|
let token;
|
|
25416
25676
|
try {
|
|
25417
25677
|
token = await this._authProvider?.token();
|
|
25418
25678
|
} catch (error2) {
|
|
25419
25679
|
throw markAuthSeamEscape(error2);
|
|
25420
25680
|
}
|
|
25421
|
-
if (token) headers
|
|
25422
|
-
if (this._protocolVersion) headers
|
|
25423
|
-
|
|
25424
|
-
return new Headers({
|
|
25425
|
-
...headers,
|
|
25426
|
-
...extraHeaders
|
|
25427
|
-
});
|
|
25681
|
+
if (token) headers.set("Authorization", `Bearer ${token}`);
|
|
25682
|
+
if (this._protocolVersion) headers.set("mcp-protocol-version", this._protocolVersion);
|
|
25683
|
+
return headers;
|
|
25428
25684
|
}
|
|
25429
25685
|
_startOrAuth() {
|
|
25430
|
-
const
|
|
25686
|
+
const eventSourceFetch = this._eventSourceInit?.fetch;
|
|
25687
|
+
const fetchImpl = this._redirects(eventSourceFetch ? this._dpop?.(eventSourceFetch) ?? eventSourceFetch : this._fetch ?? fetch);
|
|
25688
|
+
let redirect;
|
|
25431
25689
|
return new Promise((resolve5, reject) => {
|
|
25432
25690
|
this._eventSource = new EventSource(this._url.href, {
|
|
25433
25691
|
...this._eventSourceInit,
|
|
@@ -25438,6 +25696,7 @@ var init_dist4 = __esm({
|
|
|
25438
25696
|
...init,
|
|
25439
25697
|
headers
|
|
25440
25698
|
});
|
|
25699
|
+
redirect = this._unfollowedRedirect(url2, response);
|
|
25441
25700
|
if (response.status === 401) {
|
|
25442
25701
|
this._last401Response = response;
|
|
25443
25702
|
if (response.headers.has("www-authenticate")) {
|
|
@@ -25452,31 +25711,41 @@ var init_dist4 = __esm({
|
|
|
25452
25711
|
this._abortController = new AbortController();
|
|
25453
25712
|
this._eventSource.onerror = (event) => {
|
|
25454
25713
|
if (event.code === 401 && this._authProvider) {
|
|
25455
|
-
if (this._authProvider.onUnauthorized && this._last401Response) {
|
|
25714
|
+
if (this._authProvider.onUnauthorized && this._last401Response && !this._connectAuthRetried) {
|
|
25456
25715
|
const response = this._last401Response;
|
|
25457
25716
|
this._last401Response = void 0;
|
|
25717
|
+
this._connectAuthRetried = true;
|
|
25458
25718
|
this._eventSource?.close();
|
|
25459
25719
|
this._authProvider.onUnauthorized({
|
|
25460
25720
|
response,
|
|
25461
25721
|
serverUrl: this._url,
|
|
25462
25722
|
fetchFn: this._fetchWithInit
|
|
25463
25723
|
}).then(() => this._startOrAuth().then(resolve5, reject), (error$2) => {
|
|
25724
|
+
this._connectAuthRetried = false;
|
|
25464
25725
|
markAuthSeamEscape(error$2);
|
|
25465
25726
|
this.onerror?.(error$2);
|
|
25466
25727
|
reject(error$2);
|
|
25467
25728
|
});
|
|
25468
25729
|
return;
|
|
25469
25730
|
}
|
|
25470
|
-
const
|
|
25731
|
+
const retried = this._connectAuthRetried;
|
|
25732
|
+
this._connectAuthRetried = false;
|
|
25733
|
+
const error$1 = markAuthSeamEscape(retried ? new SdkHttpError(SdkErrorCode.ClientHttpAuthentication, "Server returned 401 after re-authentication", {
|
|
25734
|
+
status: 401,
|
|
25735
|
+
statusText: this._last401Response?.statusText ?? ""
|
|
25736
|
+
}) : new UnauthorizedError());
|
|
25737
|
+
this._last401Response = void 0;
|
|
25471
25738
|
reject(error$1);
|
|
25472
25739
|
this.onerror?.(error$1);
|
|
25473
25740
|
return;
|
|
25474
25741
|
}
|
|
25475
|
-
|
|
25742
|
+
this._connectAuthRetried = false;
|
|
25743
|
+
const error2 = new SseError(event.code, redirect ?? event.message, event);
|
|
25476
25744
|
reject(error2);
|
|
25477
25745
|
this.onerror?.(error2);
|
|
25478
25746
|
};
|
|
25479
25747
|
this._eventSource.onopen = () => {
|
|
25748
|
+
this._connectAuthRetried = false;
|
|
25480
25749
|
};
|
|
25481
25750
|
this._eventSource.addEventListener("endpoint", (event) => {
|
|
25482
25751
|
const messageEvent = event;
|
|
@@ -25544,7 +25813,7 @@ var init_dist4 = __esm({
|
|
|
25544
25813
|
body: JSON.stringify(message),
|
|
25545
25814
|
signal: this._abortController?.signal
|
|
25546
25815
|
};
|
|
25547
|
-
const response = await (this._fetch ?? fetch)(this._endpoint, init);
|
|
25816
|
+
const response = await this._redirects(this._fetch ?? fetch)(this._endpoint, init);
|
|
25548
25817
|
if (!response.ok) {
|
|
25549
25818
|
if (response.status === 401 && this._authProvider) {
|
|
25550
25819
|
if (response.headers.has("www-authenticate")) {
|
|
@@ -25575,7 +25844,7 @@ var init_dist4 = __esm({
|
|
|
25575
25844
|
throw markAuthSeamEscape(new UnauthorizedError());
|
|
25576
25845
|
}
|
|
25577
25846
|
const text = await response.text?.().catch(() => null);
|
|
25578
|
-
throw new Error(`Error POSTing to endpoint (HTTP ${response.status}): ${text}`);
|
|
25847
|
+
throw new Error(`Error POSTing to endpoint (HTTP ${response.status}): ${this._unfollowedRedirect(this._endpoint, response) ?? text}`);
|
|
25579
25848
|
}
|
|
25580
25849
|
await response.text?.().catch(() => {
|
|
25581
25850
|
});
|
|
@@ -25597,6 +25866,7 @@ var init_dist4 = __esm({
|
|
|
25597
25866
|
};
|
|
25598
25867
|
RESERVED_REQUEST_HEADER_NAMES = /* @__PURE__ */ new Set([
|
|
25599
25868
|
"authorization",
|
|
25869
|
+
"dpop",
|
|
25600
25870
|
"content-type",
|
|
25601
25871
|
"mcp-protocol-version",
|
|
25602
25872
|
"mcp-method",
|
|
@@ -25614,6 +25884,7 @@ var init_dist4 = __esm({
|
|
|
25614
25884
|
_skipIssuerMetadataValidation;
|
|
25615
25885
|
_fetch;
|
|
25616
25886
|
_fetchWithInit;
|
|
25887
|
+
_redirectPolicy;
|
|
25617
25888
|
_sessionId;
|
|
25618
25889
|
_reconnectionOptions;
|
|
25619
25890
|
_protocolVersion;
|
|
@@ -25638,12 +25909,15 @@ var init_dist4 = __esm({
|
|
|
25638
25909
|
this._scope = void 0;
|
|
25639
25910
|
this._requestInit = opts?.requestInit;
|
|
25640
25911
|
this._skipIssuerMetadataValidation = opts?.skipIssuerMetadataValidation;
|
|
25912
|
+
this._fetch = opts?.fetch;
|
|
25641
25913
|
if (isOAuthClientProvider(opts?.authProvider)) {
|
|
25642
25914
|
this._oauthProvider = opts.authProvider;
|
|
25643
25915
|
this._authProvider = adaptOAuthProvider(opts.authProvider, { skipIssuerMetadataValidation: opts.skipIssuerMetadataValidation });
|
|
25916
|
+
if (opts.authProvider.dpop) this._fetch = withDpopFromProvider(opts.authProvider)(opts.fetch ?? fetch);
|
|
25644
25917
|
} else this._authProvider = opts?.authProvider;
|
|
25645
|
-
this.
|
|
25918
|
+
this._redirectPolicy = opts?.redirectPolicy;
|
|
25646
25919
|
this._fetchWithInit = createFetchWithInit(opts?.fetch, opts?.requestInit);
|
|
25920
|
+
if (this._redirectPolicy === "follow") this._fetchWithInit = fetchLeavingRedirects(this._fetchWithInit);
|
|
25647
25921
|
this._sessionId = opts?.sessionId;
|
|
25648
25922
|
this._protocolVersion = opts?.protocolVersion;
|
|
25649
25923
|
this._reconnectionOptions = opts?.reconnectionOptions ?? DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS;
|
|
@@ -25695,22 +25969,27 @@ var init_dist4 = __esm({
|
|
|
25695
25969
|
skipIssuerMetadataValidation: this._skipIssuerMetadataValidation
|
|
25696
25970
|
});
|
|
25697
25971
|
}
|
|
25972
|
+
/** `baseFetch` with redirects handled as `redirectPolicy` says. */
|
|
25973
|
+
_redirects(baseFetch) {
|
|
25974
|
+
return this._redirectPolicy === "follow" ? baseFetch : fetchWithinOrigin(baseFetch);
|
|
25975
|
+
}
|
|
25976
|
+
/** Error text for a redirect `response` that was not followed, or `undefined` for any other response. */
|
|
25977
|
+
_unfollowedRedirect(url2, response) {
|
|
25978
|
+
const text = this._redirectPolicy === "follow" ? void 0 : unfollowedRedirect(url2, response);
|
|
25979
|
+
return text && `${text} (redirectPolicy: 'same-origin')`;
|
|
25980
|
+
}
|
|
25698
25981
|
async _commonHeaders() {
|
|
25699
|
-
const headers =
|
|
25982
|
+
const headers = new Headers(this._requestInit?.headers || void 0);
|
|
25700
25983
|
let token;
|
|
25701
25984
|
try {
|
|
25702
25985
|
token = await this._authProvider?.token();
|
|
25703
25986
|
} catch (error2) {
|
|
25704
25987
|
throw markAuthSeamEscape(error2);
|
|
25705
25988
|
}
|
|
25706
|
-
if (token) headers
|
|
25707
|
-
if (this._sessionId) headers
|
|
25708
|
-
if (this._protocolVersion) headers
|
|
25709
|
-
|
|
25710
|
-
return new Headers({
|
|
25711
|
-
...headers,
|
|
25712
|
-
...extraHeaders
|
|
25713
|
-
});
|
|
25989
|
+
if (token) headers.set("Authorization", `Bearer ${token}`);
|
|
25990
|
+
if (this._sessionId) headers.set("mcp-session-id", this._sessionId);
|
|
25991
|
+
if (this._protocolVersion) headers.set("mcp-protocol-version", this._protocolVersion);
|
|
25992
|
+
return headers;
|
|
25714
25993
|
}
|
|
25715
25994
|
/**
|
|
25716
25995
|
* Body-derived per-request headers: when an outgoing request carries a
|
|
@@ -25726,9 +26005,8 @@ var init_dist4 = __esm({
|
|
|
25726
26005
|
if (typeof envelopeVersion !== "string") return;
|
|
25727
26006
|
headers.set("mcp-protocol-version", envelopeVersion);
|
|
25728
26007
|
headers.set("mcp-method", message.method);
|
|
25729
|
-
const
|
|
25730
|
-
|
|
25731
|
-
if (nameHeader !== void 0) headers.set("mcp-name", encodeMcpParamValue(nameHeader));
|
|
26008
|
+
const source = mcpNameSource(message.method, message.params);
|
|
26009
|
+
if (source?.value !== void 0) headers.set("mcp-name", encodeMcpParamValue(source.value));
|
|
25732
26010
|
}
|
|
25733
26011
|
/**
|
|
25734
26012
|
* `true` when the outbound message is a single request carrying a
|
|
@@ -25751,7 +26029,7 @@ var init_dist4 = __esm({
|
|
|
25751
26029
|
if (resumptionToken) headers.set("last-event-id", resumptionToken);
|
|
25752
26030
|
const transportSignal = this._abortController?.signal;
|
|
25753
26031
|
const signal = requestSignal !== void 0 && transportSignal !== void 0 ? anySignal(transportSignal, requestSignal) : requestSignal ?? transportSignal;
|
|
25754
|
-
const response = await (this._fetch ?? fetch)(this._url, {
|
|
26032
|
+
const response = await this._redirects(this._fetch ?? fetch)(this._url, {
|
|
25755
26033
|
...this._requestInit,
|
|
25756
26034
|
method: "GET",
|
|
25757
26035
|
headers,
|
|
@@ -25806,7 +26084,8 @@ var init_dist4 = __esm({
|
|
|
25806
26084
|
options.onRequestStreamEnd?.();
|
|
25807
26085
|
return;
|
|
25808
26086
|
}
|
|
25809
|
-
|
|
26087
|
+
const reason = this._unfollowedRedirect(this._url, response) ?? response.statusText;
|
|
26088
|
+
throw new SdkHttpError(SdkErrorCode.ClientHttpFailedToOpenStream, `Failed to open SSE stream: ${reason}`, {
|
|
25810
26089
|
status: response.status,
|
|
25811
26090
|
statusText: response.statusText
|
|
25812
26091
|
});
|
|
@@ -25995,7 +26274,7 @@ var init_dist4 = __esm({
|
|
|
25995
26274
|
body: JSON.stringify(message),
|
|
25996
26275
|
signal
|
|
25997
26276
|
};
|
|
25998
|
-
const response = await (this._fetch ?? fetch)(this._url, init);
|
|
26277
|
+
const response = await this._redirects(this._fetch ?? fetch)(this._url, init);
|
|
25999
26278
|
if (isHandshake && response.ok) this._sessionId = response.headers.get("mcp-session-id") || void 0;
|
|
26000
26279
|
if (!response.ok) {
|
|
26001
26280
|
if (response.status === 401 && this._authProvider) {
|
|
@@ -26049,7 +26328,8 @@ var init_dist4 = __esm({
|
|
|
26049
26328
|
}
|
|
26050
26329
|
} catch {
|
|
26051
26330
|
}
|
|
26052
|
-
|
|
26331
|
+
const reason = this._unfollowedRedirect(this._url, response) ?? text;
|
|
26332
|
+
throw new SdkHttpError(SdkErrorCode.ClientHttpNotImplemented, `Error POSTing to endpoint: ${reason}`, {
|
|
26053
26333
|
status: response.status,
|
|
26054
26334
|
statusText: response.statusText,
|
|
26055
26335
|
text
|
|
@@ -26109,10 +26389,10 @@ var init_dist4 = __esm({
|
|
|
26109
26389
|
headers,
|
|
26110
26390
|
signal: this._abortController?.signal
|
|
26111
26391
|
};
|
|
26112
|
-
const response = await (this._fetch ?? fetch)(this._url, init);
|
|
26392
|
+
const response = await this._redirects(this._fetch ?? fetch)(this._url, init);
|
|
26113
26393
|
await response.text?.().catch(() => {
|
|
26114
26394
|
});
|
|
26115
|
-
if (!response.ok && response.status !== 405) throw new SdkHttpError(SdkErrorCode.ClientHttpFailedToTerminateSession, `Failed to terminate session: ${response.statusText}`, {
|
|
26395
|
+
if (!response.ok && response.status !== 405) throw new SdkHttpError(SdkErrorCode.ClientHttpFailedToTerminateSession, `Failed to terminate session: ${this._unfollowedRedirect(this._url, response) ?? response.statusText}`, {
|
|
26116
26396
|
status: response.status,
|
|
26117
26397
|
statusText: response.statusText
|
|
26118
26398
|
});
|
|
@@ -29421,7 +29701,7 @@ var init_package = __esm({
|
|
|
29421
29701
|
"package.json"() {
|
|
29422
29702
|
package_default = {
|
|
29423
29703
|
name: "@prefecthq/fastmcp-ts",
|
|
29424
|
-
version: "1.
|
|
29704
|
+
version: "1.8.1",
|
|
29425
29705
|
description: "\u{1F3CE}\uFE0F The official FastMCP TypeScript library - build MCP servers and clients, fast \u{1F3CE}\uFE0F",
|
|
29426
29706
|
type: "module",
|
|
29427
29707
|
exports: {
|
|
@@ -29549,11 +29829,11 @@ var init_package = __esm({
|
|
|
29549
29829
|
},
|
|
29550
29830
|
dependencies: {
|
|
29551
29831
|
"@clack/prompts": "^1.2.0",
|
|
29552
|
-
"@modelcontextprotocol/client": "^2.
|
|
29832
|
+
"@modelcontextprotocol/client": "^2.3.1",
|
|
29553
29833
|
"@modelcontextprotocol/core": "^2.0.0",
|
|
29554
29834
|
"@modelcontextprotocol/node": "^2.0.0",
|
|
29555
|
-
"@modelcontextprotocol/server": "^2.
|
|
29556
|
-
"@modelcontextprotocol/server-legacy": "^2.
|
|
29835
|
+
"@modelcontextprotocol/server": "^2.3.1",
|
|
29836
|
+
"@modelcontextprotocol/server-legacy": "^2.3.1",
|
|
29557
29837
|
"@standard-schema/spec": "^1.1.0",
|
|
29558
29838
|
"@types/express": "^5.0.6",
|
|
29559
29839
|
chalk: "^5.6.2",
|
|
@@ -30120,23 +30400,29 @@ var import_node_process4, import_node_stream2, import_cross_spawn, DEFAULT_INHER
|
|
|
30120
30400
|
var init_stdio = __esm({
|
|
30121
30401
|
"node_modules/@modelcontextprotocol/client/dist/stdio.mjs"() {
|
|
30122
30402
|
"use strict";
|
|
30123
|
-
|
|
30403
|
+
init_src_WCy6ifGf();
|
|
30124
30404
|
import_node_process4 = __toESM(require("process"), 1);
|
|
30125
30405
|
import_node_stream2 = require("stream");
|
|
30126
30406
|
import_cross_spawn = __toESM(require_cross_spawn(), 1);
|
|
30127
30407
|
DEFAULT_INHERITED_ENV_VARS = import_node_process4.default.platform === "win32" ? [
|
|
30128
30408
|
"APPDATA",
|
|
30409
|
+
"COMSPEC",
|
|
30129
30410
|
"HOMEDRIVE",
|
|
30130
30411
|
"HOMEPATH",
|
|
30131
30412
|
"LOCALAPPDATA",
|
|
30132
30413
|
"PATH",
|
|
30414
|
+
"PATHEXT",
|
|
30133
30415
|
"PROCESSOR_ARCHITECTURE",
|
|
30416
|
+
"PROGRAMDATA",
|
|
30417
|
+
"PROGRAMFILES",
|
|
30418
|
+
"PROGRAMFILES(X86)",
|
|
30419
|
+
"PROGRAMW6432",
|
|
30134
30420
|
"SYSTEMDRIVE",
|
|
30135
30421
|
"SYSTEMROOT",
|
|
30136
30422
|
"TEMP",
|
|
30137
30423
|
"USERNAME",
|
|
30138
30424
|
"USERPROFILE",
|
|
30139
|
-
"
|
|
30425
|
+
"WINDIR"
|
|
30140
30426
|
] : [
|
|
30141
30427
|
"HOME",
|
|
30142
30428
|
"LOGNAME",
|
|
@@ -33813,8 +34099,8 @@ var init_inspect = __esm({
|
|
|
33813
34099
|
// only case Python's inspect supports); over --url/--command the
|
|
33814
34100
|
// generation is unknowable from the wire.
|
|
33815
34101
|
generation: mode.kind === "inprocess" ? 2 : null,
|
|
33816
|
-
fastmcpVersion: "1.
|
|
33817
|
-
mcpVersion: "2.
|
|
34102
|
+
fastmcpVersion: "1.8.1",
|
|
34103
|
+
mcpVersion: "2.3.1",
|
|
33818
34104
|
tools: tools2,
|
|
33819
34105
|
prompts: prompts2,
|
|
33820
34106
|
resources: resources2,
|
|
@@ -47342,7 +47628,7 @@ init_format();
|
|
|
47342
47628
|
var main = defineCommand({
|
|
47343
47629
|
meta: {
|
|
47344
47630
|
name: "fastmcp",
|
|
47345
|
-
version: "1.
|
|
47631
|
+
version: "1.8.1",
|
|
47346
47632
|
description: "FastMCP CLI \u2014 build, run, and manage MCP servers"
|
|
47347
47633
|
},
|
|
47348
47634
|
args: {
|
|
@@ -47367,7 +47653,7 @@ var main = defineCommand({
|
|
|
47367
47653
|
runMain(main);
|
|
47368
47654
|
/*! Bundled license information:
|
|
47369
47655
|
|
|
47370
|
-
@modelcontextprotocol/client/dist/src-
|
|
47656
|
+
@modelcontextprotocol/client/dist/src-WCy6ifGf.mjs:
|
|
47371
47657
|
(*!
|
|
47372
47658
|
* content-type
|
|
47373
47659
|
* Copyright(c) 2015 Douglas Christopher Wilson
|