@bryan-thompson/inspector-assessment-client 1.26.1 → 1.26.3
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/assets/{OAuthCallback-BoGrFRVg.js → OAuthCallback-TVHya7KP.js} +1 -1
- package/dist/assets/{OAuthDebugCallback-CT-Cn5GD.js → OAuthDebugCallback-Cs3pMLdW.js} +1 -1
- package/dist/assets/{index-BdqZvK3a.js → index-jBP9ZYhX.js} +439 -368
- package/dist/index.html +1 -1
- package/lib/lib/assessment/extendedTypes.d.ts +80 -0
- package/lib/lib/assessment/extendedTypes.d.ts.map +1 -1
- package/lib/lib/assessment/resultTypes.d.ts +9 -0
- package/lib/lib/assessment/resultTypes.d.ts.map +1 -1
- package/lib/lib/prohibitedLibraries.d.ts +13 -0
- package/lib/lib/prohibitedLibraries.d.ts.map +1 -1
- package/lib/lib/prohibitedLibraries.js +78 -0
- package/lib/lib/securityPatterns.d.ts +2 -1
- package/lib/lib/securityPatterns.d.ts.map +1 -1
- package/lib/lib/securityPatterns.js +83 -1
- package/lib/services/assessment/modules/AuthenticationAssessor.d.ts +14 -0
- package/lib/services/assessment/modules/AuthenticationAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/AuthenticationAssessor.js +359 -2
- package/lib/services/assessment/modules/ProhibitedLibrariesAssessor.d.ts +7 -0
- package/lib/services/assessment/modules/ProhibitedLibrariesAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/ProhibitedLibrariesAssessor.js +62 -22
- package/lib/services/assessment/modules/SecurityAssessor.d.ts +5 -0
- package/lib/services/assessment/modules/SecurityAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/SecurityAssessor.js +42 -0
- package/lib/services/assessment/modules/TemporalAssessor.d.ts +44 -0
- package/lib/services/assessment/modules/TemporalAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/TemporalAssessor.js +267 -27
- package/lib/services/assessment/modules/securityTests/SecurityPayloadTester.d.ts.map +1 -1
- package/lib/services/assessment/modules/securityTests/SecurityPayloadTester.js +12 -0
- package/lib/services/assessment/modules/securityTests/SecurityResponseAnalyzer.d.ts +17 -0
- package/lib/services/assessment/modules/securityTests/SecurityResponseAnalyzer.d.ts.map +1 -1
- package/lib/services/assessment/modules/securityTests/SecurityResponseAnalyzer.js +90 -0
- package/package.json +2 -2
|
@@ -14732,7 +14732,7 @@ const JSONRPC_VERSION = "2.0";
|
|
|
14732
14732
|
const AssertObjectSchema = custom$1((v) => v !== null && (typeof v === "object" || typeof v === "function"));
|
|
14733
14733
|
const ProgressTokenSchema = union([string(), number$1().int()]);
|
|
14734
14734
|
const CursorSchema = string();
|
|
14735
|
-
|
|
14735
|
+
looseObject({
|
|
14736
14736
|
/**
|
|
14737
14737
|
* Time in milliseconds to keep task results available after completion.
|
|
14738
14738
|
* If null, the task has unlimited lifetime until manually cleaned up.
|
|
@@ -14743,7 +14743,10 @@ const TaskCreationParamsSchema = looseObject({
|
|
|
14743
14743
|
*/
|
|
14744
14744
|
pollInterval: number$1().optional()
|
|
14745
14745
|
});
|
|
14746
|
-
const
|
|
14746
|
+
const TaskMetadataSchema = object({
|
|
14747
|
+
ttl: number$1().optional()
|
|
14748
|
+
});
|
|
14749
|
+
const RelatedTaskMetadataSchema = object({
|
|
14747
14750
|
taskId: string()
|
|
14748
14751
|
});
|
|
14749
14752
|
const RequestMetaSchema = looseObject({
|
|
@@ -14756,48 +14759,45 @@ const RequestMetaSchema = looseObject({
|
|
|
14756
14759
|
*/
|
|
14757
14760
|
[RELATED_TASK_META_KEY]: RelatedTaskMetadataSchema.optional()
|
|
14758
14761
|
});
|
|
14759
|
-
const BaseRequestParamsSchema =
|
|
14760
|
-
/**
|
|
14761
|
-
* If specified, the caller is requesting that the receiver create a task to represent the request.
|
|
14762
|
-
* Task creation parameters are now at the top level instead of in _meta.
|
|
14763
|
-
*/
|
|
14764
|
-
task: TaskCreationParamsSchema.optional(),
|
|
14762
|
+
const BaseRequestParamsSchema = object({
|
|
14765
14763
|
/**
|
|
14766
14764
|
* See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
|
|
14767
14765
|
*/
|
|
14768
14766
|
_meta: RequestMetaSchema.optional()
|
|
14769
14767
|
});
|
|
14768
|
+
const TaskAugmentedRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
14769
|
+
/**
|
|
14770
|
+
* If specified, the caller is requesting task-augmented execution for this request.
|
|
14771
|
+
* The request will return a CreateTaskResult immediately, and the actual result can be
|
|
14772
|
+
* retrieved later via tasks/result.
|
|
14773
|
+
*
|
|
14774
|
+
* Task augmentation is subject to capability negotiation - receivers MUST declare support
|
|
14775
|
+
* for task augmentation of specific request types in their capabilities.
|
|
14776
|
+
*/
|
|
14777
|
+
task: TaskMetadataSchema.optional()
|
|
14778
|
+
});
|
|
14779
|
+
const isTaskAugmentedRequestParams = (value) => TaskAugmentedRequestParamsSchema.safeParse(value).success;
|
|
14770
14780
|
const RequestSchema = object({
|
|
14771
14781
|
method: string(),
|
|
14772
|
-
params: BaseRequestParamsSchema.optional()
|
|
14782
|
+
params: BaseRequestParamsSchema.loose().optional()
|
|
14773
14783
|
});
|
|
14774
|
-
const NotificationsParamsSchema =
|
|
14784
|
+
const NotificationsParamsSchema = object({
|
|
14775
14785
|
/**
|
|
14776
14786
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
14777
14787
|
* for notes on _meta usage.
|
|
14778
14788
|
*/
|
|
14779
|
-
_meta:
|
|
14780
|
-
/**
|
|
14781
|
-
* If specified, this notification is related to the provided task.
|
|
14782
|
-
*/
|
|
14783
|
-
[RELATED_TASK_META_KEY]: optional(RelatedTaskMetadataSchema)
|
|
14784
|
-
}).passthrough().optional()
|
|
14789
|
+
_meta: RequestMetaSchema.optional()
|
|
14785
14790
|
});
|
|
14786
14791
|
const NotificationSchema = object({
|
|
14787
14792
|
method: string(),
|
|
14788
|
-
params: NotificationsParamsSchema.optional()
|
|
14793
|
+
params: NotificationsParamsSchema.loose().optional()
|
|
14789
14794
|
});
|
|
14790
14795
|
const ResultSchema = looseObject({
|
|
14791
14796
|
/**
|
|
14792
14797
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
14793
14798
|
* for notes on _meta usage.
|
|
14794
14799
|
*/
|
|
14795
|
-
_meta:
|
|
14796
|
-
/**
|
|
14797
|
-
* If specified, this result is related to the provided task.
|
|
14798
|
-
*/
|
|
14799
|
-
[RELATED_TASK_META_KEY]: RelatedTaskMetadataSchema.optional()
|
|
14800
|
-
}).optional()
|
|
14800
|
+
_meta: RequestMetaSchema.optional()
|
|
14801
14801
|
});
|
|
14802
14802
|
const RequestIdSchema = union([string(), number$1().int()]);
|
|
14803
14803
|
const JSONRPCRequestSchema = object({
|
|
@@ -14811,12 +14811,12 @@ const JSONRPCNotificationSchema = object({
|
|
|
14811
14811
|
...NotificationSchema.shape
|
|
14812
14812
|
}).strict();
|
|
14813
14813
|
const isJSONRPCNotification = (value) => JSONRPCNotificationSchema.safeParse(value).success;
|
|
14814
|
-
const
|
|
14814
|
+
const JSONRPCResultResponseSchema = object({
|
|
14815
14815
|
jsonrpc: literal(JSONRPC_VERSION),
|
|
14816
14816
|
id: RequestIdSchema,
|
|
14817
14817
|
result: ResultSchema
|
|
14818
14818
|
}).strict();
|
|
14819
|
-
const
|
|
14819
|
+
const isJSONRPCResultResponse = (value) => JSONRPCResultResponseSchema.safeParse(value).success;
|
|
14820
14820
|
var ErrorCode;
|
|
14821
14821
|
(function(ErrorCode2) {
|
|
14822
14822
|
ErrorCode2[ErrorCode2["ConnectionClosed"] = -32e3] = "ConnectionClosed";
|
|
@@ -14828,9 +14828,9 @@ var ErrorCode;
|
|
|
14828
14828
|
ErrorCode2[ErrorCode2["InternalError"] = -32603] = "InternalError";
|
|
14829
14829
|
ErrorCode2[ErrorCode2["UrlElicitationRequired"] = -32042] = "UrlElicitationRequired";
|
|
14830
14830
|
})(ErrorCode || (ErrorCode = {}));
|
|
14831
|
-
const
|
|
14831
|
+
const JSONRPCErrorResponseSchema = object({
|
|
14832
14832
|
jsonrpc: literal(JSONRPC_VERSION),
|
|
14833
|
-
id: RequestIdSchema,
|
|
14833
|
+
id: RequestIdSchema.optional(),
|
|
14834
14834
|
error: object({
|
|
14835
14835
|
/**
|
|
14836
14836
|
* The error type that occurred.
|
|
@@ -14843,11 +14843,17 @@ const JSONRPCErrorSchema = object({
|
|
|
14843
14843
|
/**
|
|
14844
14844
|
* Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
|
|
14845
14845
|
*/
|
|
14846
|
-
data:
|
|
14846
|
+
data: unknown().optional()
|
|
14847
14847
|
})
|
|
14848
14848
|
}).strict();
|
|
14849
|
-
const
|
|
14850
|
-
const JSONRPCMessageSchema = union([
|
|
14849
|
+
const isJSONRPCErrorResponse = (value) => JSONRPCErrorResponseSchema.safeParse(value).success;
|
|
14850
|
+
const JSONRPCMessageSchema = union([
|
|
14851
|
+
JSONRPCRequestSchema,
|
|
14852
|
+
JSONRPCNotificationSchema,
|
|
14853
|
+
JSONRPCResultResponseSchema,
|
|
14854
|
+
JSONRPCErrorResponseSchema
|
|
14855
|
+
]);
|
|
14856
|
+
union([JSONRPCResultResponseSchema, JSONRPCErrorResponseSchema]);
|
|
14851
14857
|
const EmptyResultSchema = ResultSchema.strict();
|
|
14852
14858
|
const CancelledNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
14853
14859
|
/**
|
|
@@ -14855,7 +14861,7 @@ const CancelledNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
|
14855
14861
|
*
|
|
14856
14862
|
* This MUST correspond to the ID of a request previously issued in the same direction.
|
|
14857
14863
|
*/
|
|
14858
|
-
requestId: RequestIdSchema,
|
|
14864
|
+
requestId: RequestIdSchema.optional(),
|
|
14859
14865
|
/**
|
|
14860
14866
|
* An optional string describing the reason for the cancellation. This MAY be logged or presented to the user.
|
|
14861
14867
|
*/
|
|
@@ -14880,7 +14886,15 @@ const IconSchema = object({
|
|
|
14880
14886
|
*
|
|
14881
14887
|
* If not provided, the client should assume that the icon can be used at any size.
|
|
14882
14888
|
*/
|
|
14883
|
-
sizes: array(string()).optional()
|
|
14889
|
+
sizes: array(string()).optional(),
|
|
14890
|
+
/**
|
|
14891
|
+
* Optional specifier for the theme this icon is designed for. `light` indicates
|
|
14892
|
+
* the icon is designed to be used with a light background, and `dark` indicates
|
|
14893
|
+
* the icon is designed to be used with a dark background.
|
|
14894
|
+
*
|
|
14895
|
+
* If not provided, the client should assume the icon can be used with any theme.
|
|
14896
|
+
*/
|
|
14897
|
+
theme: _enum$2(["light", "dark"]).optional()
|
|
14884
14898
|
});
|
|
14885
14899
|
const IconsSchema = object({
|
|
14886
14900
|
/**
|
|
@@ -14916,7 +14930,15 @@ const ImplementationSchema = BaseMetadataSchema.extend({
|
|
|
14916
14930
|
/**
|
|
14917
14931
|
* An optional URL of the website for this implementation.
|
|
14918
14932
|
*/
|
|
14919
|
-
websiteUrl: string().optional()
|
|
14933
|
+
websiteUrl: string().optional(),
|
|
14934
|
+
/**
|
|
14935
|
+
* An optional human-readable description of what this implementation does.
|
|
14936
|
+
*
|
|
14937
|
+
* This can be used by clients or servers to provide context about their purpose
|
|
14938
|
+
* and capabilities. For example, a server might describe the types of resources
|
|
14939
|
+
* or tools it provides, while a client might describe its intended use case.
|
|
14940
|
+
*/
|
|
14941
|
+
description: string().optional()
|
|
14920
14942
|
});
|
|
14921
14943
|
const FormElicitationCapabilitySchema = intersection(object({
|
|
14922
14944
|
applyDefaults: boolean().optional()
|
|
@@ -14932,54 +14954,54 @@ const ElicitationCapabilitySchema = preprocess((value) => {
|
|
|
14932
14954
|
form: FormElicitationCapabilitySchema.optional(),
|
|
14933
14955
|
url: AssertObjectSchema.optional()
|
|
14934
14956
|
}), record(string(), unknown()).optional()));
|
|
14935
|
-
const ClientTasksCapabilitySchema =
|
|
14957
|
+
const ClientTasksCapabilitySchema = looseObject({
|
|
14936
14958
|
/**
|
|
14937
14959
|
* Present if the client supports listing tasks.
|
|
14938
14960
|
*/
|
|
14939
|
-
list: optional(
|
|
14961
|
+
list: AssertObjectSchema.optional(),
|
|
14940
14962
|
/**
|
|
14941
14963
|
* Present if the client supports cancelling tasks.
|
|
14942
14964
|
*/
|
|
14943
|
-
cancel: optional(
|
|
14965
|
+
cancel: AssertObjectSchema.optional(),
|
|
14944
14966
|
/**
|
|
14945
14967
|
* Capabilities for task creation on specific request types.
|
|
14946
14968
|
*/
|
|
14947
|
-
requests:
|
|
14969
|
+
requests: looseObject({
|
|
14948
14970
|
/**
|
|
14949
14971
|
* Task support for sampling requests.
|
|
14950
14972
|
*/
|
|
14951
|
-
sampling:
|
|
14952
|
-
createMessage: optional(
|
|
14953
|
-
}).
|
|
14973
|
+
sampling: looseObject({
|
|
14974
|
+
createMessage: AssertObjectSchema.optional()
|
|
14975
|
+
}).optional(),
|
|
14954
14976
|
/**
|
|
14955
14977
|
* Task support for elicitation requests.
|
|
14956
14978
|
*/
|
|
14957
|
-
elicitation:
|
|
14958
|
-
create: optional(
|
|
14959
|
-
}).
|
|
14960
|
-
}).
|
|
14961
|
-
})
|
|
14962
|
-
const ServerTasksCapabilitySchema =
|
|
14979
|
+
elicitation: looseObject({
|
|
14980
|
+
create: AssertObjectSchema.optional()
|
|
14981
|
+
}).optional()
|
|
14982
|
+
}).optional()
|
|
14983
|
+
});
|
|
14984
|
+
const ServerTasksCapabilitySchema = looseObject({
|
|
14963
14985
|
/**
|
|
14964
14986
|
* Present if the server supports listing tasks.
|
|
14965
14987
|
*/
|
|
14966
|
-
list: optional(
|
|
14988
|
+
list: AssertObjectSchema.optional(),
|
|
14967
14989
|
/**
|
|
14968
14990
|
* Present if the server supports cancelling tasks.
|
|
14969
14991
|
*/
|
|
14970
|
-
cancel: optional(
|
|
14992
|
+
cancel: AssertObjectSchema.optional(),
|
|
14971
14993
|
/**
|
|
14972
14994
|
* Capabilities for task creation on specific request types.
|
|
14973
14995
|
*/
|
|
14974
|
-
requests:
|
|
14996
|
+
requests: looseObject({
|
|
14975
14997
|
/**
|
|
14976
14998
|
* Task support for tool requests.
|
|
14977
14999
|
*/
|
|
14978
|
-
tools:
|
|
14979
|
-
call: optional(
|
|
14980
|
-
}).
|
|
14981
|
-
}).
|
|
14982
|
-
})
|
|
15000
|
+
tools: looseObject({
|
|
15001
|
+
call: AssertObjectSchema.optional()
|
|
15002
|
+
}).optional()
|
|
15003
|
+
}).optional()
|
|
15004
|
+
});
|
|
14983
15005
|
const ClientCapabilitiesSchema = object({
|
|
14984
15006
|
/**
|
|
14985
15007
|
* Experimental, non-standard capabilities that the client supports.
|
|
@@ -15015,7 +15037,7 @@ const ClientCapabilitiesSchema = object({
|
|
|
15015
15037
|
/**
|
|
15016
15038
|
* Present if the client supports task creation.
|
|
15017
15039
|
*/
|
|
15018
|
-
tasks: optional(
|
|
15040
|
+
tasks: ClientTasksCapabilitySchema.optional()
|
|
15019
15041
|
});
|
|
15020
15042
|
const InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
15021
15043
|
/**
|
|
@@ -15045,12 +15067,12 @@ const ServerCapabilitiesSchema = object({
|
|
|
15045
15067
|
/**
|
|
15046
15068
|
* Present if the server offers any prompt templates.
|
|
15047
15069
|
*/
|
|
15048
|
-
prompts:
|
|
15070
|
+
prompts: object({
|
|
15049
15071
|
/**
|
|
15050
15072
|
* Whether this server supports issuing notifications for changes to the prompt list.
|
|
15051
15073
|
*/
|
|
15052
|
-
listChanged:
|
|
15053
|
-
})),
|
|
15074
|
+
listChanged: boolean().optional()
|
|
15075
|
+
}).optional(),
|
|
15054
15076
|
/**
|
|
15055
15077
|
* Present if the server offers any resources to read.
|
|
15056
15078
|
*/
|
|
@@ -15076,8 +15098,8 @@ const ServerCapabilitiesSchema = object({
|
|
|
15076
15098
|
/**
|
|
15077
15099
|
* Present if the server supports task creation.
|
|
15078
15100
|
*/
|
|
15079
|
-
tasks: optional(
|
|
15080
|
-
})
|
|
15101
|
+
tasks: ServerTasksCapabilitySchema.optional()
|
|
15102
|
+
});
|
|
15081
15103
|
const InitializeResultSchema = ResultSchema.extend({
|
|
15082
15104
|
/**
|
|
15083
15105
|
* 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.
|
|
@@ -15093,11 +15115,13 @@ const InitializeResultSchema = ResultSchema.extend({
|
|
|
15093
15115
|
instructions: string().optional()
|
|
15094
15116
|
});
|
|
15095
15117
|
const InitializedNotificationSchema = NotificationSchema.extend({
|
|
15096
|
-
method: literal("notifications/initialized")
|
|
15118
|
+
method: literal("notifications/initialized"),
|
|
15119
|
+
params: NotificationsParamsSchema.optional()
|
|
15097
15120
|
});
|
|
15098
15121
|
const isInitializedNotification = (value) => InitializedNotificationSchema.safeParse(value).success;
|
|
15099
15122
|
const PingRequestSchema = RequestSchema.extend({
|
|
15100
|
-
method: literal("ping")
|
|
15123
|
+
method: literal("ping"),
|
|
15124
|
+
params: BaseRequestParamsSchema.optional()
|
|
15101
15125
|
});
|
|
15102
15126
|
const ProgressSchema = object({
|
|
15103
15127
|
/**
|
|
@@ -15140,11 +15164,12 @@ const PaginatedResultSchema = ResultSchema.extend({
|
|
|
15140
15164
|
* An opaque token representing the pagination position after the last returned result.
|
|
15141
15165
|
* If present, there may be more results available.
|
|
15142
15166
|
*/
|
|
15143
|
-
nextCursor: optional(
|
|
15167
|
+
nextCursor: CursorSchema.optional()
|
|
15144
15168
|
});
|
|
15169
|
+
const TaskStatusSchema = _enum$2(["working", "input_required", "completed", "failed", "cancelled"]);
|
|
15145
15170
|
const TaskSchema = object({
|
|
15146
15171
|
taskId: string(),
|
|
15147
|
-
status:
|
|
15172
|
+
status: TaskStatusSchema,
|
|
15148
15173
|
/**
|
|
15149
15174
|
* Time in milliseconds to keep task results available after completion.
|
|
15150
15175
|
* If null, the task has unlimited lifetime until manually cleaned up.
|
|
@@ -15185,6 +15210,7 @@ const GetTaskPayloadRequestSchema = RequestSchema.extend({
|
|
|
15185
15210
|
taskId: string()
|
|
15186
15211
|
})
|
|
15187
15212
|
});
|
|
15213
|
+
ResultSchema.loose();
|
|
15188
15214
|
const ListTasksRequestSchema = PaginatedRequestSchema.extend({
|
|
15189
15215
|
method: literal("tasks/list")
|
|
15190
15216
|
});
|
|
@@ -15223,7 +15249,7 @@ const Base64Schema = string().refine((val) => {
|
|
|
15223
15249
|
try {
|
|
15224
15250
|
atob(val);
|
|
15225
15251
|
return true;
|
|
15226
|
-
} catch
|
|
15252
|
+
} catch {
|
|
15227
15253
|
return false;
|
|
15228
15254
|
}
|
|
15229
15255
|
}, { message: "Invalid Base64 string" });
|
|
@@ -15233,11 +15259,12 @@ const BlobResourceContentsSchema = ResourceContentsSchema.extend({
|
|
|
15233
15259
|
*/
|
|
15234
15260
|
blob: Base64Schema
|
|
15235
15261
|
});
|
|
15262
|
+
const RoleSchema = _enum$2(["user", "assistant"]);
|
|
15236
15263
|
const AnnotationsSchema = object({
|
|
15237
15264
|
/**
|
|
15238
15265
|
* Intended audience(s) for the resource.
|
|
15239
15266
|
*/
|
|
15240
|
-
audience: array(
|
|
15267
|
+
audience: array(RoleSchema).optional(),
|
|
15241
15268
|
/**
|
|
15242
15269
|
* Importance hint for the resource, from 0 (least) to 1 (most).
|
|
15243
15270
|
*/
|
|
@@ -15330,7 +15357,8 @@ const ReadResourceResultSchema = ResultSchema.extend({
|
|
|
15330
15357
|
contents: array(union([TextResourceContentsSchema, BlobResourceContentsSchema]))
|
|
15331
15358
|
});
|
|
15332
15359
|
const ResourceListChangedNotificationSchema = NotificationSchema.extend({
|
|
15333
|
-
method: literal("notifications/resources/list_changed")
|
|
15360
|
+
method: literal("notifications/resources/list_changed"),
|
|
15361
|
+
params: NotificationsParamsSchema.optional()
|
|
15334
15362
|
});
|
|
15335
15363
|
const SubscribeRequestParamsSchema = ResourceRequestParamsSchema;
|
|
15336
15364
|
const SubscribeRequestSchema = RequestSchema.extend({
|
|
@@ -15475,13 +15503,13 @@ const ToolUseContentSchema = object({
|
|
|
15475
15503
|
* Arguments to pass to the tool.
|
|
15476
15504
|
* Must conform to the tool's inputSchema.
|
|
15477
15505
|
*/
|
|
15478
|
-
input:
|
|
15506
|
+
input: record(string(), unknown()),
|
|
15479
15507
|
/**
|
|
15480
15508
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
15481
15509
|
* for notes on _meta usage.
|
|
15482
15510
|
*/
|
|
15483
|
-
_meta:
|
|
15484
|
-
})
|
|
15511
|
+
_meta: record(string(), unknown()).optional()
|
|
15512
|
+
});
|
|
15485
15513
|
const EmbeddedResourceSchema = object({
|
|
15486
15514
|
type: literal("resource"),
|
|
15487
15515
|
resource: union([TextResourceContentsSchema, BlobResourceContentsSchema]),
|
|
@@ -15506,18 +15534,19 @@ const ContentBlockSchema = union([
|
|
|
15506
15534
|
EmbeddedResourceSchema
|
|
15507
15535
|
]);
|
|
15508
15536
|
const PromptMessageSchema = object({
|
|
15509
|
-
role:
|
|
15537
|
+
role: RoleSchema,
|
|
15510
15538
|
content: ContentBlockSchema
|
|
15511
15539
|
});
|
|
15512
15540
|
const GetPromptResultSchema = ResultSchema.extend({
|
|
15513
15541
|
/**
|
|
15514
15542
|
* An optional description for the prompt.
|
|
15515
15543
|
*/
|
|
15516
|
-
description:
|
|
15544
|
+
description: string().optional(),
|
|
15517
15545
|
messages: array(PromptMessageSchema)
|
|
15518
15546
|
});
|
|
15519
15547
|
const PromptListChangedNotificationSchema = NotificationSchema.extend({
|
|
15520
|
-
method: literal("notifications/prompts/list_changed")
|
|
15548
|
+
method: literal("notifications/prompts/list_changed"),
|
|
15549
|
+
params: NotificationsParamsSchema.optional()
|
|
15521
15550
|
});
|
|
15522
15551
|
const ToolAnnotationsSchema = object({
|
|
15523
15552
|
/**
|
|
@@ -15598,11 +15627,11 @@ const ToolSchema = object({
|
|
|
15598
15627
|
/**
|
|
15599
15628
|
* Optional additional tool information.
|
|
15600
15629
|
*/
|
|
15601
|
-
annotations: optional(
|
|
15630
|
+
annotations: ToolAnnotationsSchema.optional(),
|
|
15602
15631
|
/**
|
|
15603
15632
|
* Execution-related properties for this tool.
|
|
15604
15633
|
*/
|
|
15605
|
-
execution: optional(
|
|
15634
|
+
execution: ToolExecutionSchema.optional(),
|
|
15606
15635
|
/**
|
|
15607
15636
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
15608
15637
|
* for notes on _meta usage.
|
|
@@ -15643,12 +15672,12 @@ const CallToolResultSchema = ResultSchema.extend({
|
|
|
15643
15672
|
* server does not support tool calls, or any other exceptional conditions,
|
|
15644
15673
|
* should be reported as an MCP error response.
|
|
15645
15674
|
*/
|
|
15646
|
-
isError:
|
|
15675
|
+
isError: boolean().optional()
|
|
15647
15676
|
});
|
|
15648
15677
|
const CompatibilityCallToolResultSchema = CallToolResultSchema.or(ResultSchema.extend({
|
|
15649
15678
|
toolResult: unknown()
|
|
15650
15679
|
}));
|
|
15651
|
-
const CallToolRequestParamsSchema =
|
|
15680
|
+
const CallToolRequestParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
15652
15681
|
/**
|
|
15653
15682
|
* The name of the tool to call.
|
|
15654
15683
|
*/
|
|
@@ -15656,14 +15685,35 @@ const CallToolRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
|
15656
15685
|
/**
|
|
15657
15686
|
* Arguments to pass to the tool.
|
|
15658
15687
|
*/
|
|
15659
|
-
arguments:
|
|
15688
|
+
arguments: record(string(), unknown()).optional()
|
|
15660
15689
|
});
|
|
15661
15690
|
const CallToolRequestSchema = RequestSchema.extend({
|
|
15662
15691
|
method: literal("tools/call"),
|
|
15663
15692
|
params: CallToolRequestParamsSchema
|
|
15664
15693
|
});
|
|
15665
15694
|
const ToolListChangedNotificationSchema = NotificationSchema.extend({
|
|
15666
|
-
method: literal("notifications/tools/list_changed")
|
|
15695
|
+
method: literal("notifications/tools/list_changed"),
|
|
15696
|
+
params: NotificationsParamsSchema.optional()
|
|
15697
|
+
});
|
|
15698
|
+
const ListChangedOptionsBaseSchema = object({
|
|
15699
|
+
/**
|
|
15700
|
+
* If true, the list will be refreshed automatically when a list changed notification is received.
|
|
15701
|
+
* The callback will be called with the updated list.
|
|
15702
|
+
*
|
|
15703
|
+
* If false, the callback will be called with null items, allowing manual refresh.
|
|
15704
|
+
*
|
|
15705
|
+
* @default true
|
|
15706
|
+
*/
|
|
15707
|
+
autoRefresh: boolean().default(true),
|
|
15708
|
+
/**
|
|
15709
|
+
* Debounce time in milliseconds for list changed notification processing.
|
|
15710
|
+
*
|
|
15711
|
+
* Multiple notifications received within this timeframe will only trigger one refresh.
|
|
15712
|
+
* Set to 0 to disable debouncing.
|
|
15713
|
+
*
|
|
15714
|
+
* @default 300
|
|
15715
|
+
*/
|
|
15716
|
+
debounceMs: number$1().int().nonnegative().default(300)
|
|
15667
15717
|
});
|
|
15668
15718
|
const LoggingLevelSchema = _enum$2(["debug", "info", "notice", "warning", "error", "critical", "alert", "emergency"]);
|
|
15669
15719
|
const SetLevelRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
@@ -15704,19 +15754,19 @@ const ModelPreferencesSchema = object({
|
|
|
15704
15754
|
/**
|
|
15705
15755
|
* Optional hints to use for model selection.
|
|
15706
15756
|
*/
|
|
15707
|
-
hints:
|
|
15757
|
+
hints: array(ModelHintSchema).optional(),
|
|
15708
15758
|
/**
|
|
15709
15759
|
* How much to prioritize cost when selecting a model.
|
|
15710
15760
|
*/
|
|
15711
|
-
costPriority:
|
|
15761
|
+
costPriority: number$1().min(0).max(1).optional(),
|
|
15712
15762
|
/**
|
|
15713
15763
|
* How much to prioritize sampling speed (latency) when selecting a model.
|
|
15714
15764
|
*/
|
|
15715
|
-
speedPriority:
|
|
15765
|
+
speedPriority: number$1().min(0).max(1).optional(),
|
|
15716
15766
|
/**
|
|
15717
15767
|
* How much to prioritize intelligence and capabilities when selecting a model.
|
|
15718
15768
|
*/
|
|
15719
|
-
intelligencePriority:
|
|
15769
|
+
intelligencePriority: number$1().min(0).max(1).optional()
|
|
15720
15770
|
});
|
|
15721
15771
|
const ToolChoiceSchema = object({
|
|
15722
15772
|
/**
|
|
@@ -15725,20 +15775,20 @@ const ToolChoiceSchema = object({
|
|
|
15725
15775
|
* - "required": Model MUST use at least one tool before completing
|
|
15726
15776
|
* - "none": Model MUST NOT use any tools
|
|
15727
15777
|
*/
|
|
15728
|
-
mode:
|
|
15778
|
+
mode: _enum$2(["auto", "required", "none"]).optional()
|
|
15729
15779
|
});
|
|
15730
15780
|
const ToolResultContentSchema = object({
|
|
15731
15781
|
type: literal("tool_result"),
|
|
15732
15782
|
toolUseId: string().describe("The unique identifier for the corresponding tool call."),
|
|
15733
15783
|
content: array(ContentBlockSchema).default([]),
|
|
15734
|
-
structuredContent: object({}).
|
|
15735
|
-
isError:
|
|
15784
|
+
structuredContent: object({}).loose().optional(),
|
|
15785
|
+
isError: boolean().optional(),
|
|
15736
15786
|
/**
|
|
15737
15787
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
15738
15788
|
* for notes on _meta usage.
|
|
15739
15789
|
*/
|
|
15740
|
-
_meta:
|
|
15741
|
-
})
|
|
15790
|
+
_meta: record(string(), unknown()).optional()
|
|
15791
|
+
});
|
|
15742
15792
|
const SamplingContentSchema = discriminatedUnion("type", [TextContentSchema, ImageContentSchema, AudioContentSchema]);
|
|
15743
15793
|
const SamplingMessageContentBlockSchema = discriminatedUnion("type", [
|
|
15744
15794
|
TextContentSchema,
|
|
@@ -15748,15 +15798,15 @@ const SamplingMessageContentBlockSchema = discriminatedUnion("type", [
|
|
|
15748
15798
|
ToolResultContentSchema
|
|
15749
15799
|
]);
|
|
15750
15800
|
const SamplingMessageSchema = object({
|
|
15751
|
-
role:
|
|
15801
|
+
role: RoleSchema,
|
|
15752
15802
|
content: union([SamplingMessageContentBlockSchema, array(SamplingMessageContentBlockSchema)]),
|
|
15753
15803
|
/**
|
|
15754
15804
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
15755
15805
|
* for notes on _meta usage.
|
|
15756
15806
|
*/
|
|
15757
|
-
_meta:
|
|
15758
|
-
})
|
|
15759
|
-
const CreateMessageRequestParamsSchema =
|
|
15807
|
+
_meta: record(string(), unknown()).optional()
|
|
15808
|
+
});
|
|
15809
|
+
const CreateMessageRequestParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
15760
15810
|
messages: array(SamplingMessageSchema),
|
|
15761
15811
|
/**
|
|
15762
15812
|
* The server's preferences for which model to select. The client MAY modify or omit this request.
|
|
@@ -15790,13 +15840,13 @@ const CreateMessageRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
|
15790
15840
|
* Tools that the model may use during generation.
|
|
15791
15841
|
* The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.
|
|
15792
15842
|
*/
|
|
15793
|
-
tools:
|
|
15843
|
+
tools: array(ToolSchema).optional(),
|
|
15794
15844
|
/**
|
|
15795
15845
|
* Controls how the model uses tools.
|
|
15796
15846
|
* The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.
|
|
15797
15847
|
* Default is `{ mode: "auto" }`.
|
|
15798
15848
|
*/
|
|
15799
|
-
toolChoice: optional(
|
|
15849
|
+
toolChoice: ToolChoiceSchema.optional()
|
|
15800
15850
|
});
|
|
15801
15851
|
const CreateMessageRequestSchema = RequestSchema.extend({
|
|
15802
15852
|
method: literal("sampling/createMessage"),
|
|
@@ -15818,7 +15868,7 @@ const CreateMessageResultSchema = ResultSchema.extend({
|
|
|
15818
15868
|
* This field is an open string to allow for provider-specific stop reasons.
|
|
15819
15869
|
*/
|
|
15820
15870
|
stopReason: optional(_enum$2(["endTurn", "stopSequence", "maxTokens"]).or(string())),
|
|
15821
|
-
role:
|
|
15871
|
+
role: RoleSchema,
|
|
15822
15872
|
/**
|
|
15823
15873
|
* Response content. Single content block (text, image, or audio).
|
|
15824
15874
|
*/
|
|
@@ -15841,7 +15891,7 @@ const CreateMessageResultWithToolsSchema = ResultSchema.extend({
|
|
|
15841
15891
|
* This field is an open string to allow for provider-specific stop reasons.
|
|
15842
15892
|
*/
|
|
15843
15893
|
stopReason: optional(_enum$2(["endTurn", "stopSequence", "maxTokens", "toolUse"]).or(string())),
|
|
15844
|
-
role:
|
|
15894
|
+
role: RoleSchema,
|
|
15845
15895
|
/**
|
|
15846
15896
|
* Response content. May be a single block or array. May include ToolUseContent if stopReason is "toolUse".
|
|
15847
15897
|
*/
|
|
@@ -15925,7 +15975,7 @@ const TitledMultiSelectEnumSchemaSchema = object({
|
|
|
15925
15975
|
const MultiSelectEnumSchemaSchema = union([UntitledMultiSelectEnumSchemaSchema, TitledMultiSelectEnumSchemaSchema]);
|
|
15926
15976
|
const EnumSchemaSchema = union([LegacyTitledEnumSchemaSchema, SingleSelectEnumSchemaSchema, MultiSelectEnumSchemaSchema]);
|
|
15927
15977
|
const PrimitiveSchemaDefinitionSchema = union([EnumSchemaSchema, BooleanSchemaSchema, StringSchemaSchema, NumberSchemaSchema]);
|
|
15928
|
-
const ElicitRequestFormParamsSchema =
|
|
15978
|
+
const ElicitRequestFormParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
15929
15979
|
/**
|
|
15930
15980
|
* The elicitation mode.
|
|
15931
15981
|
*
|
|
@@ -15946,7 +15996,7 @@ const ElicitRequestFormParamsSchema = BaseRequestParamsSchema.extend({
|
|
|
15946
15996
|
required: array(string()).optional()
|
|
15947
15997
|
})
|
|
15948
15998
|
});
|
|
15949
|
-
const ElicitRequestURLParamsSchema =
|
|
15999
|
+
const ElicitRequestURLParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
15950
16000
|
/**
|
|
15951
16001
|
* The elicitation mode.
|
|
15952
16002
|
*/
|
|
@@ -16068,13 +16118,15 @@ const RootSchema = object({
|
|
|
16068
16118
|
_meta: record(string(), unknown()).optional()
|
|
16069
16119
|
});
|
|
16070
16120
|
const ListRootsRequestSchema = RequestSchema.extend({
|
|
16071
|
-
method: literal("roots/list")
|
|
16121
|
+
method: literal("roots/list"),
|
|
16122
|
+
params: BaseRequestParamsSchema.optional()
|
|
16072
16123
|
});
|
|
16073
16124
|
const ListRootsResultSchema = ResultSchema.extend({
|
|
16074
16125
|
roots: array(RootSchema)
|
|
16075
16126
|
});
|
|
16076
16127
|
const RootsListChangedNotificationSchema = NotificationSchema.extend({
|
|
16077
|
-
method: literal("notifications/roots/list_changed")
|
|
16128
|
+
method: literal("notifications/roots/list_changed"),
|
|
16129
|
+
params: NotificationsParamsSchema.optional()
|
|
16078
16130
|
});
|
|
16079
16131
|
union([
|
|
16080
16132
|
PingRequestSchema,
|
|
@@ -16092,7 +16144,8 @@ union([
|
|
|
16092
16144
|
ListToolsRequestSchema,
|
|
16093
16145
|
GetTaskRequestSchema,
|
|
16094
16146
|
GetTaskPayloadRequestSchema,
|
|
16095
|
-
ListTasksRequestSchema
|
|
16147
|
+
ListTasksRequestSchema,
|
|
16148
|
+
CancelTaskRequestSchema
|
|
16096
16149
|
]);
|
|
16097
16150
|
union([
|
|
16098
16151
|
CancelledNotificationSchema,
|
|
@@ -16118,7 +16171,8 @@ union([
|
|
|
16118
16171
|
ListRootsRequestSchema,
|
|
16119
16172
|
GetTaskRequestSchema,
|
|
16120
16173
|
GetTaskPayloadRequestSchema,
|
|
16121
|
-
ListTasksRequestSchema
|
|
16174
|
+
ListTasksRequestSchema,
|
|
16175
|
+
CancelTaskRequestSchema
|
|
16122
16176
|
]);
|
|
16123
16177
|
union([
|
|
16124
16178
|
CancelledNotificationSchema,
|
|
@@ -16173,8 +16227,7 @@ class UrlElicitationRequiredError extends McpError {
|
|
|
16173
16227
|
});
|
|
16174
16228
|
}
|
|
16175
16229
|
get elicitations() {
|
|
16176
|
-
|
|
16177
|
-
return (_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a.elicitations) !== null && _b !== void 0 ? _b : [];
|
|
16230
|
+
return this.data?.elicitations ?? [];
|
|
16178
16231
|
}
|
|
16179
16232
|
}
|
|
16180
16233
|
const SafeUrlSchema = url().superRefine((val, ctx) => {
|
|
@@ -16320,7 +16373,7 @@ object({
|
|
|
16320
16373
|
token_type_hint: string().optional()
|
|
16321
16374
|
}).strip();
|
|
16322
16375
|
const name = "@bryan-thompson/inspector-assessment-client";
|
|
16323
|
-
const version$1 = "1.26.
|
|
16376
|
+
const version$1 = "1.26.2";
|
|
16324
16377
|
const packageJson = {
|
|
16325
16378
|
name,
|
|
16326
16379
|
version: version$1
|
|
@@ -16623,7 +16676,7 @@ const OAUTH_ERRORS = {
|
|
|
16623
16676
|
};
|
|
16624
16677
|
class UnauthorizedError extends Error {
|
|
16625
16678
|
constructor(message) {
|
|
16626
|
-
super(message
|
|
16679
|
+
super(message ?? "Unauthorized");
|
|
16627
16680
|
}
|
|
16628
16681
|
}
|
|
16629
16682
|
function isClientAuthMethod(method) {
|
|
@@ -16696,22 +16749,20 @@ async function parseErrorResponse(input) {
|
|
|
16696
16749
|
}
|
|
16697
16750
|
}
|
|
16698
16751
|
async function auth(provider, options) {
|
|
16699
|
-
var _a, _b;
|
|
16700
16752
|
try {
|
|
16701
16753
|
return await authInternal(provider, options);
|
|
16702
16754
|
} catch (error) {
|
|
16703
16755
|
if (error instanceof InvalidClientError || error instanceof UnauthorizedClientError) {
|
|
16704
|
-
await
|
|
16756
|
+
await provider.invalidateCredentials?.("all");
|
|
16705
16757
|
return await authInternal(provider, options);
|
|
16706
16758
|
} else if (error instanceof InvalidGrantError) {
|
|
16707
|
-
await
|
|
16759
|
+
await provider.invalidateCredentials?.("tokens");
|
|
16708
16760
|
return await authInternal(provider, options);
|
|
16709
16761
|
}
|
|
16710
16762
|
throw error;
|
|
16711
16763
|
}
|
|
16712
16764
|
}
|
|
16713
16765
|
async function authInternal(provider, { serverUrl, authorizationCode, scope: scope2, resourceMetadataUrl, fetchFn }) {
|
|
16714
|
-
var _a, _b;
|
|
16715
16766
|
let resourceMetadata;
|
|
16716
16767
|
let authorizationServerUrl;
|
|
16717
16768
|
try {
|
|
@@ -16719,7 +16770,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope: sco
|
|
|
16719
16770
|
if (resourceMetadata.authorization_servers && resourceMetadata.authorization_servers.length > 0) {
|
|
16720
16771
|
authorizationServerUrl = resourceMetadata.authorization_servers[0];
|
|
16721
16772
|
}
|
|
16722
|
-
} catch
|
|
16773
|
+
} catch {
|
|
16723
16774
|
}
|
|
16724
16775
|
if (!authorizationServerUrl) {
|
|
16725
16776
|
authorizationServerUrl = new URL("/", serverUrl);
|
|
@@ -16733,7 +16784,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope: sco
|
|
|
16733
16784
|
if (authorizationCode !== void 0) {
|
|
16734
16785
|
throw new Error("Existing OAuth client information is required when exchanging an authorization code");
|
|
16735
16786
|
}
|
|
16736
|
-
const supportsUrlBasedClientId =
|
|
16787
|
+
const supportsUrlBasedClientId = metadata2?.client_id_metadata_document_supported === true;
|
|
16737
16788
|
const clientMetadataUrl = provider.clientMetadataUrl;
|
|
16738
16789
|
if (clientMetadataUrl && !isHttpsUrl(clientMetadataUrl)) {
|
|
16739
16790
|
throw new InvalidClientMetadataError(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${clientMetadataUrl}`);
|
|
@@ -16743,7 +16794,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope: sco
|
|
|
16743
16794
|
clientInformation = {
|
|
16744
16795
|
client_id: clientMetadataUrl
|
|
16745
16796
|
};
|
|
16746
|
-
await
|
|
16797
|
+
await provider.saveClientInformation?.(clientInformation);
|
|
16747
16798
|
} else {
|
|
16748
16799
|
if (!provider.saveClientInformation) {
|
|
16749
16800
|
throw new Error("OAuth client information must be saveable for dynamic registration");
|
|
@@ -16769,7 +16820,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope: sco
|
|
|
16769
16820
|
return "AUTHORIZED";
|
|
16770
16821
|
}
|
|
16771
16822
|
const tokens = await provider.tokens();
|
|
16772
|
-
if (tokens
|
|
16823
|
+
if (tokens?.refresh_token) {
|
|
16773
16824
|
try {
|
|
16774
16825
|
const newTokens = await refreshAuthorization(authorizationServerUrl, {
|
|
16775
16826
|
metadata: metadata2,
|
|
@@ -16794,7 +16845,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope: sco
|
|
|
16794
16845
|
clientInformation,
|
|
16795
16846
|
state,
|
|
16796
16847
|
redirectUrl: provider.redirectUrl,
|
|
16797
|
-
scope: scope2 ||
|
|
16848
|
+
scope: scope2 || resourceMetadata?.scopes_supported?.join(" ") || provider.clientMetadata.scope,
|
|
16798
16849
|
resource
|
|
16799
16850
|
});
|
|
16800
16851
|
await provider.saveCodeVerifier(codeVerifier);
|
|
@@ -16807,14 +16858,14 @@ function isHttpsUrl(value) {
|
|
|
16807
16858
|
try {
|
|
16808
16859
|
const url2 = new URL(value);
|
|
16809
16860
|
return url2.protocol === "https:" && url2.pathname !== "/";
|
|
16810
|
-
} catch
|
|
16861
|
+
} catch {
|
|
16811
16862
|
return false;
|
|
16812
16863
|
}
|
|
16813
16864
|
}
|
|
16814
16865
|
async function selectResourceURL(serverUrl, provider, resourceMetadata) {
|
|
16815
16866
|
const defaultResource = resourceUrlFromServerUrl(serverUrl);
|
|
16816
16867
|
if (provider.validateResourceURL) {
|
|
16817
|
-
return await provider.validateResourceURL(defaultResource, resourceMetadata
|
|
16868
|
+
return await provider.validateResourceURL(defaultResource, resourceMetadata?.resource);
|
|
16818
16869
|
}
|
|
16819
16870
|
if (!resourceMetadata) {
|
|
16820
16871
|
return void 0;
|
|
@@ -16838,7 +16889,7 @@ function extractWWWAuthenticateParams(res) {
|
|
|
16838
16889
|
if (resourceMetadataMatch) {
|
|
16839
16890
|
try {
|
|
16840
16891
|
resourceMetadataUrl = new URL(resourceMetadataMatch);
|
|
16841
|
-
} catch
|
|
16892
|
+
} catch {
|
|
16842
16893
|
}
|
|
16843
16894
|
}
|
|
16844
16895
|
const scope2 = extractFieldFromWwwAuth(res, "scope") || void 0;
|
|
@@ -16862,17 +16913,16 @@ function extractFieldFromWwwAuth(response, fieldName) {
|
|
|
16862
16913
|
return null;
|
|
16863
16914
|
}
|
|
16864
16915
|
async function discoverOAuthProtectedResourceMetadata(serverUrl, opts, fetchFn = fetch) {
|
|
16865
|
-
var _a, _b;
|
|
16866
16916
|
const response = await discoverMetadataWithFallback(serverUrl, "oauth-protected-resource", fetchFn, {
|
|
16867
|
-
protocolVersion: opts
|
|
16868
|
-
metadataUrl: opts
|
|
16917
|
+
protocolVersion: opts?.protocolVersion,
|
|
16918
|
+
metadataUrl: opts?.resourceMetadataUrl
|
|
16869
16919
|
});
|
|
16870
16920
|
if (!response || response.status === 404) {
|
|
16871
|
-
await
|
|
16921
|
+
await response?.body?.cancel();
|
|
16872
16922
|
throw new Error(`Resource server does not implement OAuth 2.0 Protected Resource Metadata.`);
|
|
16873
16923
|
}
|
|
16874
16924
|
if (!response.ok) {
|
|
16875
|
-
await
|
|
16925
|
+
await response.body?.cancel();
|
|
16876
16926
|
throw new Error(`HTTP ${response.status} trying to load well-known OAuth protected resource metadata.`);
|
|
16877
16927
|
}
|
|
16878
16928
|
return OAuthProtectedResourceMetadataSchema.parse(await response.json());
|
|
@@ -16907,19 +16957,18 @@ function shouldAttemptFallback(response, pathname) {
|
|
|
16907
16957
|
return !response || response.status >= 400 && response.status < 500 && pathname !== "/";
|
|
16908
16958
|
}
|
|
16909
16959
|
async function discoverMetadataWithFallback(serverUrl, wellKnownType, fetchFn, opts) {
|
|
16910
|
-
var _a, _b;
|
|
16911
16960
|
const issuer = new URL(serverUrl);
|
|
16912
|
-
const protocolVersion =
|
|
16961
|
+
const protocolVersion = opts?.protocolVersion ?? LATEST_PROTOCOL_VERSION;
|
|
16913
16962
|
let url2;
|
|
16914
|
-
if (opts
|
|
16963
|
+
if (opts?.metadataUrl) {
|
|
16915
16964
|
url2 = new URL(opts.metadataUrl);
|
|
16916
16965
|
} else {
|
|
16917
16966
|
const wellKnownPath = buildWellKnownPath(wellKnownType, issuer.pathname);
|
|
16918
|
-
url2 = new URL(wellKnownPath,
|
|
16967
|
+
url2 = new URL(wellKnownPath, opts?.metadataServerUrl ?? issuer);
|
|
16919
16968
|
url2.search = issuer.search;
|
|
16920
16969
|
}
|
|
16921
16970
|
let response = await tryMetadataDiscovery(url2, protocolVersion, fetchFn);
|
|
16922
|
-
if (!
|
|
16971
|
+
if (!opts?.metadataUrl && shouldAttemptFallback(response, issuer.pathname)) {
|
|
16923
16972
|
const rootUrl = new URL(`/.well-known/${wellKnownType}`, issuer);
|
|
16924
16973
|
response = await tryMetadataDiscovery(rootUrl, protocolVersion, fetchFn);
|
|
16925
16974
|
}
|
|
@@ -16959,7 +17008,6 @@ function buildDiscoveryUrls(authorizationServerUrl) {
|
|
|
16959
17008
|
return urlsToTry;
|
|
16960
17009
|
}
|
|
16961
17010
|
async function discoverAuthorizationServerMetadata(authorizationServerUrl, { fetchFn = fetch, protocolVersion = LATEST_PROTOCOL_VERSION } = {}) {
|
|
16962
|
-
var _a;
|
|
16963
17011
|
const headers = {
|
|
16964
17012
|
"MCP-Protocol-Version": protocolVersion,
|
|
16965
17013
|
Accept: "application/json"
|
|
@@ -16971,7 +17019,7 @@ async function discoverAuthorizationServerMetadata(authorizationServerUrl, { fet
|
|
|
16971
17019
|
continue;
|
|
16972
17020
|
}
|
|
16973
17021
|
if (!response.ok) {
|
|
16974
|
-
await
|
|
17022
|
+
await response.body?.cancel();
|
|
16975
17023
|
if (response.status >= 400 && response.status < 500) {
|
|
16976
17024
|
continue;
|
|
16977
17025
|
}
|
|
@@ -17012,7 +17060,7 @@ async function startAuthorization(authorizationServerUrl, { metadata: metadata2,
|
|
|
17012
17060
|
if (scope2) {
|
|
17013
17061
|
authorizationUrl.searchParams.set("scope", scope2);
|
|
17014
17062
|
}
|
|
17015
|
-
if (scope2
|
|
17063
|
+
if (scope2?.includes("offline_access")) {
|
|
17016
17064
|
authorizationUrl.searchParams.append("prompt", "consent");
|
|
17017
17065
|
}
|
|
17018
17066
|
if (resource) {
|
|
@@ -17029,8 +17077,7 @@ function prepareAuthorizationCodeRequest(authorizationCode, codeVerifier, redire
|
|
|
17029
17077
|
});
|
|
17030
17078
|
}
|
|
17031
17079
|
async function executeTokenRequest(authorizationServerUrl, { metadata: metadata2, tokenRequestParams, clientInformation, addClientAuthentication, resource, fetchFn }) {
|
|
17032
|
-
|
|
17033
|
-
const tokenUrl = (metadata2 === null || metadata2 === void 0 ? void 0 : metadata2.token_endpoint) ? new URL(metadata2.token_endpoint) : new URL("/token", authorizationServerUrl);
|
|
17080
|
+
const tokenUrl = metadata2?.token_endpoint ? new URL(metadata2.token_endpoint) : new URL("/token", authorizationServerUrl);
|
|
17034
17081
|
const headers = new Headers({
|
|
17035
17082
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
17036
17083
|
Accept: "application/json"
|
|
@@ -17041,11 +17088,11 @@ async function executeTokenRequest(authorizationServerUrl, { metadata: metadata2
|
|
|
17041
17088
|
if (addClientAuthentication) {
|
|
17042
17089
|
await addClientAuthentication(headers, tokenRequestParams, tokenUrl, metadata2);
|
|
17043
17090
|
} else if (clientInformation) {
|
|
17044
|
-
const supportedMethods =
|
|
17091
|
+
const supportedMethods = metadata2?.token_endpoint_auth_methods_supported ?? [];
|
|
17045
17092
|
const authMethod = selectClientAuthMethod(clientInformation, supportedMethods);
|
|
17046
17093
|
applyClientAuthentication(authMethod, clientInformation, headers, tokenRequestParams);
|
|
17047
17094
|
}
|
|
17048
|
-
const response = await (fetchFn
|
|
17095
|
+
const response = await (fetchFn ?? fetch)(tokenUrl, {
|
|
17049
17096
|
method: "POST",
|
|
17050
17097
|
headers,
|
|
17051
17098
|
body: tokenRequestParams
|
|
@@ -17101,7 +17148,7 @@ async function fetchToken(provider, authorizationServerUrl, { metadata: metadata
|
|
|
17101
17148
|
return executeTokenRequest(authorizationServerUrl, {
|
|
17102
17149
|
metadata: metadata2,
|
|
17103
17150
|
tokenRequestParams,
|
|
17104
|
-
clientInformation: clientInformation
|
|
17151
|
+
clientInformation: clientInformation ?? void 0,
|
|
17105
17152
|
addClientAuthentication: provider.addClientAuthentication,
|
|
17106
17153
|
resource,
|
|
17107
17154
|
fetchFn
|
|
@@ -17117,7 +17164,7 @@ async function registerClient(authorizationServerUrl, { metadata: metadata2, cli
|
|
|
17117
17164
|
} else {
|
|
17118
17165
|
registrationUrl = new URL("/register", authorizationServerUrl);
|
|
17119
17166
|
}
|
|
17120
|
-
const response = await (fetchFn
|
|
17167
|
+
const response = await (fetchFn ?? fetch)(registrationUrl, {
|
|
17121
17168
|
method: "POST",
|
|
17122
17169
|
headers: {
|
|
17123
17170
|
"Content-Type": "application/json"
|
|
@@ -23610,8 +23657,8 @@ function requireAjv$1() {
|
|
|
23610
23657
|
return ajv$2;
|
|
23611
23658
|
}
|
|
23612
23659
|
var ajvExports$1 = requireAjv$1();
|
|
23613
|
-
const Ajv = /* @__PURE__ */ getDefaultExportFromCjs(ajvExports$1);
|
|
23614
|
-
const ajv$1 = new Ajv();
|
|
23660
|
+
const Ajv$1 = /* @__PURE__ */ getDefaultExportFromCjs(ajvExports$1);
|
|
23661
|
+
const ajv$1 = new Ajv$1();
|
|
23615
23662
|
const toolOutputValidators = /* @__PURE__ */ new Map();
|
|
23616
23663
|
function cacheToolOutputSchemas(tools) {
|
|
23617
23664
|
toolOutputValidators.clear();
|
|
@@ -23822,13 +23869,12 @@ function safeParse(schema, data2) {
|
|
|
23822
23869
|
return result;
|
|
23823
23870
|
}
|
|
23824
23871
|
function getObjectShape(schema) {
|
|
23825
|
-
var _a, _b;
|
|
23826
23872
|
if (!schema)
|
|
23827
23873
|
return void 0;
|
|
23828
23874
|
let rawShape;
|
|
23829
23875
|
if (isZ4Schema(schema)) {
|
|
23830
23876
|
const v4Schema = schema;
|
|
23831
|
-
rawShape =
|
|
23877
|
+
rawShape = v4Schema._zod?.def?.shape;
|
|
23832
23878
|
} else {
|
|
23833
23879
|
const v3Schema = schema;
|
|
23834
23880
|
rawShape = v3Schema.shape;
|
|
@@ -23838,17 +23884,16 @@ function getObjectShape(schema) {
|
|
|
23838
23884
|
if (typeof rawShape === "function") {
|
|
23839
23885
|
try {
|
|
23840
23886
|
return rawShape();
|
|
23841
|
-
} catch
|
|
23887
|
+
} catch {
|
|
23842
23888
|
return void 0;
|
|
23843
23889
|
}
|
|
23844
23890
|
}
|
|
23845
23891
|
return rawShape;
|
|
23846
23892
|
}
|
|
23847
23893
|
function getLiteralValue(schema) {
|
|
23848
|
-
var _a;
|
|
23849
23894
|
if (isZ4Schema(schema)) {
|
|
23850
23895
|
const v4Schema = schema;
|
|
23851
|
-
const def2 =
|
|
23896
|
+
const def2 = v4Schema._zod?.def;
|
|
23852
23897
|
if (def2) {
|
|
23853
23898
|
if (def2.value !== void 0)
|
|
23854
23899
|
return def2.value;
|
|
@@ -23877,7 +23922,7 @@ function isTerminal(status) {
|
|
|
23877
23922
|
new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
23878
23923
|
function getMethodLiteral(schema) {
|
|
23879
23924
|
const shape = getObjectShape(schema);
|
|
23880
|
-
const methodSchema = shape
|
|
23925
|
+
const methodSchema = shape?.method;
|
|
23881
23926
|
if (!methodSchema) {
|
|
23882
23927
|
throw new Error("Schema is missing a method literal");
|
|
23883
23928
|
}
|
|
@@ -23919,8 +23964,8 @@ class Protocol {
|
|
|
23919
23964
|
// Automatic pong by default.
|
|
23920
23965
|
(_request) => ({})
|
|
23921
23966
|
);
|
|
23922
|
-
this._taskStore = _options
|
|
23923
|
-
this._taskMessageQueue = _options
|
|
23967
|
+
this._taskStore = _options?.taskStore;
|
|
23968
|
+
this._taskMessageQueue = _options?.taskMessageQueue;
|
|
23924
23969
|
if (this._taskStore) {
|
|
23925
23970
|
this.setRequestHandler(GetTaskRequestSchema, async (request, extra) => {
|
|
23926
23971
|
const task = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
|
|
@@ -23933,7 +23978,6 @@ class Protocol {
|
|
|
23933
23978
|
});
|
|
23934
23979
|
this.setRequestHandler(GetTaskPayloadRequestSchema, async (request, extra) => {
|
|
23935
23980
|
const handleTaskResult = async () => {
|
|
23936
|
-
var _a;
|
|
23937
23981
|
const taskId = request.params.taskId;
|
|
23938
23982
|
if (this._taskMessageQueue) {
|
|
23939
23983
|
let queuedMessage;
|
|
@@ -23957,7 +24001,7 @@ class Protocol {
|
|
|
23957
24001
|
}
|
|
23958
24002
|
continue;
|
|
23959
24003
|
}
|
|
23960
|
-
await
|
|
24004
|
+
await this._transport?.send(queuedMessage.message, { relatedRequestId: extra.requestId });
|
|
23961
24005
|
}
|
|
23962
24006
|
}
|
|
23963
24007
|
const task = await this._taskStore.getTask(taskId, extra.sessionId);
|
|
@@ -23986,9 +24030,8 @@ class Protocol {
|
|
|
23986
24030
|
return await handleTaskResult();
|
|
23987
24031
|
});
|
|
23988
24032
|
this.setRequestHandler(ListTasksRequestSchema, async (request, extra) => {
|
|
23989
|
-
var _a;
|
|
23990
24033
|
try {
|
|
23991
|
-
const { tasks, nextCursor } = await this._taskStore.listTasks(
|
|
24034
|
+
const { tasks, nextCursor } = await this._taskStore.listTasks(request.params?.cursor, extra.sessionId);
|
|
23992
24035
|
return {
|
|
23993
24036
|
tasks,
|
|
23994
24037
|
nextCursor,
|
|
@@ -24027,8 +24070,11 @@ class Protocol {
|
|
|
24027
24070
|
}
|
|
24028
24071
|
}
|
|
24029
24072
|
async _oncancel(notification) {
|
|
24073
|
+
if (!notification.params.requestId) {
|
|
24074
|
+
return;
|
|
24075
|
+
}
|
|
24030
24076
|
const controller = this._requestHandlerAbortControllers.get(notification.params.requestId);
|
|
24031
|
-
controller
|
|
24077
|
+
controller?.abort(notification.params.reason);
|
|
24032
24078
|
}
|
|
24033
24079
|
_setupTimeout(messageId, timeout, maxTotalTimeout, onTimeout, resetTimeoutOnProgress = false) {
|
|
24034
24080
|
this._timeoutInfo.set(messageId, {
|
|
@@ -24069,22 +24115,21 @@ class Protocol {
|
|
|
24069
24115
|
* The Protocol object assumes ownership of the Transport, replacing any callbacks that have already been set, and expects that it is the only user of the Transport instance going forward.
|
|
24070
24116
|
*/
|
|
24071
24117
|
async connect(transport) {
|
|
24072
|
-
var _a, _b, _c;
|
|
24073
24118
|
this._transport = transport;
|
|
24074
|
-
const _onclose =
|
|
24119
|
+
const _onclose = this.transport?.onclose;
|
|
24075
24120
|
this._transport.onclose = () => {
|
|
24076
|
-
_onclose
|
|
24121
|
+
_onclose?.();
|
|
24077
24122
|
this._onclose();
|
|
24078
24123
|
};
|
|
24079
|
-
const _onerror =
|
|
24124
|
+
const _onerror = this.transport?.onerror;
|
|
24080
24125
|
this._transport.onerror = (error) => {
|
|
24081
|
-
_onerror
|
|
24126
|
+
_onerror?.(error);
|
|
24082
24127
|
this._onerror(error);
|
|
24083
24128
|
};
|
|
24084
|
-
const _onmessage =
|
|
24129
|
+
const _onmessage = this._transport?.onmessage;
|
|
24085
24130
|
this._transport.onmessage = (message, extra) => {
|
|
24086
|
-
_onmessage
|
|
24087
|
-
if (
|
|
24131
|
+
_onmessage?.(message, extra);
|
|
24132
|
+
if (isJSONRPCResultResponse(message) || isJSONRPCErrorResponse(message)) {
|
|
24088
24133
|
this._onresponse(message);
|
|
24089
24134
|
} else if (isJSONRPCRequest(message)) {
|
|
24090
24135
|
this._onrequest(message, extra);
|
|
@@ -24097,7 +24142,6 @@ class Protocol {
|
|
|
24097
24142
|
await this._transport.start();
|
|
24098
24143
|
}
|
|
24099
24144
|
_onclose() {
|
|
24100
|
-
var _a;
|
|
24101
24145
|
const responseHandlers = this._responseHandlers;
|
|
24102
24146
|
this._responseHandlers = /* @__PURE__ */ new Map();
|
|
24103
24147
|
this._progressHandlers.clear();
|
|
@@ -24105,28 +24149,25 @@ class Protocol {
|
|
|
24105
24149
|
this._pendingDebouncedNotifications.clear();
|
|
24106
24150
|
const error = McpError.fromError(ErrorCode.ConnectionClosed, "Connection closed");
|
|
24107
24151
|
this._transport = void 0;
|
|
24108
|
-
|
|
24152
|
+
this.onclose?.();
|
|
24109
24153
|
for (const handler of responseHandlers.values()) {
|
|
24110
24154
|
handler(error);
|
|
24111
24155
|
}
|
|
24112
24156
|
}
|
|
24113
24157
|
_onerror(error) {
|
|
24114
|
-
|
|
24115
|
-
(_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);
|
|
24158
|
+
this.onerror?.(error);
|
|
24116
24159
|
}
|
|
24117
24160
|
_onnotification(notification) {
|
|
24118
|
-
|
|
24119
|
-
const handler = (_a = this._notificationHandlers.get(notification.method)) !== null && _a !== void 0 ? _a : this.fallbackNotificationHandler;
|
|
24161
|
+
const handler = this._notificationHandlers.get(notification.method) ?? this.fallbackNotificationHandler;
|
|
24120
24162
|
if (handler === void 0) {
|
|
24121
24163
|
return;
|
|
24122
24164
|
}
|
|
24123
24165
|
Promise.resolve().then(() => handler(notification)).catch((error) => this._onerror(new Error(`Uncaught error in notification handler: ${error}`)));
|
|
24124
24166
|
}
|
|
24125
24167
|
_onrequest(request, extra) {
|
|
24126
|
-
|
|
24127
|
-
const handler = (_a = this._requestHandlers.get(request.method)) !== null && _a !== void 0 ? _a : this.fallbackRequestHandler;
|
|
24168
|
+
const handler = this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;
|
|
24128
24169
|
const capturedTransport = this._transport;
|
|
24129
|
-
const relatedTaskId =
|
|
24170
|
+
const relatedTaskId = request.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
|
|
24130
24171
|
if (handler === void 0) {
|
|
24131
24172
|
const errorResponse = {
|
|
24132
24173
|
jsonrpc: "2.0",
|
|
@@ -24141,20 +24182,20 @@ class Protocol {
|
|
|
24141
24182
|
type: "error",
|
|
24142
24183
|
message: errorResponse,
|
|
24143
24184
|
timestamp: Date.now()
|
|
24144
|
-
}, capturedTransport
|
|
24185
|
+
}, capturedTransport?.sessionId).catch((error) => this._onerror(new Error(`Failed to enqueue error response: ${error}`)));
|
|
24145
24186
|
} else {
|
|
24146
|
-
capturedTransport
|
|
24187
|
+
capturedTransport?.send(errorResponse).catch((error) => this._onerror(new Error(`Failed to send an error response: ${error}`)));
|
|
24147
24188
|
}
|
|
24148
24189
|
return;
|
|
24149
24190
|
}
|
|
24150
24191
|
const abortController = new AbortController();
|
|
24151
24192
|
this._requestHandlerAbortControllers.set(request.id, abortController);
|
|
24152
|
-
const taskCreationParams = (
|
|
24153
|
-
const taskStore = this._taskStore ? this.requestTaskStore(request, capturedTransport
|
|
24193
|
+
const taskCreationParams = isTaskAugmentedRequestParams(request.params) ? request.params.task : void 0;
|
|
24194
|
+
const taskStore = this._taskStore ? this.requestTaskStore(request, capturedTransport?.sessionId) : void 0;
|
|
24154
24195
|
const fullExtra = {
|
|
24155
24196
|
signal: abortController.signal,
|
|
24156
|
-
sessionId: capturedTransport
|
|
24157
|
-
_meta:
|
|
24197
|
+
sessionId: capturedTransport?.sessionId,
|
|
24198
|
+
_meta: request.params?._meta,
|
|
24158
24199
|
sendNotification: async (notification) => {
|
|
24159
24200
|
const notificationOptions = { relatedRequestId: request.id };
|
|
24160
24201
|
if (relatedTaskId) {
|
|
@@ -24163,25 +24204,24 @@ class Protocol {
|
|
|
24163
24204
|
await this.notification(notification, notificationOptions);
|
|
24164
24205
|
},
|
|
24165
24206
|
sendRequest: async (r2, resultSchema, options) => {
|
|
24166
|
-
var _a2, _b2;
|
|
24167
24207
|
const requestOptions = { ...options, relatedRequestId: request.id };
|
|
24168
24208
|
if (relatedTaskId && !requestOptions.relatedTask) {
|
|
24169
24209
|
requestOptions.relatedTask = { taskId: relatedTaskId };
|
|
24170
24210
|
}
|
|
24171
|
-
const effectiveTaskId =
|
|
24211
|
+
const effectiveTaskId = requestOptions.relatedTask?.taskId ?? relatedTaskId;
|
|
24172
24212
|
if (effectiveTaskId && taskStore) {
|
|
24173
24213
|
await taskStore.updateTaskStatus(effectiveTaskId, "input_required");
|
|
24174
24214
|
}
|
|
24175
24215
|
return await this.request(r2, resultSchema, requestOptions);
|
|
24176
24216
|
},
|
|
24177
|
-
authInfo: extra
|
|
24217
|
+
authInfo: extra?.authInfo,
|
|
24178
24218
|
requestId: request.id,
|
|
24179
|
-
requestInfo: extra
|
|
24219
|
+
requestInfo: extra?.requestInfo,
|
|
24180
24220
|
taskId: relatedTaskId,
|
|
24181
24221
|
taskStore,
|
|
24182
|
-
taskRequestedTtl: taskCreationParams
|
|
24183
|
-
closeSSEStream: extra
|
|
24184
|
-
closeStandaloneSSEStream: extra
|
|
24222
|
+
taskRequestedTtl: taskCreationParams?.ttl,
|
|
24223
|
+
closeSSEStream: extra?.closeSSEStream,
|
|
24224
|
+
closeStandaloneSSEStream: extra?.closeStandaloneSSEStream
|
|
24185
24225
|
};
|
|
24186
24226
|
Promise.resolve().then(() => {
|
|
24187
24227
|
if (taskCreationParams) {
|
|
@@ -24201,12 +24241,11 @@ class Protocol {
|
|
|
24201
24241
|
type: "response",
|
|
24202
24242
|
message: response,
|
|
24203
24243
|
timestamp: Date.now()
|
|
24204
|
-
}, capturedTransport
|
|
24244
|
+
}, capturedTransport?.sessionId);
|
|
24205
24245
|
} else {
|
|
24206
|
-
await
|
|
24246
|
+
await capturedTransport?.send(response);
|
|
24207
24247
|
}
|
|
24208
24248
|
}, async (error) => {
|
|
24209
|
-
var _a2;
|
|
24210
24249
|
if (abortController.signal.aborted) {
|
|
24211
24250
|
return;
|
|
24212
24251
|
}
|
|
@@ -24215,7 +24254,7 @@ class Protocol {
|
|
|
24215
24254
|
id: request.id,
|
|
24216
24255
|
error: {
|
|
24217
24256
|
code: Number.isSafeInteger(error["code"]) ? error["code"] : ErrorCode.InternalError,
|
|
24218
|
-
message:
|
|
24257
|
+
message: error.message ?? "Internal error",
|
|
24219
24258
|
...error["data"] !== void 0 && { data: error["data"] }
|
|
24220
24259
|
}
|
|
24221
24260
|
};
|
|
@@ -24224,9 +24263,9 @@ class Protocol {
|
|
|
24224
24263
|
type: "error",
|
|
24225
24264
|
message: errorResponse,
|
|
24226
24265
|
timestamp: Date.now()
|
|
24227
|
-
}, capturedTransport
|
|
24266
|
+
}, capturedTransport?.sessionId);
|
|
24228
24267
|
} else {
|
|
24229
|
-
await
|
|
24268
|
+
await capturedTransport?.send(errorResponse);
|
|
24230
24269
|
}
|
|
24231
24270
|
}).catch((error) => this._onerror(new Error(`Failed to send response: ${error}`))).finally(() => {
|
|
24232
24271
|
this._requestHandlerAbortControllers.delete(request.id);
|
|
@@ -24260,7 +24299,7 @@ class Protocol {
|
|
|
24260
24299
|
const resolver = this._requestResolvers.get(messageId);
|
|
24261
24300
|
if (resolver) {
|
|
24262
24301
|
this._requestResolvers.delete(messageId);
|
|
24263
|
-
if (
|
|
24302
|
+
if (isJSONRPCResultResponse(response)) {
|
|
24264
24303
|
resolver(response);
|
|
24265
24304
|
} else {
|
|
24266
24305
|
const error = new McpError(response.error.code, response.error.message, response.error.data);
|
|
@@ -24276,7 +24315,7 @@ class Protocol {
|
|
|
24276
24315
|
this._responseHandlers.delete(messageId);
|
|
24277
24316
|
this._cleanupTimeout(messageId);
|
|
24278
24317
|
let isTaskResponse = false;
|
|
24279
|
-
if (
|
|
24318
|
+
if (isJSONRPCResultResponse(response) && response.result && typeof response.result === "object") {
|
|
24280
24319
|
const result = response.result;
|
|
24281
24320
|
if (result.task && typeof result.task === "object") {
|
|
24282
24321
|
const task = result.task;
|
|
@@ -24289,7 +24328,7 @@ class Protocol {
|
|
|
24289
24328
|
if (!isTaskResponse) {
|
|
24290
24329
|
this._progressHandlers.delete(messageId);
|
|
24291
24330
|
}
|
|
24292
|
-
if (
|
|
24331
|
+
if (isJSONRPCResultResponse(response)) {
|
|
24293
24332
|
handler(response);
|
|
24294
24333
|
} else {
|
|
24295
24334
|
const error = McpError.fromError(response.error.code, response.error.message, response.error.data);
|
|
@@ -24303,8 +24342,7 @@ class Protocol {
|
|
|
24303
24342
|
* Closes the connection.
|
|
24304
24343
|
*/
|
|
24305
24344
|
async close() {
|
|
24306
|
-
|
|
24307
|
-
await ((_a = this._transport) === null || _a === void 0 ? void 0 : _a.close());
|
|
24345
|
+
await this._transport?.close();
|
|
24308
24346
|
}
|
|
24309
24347
|
/**
|
|
24310
24348
|
* Sends a request and returns an AsyncGenerator that yields response messages.
|
|
@@ -24334,8 +24372,7 @@ class Protocol {
|
|
|
24334
24372
|
* @experimental Use `client.experimental.tasks.requestStream()` to access this method.
|
|
24335
24373
|
*/
|
|
24336
24374
|
async *requestStream(request, resultSchema, options) {
|
|
24337
|
-
|
|
24338
|
-
const { task } = options !== null && options !== void 0 ? options : {};
|
|
24375
|
+
const { task } = options ?? {};
|
|
24339
24376
|
if (!task) {
|
|
24340
24377
|
try {
|
|
24341
24378
|
const result = await this.request(request, resultSchema, options);
|
|
@@ -24382,9 +24419,9 @@ class Protocol {
|
|
|
24382
24419
|
yield { type: "result", result };
|
|
24383
24420
|
return;
|
|
24384
24421
|
}
|
|
24385
|
-
const pollInterval =
|
|
24422
|
+
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
24386
24423
|
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
24387
|
-
|
|
24424
|
+
options?.signal?.throwIfAborted();
|
|
24388
24425
|
}
|
|
24389
24426
|
} catch (error) {
|
|
24390
24427
|
yield {
|
|
@@ -24399,9 +24436,8 @@ class Protocol {
|
|
|
24399
24436
|
* Do not use this method to emit notifications! Use notification() instead.
|
|
24400
24437
|
*/
|
|
24401
24438
|
request(request, resultSchema, options) {
|
|
24402
|
-
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options
|
|
24439
|
+
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
24403
24440
|
return new Promise((resolve2, reject) => {
|
|
24404
|
-
var _a, _b, _c, _d, _e2, _f, _g;
|
|
24405
24441
|
const earlyReject = (error) => {
|
|
24406
24442
|
reject(error);
|
|
24407
24443
|
};
|
|
@@ -24409,7 +24445,7 @@ class Protocol {
|
|
|
24409
24445
|
earlyReject(new Error("Not connected"));
|
|
24410
24446
|
return;
|
|
24411
24447
|
}
|
|
24412
|
-
if (
|
|
24448
|
+
if (this._options?.enforceStrictCapabilities === true) {
|
|
24413
24449
|
try {
|
|
24414
24450
|
this.assertCapabilityForMethod(request.method);
|
|
24415
24451
|
if (task) {
|
|
@@ -24420,19 +24456,19 @@ class Protocol {
|
|
|
24420
24456
|
return;
|
|
24421
24457
|
}
|
|
24422
24458
|
}
|
|
24423
|
-
|
|
24459
|
+
options?.signal?.throwIfAborted();
|
|
24424
24460
|
const messageId = this._requestMessageId++;
|
|
24425
24461
|
const jsonrpcRequest = {
|
|
24426
24462
|
...request,
|
|
24427
24463
|
jsonrpc: "2.0",
|
|
24428
24464
|
id: messageId
|
|
24429
24465
|
};
|
|
24430
|
-
if (options
|
|
24466
|
+
if (options?.onprogress) {
|
|
24431
24467
|
this._progressHandlers.set(messageId, options.onprogress);
|
|
24432
24468
|
jsonrpcRequest.params = {
|
|
24433
24469
|
...request.params,
|
|
24434
24470
|
_meta: {
|
|
24435
|
-
...
|
|
24471
|
+
...request.params?._meta || {},
|
|
24436
24472
|
progressToken: messageId
|
|
24437
24473
|
}
|
|
24438
24474
|
};
|
|
@@ -24447,17 +24483,16 @@ class Protocol {
|
|
|
24447
24483
|
jsonrpcRequest.params = {
|
|
24448
24484
|
...jsonrpcRequest.params,
|
|
24449
24485
|
_meta: {
|
|
24450
|
-
...
|
|
24486
|
+
...jsonrpcRequest.params?._meta || {},
|
|
24451
24487
|
[RELATED_TASK_META_KEY]: relatedTask
|
|
24452
24488
|
}
|
|
24453
24489
|
};
|
|
24454
24490
|
}
|
|
24455
24491
|
const cancel = (reason) => {
|
|
24456
|
-
var _a2;
|
|
24457
24492
|
this._responseHandlers.delete(messageId);
|
|
24458
24493
|
this._progressHandlers.delete(messageId);
|
|
24459
24494
|
this._cleanupTimeout(messageId);
|
|
24460
|
-
|
|
24495
|
+
this._transport?.send({
|
|
24461
24496
|
jsonrpc: "2.0",
|
|
24462
24497
|
method: "notifications/cancelled",
|
|
24463
24498
|
params: {
|
|
@@ -24469,8 +24504,7 @@ class Protocol {
|
|
|
24469
24504
|
reject(error);
|
|
24470
24505
|
};
|
|
24471
24506
|
this._responseHandlers.set(messageId, (response) => {
|
|
24472
|
-
|
|
24473
|
-
if ((_a2 = options === null || options === void 0 ? void 0 : options.signal) === null || _a2 === void 0 ? void 0 : _a2.aborted) {
|
|
24507
|
+
if (options?.signal?.aborted) {
|
|
24474
24508
|
return;
|
|
24475
24509
|
}
|
|
24476
24510
|
if (response instanceof Error) {
|
|
@@ -24487,14 +24521,13 @@ class Protocol {
|
|
|
24487
24521
|
reject(error);
|
|
24488
24522
|
}
|
|
24489
24523
|
});
|
|
24490
|
-
|
|
24491
|
-
|
|
24492
|
-
cancel((_a2 = options === null || options === void 0 ? void 0 : options.signal) === null || _a2 === void 0 ? void 0 : _a2.reason);
|
|
24524
|
+
options?.signal?.addEventListener("abort", () => {
|
|
24525
|
+
cancel(options?.signal?.reason);
|
|
24493
24526
|
});
|
|
24494
|
-
const timeout =
|
|
24527
|
+
const timeout = options?.timeout ?? DEFAULT_REQUEST_TIMEOUT_MSEC;
|
|
24495
24528
|
const timeoutHandler = () => cancel(McpError.fromError(ErrorCode.RequestTimeout, "Request timed out", { timeout }));
|
|
24496
|
-
this._setupTimeout(messageId, timeout, options
|
|
24497
|
-
const relatedTaskId = relatedTask
|
|
24529
|
+
this._setupTimeout(messageId, timeout, options?.maxTotalTimeout, timeoutHandler, options?.resetTimeoutOnProgress ?? false);
|
|
24530
|
+
const relatedTaskId = relatedTask?.taskId;
|
|
24498
24531
|
if (relatedTaskId) {
|
|
24499
24532
|
const responseResolver = (response) => {
|
|
24500
24533
|
const handler = this._responseHandlers.get(messageId);
|
|
@@ -24557,12 +24590,11 @@ class Protocol {
|
|
|
24557
24590
|
* Emits a notification, which is a one-way message that does not expect a response.
|
|
24558
24591
|
*/
|
|
24559
24592
|
async notification(notification, options) {
|
|
24560
|
-
var _a, _b, _c, _d, _e2;
|
|
24561
24593
|
if (!this._transport) {
|
|
24562
24594
|
throw new Error("Not connected");
|
|
24563
24595
|
}
|
|
24564
24596
|
this.assertNotificationCapability(notification.method);
|
|
24565
|
-
const relatedTaskId =
|
|
24597
|
+
const relatedTaskId = options?.relatedTask?.taskId;
|
|
24566
24598
|
if (relatedTaskId) {
|
|
24567
24599
|
const jsonrpcNotification2 = {
|
|
24568
24600
|
...notification,
|
|
@@ -24570,7 +24602,7 @@ class Protocol {
|
|
|
24570
24602
|
params: {
|
|
24571
24603
|
...notification.params,
|
|
24572
24604
|
_meta: {
|
|
24573
|
-
...
|
|
24605
|
+
...notification.params?._meta || {},
|
|
24574
24606
|
[RELATED_TASK_META_KEY]: options.relatedTask
|
|
24575
24607
|
}
|
|
24576
24608
|
}
|
|
@@ -24582,15 +24614,14 @@ class Protocol {
|
|
|
24582
24614
|
});
|
|
24583
24615
|
return;
|
|
24584
24616
|
}
|
|
24585
|
-
const debouncedMethods =
|
|
24586
|
-
const canDebounce = debouncedMethods.includes(notification.method) && !notification.params && !
|
|
24617
|
+
const debouncedMethods = this._options?.debouncedNotificationMethods ?? [];
|
|
24618
|
+
const canDebounce = debouncedMethods.includes(notification.method) && !notification.params && !options?.relatedRequestId && !options?.relatedTask;
|
|
24587
24619
|
if (canDebounce) {
|
|
24588
24620
|
if (this._pendingDebouncedNotifications.has(notification.method)) {
|
|
24589
24621
|
return;
|
|
24590
24622
|
}
|
|
24591
24623
|
this._pendingDebouncedNotifications.add(notification.method);
|
|
24592
24624
|
Promise.resolve().then(() => {
|
|
24593
|
-
var _a2, _b2;
|
|
24594
24625
|
this._pendingDebouncedNotifications.delete(notification.method);
|
|
24595
24626
|
if (!this._transport) {
|
|
24596
24627
|
return;
|
|
@@ -24599,19 +24630,19 @@ class Protocol {
|
|
|
24599
24630
|
...notification,
|
|
24600
24631
|
jsonrpc: "2.0"
|
|
24601
24632
|
};
|
|
24602
|
-
if (options
|
|
24633
|
+
if (options?.relatedTask) {
|
|
24603
24634
|
jsonrpcNotification2 = {
|
|
24604
24635
|
...jsonrpcNotification2,
|
|
24605
24636
|
params: {
|
|
24606
24637
|
...jsonrpcNotification2.params,
|
|
24607
24638
|
_meta: {
|
|
24608
|
-
...
|
|
24639
|
+
...jsonrpcNotification2.params?._meta || {},
|
|
24609
24640
|
[RELATED_TASK_META_KEY]: options.relatedTask
|
|
24610
24641
|
}
|
|
24611
24642
|
}
|
|
24612
24643
|
};
|
|
24613
24644
|
}
|
|
24614
|
-
|
|
24645
|
+
this._transport?.send(jsonrpcNotification2, options).catch((error) => this._onerror(error));
|
|
24615
24646
|
});
|
|
24616
24647
|
return;
|
|
24617
24648
|
}
|
|
@@ -24619,13 +24650,13 @@ class Protocol {
|
|
|
24619
24650
|
...notification,
|
|
24620
24651
|
jsonrpc: "2.0"
|
|
24621
24652
|
};
|
|
24622
|
-
if (options
|
|
24653
|
+
if (options?.relatedTask) {
|
|
24623
24654
|
jsonrpcNotification = {
|
|
24624
24655
|
...jsonrpcNotification,
|
|
24625
24656
|
params: {
|
|
24626
24657
|
...jsonrpcNotification.params,
|
|
24627
24658
|
_meta: {
|
|
24628
|
-
...
|
|
24659
|
+
...jsonrpcNotification.params?._meta || {},
|
|
24629
24660
|
[RELATED_TASK_META_KEY]: options.relatedTask
|
|
24630
24661
|
}
|
|
24631
24662
|
}
|
|
@@ -24701,11 +24732,10 @@ class Protocol {
|
|
|
24701
24732
|
* simply propagates the error.
|
|
24702
24733
|
*/
|
|
24703
24734
|
async _enqueueTaskMessage(taskId, message, sessionId) {
|
|
24704
|
-
var _a;
|
|
24705
24735
|
if (!this._taskStore || !this._taskMessageQueue) {
|
|
24706
24736
|
throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
|
|
24707
24737
|
}
|
|
24708
|
-
const maxQueueSize =
|
|
24738
|
+
const maxQueueSize = this._options?.maxTaskQueueSize;
|
|
24709
24739
|
await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
|
|
24710
24740
|
}
|
|
24711
24741
|
/**
|
|
@@ -24738,14 +24768,13 @@ class Protocol {
|
|
|
24738
24768
|
* @returns Promise that resolves when an update occurs or rejects if aborted
|
|
24739
24769
|
*/
|
|
24740
24770
|
async _waitForTaskUpdate(taskId, signal) {
|
|
24741
|
-
|
|
24742
|
-
let interval = (_b = (_a = this._options) === null || _a === void 0 ? void 0 : _a.defaultTaskPollInterval) !== null && _b !== void 0 ? _b : 1e3;
|
|
24771
|
+
let interval = this._options?.defaultTaskPollInterval ?? 1e3;
|
|
24743
24772
|
try {
|
|
24744
|
-
const task = await
|
|
24745
|
-
if (task
|
|
24773
|
+
const task = await this._taskStore?.getTask(taskId);
|
|
24774
|
+
if (task?.pollInterval) {
|
|
24746
24775
|
interval = task.pollInterval;
|
|
24747
24776
|
}
|
|
24748
|
-
} catch
|
|
24777
|
+
} catch {
|
|
24749
24778
|
}
|
|
24750
24779
|
return new Promise((resolve2, reject) => {
|
|
24751
24780
|
if (signal.aborted) {
|
|
@@ -31119,6 +31148,7 @@ function requireAjv() {
|
|
|
31119
31148
|
return ajv.exports;
|
|
31120
31149
|
}
|
|
31121
31150
|
var ajvExports = requireAjv();
|
|
31151
|
+
const Ajv = /* @__PURE__ */ getDefaultExportFromCjs(ajvExports);
|
|
31122
31152
|
var dist = { exports: {} };
|
|
31123
31153
|
var formats = {};
|
|
31124
31154
|
var hasRequiredFormats;
|
|
@@ -31445,7 +31475,7 @@ function requireDist() {
|
|
|
31445
31475
|
var distExports = requireDist();
|
|
31446
31476
|
const _addFormats = /* @__PURE__ */ getDefaultExportFromCjs(distExports);
|
|
31447
31477
|
function createDefaultAjvInstance() {
|
|
31448
|
-
const ajv2 = new
|
|
31478
|
+
const ajv2 = new Ajv({
|
|
31449
31479
|
strict: false,
|
|
31450
31480
|
validateFormats: true,
|
|
31451
31481
|
validateSchema: false,
|
|
@@ -31477,7 +31507,7 @@ class AjvJsonSchemaValidator {
|
|
|
31477
31507
|
* ```
|
|
31478
31508
|
*/
|
|
31479
31509
|
constructor(ajv2) {
|
|
31480
|
-
this._ajv = ajv2
|
|
31510
|
+
this._ajv = ajv2 ?? createDefaultAjvInstance();
|
|
31481
31511
|
}
|
|
31482
31512
|
/**
|
|
31483
31513
|
* Create a validator for the given JSON Schema
|
|
@@ -31489,8 +31519,7 @@ class AjvJsonSchemaValidator {
|
|
|
31489
31519
|
* @returns A validator function that validates input data
|
|
31490
31520
|
*/
|
|
31491
31521
|
getValidator(schema) {
|
|
31492
|
-
|
|
31493
|
-
const ajvValidator = "$id" in schema && typeof schema.$id === "string" ? (_a = this._ajv.getSchema(schema.$id)) !== null && _a !== void 0 ? _a : this._ajv.compile(schema) : this._ajv.compile(schema);
|
|
31522
|
+
const ajvValidator = "$id" in schema && typeof schema.$id === "string" ? this._ajv.getSchema(schema.$id) ?? this._ajv.compile(schema) : this._ajv.compile(schema);
|
|
31494
31523
|
return (input) => {
|
|
31495
31524
|
const valid = ajvValidator(input);
|
|
31496
31525
|
if (valid) {
|
|
@@ -31550,13 +31579,12 @@ class ExperimentalClientTasks {
|
|
|
31550
31579
|
* @experimental
|
|
31551
31580
|
*/
|
|
31552
31581
|
async *callToolStream(params, resultSchema = CallToolResultSchema, options) {
|
|
31553
|
-
var _a;
|
|
31554
31582
|
const clientInternal = this._client;
|
|
31555
31583
|
const optionsWithTask = {
|
|
31556
31584
|
...options,
|
|
31557
31585
|
// We check if the tool is known to be a task during auto-configuration, but assume
|
|
31558
31586
|
// the caller knows what they're doing if they pass this explicitly
|
|
31559
|
-
task:
|
|
31587
|
+
task: options?.task ?? (clientInternal.isToolTask(params.name) ? {} : void 0)
|
|
31560
31588
|
};
|
|
31561
31589
|
const stream = clientInternal.requestStream({ method: "tools/call", params }, resultSchema, optionsWithTask);
|
|
31562
31590
|
const validator = clientInternal.getToolOutputValidator(params.name);
|
|
@@ -31663,31 +31691,29 @@ class ExperimentalClientTasks {
|
|
|
31663
31691
|
}
|
|
31664
31692
|
}
|
|
31665
31693
|
function assertToolsCallTaskCapability(requests, method, entityName) {
|
|
31666
|
-
var _a;
|
|
31667
31694
|
if (!requests) {
|
|
31668
31695
|
throw new Error(`${entityName} does not support task creation (required for ${method})`);
|
|
31669
31696
|
}
|
|
31670
31697
|
switch (method) {
|
|
31671
31698
|
case "tools/call":
|
|
31672
|
-
if (!
|
|
31699
|
+
if (!requests.tools?.call) {
|
|
31673
31700
|
throw new Error(`${entityName} does not support task creation for tools/call (required for ${method})`);
|
|
31674
31701
|
}
|
|
31675
31702
|
break;
|
|
31676
31703
|
}
|
|
31677
31704
|
}
|
|
31678
31705
|
function assertClientRequestTaskCapability(requests, method, entityName) {
|
|
31679
|
-
var _a, _b;
|
|
31680
31706
|
if (!requests) {
|
|
31681
31707
|
throw new Error(`${entityName} does not support task creation (required for ${method})`);
|
|
31682
31708
|
}
|
|
31683
31709
|
switch (method) {
|
|
31684
31710
|
case "sampling/createMessage":
|
|
31685
|
-
if (!
|
|
31711
|
+
if (!requests.sampling?.createMessage) {
|
|
31686
31712
|
throw new Error(`${entityName} does not support task creation for sampling/createMessage (required for ${method})`);
|
|
31687
31713
|
}
|
|
31688
31714
|
break;
|
|
31689
31715
|
case "elicitation/create":
|
|
31690
|
-
if (!
|
|
31716
|
+
if (!requests.elicitation?.create) {
|
|
31691
31717
|
throw new Error(`${entityName} does not support task creation for elicitation/create (required for ${method})`);
|
|
31692
31718
|
}
|
|
31693
31719
|
break;
|
|
@@ -31711,12 +31737,16 @@ function applyElicitationDefaults(schema, data2) {
|
|
|
31711
31737
|
}
|
|
31712
31738
|
if (Array.isArray(schema.anyOf)) {
|
|
31713
31739
|
for (const sub of schema.anyOf) {
|
|
31714
|
-
|
|
31740
|
+
if (typeof sub !== "boolean") {
|
|
31741
|
+
applyElicitationDefaults(sub, data2);
|
|
31742
|
+
}
|
|
31715
31743
|
}
|
|
31716
31744
|
}
|
|
31717
31745
|
if (Array.isArray(schema.oneOf)) {
|
|
31718
31746
|
for (const sub of schema.oneOf) {
|
|
31719
|
-
|
|
31747
|
+
if (typeof sub !== "boolean") {
|
|
31748
|
+
applyElicitationDefaults(sub, data2);
|
|
31749
|
+
}
|
|
31720
31750
|
}
|
|
31721
31751
|
}
|
|
31722
31752
|
}
|
|
@@ -31735,14 +31765,43 @@ class Client extends Protocol {
|
|
|
31735
31765
|
* Initializes this client with the given name and version information.
|
|
31736
31766
|
*/
|
|
31737
31767
|
constructor(_clientInfo, options) {
|
|
31738
|
-
var _a, _b;
|
|
31739
31768
|
super(options);
|
|
31740
31769
|
this._clientInfo = _clientInfo;
|
|
31741
31770
|
this._cachedToolOutputValidators = /* @__PURE__ */ new Map();
|
|
31742
31771
|
this._cachedKnownTaskTools = /* @__PURE__ */ new Set();
|
|
31743
31772
|
this._cachedRequiredTaskTools = /* @__PURE__ */ new Set();
|
|
31744
|
-
this.
|
|
31745
|
-
this.
|
|
31773
|
+
this._listChangedDebounceTimers = /* @__PURE__ */ new Map();
|
|
31774
|
+
this._capabilities = options?.capabilities ?? {};
|
|
31775
|
+
this._jsonSchemaValidator = options?.jsonSchemaValidator ?? new AjvJsonSchemaValidator();
|
|
31776
|
+
if (options?.listChanged) {
|
|
31777
|
+
this._pendingListChangedConfig = options.listChanged;
|
|
31778
|
+
}
|
|
31779
|
+
}
|
|
31780
|
+
/**
|
|
31781
|
+
* Set up handlers for list changed notifications based on config and server capabilities.
|
|
31782
|
+
* This should only be called after initialization when server capabilities are known.
|
|
31783
|
+
* Handlers are silently skipped if the server doesn't advertise the corresponding listChanged capability.
|
|
31784
|
+
* @internal
|
|
31785
|
+
*/
|
|
31786
|
+
_setupListChangedHandlers(config2) {
|
|
31787
|
+
if (config2.tools && this._serverCapabilities?.tools?.listChanged) {
|
|
31788
|
+
this._setupListChangedHandler("tools", ToolListChangedNotificationSchema, config2.tools, async () => {
|
|
31789
|
+
const result = await this.listTools();
|
|
31790
|
+
return result.tools;
|
|
31791
|
+
});
|
|
31792
|
+
}
|
|
31793
|
+
if (config2.prompts && this._serverCapabilities?.prompts?.listChanged) {
|
|
31794
|
+
this._setupListChangedHandler("prompts", PromptListChangedNotificationSchema, config2.prompts, async () => {
|
|
31795
|
+
const result = await this.listPrompts();
|
|
31796
|
+
return result.prompts;
|
|
31797
|
+
});
|
|
31798
|
+
}
|
|
31799
|
+
if (config2.resources && this._serverCapabilities?.resources?.listChanged) {
|
|
31800
|
+
this._setupListChangedHandler("resources", ResourceListChangedNotificationSchema, config2.resources, async () => {
|
|
31801
|
+
const result = await this.listResources();
|
|
31802
|
+
return result.resources;
|
|
31803
|
+
});
|
|
31804
|
+
}
|
|
31746
31805
|
}
|
|
31747
31806
|
/**
|
|
31748
31807
|
* Access experimental features.
|
|
@@ -31774,21 +31833,20 @@ class Client extends Protocol {
|
|
|
31774
31833
|
* Override request handler registration to enforce client-side validation for elicitation.
|
|
31775
31834
|
*/
|
|
31776
31835
|
setRequestHandler(requestSchema, handler) {
|
|
31777
|
-
var _a, _b, _c;
|
|
31778
31836
|
const shape = getObjectShape(requestSchema);
|
|
31779
|
-
const methodSchema = shape
|
|
31837
|
+
const methodSchema = shape?.method;
|
|
31780
31838
|
if (!methodSchema) {
|
|
31781
31839
|
throw new Error("Schema is missing a method literal");
|
|
31782
31840
|
}
|
|
31783
31841
|
let methodValue;
|
|
31784
31842
|
if (isZ4Schema(methodSchema)) {
|
|
31785
31843
|
const v4Schema = methodSchema;
|
|
31786
|
-
const v4Def =
|
|
31787
|
-
methodValue =
|
|
31844
|
+
const v4Def = v4Schema._zod?.def;
|
|
31845
|
+
methodValue = v4Def?.value ?? v4Schema.value;
|
|
31788
31846
|
} else {
|
|
31789
31847
|
const v3Schema = methodSchema;
|
|
31790
31848
|
const legacyDef = v3Schema._def;
|
|
31791
|
-
methodValue =
|
|
31849
|
+
methodValue = legacyDef?.value ?? v3Schema.value;
|
|
31792
31850
|
}
|
|
31793
31851
|
if (typeof methodValue !== "string") {
|
|
31794
31852
|
throw new Error("Schema method literal must be a string");
|
|
@@ -31796,19 +31854,18 @@ class Client extends Protocol {
|
|
|
31796
31854
|
const method = methodValue;
|
|
31797
31855
|
if (method === "elicitation/create") {
|
|
31798
31856
|
const wrappedHandler = async (request, extra) => {
|
|
31799
|
-
var _a2, _b2, _c2;
|
|
31800
31857
|
const validatedRequest = safeParse(ElicitRequestSchema, request);
|
|
31801
31858
|
if (!validatedRequest.success) {
|
|
31802
31859
|
const errorMessage = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
|
|
31803
31860
|
throw new McpError(ErrorCode.InvalidParams, `Invalid elicitation request: ${errorMessage}`);
|
|
31804
31861
|
}
|
|
31805
31862
|
const { params } = validatedRequest.data;
|
|
31806
|
-
|
|
31863
|
+
params.mode = params.mode ?? "form";
|
|
31807
31864
|
const { supportsFormMode, supportsUrlMode } = getSupportedElicitationModes(this._capabilities.elicitation);
|
|
31808
|
-
if (mode === "form" && !supportsFormMode) {
|
|
31865
|
+
if (params.mode === "form" && !supportsFormMode) {
|
|
31809
31866
|
throw new McpError(ErrorCode.InvalidParams, "Client does not support form-mode elicitation requests");
|
|
31810
31867
|
}
|
|
31811
|
-
if (mode === "url" && !supportsUrlMode) {
|
|
31868
|
+
if (params.mode === "url" && !supportsUrlMode) {
|
|
31812
31869
|
throw new McpError(ErrorCode.InvalidParams, "Client does not support URL-mode elicitation requests");
|
|
31813
31870
|
}
|
|
31814
31871
|
const result = await Promise.resolve(handler(request, extra));
|
|
@@ -31826,12 +31883,12 @@ class Client extends Protocol {
|
|
|
31826
31883
|
throw new McpError(ErrorCode.InvalidParams, `Invalid elicitation result: ${errorMessage}`);
|
|
31827
31884
|
}
|
|
31828
31885
|
const validatedResult = validationResult.data;
|
|
31829
|
-
const requestedSchema = mode === "form" ? params.requestedSchema : void 0;
|
|
31830
|
-
if (mode === "form" && validatedResult.action === "accept" && validatedResult.content && requestedSchema) {
|
|
31831
|
-
if (
|
|
31886
|
+
const requestedSchema = params.mode === "form" ? params.requestedSchema : void 0;
|
|
31887
|
+
if (params.mode === "form" && validatedResult.action === "accept" && validatedResult.content && requestedSchema) {
|
|
31888
|
+
if (this._capabilities.elicitation?.form?.applyDefaults) {
|
|
31832
31889
|
try {
|
|
31833
31890
|
applyElicitationDefaults(requestedSchema, validatedResult.content);
|
|
31834
|
-
} catch
|
|
31891
|
+
} catch {
|
|
31835
31892
|
}
|
|
31836
31893
|
}
|
|
31837
31894
|
}
|
|
@@ -31868,8 +31925,7 @@ class Client extends Protocol {
|
|
|
31868
31925
|
return super.setRequestHandler(requestSchema, handler);
|
|
31869
31926
|
}
|
|
31870
31927
|
assertCapability(capability, method) {
|
|
31871
|
-
|
|
31872
|
-
if (!((_a = this._serverCapabilities) === null || _a === void 0 ? void 0 : _a[capability])) {
|
|
31928
|
+
if (!this._serverCapabilities?.[capability]) {
|
|
31873
31929
|
throw new Error(`Server does not support ${capability} (required for ${method})`);
|
|
31874
31930
|
}
|
|
31875
31931
|
}
|
|
@@ -31902,6 +31958,10 @@ class Client extends Protocol {
|
|
|
31902
31958
|
await this.notification({
|
|
31903
31959
|
method: "notifications/initialized"
|
|
31904
31960
|
});
|
|
31961
|
+
if (this._pendingListChangedConfig) {
|
|
31962
|
+
this._setupListChangedHandlers(this._pendingListChangedConfig);
|
|
31963
|
+
this._pendingListChangedConfig = void 0;
|
|
31964
|
+
}
|
|
31905
31965
|
} catch (error) {
|
|
31906
31966
|
void this.close();
|
|
31907
31967
|
throw error;
|
|
@@ -31926,16 +31986,15 @@ class Client extends Protocol {
|
|
|
31926
31986
|
return this._instructions;
|
|
31927
31987
|
}
|
|
31928
31988
|
assertCapabilityForMethod(method) {
|
|
31929
|
-
var _a, _b, _c, _d, _e2;
|
|
31930
31989
|
switch (method) {
|
|
31931
31990
|
case "logging/setLevel":
|
|
31932
|
-
if (!
|
|
31991
|
+
if (!this._serverCapabilities?.logging) {
|
|
31933
31992
|
throw new Error(`Server does not support logging (required for ${method})`);
|
|
31934
31993
|
}
|
|
31935
31994
|
break;
|
|
31936
31995
|
case "prompts/get":
|
|
31937
31996
|
case "prompts/list":
|
|
31938
|
-
if (!
|
|
31997
|
+
if (!this._serverCapabilities?.prompts) {
|
|
31939
31998
|
throw new Error(`Server does not support prompts (required for ${method})`);
|
|
31940
31999
|
}
|
|
31941
32000
|
break;
|
|
@@ -31944,7 +32003,7 @@ class Client extends Protocol {
|
|
|
31944
32003
|
case "resources/read":
|
|
31945
32004
|
case "resources/subscribe":
|
|
31946
32005
|
case "resources/unsubscribe":
|
|
31947
|
-
if (!
|
|
32006
|
+
if (!this._serverCapabilities?.resources) {
|
|
31948
32007
|
throw new Error(`Server does not support resources (required for ${method})`);
|
|
31949
32008
|
}
|
|
31950
32009
|
if (method === "resources/subscribe" && !this._serverCapabilities.resources.subscribe) {
|
|
@@ -31953,22 +32012,21 @@ class Client extends Protocol {
|
|
|
31953
32012
|
break;
|
|
31954
32013
|
case "tools/call":
|
|
31955
32014
|
case "tools/list":
|
|
31956
|
-
if (!
|
|
32015
|
+
if (!this._serverCapabilities?.tools) {
|
|
31957
32016
|
throw new Error(`Server does not support tools (required for ${method})`);
|
|
31958
32017
|
}
|
|
31959
32018
|
break;
|
|
31960
32019
|
case "completion/complete":
|
|
31961
|
-
if (!
|
|
32020
|
+
if (!this._serverCapabilities?.completions) {
|
|
31962
32021
|
throw new Error(`Server does not support completions (required for ${method})`);
|
|
31963
32022
|
}
|
|
31964
32023
|
break;
|
|
31965
32024
|
}
|
|
31966
32025
|
}
|
|
31967
32026
|
assertNotificationCapability(method) {
|
|
31968
|
-
var _a;
|
|
31969
32027
|
switch (method) {
|
|
31970
32028
|
case "notifications/roots/list_changed":
|
|
31971
|
-
if (!
|
|
32029
|
+
if (!this._capabilities.roots?.listChanged) {
|
|
31972
32030
|
throw new Error(`Client does not support roots list changed notifications (required for ${method})`);
|
|
31973
32031
|
}
|
|
31974
32032
|
break;
|
|
@@ -32005,15 +32063,13 @@ class Client extends Protocol {
|
|
|
32005
32063
|
}
|
|
32006
32064
|
}
|
|
32007
32065
|
assertTaskCapability(method) {
|
|
32008
|
-
|
|
32009
|
-
assertToolsCallTaskCapability((_b = (_a = this._serverCapabilities) === null || _a === void 0 ? void 0 : _a.tasks) === null || _b === void 0 ? void 0 : _b.requests, method, "Server");
|
|
32066
|
+
assertToolsCallTaskCapability(this._serverCapabilities?.tasks?.requests, method, "Server");
|
|
32010
32067
|
}
|
|
32011
32068
|
assertTaskHandlerCapability(method) {
|
|
32012
|
-
var _a;
|
|
32013
32069
|
if (!this._capabilities) {
|
|
32014
32070
|
return;
|
|
32015
32071
|
}
|
|
32016
|
-
assertClientRequestTaskCapability(
|
|
32072
|
+
assertClientRequestTaskCapability(this._capabilities.tasks?.requests, method, "Client");
|
|
32017
32073
|
}
|
|
32018
32074
|
async ping(options) {
|
|
32019
32075
|
return this.request({ method: "ping" }, EmptyResultSchema, options);
|
|
@@ -32077,8 +32133,7 @@ class Client extends Protocol {
|
|
|
32077
32133
|
return result;
|
|
32078
32134
|
}
|
|
32079
32135
|
isToolTask(toolName) {
|
|
32080
|
-
|
|
32081
|
-
if (!((_d = (_c = (_b = (_a = this._serverCapabilities) === null || _a === void 0 ? void 0 : _a.tasks) === null || _b === void 0 ? void 0 : _b.requests) === null || _c === void 0 ? void 0 : _c.tools) === null || _d === void 0 ? void 0 : _d.call)) {
|
|
32136
|
+
if (!this._serverCapabilities?.tasks?.requests?.tools?.call) {
|
|
32082
32137
|
return false;
|
|
32083
32138
|
}
|
|
32084
32139
|
return this._cachedKnownTaskTools.has(toolName);
|
|
@@ -32095,7 +32150,6 @@ class Client extends Protocol {
|
|
|
32095
32150
|
* Called after listTools() to pre-compile validators for better performance.
|
|
32096
32151
|
*/
|
|
32097
32152
|
cacheToolMetadata(tools) {
|
|
32098
|
-
var _a;
|
|
32099
32153
|
this._cachedToolOutputValidators.clear();
|
|
32100
32154
|
this._cachedKnownTaskTools.clear();
|
|
32101
32155
|
this._cachedRequiredTaskTools.clear();
|
|
@@ -32104,7 +32158,7 @@ class Client extends Protocol {
|
|
|
32104
32158
|
const toolValidator = this._jsonSchemaValidator.getValidator(tool.outputSchema);
|
|
32105
32159
|
this._cachedToolOutputValidators.set(tool.name, toolValidator);
|
|
32106
32160
|
}
|
|
32107
|
-
const taskSupport =
|
|
32161
|
+
const taskSupport = tool.execution?.taskSupport;
|
|
32108
32162
|
if (taskSupport === "required" || taskSupport === "optional") {
|
|
32109
32163
|
this._cachedKnownTaskTools.add(tool.name);
|
|
32110
32164
|
}
|
|
@@ -32124,6 +32178,47 @@ class Client extends Protocol {
|
|
|
32124
32178
|
this.cacheToolMetadata(result.tools);
|
|
32125
32179
|
return result;
|
|
32126
32180
|
}
|
|
32181
|
+
/**
|
|
32182
|
+
* Set up a single list changed handler.
|
|
32183
|
+
* @internal
|
|
32184
|
+
*/
|
|
32185
|
+
_setupListChangedHandler(listType, notificationSchema, options, fetcher) {
|
|
32186
|
+
const parseResult = ListChangedOptionsBaseSchema.safeParse(options);
|
|
32187
|
+
if (!parseResult.success) {
|
|
32188
|
+
throw new Error(`Invalid ${listType} listChanged options: ${parseResult.error.message}`);
|
|
32189
|
+
}
|
|
32190
|
+
if (typeof options.onChanged !== "function") {
|
|
32191
|
+
throw new Error(`Invalid ${listType} listChanged options: onChanged must be a function`);
|
|
32192
|
+
}
|
|
32193
|
+
const { autoRefresh, debounceMs } = parseResult.data;
|
|
32194
|
+
const { onChanged } = options;
|
|
32195
|
+
const refresh = async () => {
|
|
32196
|
+
if (!autoRefresh) {
|
|
32197
|
+
onChanged(null, null);
|
|
32198
|
+
return;
|
|
32199
|
+
}
|
|
32200
|
+
try {
|
|
32201
|
+
const items2 = await fetcher();
|
|
32202
|
+
onChanged(null, items2);
|
|
32203
|
+
} catch (e) {
|
|
32204
|
+
const error = e instanceof Error ? e : new Error(String(e));
|
|
32205
|
+
onChanged(error, null);
|
|
32206
|
+
}
|
|
32207
|
+
};
|
|
32208
|
+
const handler = () => {
|
|
32209
|
+
if (debounceMs) {
|
|
32210
|
+
const existingTimer = this._listChangedDebounceTimers.get(listType);
|
|
32211
|
+
if (existingTimer) {
|
|
32212
|
+
clearTimeout(existingTimer);
|
|
32213
|
+
}
|
|
32214
|
+
const timer = setTimeout(refresh, debounceMs);
|
|
32215
|
+
this._listChangedDebounceTimers.set(listType, timer);
|
|
32216
|
+
} else {
|
|
32217
|
+
refresh();
|
|
32218
|
+
}
|
|
32219
|
+
};
|
|
32220
|
+
this.setNotificationHandler(notificationSchema, handler);
|
|
32221
|
+
}
|
|
32127
32222
|
async sendRootsListChanged() {
|
|
32128
32223
|
return this.notification({ method: "notifications/roots/list_changed" });
|
|
32129
32224
|
}
|
|
@@ -32516,7 +32611,7 @@ function createFetchWithInit(baseFetch = fetch, baseInit) {
|
|
|
32516
32611
|
...baseInit,
|
|
32517
32612
|
...init,
|
|
32518
32613
|
// Headers need special handling - merge instead of replace
|
|
32519
|
-
headers:
|
|
32614
|
+
headers: init?.headers ? { ...normalizeHeaders(baseInit.headers), ...normalizeHeaders(init.headers) } : baseInit.headers
|
|
32520
32615
|
};
|
|
32521
32616
|
return baseFetch(url2, mergedInit);
|
|
32522
32617
|
};
|
|
@@ -32533,14 +32628,13 @@ class SSEClientTransport {
|
|
|
32533
32628
|
this._url = url2;
|
|
32534
32629
|
this._resourceMetadataUrl = void 0;
|
|
32535
32630
|
this._scope = void 0;
|
|
32536
|
-
this._eventSourceInit = opts
|
|
32537
|
-
this._requestInit = opts
|
|
32538
|
-
this._authProvider = opts
|
|
32539
|
-
this._fetch = opts
|
|
32540
|
-
this._fetchWithInit = createFetchWithInit(opts
|
|
32631
|
+
this._eventSourceInit = opts?.eventSourceInit;
|
|
32632
|
+
this._requestInit = opts?.requestInit;
|
|
32633
|
+
this._authProvider = opts?.authProvider;
|
|
32634
|
+
this._fetch = opts?.fetch;
|
|
32635
|
+
this._fetchWithInit = createFetchWithInit(opts?.fetch, opts?.requestInit);
|
|
32541
32636
|
}
|
|
32542
32637
|
async _authThenStart() {
|
|
32543
|
-
var _a;
|
|
32544
32638
|
if (!this._authProvider) {
|
|
32545
32639
|
throw new UnauthorizedError("No auth provider");
|
|
32546
32640
|
}
|
|
@@ -32553,7 +32647,7 @@ class SSEClientTransport {
|
|
|
32553
32647
|
fetchFn: this._fetchWithInit
|
|
32554
32648
|
});
|
|
32555
32649
|
} catch (error) {
|
|
32556
|
-
|
|
32650
|
+
this.onerror?.(error);
|
|
32557
32651
|
throw error;
|
|
32558
32652
|
}
|
|
32559
32653
|
if (result !== "AUTHORIZED") {
|
|
@@ -32562,7 +32656,6 @@ class SSEClientTransport {
|
|
|
32562
32656
|
return await this._startOrAuth();
|
|
32563
32657
|
}
|
|
32564
32658
|
async _commonHeaders() {
|
|
32565
|
-
var _a;
|
|
32566
32659
|
const headers = {};
|
|
32567
32660
|
if (this._authProvider) {
|
|
32568
32661
|
const tokens = await this._authProvider.tokens();
|
|
@@ -32573,15 +32666,14 @@ class SSEClientTransport {
|
|
|
32573
32666
|
if (this._protocolVersion) {
|
|
32574
32667
|
headers["mcp-protocol-version"] = this._protocolVersion;
|
|
32575
32668
|
}
|
|
32576
|
-
const extraHeaders = normalizeHeaders(
|
|
32669
|
+
const extraHeaders = normalizeHeaders(this._requestInit?.headers);
|
|
32577
32670
|
return new Headers({
|
|
32578
32671
|
...headers,
|
|
32579
32672
|
...extraHeaders
|
|
32580
32673
|
});
|
|
32581
32674
|
}
|
|
32582
32675
|
_startOrAuth() {
|
|
32583
|
-
|
|
32584
|
-
const fetchImpl = (_c = (_b = (_a = this === null || this === void 0 ? void 0 : this._eventSourceInit) === null || _a === void 0 ? void 0 : _a.fetch) !== null && _b !== void 0 ? _b : this._fetch) !== null && _c !== void 0 ? _c : fetch;
|
|
32676
|
+
const fetchImpl = this?._eventSourceInit?.fetch ?? this._fetch ?? fetch;
|
|
32585
32677
|
return new Promise((resolve2, reject) => {
|
|
32586
32678
|
this._eventSource = new EventSource(this._url.href, {
|
|
32587
32679
|
...this._eventSourceInit,
|
|
@@ -32602,19 +32694,17 @@ class SSEClientTransport {
|
|
|
32602
32694
|
});
|
|
32603
32695
|
this._abortController = new AbortController();
|
|
32604
32696
|
this._eventSource.onerror = (event) => {
|
|
32605
|
-
var _a2;
|
|
32606
32697
|
if (event.code === 401 && this._authProvider) {
|
|
32607
32698
|
this._authThenStart().then(resolve2, reject);
|
|
32608
32699
|
return;
|
|
32609
32700
|
}
|
|
32610
32701
|
const error = new SseError(event.code, event.message, event);
|
|
32611
32702
|
reject(error);
|
|
32612
|
-
|
|
32703
|
+
this.onerror?.(error);
|
|
32613
32704
|
};
|
|
32614
32705
|
this._eventSource.onopen = () => {
|
|
32615
32706
|
};
|
|
32616
32707
|
this._eventSource.addEventListener("endpoint", (event) => {
|
|
32617
|
-
var _a2;
|
|
32618
32708
|
const messageEvent = event;
|
|
32619
32709
|
try {
|
|
32620
32710
|
this._endpoint = new URL(messageEvent.data, this._url);
|
|
@@ -32623,23 +32713,22 @@ class SSEClientTransport {
|
|
|
32623
32713
|
}
|
|
32624
32714
|
} catch (error) {
|
|
32625
32715
|
reject(error);
|
|
32626
|
-
|
|
32716
|
+
this.onerror?.(error);
|
|
32627
32717
|
void this.close();
|
|
32628
32718
|
return;
|
|
32629
32719
|
}
|
|
32630
32720
|
resolve2();
|
|
32631
32721
|
});
|
|
32632
32722
|
this._eventSource.onmessage = (event) => {
|
|
32633
|
-
var _a2, _b2;
|
|
32634
32723
|
const messageEvent = event;
|
|
32635
32724
|
let message;
|
|
32636
32725
|
try {
|
|
32637
32726
|
message = JSONRPCMessageSchema.parse(JSON.parse(messageEvent.data));
|
|
32638
32727
|
} catch (error) {
|
|
32639
|
-
|
|
32728
|
+
this.onerror?.(error);
|
|
32640
32729
|
return;
|
|
32641
32730
|
}
|
|
32642
|
-
|
|
32731
|
+
this.onmessage?.(message);
|
|
32643
32732
|
};
|
|
32644
32733
|
});
|
|
32645
32734
|
}
|
|
@@ -32668,13 +32757,11 @@ class SSEClientTransport {
|
|
|
32668
32757
|
}
|
|
32669
32758
|
}
|
|
32670
32759
|
async close() {
|
|
32671
|
-
|
|
32672
|
-
|
|
32673
|
-
|
|
32674
|
-
(_c = this.onclose) === null || _c === void 0 ? void 0 : _c.call(this);
|
|
32760
|
+
this._abortController?.abort();
|
|
32761
|
+
this._eventSource?.close();
|
|
32762
|
+
this.onclose?.();
|
|
32675
32763
|
}
|
|
32676
32764
|
async send(message) {
|
|
32677
|
-
var _a, _b, _c, _d;
|
|
32678
32765
|
if (!this._endpoint) {
|
|
32679
32766
|
throw new Error("Not connected");
|
|
32680
32767
|
}
|
|
@@ -32686,9 +32773,9 @@ class SSEClientTransport {
|
|
|
32686
32773
|
method: "POST",
|
|
32687
32774
|
headers,
|
|
32688
32775
|
body: JSON.stringify(message),
|
|
32689
|
-
signal:
|
|
32776
|
+
signal: this._abortController?.signal
|
|
32690
32777
|
};
|
|
32691
|
-
const response = await (
|
|
32778
|
+
const response = await (this._fetch ?? fetch)(this._endpoint, init);
|
|
32692
32779
|
if (!response.ok) {
|
|
32693
32780
|
const text = await response.text().catch(() => null);
|
|
32694
32781
|
if (response.status === 401 && this._authProvider) {
|
|
@@ -32708,9 +32795,9 @@ class SSEClientTransport {
|
|
|
32708
32795
|
}
|
|
32709
32796
|
throw new Error(`Error POSTing to endpoint (HTTP ${response.status}): ${text}`);
|
|
32710
32797
|
}
|
|
32711
|
-
await
|
|
32798
|
+
await response.body?.cancel();
|
|
32712
32799
|
} catch (error) {
|
|
32713
|
-
|
|
32800
|
+
this.onerror?.(error);
|
|
32714
32801
|
throw error;
|
|
32715
32802
|
}
|
|
32716
32803
|
}
|
|
@@ -32754,20 +32841,18 @@ class StreamableHTTPError extends Error {
|
|
|
32754
32841
|
}
|
|
32755
32842
|
class StreamableHTTPClientTransport {
|
|
32756
32843
|
constructor(url2, opts) {
|
|
32757
|
-
var _a;
|
|
32758
32844
|
this._hasCompletedAuthFlow = false;
|
|
32759
32845
|
this._url = url2;
|
|
32760
32846
|
this._resourceMetadataUrl = void 0;
|
|
32761
32847
|
this._scope = void 0;
|
|
32762
|
-
this._requestInit = opts
|
|
32763
|
-
this._authProvider = opts
|
|
32764
|
-
this._fetch = opts
|
|
32765
|
-
this._fetchWithInit = createFetchWithInit(opts
|
|
32766
|
-
this._sessionId = opts
|
|
32767
|
-
this._reconnectionOptions =
|
|
32848
|
+
this._requestInit = opts?.requestInit;
|
|
32849
|
+
this._authProvider = opts?.authProvider;
|
|
32850
|
+
this._fetch = opts?.fetch;
|
|
32851
|
+
this._fetchWithInit = createFetchWithInit(opts?.fetch, opts?.requestInit);
|
|
32852
|
+
this._sessionId = opts?.sessionId;
|
|
32853
|
+
this._reconnectionOptions = opts?.reconnectionOptions ?? DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS;
|
|
32768
32854
|
}
|
|
32769
32855
|
async _authThenStart() {
|
|
32770
|
-
var _a;
|
|
32771
32856
|
if (!this._authProvider) {
|
|
32772
32857
|
throw new UnauthorizedError("No auth provider");
|
|
32773
32858
|
}
|
|
@@ -32780,7 +32865,7 @@ class StreamableHTTPClientTransport {
|
|
|
32780
32865
|
fetchFn: this._fetchWithInit
|
|
32781
32866
|
});
|
|
32782
32867
|
} catch (error) {
|
|
32783
|
-
|
|
32868
|
+
this.onerror?.(error);
|
|
32784
32869
|
throw error;
|
|
32785
32870
|
}
|
|
32786
32871
|
if (result !== "AUTHORIZED") {
|
|
@@ -32789,7 +32874,6 @@ class StreamableHTTPClientTransport {
|
|
|
32789
32874
|
return await this._startOrAuthSse({ resumptionToken: void 0 });
|
|
32790
32875
|
}
|
|
32791
32876
|
async _commonHeaders() {
|
|
32792
|
-
var _a;
|
|
32793
32877
|
const headers = {};
|
|
32794
32878
|
if (this._authProvider) {
|
|
32795
32879
|
const tokens = await this._authProvider.tokens();
|
|
@@ -32803,14 +32887,13 @@ class StreamableHTTPClientTransport {
|
|
|
32803
32887
|
if (this._protocolVersion) {
|
|
32804
32888
|
headers["mcp-protocol-version"] = this._protocolVersion;
|
|
32805
32889
|
}
|
|
32806
|
-
const extraHeaders = normalizeHeaders(
|
|
32890
|
+
const extraHeaders = normalizeHeaders(this._requestInit?.headers);
|
|
32807
32891
|
return new Headers({
|
|
32808
32892
|
...headers,
|
|
32809
32893
|
...extraHeaders
|
|
32810
32894
|
});
|
|
32811
32895
|
}
|
|
32812
32896
|
async _startOrAuthSse(options) {
|
|
32813
|
-
var _a, _b, _c, _d;
|
|
32814
32897
|
const { resumptionToken } = options;
|
|
32815
32898
|
try {
|
|
32816
32899
|
const headers = await this._commonHeaders();
|
|
@@ -32818,13 +32901,13 @@ class StreamableHTTPClientTransport {
|
|
|
32818
32901
|
if (resumptionToken) {
|
|
32819
32902
|
headers.set("last-event-id", resumptionToken);
|
|
32820
32903
|
}
|
|
32821
|
-
const response = await (
|
|
32904
|
+
const response = await (this._fetch ?? fetch)(this._url, {
|
|
32822
32905
|
method: "GET",
|
|
32823
32906
|
headers,
|
|
32824
|
-
signal:
|
|
32907
|
+
signal: this._abortController?.signal
|
|
32825
32908
|
});
|
|
32826
32909
|
if (!response.ok) {
|
|
32827
|
-
await
|
|
32910
|
+
await response.body?.cancel();
|
|
32828
32911
|
if (response.status === 401 && this._authProvider) {
|
|
32829
32912
|
return await this._authThenStart();
|
|
32830
32913
|
}
|
|
@@ -32835,7 +32918,7 @@ class StreamableHTTPClientTransport {
|
|
|
32835
32918
|
}
|
|
32836
32919
|
this._handleSseStream(response.body, options, true);
|
|
32837
32920
|
} catch (error) {
|
|
32838
|
-
|
|
32921
|
+
this.onerror?.(error);
|
|
32839
32922
|
throw error;
|
|
32840
32923
|
}
|
|
32841
32924
|
}
|
|
@@ -32861,17 +32944,15 @@ class StreamableHTTPClientTransport {
|
|
|
32861
32944
|
* @param attemptCount Current reconnection attempt count for this specific stream
|
|
32862
32945
|
*/
|
|
32863
32946
|
_scheduleReconnection(options, attemptCount = 0) {
|
|
32864
|
-
var _a;
|
|
32865
32947
|
const maxRetries = this._reconnectionOptions.maxRetries;
|
|
32866
32948
|
if (attemptCount >= maxRetries) {
|
|
32867
|
-
|
|
32949
|
+
this.onerror?.(new Error(`Maximum reconnection attempts (${maxRetries}) exceeded.`));
|
|
32868
32950
|
return;
|
|
32869
32951
|
}
|
|
32870
32952
|
const delay = this._getNextReconnectionDelay(attemptCount);
|
|
32871
32953
|
this._reconnectionTimeout = setTimeout(() => {
|
|
32872
32954
|
this._startOrAuthSse(options).catch((error) => {
|
|
32873
|
-
|
|
32874
|
-
(_a2 = this.onerror) === null || _a2 === void 0 ? void 0 : _a2.call(this, new Error(`Failed to reconnect SSE stream: ${error instanceof Error ? error.message : String(error)}`));
|
|
32955
|
+
this.onerror?.(new Error(`Failed to reconnect SSE stream: ${error instanceof Error ? error.message : String(error)}`));
|
|
32875
32956
|
this._scheduleReconnection(options, attemptCount + 1);
|
|
32876
32957
|
});
|
|
32877
32958
|
}, delay);
|
|
@@ -32885,7 +32966,6 @@ class StreamableHTTPClientTransport {
|
|
|
32885
32966
|
let hasPrimingEvent = false;
|
|
32886
32967
|
let receivedResponse = false;
|
|
32887
32968
|
const processStream = async () => {
|
|
32888
|
-
var _a, _b, _c, _d;
|
|
32889
32969
|
try {
|
|
32890
32970
|
const reader = stream.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream({
|
|
32891
32971
|
onRetry: (retryMs) => {
|
|
@@ -32900,7 +32980,7 @@ class StreamableHTTPClientTransport {
|
|
|
32900
32980
|
if (event.id) {
|
|
32901
32981
|
lastEventId = event.id;
|
|
32902
32982
|
hasPrimingEvent = true;
|
|
32903
|
-
onresumptiontoken
|
|
32983
|
+
onresumptiontoken?.(event.id);
|
|
32904
32984
|
}
|
|
32905
32985
|
if (!event.data) {
|
|
32906
32986
|
continue;
|
|
@@ -32908,15 +32988,15 @@ class StreamableHTTPClientTransport {
|
|
|
32908
32988
|
if (!event.event || event.event === "message") {
|
|
32909
32989
|
try {
|
|
32910
32990
|
const message = JSONRPCMessageSchema.parse(JSON.parse(event.data));
|
|
32911
|
-
if (
|
|
32991
|
+
if (isJSONRPCResultResponse(message)) {
|
|
32912
32992
|
receivedResponse = true;
|
|
32913
32993
|
if (replayMessageId !== void 0) {
|
|
32914
32994
|
message.id = replayMessageId;
|
|
32915
32995
|
}
|
|
32916
32996
|
}
|
|
32917
|
-
|
|
32997
|
+
this.onmessage?.(message);
|
|
32918
32998
|
} catch (error) {
|
|
32919
|
-
|
|
32999
|
+
this.onerror?.(error);
|
|
32920
33000
|
}
|
|
32921
33001
|
}
|
|
32922
33002
|
}
|
|
@@ -32930,7 +33010,7 @@ class StreamableHTTPClientTransport {
|
|
|
32930
33010
|
}, 0);
|
|
32931
33011
|
}
|
|
32932
33012
|
} catch (error) {
|
|
32933
|
-
|
|
33013
|
+
this.onerror?.(new Error(`SSE stream disconnected: ${error}`));
|
|
32934
33014
|
const canResume = isReconnectable || hasPrimingEvent;
|
|
32935
33015
|
const needsReconnect = canResume && !receivedResponse;
|
|
32936
33016
|
if (needsReconnect && this._abortController && !this._abortController.signal.aborted) {
|
|
@@ -32941,7 +33021,7 @@ class StreamableHTTPClientTransport {
|
|
|
32941
33021
|
replayMessageId
|
|
32942
33022
|
}, 0);
|
|
32943
33023
|
} catch (error2) {
|
|
32944
|
-
|
|
33024
|
+
this.onerror?.(new Error(`Failed to reconnect: ${error2 instanceof Error ? error2.message : String(error2)}`));
|
|
32945
33025
|
}
|
|
32946
33026
|
}
|
|
32947
33027
|
}
|
|
@@ -32973,23 +33053,18 @@ class StreamableHTTPClientTransport {
|
|
|
32973
33053
|
}
|
|
32974
33054
|
}
|
|
32975
33055
|
async close() {
|
|
32976
|
-
var _a, _b;
|
|
32977
33056
|
if (this._reconnectionTimeout) {
|
|
32978
33057
|
clearTimeout(this._reconnectionTimeout);
|
|
32979
33058
|
this._reconnectionTimeout = void 0;
|
|
32980
33059
|
}
|
|
32981
|
-
|
|
32982
|
-
|
|
33060
|
+
this._abortController?.abort();
|
|
33061
|
+
this.onclose?.();
|
|
32983
33062
|
}
|
|
32984
33063
|
async send(message, options) {
|
|
32985
|
-
var _a, _b, _c, _d, _e2, _f, _g;
|
|
32986
33064
|
try {
|
|
32987
33065
|
const { resumptionToken, onresumptiontoken } = options || {};
|
|
32988
33066
|
if (resumptionToken) {
|
|
32989
|
-
this._startOrAuthSse({ resumptionToken, replayMessageId: isJSONRPCRequest(message) ? message.id : void 0 }).catch((err) =>
|
|
32990
|
-
var _a2;
|
|
32991
|
-
return (_a2 = this.onerror) === null || _a2 === void 0 ? void 0 : _a2.call(this, err);
|
|
32992
|
-
});
|
|
33067
|
+
this._startOrAuthSse({ resumptionToken, replayMessageId: isJSONRPCRequest(message) ? message.id : void 0 }).catch((err) => this.onerror?.(err));
|
|
32993
33068
|
return;
|
|
32994
33069
|
}
|
|
32995
33070
|
const headers = await this._commonHeaders();
|
|
@@ -33000,9 +33075,9 @@ class StreamableHTTPClientTransport {
|
|
|
33000
33075
|
method: "POST",
|
|
33001
33076
|
headers,
|
|
33002
33077
|
body: JSON.stringify(message),
|
|
33003
|
-
signal:
|
|
33078
|
+
signal: this._abortController?.signal
|
|
33004
33079
|
};
|
|
33005
|
-
const response = await (
|
|
33080
|
+
const response = await (this._fetch ?? fetch)(this._url, init);
|
|
33006
33081
|
const sessionId = response.headers.get("mcp-session-id");
|
|
33007
33082
|
if (sessionId) {
|
|
33008
33083
|
this._sessionId = sessionId;
|
|
@@ -33041,7 +33116,7 @@ class StreamableHTTPClientTransport {
|
|
|
33041
33116
|
if (resourceMetadataUrl) {
|
|
33042
33117
|
this._resourceMetadataUrl = resourceMetadataUrl;
|
|
33043
33118
|
}
|
|
33044
|
-
this._lastUpscopingHeader = wwwAuthHeader
|
|
33119
|
+
this._lastUpscopingHeader = wwwAuthHeader ?? void 0;
|
|
33045
33120
|
const result = await auth(this._authProvider, {
|
|
33046
33121
|
serverUrl: this._url,
|
|
33047
33122
|
resourceMetadataUrl: this._resourceMetadataUrl,
|
|
@@ -33059,12 +33134,9 @@ class StreamableHTTPClientTransport {
|
|
|
33059
33134
|
this._hasCompletedAuthFlow = false;
|
|
33060
33135
|
this._lastUpscopingHeader = void 0;
|
|
33061
33136
|
if (response.status === 202) {
|
|
33062
|
-
await
|
|
33137
|
+
await response.body?.cancel();
|
|
33063
33138
|
if (isInitializedNotification(message)) {
|
|
33064
|
-
this._startOrAuthSse({ resumptionToken: void 0 }).catch((err) =>
|
|
33065
|
-
var _a2;
|
|
33066
|
-
return (_a2 = this.onerror) === null || _a2 === void 0 ? void 0 : _a2.call(this, err);
|
|
33067
|
-
});
|
|
33139
|
+
this._startOrAuthSse({ resumptionToken: void 0 }).catch((err) => this.onerror?.(err));
|
|
33068
33140
|
}
|
|
33069
33141
|
return;
|
|
33070
33142
|
}
|
|
@@ -33072,23 +33144,23 @@ class StreamableHTTPClientTransport {
|
|
|
33072
33144
|
const hasRequests = messages.filter((msg) => "method" in msg && "id" in msg && msg.id !== void 0).length > 0;
|
|
33073
33145
|
const contentType = response.headers.get("content-type");
|
|
33074
33146
|
if (hasRequests) {
|
|
33075
|
-
if (contentType
|
|
33147
|
+
if (contentType?.includes("text/event-stream")) {
|
|
33076
33148
|
this._handleSseStream(response.body, { onresumptiontoken }, false);
|
|
33077
|
-
} else if (contentType
|
|
33149
|
+
} else if (contentType?.includes("application/json")) {
|
|
33078
33150
|
const data2 = await response.json();
|
|
33079
33151
|
const responseMessages = Array.isArray(data2) ? data2.map((msg) => JSONRPCMessageSchema.parse(msg)) : [JSONRPCMessageSchema.parse(data2)];
|
|
33080
33152
|
for (const msg of responseMessages) {
|
|
33081
|
-
|
|
33153
|
+
this.onmessage?.(msg);
|
|
33082
33154
|
}
|
|
33083
33155
|
} else {
|
|
33084
|
-
await
|
|
33156
|
+
await response.body?.cancel();
|
|
33085
33157
|
throw new StreamableHTTPError(-1, `Unexpected content type: ${contentType}`);
|
|
33086
33158
|
}
|
|
33087
33159
|
} else {
|
|
33088
|
-
await
|
|
33160
|
+
await response.body?.cancel();
|
|
33089
33161
|
}
|
|
33090
33162
|
} catch (error) {
|
|
33091
|
-
|
|
33163
|
+
this.onerror?.(error);
|
|
33092
33164
|
throw error;
|
|
33093
33165
|
}
|
|
33094
33166
|
}
|
|
@@ -33107,7 +33179,6 @@ class StreamableHTTPClientTransport {
|
|
|
33107
33179
|
* the server does not allow clients to terminate sessions.
|
|
33108
33180
|
*/
|
|
33109
33181
|
async terminateSession() {
|
|
33110
|
-
var _a, _b, _c, _d;
|
|
33111
33182
|
if (!this._sessionId) {
|
|
33112
33183
|
return;
|
|
33113
33184
|
}
|
|
@@ -33117,16 +33188,16 @@ class StreamableHTTPClientTransport {
|
|
|
33117
33188
|
...this._requestInit,
|
|
33118
33189
|
method: "DELETE",
|
|
33119
33190
|
headers,
|
|
33120
|
-
signal:
|
|
33191
|
+
signal: this._abortController?.signal
|
|
33121
33192
|
};
|
|
33122
|
-
const response = await (
|
|
33123
|
-
await
|
|
33193
|
+
const response = await (this._fetch ?? fetch)(this._url, init);
|
|
33194
|
+
await response.body?.cancel();
|
|
33124
33195
|
if (!response.ok && response.status !== 405) {
|
|
33125
33196
|
throw new StreamableHTTPError(response.status, `Failed to terminate session: ${response.statusText}`);
|
|
33126
33197
|
}
|
|
33127
33198
|
this._sessionId = void 0;
|
|
33128
33199
|
} catch (error) {
|
|
33129
|
-
|
|
33200
|
+
this.onerror?.(error);
|
|
33130
33201
|
throw error;
|
|
33131
33202
|
}
|
|
33132
33203
|
}
|
|
@@ -33146,7 +33217,7 @@ class StreamableHTTPClientTransport {
|
|
|
33146
33217
|
async resumeStream(lastEventId, options) {
|
|
33147
33218
|
await this._startOrAuthSse({
|
|
33148
33219
|
resumptionToken: lastEventId,
|
|
33149
|
-
onresumptiontoken: options
|
|
33220
|
+
onresumptiontoken: options?.onresumptiontoken
|
|
33150
33221
|
});
|
|
33151
33222
|
}
|
|
33152
33223
|
}
|
|
@@ -40946,7 +41017,7 @@ class UriTemplate {
|
|
|
40946
41017
|
const name2 = part.name;
|
|
40947
41018
|
switch (part.operator) {
|
|
40948
41019
|
case "":
|
|
40949
|
-
pattern2 = part.exploded ? "([
|
|
41020
|
+
pattern2 = part.exploded ? "([^/,]+(?:,[^/,]+)*)" : "([^/,]+)";
|
|
40950
41021
|
break;
|
|
40951
41022
|
case "+":
|
|
40952
41023
|
case "#":
|
|
@@ -40956,7 +41027,7 @@ class UriTemplate {
|
|
|
40956
41027
|
pattern2 = "\\.([^/,]+)";
|
|
40957
41028
|
break;
|
|
40958
41029
|
case "/":
|
|
40959
|
-
pattern2 = "/" + (part.exploded ? "([
|
|
41030
|
+
pattern2 = "/" + (part.exploded ? "([^/,]+(?:,[^/,]+)*)" : "([^/,]+)");
|
|
40960
41031
|
break;
|
|
40961
41032
|
default:
|
|
40962
41033
|
pattern2 = "([^/]+)";
|
|
@@ -45217,7 +45288,7 @@ const useTheme = () => {
|
|
|
45217
45288
|
[theme, setThemeWithSideEffect]
|
|
45218
45289
|
);
|
|
45219
45290
|
};
|
|
45220
|
-
const version = "1.26.
|
|
45291
|
+
const version = "1.26.2";
|
|
45221
45292
|
var [createTooltipContext] = createContextScope("Tooltip", [
|
|
45222
45293
|
createPopperScope
|
|
45223
45294
|
]);
|
|
@@ -47931,7 +48002,7 @@ const ElicitationRequest = ({
|
|
|
47931
48002
|
if (!validateFormData(formData, request.request.requestedSchema)) {
|
|
47932
48003
|
return;
|
|
47933
48004
|
}
|
|
47934
|
-
const ajv2 = new Ajv();
|
|
48005
|
+
const ajv2 = new Ajv$1();
|
|
47935
48006
|
const validate2 = ajv2.compile(request.request.requestedSchema);
|
|
47936
48007
|
const isValid = validate2(formData);
|
|
47937
48008
|
if (!isValid) {
|
|
@@ -48774,13 +48845,13 @@ const App = () => {
|
|
|
48774
48845
|
) });
|
|
48775
48846
|
if (window.location.pathname === "/oauth/callback") {
|
|
48776
48847
|
const OAuthCallback = React.lazy(
|
|
48777
|
-
() => __vitePreload(() => import("./OAuthCallback-
|
|
48848
|
+
() => __vitePreload(() => import("./OAuthCallback-TVHya7KP.js"), true ? [] : void 0)
|
|
48778
48849
|
);
|
|
48779
48850
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(OAuthCallback, { onConnect: onOAuthConnect }) });
|
|
48780
48851
|
}
|
|
48781
48852
|
if (window.location.pathname === "/oauth/callback/debug") {
|
|
48782
48853
|
const OAuthDebugCallback = React.lazy(
|
|
48783
|
-
() => __vitePreload(() => import("./OAuthDebugCallback-
|
|
48854
|
+
() => __vitePreload(() => import("./OAuthDebugCallback-Cs3pMLdW.js"), true ? [] : void 0)
|
|
48784
48855
|
);
|
|
48785
48856
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(OAuthDebugCallback, { onConnect: onOAuthDebugConnect }) });
|
|
48786
48857
|
}
|