@modelcontextprotocol/server 2.0.0-alpha.2 → 2.0.0-alpha.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/README.md +6 -2
- package/dist/{src-IKPjmxu7.mjs → ajvProvider-Birb50r-.mjs} +21 -3421
- package/dist/ajvProvider-Birb50r-.mjs.map +1 -0
- package/dist/ajvProvider-DZ_siXcF.d.mts +983 -0
- package/dist/ajvProvider-DZ_siXcF.d.mts.map +1 -0
- package/dist/cfWorkerProvider-BrJKpSFH.mjs +954 -0
- package/dist/cfWorkerProvider-BrJKpSFH.mjs.map +1 -0
- package/dist/cfWorkerProvider-DUhk5Ewx.d.mts +52 -0
- package/dist/cfWorkerProvider-DUhk5Ewx.d.mts.map +1 -0
- package/dist/chunk-BRhqBsOc.mjs +42 -0
- package/dist/index.d.mts +1526 -334
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +91 -766
- package/dist/index.mjs.map +1 -1
- package/dist/shimsNode.d.mts +1 -1
- package/dist/shimsNode.mjs +1 -1
- package/dist/shimsWorkerd.d.mts +1 -1
- package/dist/shimsWorkerd.mjs +1 -1
- package/dist/shimsWorkerd.mjs.map +1 -1
- package/dist/src-Pa1iAvsj.mjs +3386 -0
- package/dist/src-Pa1iAvsj.mjs.map +1 -0
- package/dist/stdio.d.mts +49 -0
- package/dist/stdio.d.mts.map +1 -0
- package/dist/stdio.mjs +106 -0
- package/dist/stdio.mjs.map +1 -0
- package/dist/{index-Bhfkexnj.d.mts → transport-DMKhEchd.d.mts} +636 -1907
- package/dist/transport-DMKhEchd.d.mts.map +1 -0
- package/dist/types-R2RTIcjk.d.mts +66 -0
- package/dist/types-R2RTIcjk.d.mts.map +1 -0
- package/dist/validators/ajv.d.mts +2 -0
- package/dist/validators/ajv.mjs +4 -0
- package/dist/validators/cfWorker.d.mts +2 -0
- package/dist/validators/cfWorker.mjs +3 -0
- package/package.json +35 -16
- package/dist/index-Bhfkexnj.d.mts.map +0 -1
- package/dist/src-IKPjmxu7.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,336 +1,1496 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import {
|
|
1
|
+
import { $ as GetTaskPayloadResult, $n as TaskAugmentedRequestParams, $t as PaginatedRequestParams, A as CreateMessageRequestParams, An as ResourceTemplateReference, Ar as LATEST_PROTOCOL_VERSION, At as ListResourcesRequest, B as ElicitRequestFormParams, Bn as SamplingMessage, Bt as LoggingMessageNotificationParams, C as CompleteRequest, Cn as RequestParams, Cr as CLIENT_CAPABILITIES_META_KEY, Ct as ListChangedCallback, D as CompleteResult, Dn as ResourceLink, Dr as INVALID_PARAMS, Dt as ListPromptsResult, E as CompleteRequestResourceTemplate, En as ResourceContents, Er as INTERNAL_ERROR, Et as ListPromptsRequest, F as CreateTaskResult, Fn as ResultTypeMap, Fr as RELATED_TASK_META_KEY, Ft as ListTasksResult, G as ElicitationCompleteNotificationParams, Gn as ServerResult, Gt as ModelPreferences, H as ElicitRequestURLParams, Hn as ServerCapabilities, Ht as MetaObject, I as Cursor, In as Role, Ir as SUPPORTED_PROTOCOL_VERSIONS, It as ListToolsRequest, J as EnumSchema, Jn as SingleSelectEnumSchema, Jt as NotificationMethod, K as EmbeddedResource, Kn as SetLevelRequest, Kt as MultiSelectEnumSchema, L as DiscoverRequest, Ln as Root, Lr as TRACEPARENT_META_KEY, Lt as ListToolsResult, M as CreateMessageRequestParamsWithTools, Mn as ResourceUpdatedNotification, Mr as METHOD_NOT_FOUND, Mt as ListRootsRequest, N as CreateMessageResult, Nn as ResourceUpdatedNotificationParams, Nr as PARSE_ERROR, Nt as ListRootsResult, O as ContentBlock, On as ResourceListChangedNotification, Or as INVALID_REQUEST, Ot as ListResourceTemplatesRequest, P as CreateMessageResultWithTools, Pn as Result$1, Pr as PROTOCOL_VERSION_META_KEY, Pt as ListTasksRequest, Q as GetTaskPayloadRequest, Qn as Task, Qt as PaginatedRequest, R as DiscoverResult, Rn as RootsListChangedNotification, Rr as TRACESTATE_META_KEY, Rt as LoggingLevel, S as CompatibilityCallToolResult, Sn as RequestMethod, Sr as BAGGAGE_META_KEY, St as LegacyTitledEnumSchema, T as CompleteRequestPrompt, Tn as Resource, Tr as DEFAULT_NEGOTIATED_PROTOCOL_VERSION, Tt as ListChangedOptions, U as ElicitResult, Un as ServerNotification, Ut as MethodNotFoundError, V as ElicitRequestParams, Vn as SamplingMessageContentBlock, Vt as MessageExtraInfo, W as ElicitationCompleteNotification, Wn as ServerRequest, Wt as ModelHint, X as GetPromptRequestParams, Xn as SubscribeRequest, Xt as NotificationTypeMap, Y as GetPromptRequest, Yn as StringSchema, Yt as NotificationParams, Z as GetPromptResult, Zn as SubscribeRequestParams, Zt as NumberSchema, _ as CancelledNotificationParams, _n as Request$1, _r as UnsubscribeRequestParams, _t as JSONRPCNotification, a as Annotations, an as ProgressNotification, ar as TextContent, at as Implementation, b as ClientRequest, bn as RequestMetaEnvelope, br as UntitledSingleSelectEnumSchema, bt as JSONRPCResultResponse, c as BaseMetadata, cn as Prompt, cr as TitledSingleSelectEnumSchema, ct as InitializeResult, d as CallToolRequest, dn as PromptMessage, dr as ToolChoice, dt as InvalidParamsError, en as PaginatedResult, er as TaskCreationParams, et as GetTaskRequest, f as CallToolRequestParams, fn as PromptReference, fr as ToolExecution, ft as InvalidRequestError, g as CancelledNotification, gn as RelatedTaskMetadata, gr as UnsubscribeRequest, gt as JSONRPCMessage, h as CancelTaskResult, hn as ReadResourceResult, hr as ToolUseContent, ht as JSONRPCErrorResponse, i as createFetchWithInit, in as Progress, ir as TaskStatusNotificationParams, it as ImageContent, j as CreateMessageRequestParamsBase, jn as ResourceTemplateType, jr as LOG_LEVEL_META_KEY, jt as ListResourcesResult, k as CreateMessageRequest, kn as ResourceRequestParams, kr as JSONRPC_VERSION, kt as ListResourceTemplatesResult, l as BlobResourceContents, ln as PromptArgument, lr as Tool, lt as InitializedNotification, m as CancelTaskRequest, mn as ReadResourceRequestParams, mr as ToolResultContent, mt as JSONObject, n as Transport, nn as PingRequest, nr as TaskStatus, nt as Icon, o as AudioContent, on as ProgressNotificationParams, or as TextResourceContents, ot as InitializeRequest, p as CallToolResult, pn as ReadResourceRequest, pr as ToolListChangedNotification, pt as JSONArray, q as EmptyResult, qn as SetLevelRequestParams, qt as Notification, r as TransportSendOptions, rn as PrimitiveSchemaDefinition, rr as TaskStatusNotification, rt as Icons, s as AuthInfo, sn as ProgressToken, sr as TitledMultiSelectEnumSchema, st as InitializeRequestParams, t as FetchLike, tn as ParseError, tr as TaskMetadata, tt as GetTaskResult, u as BooleanSchema, un as PromptListChangedNotification, ur as ToolAnnotations, ut as InternalError, v as ClientCapabilities, vn as RequestId, vr as UnsupportedProtocolVersionErrorData, vt as JSONRPCRequest, w as CompleteRequestParams, wn as RequestTypeMap, wr as CLIENT_INFO_META_KEY, wt as ListChangedHandlers, x as ClientResult, xn as RequestMetaObject, xr as schemas_d_exports, xt as JSONValue, y as ClientNotification, yn as RequestMeta, yr as UntitledMultiSelectEnumSchema, yt as JSONRPCResponse, z as ElicitRequest, zn as SamplingContent, zt as LoggingMessageNotification } from "./transport-DMKhEchd.mjs";
|
|
2
|
+
import { t as AjvJsonSchemaValidator } from "./ajvProvider-DZ_siXcF.mjs";
|
|
3
|
+
import { i as jsonSchemaValidator, n as JsonSchemaValidator, r as JsonSchemaValidatorResult, t as JsonSchemaType } from "./types-R2RTIcjk.mjs";
|
|
4
|
+
import { n as CfWorkerSchemaDraft, t as CfWorkerJsonSchemaValidator } from "./cfWorkerProvider-DUhk5Ewx.mjs";
|
|
5
|
+
import * as z from "zod/v4";
|
|
6
|
+
|
|
7
|
+
//#region ../core-internal/src/shared/auth.d.ts
|
|
3
8
|
|
|
4
|
-
//#region src/server/completable.d.ts
|
|
5
|
-
declare const COMPLETABLE_SYMBOL: unique symbol;
|
|
6
|
-
type CompleteCallback<T extends StandardSchemaWithJSON = StandardSchemaWithJSON> = (value: StandardSchemaWithJSON.InferInput<T>, context?: {
|
|
7
|
-
arguments?: Record<string, string>;
|
|
8
|
-
}) => StandardSchemaWithJSON.InferInput<T>[] | Promise<StandardSchemaWithJSON.InferInput<T>[]>;
|
|
9
|
-
type CompletableMeta<T extends StandardSchemaWithJSON = StandardSchemaWithJSON> = {
|
|
10
|
-
complete: CompleteCallback<T>;
|
|
11
|
-
};
|
|
12
|
-
type CompletableSchema<T extends StandardSchemaWithJSON> = T & {
|
|
13
|
-
[COMPLETABLE_SYMBOL]: CompletableMeta<T>;
|
|
14
|
-
};
|
|
15
9
|
/**
|
|
16
|
-
*
|
|
10
|
+
* RFC 9728 OAuth Protected Resource Metadata
|
|
11
|
+
*/
|
|
12
|
+
declare const OAuthProtectedResourceMetadataSchema: z.ZodObject<{
|
|
13
|
+
resource: z.ZodString;
|
|
14
|
+
authorization_servers: z.ZodOptional<z.ZodArray<z.ZodURL>>;
|
|
15
|
+
jwks_uri: z.ZodOptional<z.ZodString>;
|
|
16
|
+
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
17
|
+
bearer_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
18
|
+
resource_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
19
|
+
resource_name: z.ZodOptional<z.ZodString>;
|
|
20
|
+
resource_documentation: z.ZodOptional<z.ZodString>;
|
|
21
|
+
resource_policy_uri: z.ZodOptional<z.ZodString>;
|
|
22
|
+
resource_tos_uri: z.ZodOptional<z.ZodString>;
|
|
23
|
+
tls_client_certificate_bound_access_tokens: z.ZodOptional<z.ZodBoolean>;
|
|
24
|
+
authorization_details_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
25
|
+
dpop_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
26
|
+
dpop_bound_access_tokens_required: z.ZodOptional<z.ZodBoolean>;
|
|
27
|
+
}, z.core.$loose>;
|
|
28
|
+
/**
|
|
29
|
+
* RFC 8414 OAuth 2.0 Authorization Server Metadata
|
|
30
|
+
*/
|
|
31
|
+
declare const OAuthMetadataSchema: z.ZodObject<{
|
|
32
|
+
issuer: z.ZodString;
|
|
33
|
+
authorization_endpoint: z.ZodURL;
|
|
34
|
+
token_endpoint: z.ZodURL;
|
|
35
|
+
registration_endpoint: z.ZodOptional<z.ZodURL>;
|
|
36
|
+
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
37
|
+
response_types_supported: z.ZodArray<z.ZodString>;
|
|
38
|
+
response_modes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
39
|
+
grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
40
|
+
token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
41
|
+
token_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
42
|
+
service_documentation: z.ZodOptional<z.ZodURL>;
|
|
43
|
+
revocation_endpoint: z.ZodOptional<z.ZodURL>;
|
|
44
|
+
revocation_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
45
|
+
revocation_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
46
|
+
introspection_endpoint: z.ZodOptional<z.ZodString>;
|
|
47
|
+
introspection_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
48
|
+
introspection_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
49
|
+
code_challenge_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
50
|
+
client_id_metadata_document_supported: z.ZodOptional<z.ZodBoolean>;
|
|
51
|
+
}, z.core.$loose>;
|
|
52
|
+
/**
|
|
53
|
+
* OpenID Connect Discovery 1.0 Provider Metadata
|
|
17
54
|
*
|
|
18
|
-
* @
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
55
|
+
* @see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
|
|
56
|
+
*/
|
|
57
|
+
declare const OpenIdProviderMetadataSchema: z.ZodObject<{
|
|
58
|
+
issuer: z.ZodString;
|
|
59
|
+
authorization_endpoint: z.ZodURL;
|
|
60
|
+
token_endpoint: z.ZodURL;
|
|
61
|
+
userinfo_endpoint: z.ZodOptional<z.ZodURL>;
|
|
62
|
+
jwks_uri: z.ZodURL;
|
|
63
|
+
registration_endpoint: z.ZodOptional<z.ZodURL>;
|
|
64
|
+
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
65
|
+
response_types_supported: z.ZodArray<z.ZodString>;
|
|
66
|
+
response_modes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
67
|
+
grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
68
|
+
acr_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
69
|
+
subject_types_supported: z.ZodArray<z.ZodString>;
|
|
70
|
+
id_token_signing_alg_values_supported: z.ZodArray<z.ZodString>;
|
|
71
|
+
id_token_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
72
|
+
id_token_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
73
|
+
userinfo_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
74
|
+
userinfo_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
75
|
+
userinfo_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
76
|
+
request_object_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
77
|
+
request_object_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
78
|
+
request_object_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
79
|
+
token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
80
|
+
token_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
81
|
+
display_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
82
|
+
claim_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
83
|
+
claims_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
84
|
+
service_documentation: z.ZodOptional<z.ZodString>;
|
|
85
|
+
claims_locales_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
86
|
+
ui_locales_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
87
|
+
claims_parameter_supported: z.ZodOptional<z.ZodBoolean>;
|
|
88
|
+
request_parameter_supported: z.ZodOptional<z.ZodBoolean>;
|
|
89
|
+
request_uri_parameter_supported: z.ZodOptional<z.ZodBoolean>;
|
|
90
|
+
require_request_uri_registration: z.ZodOptional<z.ZodBoolean>;
|
|
91
|
+
op_policy_uri: z.ZodOptional<z.ZodURL>;
|
|
92
|
+
op_tos_uri: z.ZodOptional<z.ZodURL>;
|
|
93
|
+
client_id_metadata_document_supported: z.ZodOptional<z.ZodBoolean>;
|
|
94
|
+
}, z.core.$loose>;
|
|
95
|
+
/**
|
|
96
|
+
* OpenID Connect Discovery metadata that may include OAuth 2.0 fields
|
|
97
|
+
* This schema represents the real-world scenario where OIDC providers
|
|
98
|
+
* return a mix of OpenID Connect and OAuth 2.0 metadata fields
|
|
99
|
+
*/
|
|
100
|
+
declare const OpenIdProviderDiscoveryMetadataSchema: z.ZodObject<{
|
|
101
|
+
code_challenge_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
102
|
+
issuer: z.ZodString;
|
|
103
|
+
authorization_endpoint: z.ZodURL;
|
|
104
|
+
token_endpoint: z.ZodURL;
|
|
105
|
+
userinfo_endpoint: z.ZodOptional<z.ZodURL>;
|
|
106
|
+
jwks_uri: z.ZodURL;
|
|
107
|
+
registration_endpoint: z.ZodOptional<z.ZodURL>;
|
|
108
|
+
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
109
|
+
response_types_supported: z.ZodArray<z.ZodString>;
|
|
110
|
+
response_modes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
111
|
+
grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
112
|
+
acr_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
113
|
+
subject_types_supported: z.ZodArray<z.ZodString>;
|
|
114
|
+
id_token_signing_alg_values_supported: z.ZodArray<z.ZodString>;
|
|
115
|
+
id_token_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
116
|
+
id_token_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
117
|
+
userinfo_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
118
|
+
userinfo_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
119
|
+
userinfo_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
120
|
+
request_object_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
121
|
+
request_object_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
122
|
+
request_object_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
123
|
+
token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
124
|
+
token_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
125
|
+
display_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
126
|
+
claim_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
127
|
+
claims_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
128
|
+
service_documentation: z.ZodOptional<z.ZodString>;
|
|
129
|
+
claims_locales_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
130
|
+
ui_locales_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
131
|
+
claims_parameter_supported: z.ZodOptional<z.ZodBoolean>;
|
|
132
|
+
request_parameter_supported: z.ZodOptional<z.ZodBoolean>;
|
|
133
|
+
request_uri_parameter_supported: z.ZodOptional<z.ZodBoolean>;
|
|
134
|
+
require_request_uri_registration: z.ZodOptional<z.ZodBoolean>;
|
|
135
|
+
op_policy_uri: z.ZodOptional<z.ZodURL>;
|
|
136
|
+
op_tos_uri: z.ZodOptional<z.ZodURL>;
|
|
137
|
+
client_id_metadata_document_supported: z.ZodOptional<z.ZodBoolean>;
|
|
138
|
+
}, z.core.$strip>;
|
|
139
|
+
/**
|
|
140
|
+
* OAuth 2.1 token response
|
|
141
|
+
*/
|
|
142
|
+
declare const OAuthTokensSchema: z.ZodObject<{
|
|
143
|
+
access_token: z.ZodString;
|
|
144
|
+
id_token: z.ZodOptional<z.ZodString>;
|
|
145
|
+
token_type: z.ZodString;
|
|
146
|
+
expires_in: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
147
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
148
|
+
refresh_token: z.ZodOptional<z.ZodString>;
|
|
149
|
+
}, z.core.$strip>;
|
|
150
|
+
/**
|
|
151
|
+
* RFC 8693 §2.2.1 Token Exchange response for ID-JAG tokens.
|
|
43
152
|
*
|
|
44
|
-
*
|
|
153
|
+
* `token_type` is intentionally optional: per RFC 8693 §2.2.1 it is informational when
|
|
154
|
+
* the issued token is not an access token, and per RFC 6749 §5.1 it is case-insensitive,
|
|
155
|
+
* so strict checking rejects conformant IdPs.
|
|
45
156
|
*/
|
|
46
|
-
declare
|
|
157
|
+
declare const IdJagTokenExchangeResponseSchema: z.ZodObject<{
|
|
158
|
+
issued_token_type: z.ZodLiteral<"urn:ietf:params:oauth:token-type:id-jag">;
|
|
159
|
+
access_token: z.ZodString;
|
|
160
|
+
token_type: z.ZodOptional<z.ZodString>;
|
|
161
|
+
expires_in: z.ZodOptional<z.ZodNumber>;
|
|
162
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
163
|
+
}, z.core.$strip>;
|
|
164
|
+
type IdJagTokenExchangeResponse = z.infer<typeof IdJagTokenExchangeResponseSchema>;
|
|
47
165
|
/**
|
|
48
|
-
*
|
|
166
|
+
* OAuth 2.1 error response
|
|
49
167
|
*/
|
|
50
|
-
declare
|
|
51
|
-
|
|
52
|
-
|
|
168
|
+
declare const OAuthErrorResponseSchema: z.ZodObject<{
|
|
169
|
+
error: z.ZodString;
|
|
170
|
+
error_description: z.ZodOptional<z.ZodString>;
|
|
171
|
+
error_uri: z.ZodOptional<z.ZodString>;
|
|
172
|
+
}, z.core.$strip>;
|
|
53
173
|
/**
|
|
54
|
-
*
|
|
55
|
-
* @experimental
|
|
174
|
+
* RFC 7591 OAuth 2.0 Dynamic Client Registration metadata
|
|
56
175
|
*/
|
|
57
|
-
|
|
176
|
+
declare const OAuthClientMetadataSchema: z.ZodObject<{
|
|
177
|
+
redirect_uris: z.ZodArray<z.ZodURL>;
|
|
178
|
+
token_endpoint_auth_method: z.ZodOptional<z.ZodString>;
|
|
179
|
+
grant_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
180
|
+
response_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
181
|
+
client_name: z.ZodOptional<z.ZodString>;
|
|
182
|
+
client_uri: z.ZodOptional<z.ZodURL>;
|
|
183
|
+
logo_uri: z.ZodUnion<[z.ZodOptional<z.ZodURL>, z.ZodPipe<z.ZodLiteral<"">, z.ZodTransform<undefined, "">>]>;
|
|
184
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
185
|
+
contacts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
186
|
+
tos_uri: z.ZodUnion<[z.ZodOptional<z.ZodURL>, z.ZodPipe<z.ZodLiteral<"">, z.ZodTransform<undefined, "">>]>;
|
|
187
|
+
policy_uri: z.ZodOptional<z.ZodString>;
|
|
188
|
+
jwks_uri: z.ZodOptional<z.ZodURL>;
|
|
189
|
+
jwks: z.ZodOptional<z.ZodAny>;
|
|
190
|
+
software_id: z.ZodOptional<z.ZodString>;
|
|
191
|
+
software_version: z.ZodOptional<z.ZodString>;
|
|
192
|
+
software_statement: z.ZodOptional<z.ZodString>;
|
|
193
|
+
}, z.core.$strip>;
|
|
58
194
|
/**
|
|
59
|
-
*
|
|
60
|
-
* @experimental
|
|
195
|
+
* RFC 7591 OAuth 2.0 Dynamic Client Registration client information
|
|
61
196
|
*/
|
|
62
|
-
|
|
197
|
+
declare const OAuthClientInformationSchema: z.ZodObject<{
|
|
198
|
+
client_id: z.ZodString;
|
|
199
|
+
client_secret: z.ZodOptional<z.ZodString>;
|
|
200
|
+
client_id_issued_at: z.ZodOptional<z.ZodNumber>;
|
|
201
|
+
client_secret_expires_at: z.ZodOptional<z.ZodNumber>;
|
|
202
|
+
}, z.core.$strip>;
|
|
63
203
|
/**
|
|
64
|
-
*
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
204
|
+
* RFC 7591 OAuth 2.0 Dynamic Client Registration full response (client information plus metadata)
|
|
205
|
+
*/
|
|
206
|
+
declare const OAuthClientInformationFullSchema: z.ZodObject<{
|
|
207
|
+
redirect_uris: z.ZodArray<z.ZodURL>;
|
|
208
|
+
token_endpoint_auth_method: z.ZodOptional<z.ZodString>;
|
|
209
|
+
grant_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
210
|
+
response_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
211
|
+
client_name: z.ZodOptional<z.ZodString>;
|
|
212
|
+
client_uri: z.ZodOptional<z.ZodURL>;
|
|
213
|
+
logo_uri: z.ZodUnion<[z.ZodOptional<z.ZodURL>, z.ZodPipe<z.ZodLiteral<"">, z.ZodTransform<undefined, "">>]>;
|
|
214
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
215
|
+
contacts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
216
|
+
tos_uri: z.ZodUnion<[z.ZodOptional<z.ZodURL>, z.ZodPipe<z.ZodLiteral<"">, z.ZodTransform<undefined, "">>]>;
|
|
217
|
+
policy_uri: z.ZodOptional<z.ZodString>;
|
|
218
|
+
jwks_uri: z.ZodOptional<z.ZodURL>;
|
|
219
|
+
jwks: z.ZodOptional<z.ZodAny>;
|
|
220
|
+
software_id: z.ZodOptional<z.ZodString>;
|
|
221
|
+
software_version: z.ZodOptional<z.ZodString>;
|
|
222
|
+
software_statement: z.ZodOptional<z.ZodString>;
|
|
223
|
+
client_id: z.ZodString;
|
|
224
|
+
client_secret: z.ZodOptional<z.ZodString>;
|
|
225
|
+
client_id_issued_at: z.ZodOptional<z.ZodNumber>;
|
|
226
|
+
client_secret_expires_at: z.ZodOptional<z.ZodNumber>;
|
|
227
|
+
}, z.core.$strip>;
|
|
228
|
+
/**
|
|
229
|
+
* RFC 7591 OAuth 2.0 Dynamic Client Registration error response
|
|
230
|
+
*/
|
|
231
|
+
declare const OAuthClientRegistrationErrorSchema: z.ZodObject<{
|
|
232
|
+
error: z.ZodString;
|
|
233
|
+
error_description: z.ZodOptional<z.ZodString>;
|
|
234
|
+
}, z.core.$strip>;
|
|
235
|
+
/**
|
|
236
|
+
* RFC 7009 OAuth 2.0 Token Revocation request
|
|
71
237
|
*/
|
|
72
|
-
|
|
238
|
+
declare const OAuthTokenRevocationRequestSchema: z.ZodObject<{
|
|
239
|
+
token: z.ZodString;
|
|
240
|
+
token_type_hint: z.ZodOptional<z.ZodString>;
|
|
241
|
+
}, z.core.$strip>;
|
|
242
|
+
type OAuthMetadata = z.infer<typeof OAuthMetadataSchema>;
|
|
243
|
+
type OpenIdProviderMetadata = z.infer<typeof OpenIdProviderMetadataSchema>;
|
|
244
|
+
type OpenIdProviderDiscoveryMetadata = z.infer<typeof OpenIdProviderDiscoveryMetadataSchema>;
|
|
245
|
+
type OAuthTokens = z.infer<typeof OAuthTokensSchema>;
|
|
246
|
+
type OAuthErrorResponse = z.infer<typeof OAuthErrorResponseSchema>;
|
|
247
|
+
type OAuthClientMetadata = z.infer<typeof OAuthClientMetadataSchema>;
|
|
248
|
+
type OAuthClientInformation = z.infer<typeof OAuthClientInformationSchema>;
|
|
249
|
+
type OAuthClientInformationFull = z.infer<typeof OAuthClientInformationFullSchema>;
|
|
250
|
+
type OAuthClientInformationMixed = OAuthClientInformation | OAuthClientInformationFull;
|
|
251
|
+
type OAuthClientRegistrationError = z.infer<typeof OAuthClientRegistrationErrorSchema>;
|
|
252
|
+
type OAuthTokenRevocationRequest = z.infer<typeof OAuthTokenRevocationRequestSchema>;
|
|
253
|
+
type OAuthProtectedResourceMetadata = z.infer<typeof OAuthProtectedResourceMetadataSchema>;
|
|
254
|
+
type AuthorizationServerMetadata = OAuthMetadata | OpenIdProviderDiscoveryMetadata;
|
|
255
|
+
//#endregion
|
|
256
|
+
//#region ../core-internal/src/auth/errors.d.ts
|
|
257
|
+
/**
|
|
258
|
+
* OAuth error codes as defined by {@link https://datatracker.ietf.org/doc/html/rfc6749#section-5.2 | RFC 6749}
|
|
259
|
+
* and extensions.
|
|
260
|
+
*/
|
|
261
|
+
declare enum OAuthErrorCode {
|
|
73
262
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
|
|
77
|
-
|
|
263
|
+
* The request is missing a required parameter, includes an invalid parameter value,
|
|
264
|
+
* includes a parameter more than once, or is otherwise malformed.
|
|
265
|
+
*/
|
|
266
|
+
InvalidRequest = "invalid_request",
|
|
267
|
+
/**
|
|
268
|
+
* Client authentication failed (e.g., unknown client, no client authentication included,
|
|
269
|
+
* or unsupported authentication method).
|
|
270
|
+
*/
|
|
271
|
+
InvalidClient = "invalid_client",
|
|
272
|
+
/**
|
|
273
|
+
* The provided authorization grant or refresh token is invalid, expired, revoked,
|
|
274
|
+
* does not match the redirection URI used in the authorization request, or was issued to another client.
|
|
78
275
|
*/
|
|
79
|
-
|
|
276
|
+
InvalidGrant = "invalid_grant",
|
|
80
277
|
/**
|
|
81
|
-
*
|
|
278
|
+
* The authenticated client is not authorized to use this authorization grant type.
|
|
82
279
|
*/
|
|
83
|
-
|
|
280
|
+
UnauthorizedClient = "unauthorized_client",
|
|
84
281
|
/**
|
|
85
|
-
*
|
|
282
|
+
* The authorization grant type is not supported by the authorization server.
|
|
86
283
|
*/
|
|
87
|
-
|
|
284
|
+
UnsupportedGrantType = "unsupported_grant_type",
|
|
285
|
+
/**
|
|
286
|
+
* The requested scope is invalid, unknown, malformed, or exceeds the scope granted by the resource owner.
|
|
287
|
+
*/
|
|
288
|
+
InvalidScope = "invalid_scope",
|
|
289
|
+
/**
|
|
290
|
+
* The resource owner or authorization server denied the request.
|
|
291
|
+
*/
|
|
292
|
+
AccessDenied = "access_denied",
|
|
293
|
+
/**
|
|
294
|
+
* The authorization server encountered an unexpected condition that prevented it from fulfilling the request.
|
|
295
|
+
*/
|
|
296
|
+
ServerError = "server_error",
|
|
297
|
+
/**
|
|
298
|
+
* The authorization server is currently unable to handle the request due to temporary overloading or maintenance.
|
|
299
|
+
*/
|
|
300
|
+
TemporarilyUnavailable = "temporarily_unavailable",
|
|
301
|
+
/**
|
|
302
|
+
* The authorization server does not support obtaining an authorization code using this method.
|
|
303
|
+
*/
|
|
304
|
+
UnsupportedResponseType = "unsupported_response_type",
|
|
305
|
+
/**
|
|
306
|
+
* The authorization server does not support the requested token type.
|
|
307
|
+
*/
|
|
308
|
+
UnsupportedTokenType = "unsupported_token_type",
|
|
309
|
+
/**
|
|
310
|
+
* The access token provided is expired, revoked, malformed, or invalid for other reasons.
|
|
311
|
+
*/
|
|
312
|
+
InvalidToken = "invalid_token",
|
|
313
|
+
/**
|
|
314
|
+
* The HTTP method used is not allowed for this endpoint. (Custom, non-standard error)
|
|
315
|
+
*/
|
|
316
|
+
MethodNotAllowed = "method_not_allowed",
|
|
317
|
+
/**
|
|
318
|
+
* Rate limit exceeded. (Custom, non-standard error based on RFC 6585)
|
|
319
|
+
*/
|
|
320
|
+
TooManyRequests = "too_many_requests",
|
|
321
|
+
/**
|
|
322
|
+
* The client metadata is invalid. (Custom error for dynamic client registration - RFC 7591)
|
|
323
|
+
*/
|
|
324
|
+
InvalidClientMetadata = "invalid_client_metadata",
|
|
325
|
+
/**
|
|
326
|
+
* The request requires higher privileges than provided by the access token.
|
|
327
|
+
*/
|
|
328
|
+
InsufficientScope = "insufficient_scope",
|
|
329
|
+
/**
|
|
330
|
+
* The requested resource is invalid, missing, unknown, or malformed. (Custom error for resource indicators - RFC 8707)
|
|
331
|
+
*/
|
|
332
|
+
InvalidTarget = "invalid_target",
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* OAuth error class for all OAuth-related errors.
|
|
336
|
+
*/
|
|
337
|
+
declare class OAuthError extends Error {
|
|
338
|
+
readonly code: OAuthErrorCode | string;
|
|
339
|
+
readonly errorUri?: string | undefined;
|
|
340
|
+
constructor(code: OAuthErrorCode | string, message: string, errorUri?: string | undefined);
|
|
341
|
+
/**
|
|
342
|
+
* Converts the error to a standard OAuth error response object.
|
|
343
|
+
*/
|
|
344
|
+
toResponseObject(): OAuthErrorResponse;
|
|
345
|
+
/**
|
|
346
|
+
* Creates an {@linkcode OAuthError} from an OAuth error response.
|
|
347
|
+
*/
|
|
348
|
+
static fromResponse(response: OAuthErrorResponse): OAuthError;
|
|
88
349
|
}
|
|
89
350
|
//#endregion
|
|
90
|
-
//#region src/
|
|
351
|
+
//#region ../core-internal/src/errors/sdkErrors.d.ts
|
|
91
352
|
/**
|
|
92
|
-
*
|
|
353
|
+
* Error codes for SDK errors (local errors that never cross the wire).
|
|
354
|
+
* Unlike {@linkcode ProtocolErrorCode} which uses numeric JSON-RPC codes, `SdkErrorCode` uses
|
|
355
|
+
* descriptive string values for better developer experience.
|
|
93
356
|
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
|
|
357
|
+
* These errors are thrown locally by the SDK and are never serialized as
|
|
358
|
+
* JSON-RPC error responses.
|
|
359
|
+
*/
|
|
360
|
+
declare enum SdkErrorCode {
|
|
361
|
+
/** Transport is not connected */
|
|
362
|
+
NotConnected = "NOT_CONNECTED",
|
|
363
|
+
/** Transport is already connected */
|
|
364
|
+
AlreadyConnected = "ALREADY_CONNECTED",
|
|
365
|
+
/** Protocol is not initialized */
|
|
366
|
+
NotInitialized = "NOT_INITIALIZED",
|
|
367
|
+
/** Required capability is not supported by the remote side */
|
|
368
|
+
CapabilityNotSupported = "CAPABILITY_NOT_SUPPORTED",
|
|
369
|
+
/** Request timed out waiting for response */
|
|
370
|
+
RequestTimeout = "REQUEST_TIMEOUT",
|
|
371
|
+
/** Connection was closed */
|
|
372
|
+
ConnectionClosed = "CONNECTION_CLOSED",
|
|
373
|
+
/** Failed to send message */
|
|
374
|
+
SendFailed = "SEND_FAILED",
|
|
375
|
+
/** Response result failed local schema validation */
|
|
376
|
+
InvalidResult = "INVALID_RESULT",
|
|
377
|
+
ClientHttpNotImplemented = "CLIENT_HTTP_NOT_IMPLEMENTED",
|
|
378
|
+
ClientHttpAuthentication = "CLIENT_HTTP_AUTHENTICATION",
|
|
379
|
+
ClientHttpForbidden = "CLIENT_HTTP_FORBIDDEN",
|
|
380
|
+
ClientHttpUnexpectedContent = "CLIENT_HTTP_UNEXPECTED_CONTENT",
|
|
381
|
+
ClientHttpFailedToOpenStream = "CLIENT_HTTP_FAILED_TO_OPEN_STREAM",
|
|
382
|
+
ClientHttpFailedToTerminateSession = "CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION",
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* SDK errors are local errors that never cross the wire.
|
|
386
|
+
* They are distinct from {@linkcode ProtocolError} which represents JSON-RPC protocol errors
|
|
387
|
+
* that are serialized and sent as error responses.
|
|
388
|
+
*
|
|
389
|
+
* @example
|
|
390
|
+
* ```ts source="./sdkErrors.examples.ts#SdkError_basicUsage"
|
|
391
|
+
* try {
|
|
392
|
+
* // Throwing an SDK error
|
|
393
|
+
* throw new SdkError(SdkErrorCode.NotConnected, 'Transport is not connected');
|
|
394
|
+
* } catch (error) {
|
|
395
|
+
* // Checking error type by code
|
|
396
|
+
* if (error instanceof SdkError && error.code === SdkErrorCode.RequestTimeout) {
|
|
397
|
+
* // Handle timeout
|
|
398
|
+
* }
|
|
399
|
+
* }
|
|
400
|
+
* ```
|
|
401
|
+
*/
|
|
402
|
+
declare class SdkError extends Error {
|
|
403
|
+
readonly code: SdkErrorCode;
|
|
404
|
+
readonly data?: unknown | undefined;
|
|
405
|
+
constructor(code: SdkErrorCode, message: string, data?: unknown | undefined);
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Typed shape for HTTP error data carried by {@linkcode SdkHttpError}.
|
|
409
|
+
*/
|
|
410
|
+
interface SdkHttpErrorData {
|
|
411
|
+
status: number;
|
|
412
|
+
statusText?: string;
|
|
413
|
+
[key: string]: unknown;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* An {@linkcode SdkError} subclass for HTTP transport failures.
|
|
417
|
+
*
|
|
418
|
+
* Thrown by the streamable HTTP transport when the server responds with a
|
|
419
|
+
* non-OK status code. Narrows {@linkcode SdkError.data | data} to
|
|
420
|
+
* {@linkcode SdkHttpErrorData} so consumers can inspect the HTTP status
|
|
421
|
+
* without unsafe casting.
|
|
422
|
+
*
|
|
423
|
+
* @example
|
|
424
|
+
* ```ts source="./sdkErrors.examples.ts#SdkHttpError_basicUsage"
|
|
425
|
+
* if (error instanceof SdkHttpError) {
|
|
426
|
+
* console.log(error.status); // number
|
|
427
|
+
* console.log(error.statusText); // string | undefined
|
|
428
|
+
* }
|
|
97
429
|
* ```
|
|
430
|
+
*/
|
|
431
|
+
declare class SdkHttpError extends SdkError {
|
|
432
|
+
readonly data: SdkHttpErrorData;
|
|
433
|
+
constructor(code: SdkErrorCode, message: string, data: SdkHttpErrorData);
|
|
434
|
+
get status(): number;
|
|
435
|
+
get statusText(): string | undefined;
|
|
436
|
+
}
|
|
437
|
+
//#endregion
|
|
438
|
+
//#region ../core-internal/src/shared/authUtils.d.ts
|
|
439
|
+
/**
|
|
440
|
+
* Utilities for handling OAuth resource URIs.
|
|
441
|
+
*/
|
|
442
|
+
/**
|
|
443
|
+
* Converts a server URL to a resource URL by removing the fragment.
|
|
444
|
+
* {@link https://datatracker.ietf.org/doc/html/rfc8707#section-2 | RFC 8707 section 2}
|
|
445
|
+
* states that resource URIs "MUST NOT include a fragment component".
|
|
446
|
+
* Keeps everything else unchanged (scheme, domain, port, path, query).
|
|
447
|
+
*/
|
|
448
|
+
declare function resourceUrlFromServerUrl(url: URL | string): URL;
|
|
449
|
+
/**
|
|
450
|
+
* Checks if a requested resource URL matches a configured resource URL.
|
|
451
|
+
* A requested resource matches if it has the same scheme, domain, port,
|
|
452
|
+
* and its path starts with the configured resource's path.
|
|
98
453
|
*
|
|
99
|
-
* @
|
|
454
|
+
* @param options - The options object
|
|
455
|
+
* @param options.requestedResource - The resource URL being requested
|
|
456
|
+
* @param options.configuredResource - The resource URL that has been configured
|
|
457
|
+
* @returns true if the requested resource matches the configured resource, false otherwise
|
|
458
|
+
*/
|
|
459
|
+
declare function checkResourceAllowed({
|
|
460
|
+
requestedResource,
|
|
461
|
+
configuredResource
|
|
462
|
+
}: {
|
|
463
|
+
requestedResource: URL | string;
|
|
464
|
+
configuredResource: URL | string;
|
|
465
|
+
}): boolean;
|
|
466
|
+
//#endregion
|
|
467
|
+
//#region ../core-internal/src/types/enums.d.ts
|
|
468
|
+
/**
|
|
469
|
+
* Error codes for protocol errors that cross the wire as JSON-RPC error responses.
|
|
470
|
+
* These follow the JSON-RPC specification and MCP-specific extensions.
|
|
100
471
|
*/
|
|
101
|
-
declare
|
|
102
|
-
|
|
103
|
-
|
|
472
|
+
declare enum ProtocolErrorCode {
|
|
473
|
+
ParseError = -32700,
|
|
474
|
+
InvalidRequest = -32600,
|
|
475
|
+
MethodNotFound = -32601,
|
|
476
|
+
InvalidParams = -32602,
|
|
477
|
+
InternalError = -32603,
|
|
478
|
+
ResourceNotFound = -32002,
|
|
104
479
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* Task-based tools support long-running operations that can be polled for status
|
|
108
|
-
* and results. The handler must implement {@linkcode ToolTaskHandler.createTask | createTask}, {@linkcode ToolTaskHandler.getTask | getTask}, and {@linkcode ToolTaskHandler.getTaskResult | getTaskResult}
|
|
109
|
-
* methods.
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* ```typescript
|
|
113
|
-
* server.experimental.tasks.registerToolTask('long-computation', {
|
|
114
|
-
* description: 'Performs a long computation',
|
|
115
|
-
* inputSchema: z.object({ input: z.string() }),
|
|
116
|
-
* execution: { taskSupport: 'required' }
|
|
117
|
-
* }, {
|
|
118
|
-
* createTask: async (args, ctx) => {
|
|
119
|
-
* const task = await ctx.task.store.createTask({ ttl: 300000 });
|
|
120
|
-
* startBackgroundWork(task.taskId, args);
|
|
121
|
-
* return { task };
|
|
122
|
-
* },
|
|
123
|
-
* getTask: async (args, ctx) => {
|
|
124
|
-
* return ctx.task.store.getTask(ctx.task.id);
|
|
125
|
-
* },
|
|
126
|
-
* getTaskResult: async (args, ctx) => {
|
|
127
|
-
* return ctx.task.store.getTaskResult(ctx.task.id);
|
|
128
|
-
* }
|
|
129
|
-
* });
|
|
130
|
-
* ```
|
|
131
|
-
*
|
|
132
|
-
* @param name - The tool name
|
|
133
|
-
* @param config - Tool configuration (description, schemas, etc.)
|
|
134
|
-
* @param handler - Task handler with {@linkcode ToolTaskHandler.createTask | createTask}, {@linkcode ToolTaskHandler.getTask | getTask}, {@linkcode ToolTaskHandler.getTaskResult | getTaskResult} methods
|
|
135
|
-
* @returns {@linkcode server/mcp.RegisteredTool | RegisteredTool} for managing the tool's lifecycle
|
|
136
|
-
*
|
|
137
|
-
* @experimental
|
|
480
|
+
* Processing the request requires a capability the client did not declare
|
|
481
|
+
* in the request's `clientCapabilities` (protocol revision 2026-07-28).
|
|
138
482
|
*/
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}, handler: ToolTaskHandler<undefined>): RegisteredTool;
|
|
147
|
-
registerToolTask<InputArgs extends StandardSchemaWithJSON, OutputArgs extends StandardSchemaWithJSON | undefined>(name: string, config: {
|
|
148
|
-
title?: string;
|
|
149
|
-
description?: string;
|
|
150
|
-
inputSchema: InputArgs;
|
|
151
|
-
outputSchema?: OutputArgs;
|
|
152
|
-
annotations?: ToolAnnotations;
|
|
153
|
-
execution?: TaskToolExecution;
|
|
154
|
-
_meta?: Record<string, unknown>;
|
|
155
|
-
}, handler: ToolTaskHandler<InputArgs>): RegisteredTool;
|
|
483
|
+
MissingRequiredClientCapability = -32003,
|
|
484
|
+
/**
|
|
485
|
+
* The request's protocol version is unknown to the server or unsupported
|
|
486
|
+
* by it (protocol revision 2026-07-28).
|
|
487
|
+
*/
|
|
488
|
+
UnsupportedProtocolVersion = -32004,
|
|
489
|
+
UrlElicitationRequired = -32042,
|
|
156
490
|
}
|
|
157
491
|
//#endregion
|
|
158
|
-
//#region src/
|
|
492
|
+
//#region ../core-internal/src/types/errors.d.ts
|
|
493
|
+
/**
|
|
494
|
+
* Protocol errors are JSON-RPC errors that cross the wire as error responses.
|
|
495
|
+
* They use numeric error codes from the {@linkcode ProtocolErrorCode} enum.
|
|
496
|
+
*/
|
|
497
|
+
declare class ProtocolError extends Error {
|
|
498
|
+
readonly code: number;
|
|
499
|
+
readonly data?: unknown | undefined;
|
|
500
|
+
constructor(code: number, message: string, data?: unknown | undefined);
|
|
501
|
+
/**
|
|
502
|
+
* Factory method to create the appropriate error type based on the error code and data
|
|
503
|
+
*/
|
|
504
|
+
static fromError(code: number, message: string, data?: unknown): ProtocolError;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Specialized error type when a tool requires a URL mode elicitation.
|
|
508
|
+
* This makes it nicer for the client to handle since there is specific data to work with instead of just a code to check against.
|
|
509
|
+
*/
|
|
510
|
+
declare class UrlElicitationRequiredError extends ProtocolError {
|
|
511
|
+
constructor(elicitations: ElicitRequestURLParams[], message?: string);
|
|
512
|
+
get elicitations(): ElicitRequestURLParams[];
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Error type for the `-32004` UnsupportedProtocolVersion protocol error (protocol
|
|
516
|
+
* revision 2026-07-28): the request's protocol version is unknown to the server or
|
|
517
|
+
* unsupported by it.
|
|
518
|
+
*
|
|
519
|
+
* The error data lists the protocol versions the receiver supports (`supported`),
|
|
520
|
+
* so the sender can choose a mutually supported version and retry, and echoes the
|
|
521
|
+
* version that was requested (`requested`).
|
|
522
|
+
*/
|
|
523
|
+
declare class UnsupportedProtocolVersionError extends ProtocolError {
|
|
524
|
+
constructor(data: UnsupportedProtocolVersionErrorData, message?: string);
|
|
525
|
+
/**
|
|
526
|
+
* Protocol versions the receiver supports.
|
|
527
|
+
*/
|
|
528
|
+
get supported(): string[];
|
|
529
|
+
/**
|
|
530
|
+
* The protocol version that was requested.
|
|
531
|
+
*/
|
|
532
|
+
get requested(): string;
|
|
533
|
+
}
|
|
534
|
+
//#endregion
|
|
535
|
+
//#region ../core-internal/src/types/guards.d.ts
|
|
536
|
+
/**
|
|
537
|
+
* Validates and parses an unknown value as a JSON-RPC message.
|
|
538
|
+
*
|
|
539
|
+
* Use this to validate incoming messages in custom transport implementations.
|
|
540
|
+
* Throws if the value does not conform to the JSON-RPC message schema.
|
|
541
|
+
*
|
|
542
|
+
* @param value - The value to validate (typically a parsed JSON object).
|
|
543
|
+
* @returns The validated {@linkcode JSONRPCMessage}.
|
|
544
|
+
* @throws If validation fails.
|
|
545
|
+
*/
|
|
546
|
+
declare function parseJSONRPCMessage(value: unknown): JSONRPCMessage;
|
|
547
|
+
declare const isJSONRPCRequest: (value: unknown) => value is JSONRPCRequest;
|
|
548
|
+
declare const isJSONRPCNotification: (value: unknown) => value is JSONRPCNotification;
|
|
549
|
+
/**
|
|
550
|
+
* Checks if a value is a valid {@linkcode JSONRPCResultResponse}.
|
|
551
|
+
* @param value - The value to check.
|
|
552
|
+
*
|
|
553
|
+
* @returns True if the value is a valid {@linkcode JSONRPCResultResponse}, false otherwise.
|
|
554
|
+
*/
|
|
555
|
+
declare const isJSONRPCResultResponse: (value: unknown) => value is JSONRPCResultResponse;
|
|
556
|
+
/**
|
|
557
|
+
* Checks if a value is a valid {@linkcode JSONRPCErrorResponse}.
|
|
558
|
+
* @param value - The value to check.
|
|
559
|
+
*
|
|
560
|
+
* @returns True if the value is a valid {@linkcode JSONRPCErrorResponse}, false otherwise.
|
|
561
|
+
*/
|
|
562
|
+
declare const isJSONRPCErrorResponse: (value: unknown) => value is JSONRPCErrorResponse;
|
|
563
|
+
/**
|
|
564
|
+
* Checks if a value is a valid {@linkcode JSONRPCResponse} (either a result or error response).
|
|
565
|
+
* @param value - The value to check.
|
|
566
|
+
*
|
|
567
|
+
* @returns True if the value is a valid {@linkcode JSONRPCResponse}, false otherwise.
|
|
568
|
+
*/
|
|
569
|
+
declare const isJSONRPCResponse: (value: unknown) => value is JSONRPCResponse;
|
|
570
|
+
/**
|
|
571
|
+
* Checks if a value is a valid {@linkcode CallToolResult}.
|
|
572
|
+
* @param value - The value to check.
|
|
573
|
+
*
|
|
574
|
+
* @returns True if the value is a valid {@linkcode CallToolResult}, false otherwise.
|
|
575
|
+
*/
|
|
576
|
+
declare const isCallToolResult: (value: unknown) => value is CallToolResult;
|
|
577
|
+
/**
|
|
578
|
+
* Checks if a value is a valid {@linkcode TaskAugmentedRequestParams}.
|
|
579
|
+
* @param value - The value to check.
|
|
580
|
+
*
|
|
581
|
+
* @returns True if the value is a valid {@linkcode TaskAugmentedRequestParams}, false otherwise.
|
|
582
|
+
*/
|
|
583
|
+
declare const isTaskAugmentedRequestParams: (value: unknown) => value is TaskAugmentedRequestParams;
|
|
584
|
+
declare const isInitializeRequest: (value: unknown) => value is InitializeRequest;
|
|
585
|
+
declare const isInitializedNotification: (value: unknown) => value is InitializedNotification;
|
|
586
|
+
declare function assertCompleteRequestPrompt(request: CompleteRequest): asserts request is CompleteRequestPrompt;
|
|
587
|
+
declare function assertCompleteRequestResourceTemplate(request: CompleteRequest): asserts request is CompleteRequestResourceTemplate;
|
|
588
|
+
//#endregion
|
|
589
|
+
//#region ../core-internal/src/util/standardSchema.d.ts
|
|
590
|
+
/**
|
|
591
|
+
* Standard Schema utilities for user-provided schemas.
|
|
592
|
+
* Supports Zod v4, Valibot, ArkType, and other Standard Schema implementations.
|
|
593
|
+
* @see https://standardschema.dev
|
|
594
|
+
*/
|
|
595
|
+
interface StandardTypedV1<Input = unknown, Output = Input> {
|
|
596
|
+
readonly '~standard': StandardTypedV1.Props<Input, Output>;
|
|
597
|
+
}
|
|
598
|
+
declare namespace StandardTypedV1 {
|
|
599
|
+
interface Props<Input = unknown, Output = Input> {
|
|
600
|
+
readonly version: 1;
|
|
601
|
+
readonly vendor: string;
|
|
602
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
603
|
+
}
|
|
604
|
+
interface Types<Input = unknown, Output = Input> {
|
|
605
|
+
readonly input: Input;
|
|
606
|
+
readonly output: Output;
|
|
607
|
+
}
|
|
608
|
+
type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema['~standard']['types']>['input'];
|
|
609
|
+
type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema['~standard']['types']>['output'];
|
|
610
|
+
}
|
|
611
|
+
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
612
|
+
readonly '~standard': StandardSchemaV1.Props<Input, Output>;
|
|
613
|
+
}
|
|
614
|
+
declare namespace StandardSchemaV1 {
|
|
615
|
+
interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
|
|
616
|
+
readonly validate: (value: unknown, options?: Options | undefined) => Result<Output> | Promise<Result<Output>>;
|
|
617
|
+
}
|
|
618
|
+
interface Options {
|
|
619
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
620
|
+
}
|
|
621
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
622
|
+
interface SuccessResult<Output> {
|
|
623
|
+
readonly value: Output;
|
|
624
|
+
readonly issues?: undefined;
|
|
625
|
+
}
|
|
626
|
+
interface FailureResult {
|
|
627
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
628
|
+
}
|
|
629
|
+
interface Issue {
|
|
630
|
+
readonly message: string;
|
|
631
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
632
|
+
}
|
|
633
|
+
interface PathSegment {
|
|
634
|
+
readonly key: PropertyKey;
|
|
635
|
+
}
|
|
636
|
+
type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
|
|
637
|
+
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
|
638
|
+
}
|
|
639
|
+
interface StandardJSONSchemaV1<Input = unknown, Output = Input> {
|
|
640
|
+
readonly '~standard': StandardJSONSchemaV1.Props<Input, Output>;
|
|
641
|
+
}
|
|
642
|
+
declare namespace StandardJSONSchemaV1 {
|
|
643
|
+
interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
|
|
644
|
+
readonly jsonSchema: Converter;
|
|
645
|
+
}
|
|
646
|
+
interface Converter {
|
|
647
|
+
readonly input: (options: Options) => Record<string, unknown>;
|
|
648
|
+
readonly output: (options: Options) => Record<string, unknown>;
|
|
649
|
+
}
|
|
650
|
+
type Target = 'draft-2020-12' | 'draft-07' | 'openapi-3.0' | (object & string);
|
|
651
|
+
interface Options {
|
|
652
|
+
readonly target: Target;
|
|
653
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
654
|
+
}
|
|
655
|
+
type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
|
|
656
|
+
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
|
657
|
+
}
|
|
159
658
|
/**
|
|
160
|
-
*
|
|
659
|
+
* Combined interface for schemas with both validation and JSON Schema conversion —
|
|
660
|
+
* the intersection of {@linkcode StandardSchemaV1} and {@linkcode StandardJSONSchemaV1}.
|
|
161
661
|
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
662
|
+
* This is the type accepted by `registerTool` / `registerPrompt`. The SDK needs
|
|
663
|
+
* `~standard.jsonSchema` to advertise the tool's argument shape in `tools/list`, and
|
|
664
|
+
* `~standard.validate` to check incoming arguments when a `tools/call` arrives.
|
|
665
|
+
*
|
|
666
|
+
* Zod v4, ArkType, and Valibot (via `@valibot/to-json-schema`'s `toStandardJsonSchema`)
|
|
667
|
+
* all implement both interfaces.
|
|
668
|
+
*
|
|
669
|
+
* @see https://standardschema.dev/ for the Standard Schema specification
|
|
670
|
+
*/
|
|
671
|
+
interface StandardSchemaWithJSON<Input = unknown, Output = Input> {
|
|
672
|
+
readonly '~standard': StandardSchemaV1.Props<Input, Output> & StandardJSONSchemaV1.Props<Input, Output>;
|
|
673
|
+
}
|
|
674
|
+
declare namespace StandardSchemaWithJSON {
|
|
675
|
+
type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
|
|
676
|
+
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* Narrowing of {@linkcode StandardSchemaV1} whose `validate` is guaranteed synchronous.
|
|
680
|
+
*
|
|
681
|
+
* The Zod schemas backing `specTypeSchemas` contain no async refinements or transforms,
|
|
682
|
+
* so every entry satisfies this interface. Consumers can call `validate()` and access
|
|
683
|
+
* `.issues` / `.value` on the result without `await`.
|
|
684
|
+
*
|
|
685
|
+
* `StandardSchemaV1Sync` is assignable to `StandardSchemaV1` — it is a strict subtype.
|
|
686
|
+
*/
|
|
687
|
+
interface StandardSchemaV1Sync<Input = unknown, Output = Input> extends StandardSchemaV1<Input, Output> {
|
|
688
|
+
readonly '~standard': StandardSchemaV1Sync.Props<Input, Output>;
|
|
689
|
+
}
|
|
690
|
+
declare namespace StandardSchemaV1Sync {
|
|
691
|
+
interface Props<Input = unknown, Output = Input> extends StandardSchemaV1.Props<Input, Output> {
|
|
692
|
+
readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => StandardSchemaV1.Result<Output>;
|
|
693
|
+
}
|
|
694
|
+
type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
|
|
695
|
+
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
|
696
|
+
}
|
|
697
|
+
//#endregion
|
|
698
|
+
//#region ../core-internal/src/types/specTypeSchema.d.ts
|
|
699
|
+
/**
|
|
700
|
+
* Explicit allowlist of protocol Zod schemas that correspond to a public spec type in `types.ts`.
|
|
701
|
+
*
|
|
702
|
+
* This intentionally excludes internal helper schemas exported from `schemas.ts` that have no
|
|
703
|
+
* matching public type (e.g. `ListChangedOptionsBaseSchema`, `BaseRequestParamsSchema`,
|
|
704
|
+
* `NotificationsParamsSchema`, `ClientTasksCapabilitySchema`, `ServerTasksCapabilitySchema`).
|
|
705
|
+
* Keeping the list explicit means new public spec types must be added here deliberately, and
|
|
706
|
+
* internals never leak into `SpecTypeName`.
|
|
707
|
+
*
|
|
708
|
+
* `ResourceTemplateSchema` is included; its public type is exported as `ResourceTemplateType`
|
|
709
|
+
* (the bare name collides with the server package's `ResourceTemplate` class), so
|
|
710
|
+
* `SpecTypes['ResourceTemplate']` is structurally equal to `ResourceTemplateType` rather than to
|
|
711
|
+
* a type literally named `ResourceTemplate`.
|
|
712
|
+
*/
|
|
713
|
+
declare const SPEC_SCHEMA_KEYS: readonly ["AnnotationsSchema", "AudioContentSchema", "BaseMetadataSchema", "BlobResourceContentsSchema", "BooleanSchemaSchema", "CallToolRequestSchema", "CallToolRequestParamsSchema", "CallToolResultSchema", "CancelledNotificationSchema", "CancelledNotificationParamsSchema", "CancelTaskRequestSchema", "CancelTaskResultSchema", "ClientCapabilitiesSchema", "ClientNotificationSchema", "ClientRequestSchema", "ClientResultSchema", "CompatibilityCallToolResultSchema", "CompleteRequestSchema", "CompleteRequestParamsSchema", "CompleteResultSchema", "ContentBlockSchema", "CreateMessageRequestSchema", "CreateMessageRequestParamsSchema", "CreateMessageResultSchema", "CreateMessageResultWithToolsSchema", "CreateTaskResultSchema", "CursorSchema", "DiscoverRequestSchema", "DiscoverResultSchema", "ElicitationCompleteNotificationSchema", "ElicitationCompleteNotificationParamsSchema", "ElicitRequestSchema", "ElicitRequestFormParamsSchema", "ElicitRequestParamsSchema", "ElicitRequestURLParamsSchema", "ElicitResultSchema", "EmbeddedResourceSchema", "EmptyResultSchema", "EnumSchemaSchema", "GetPromptRequestSchema", "GetPromptRequestParamsSchema", "GetPromptResultSchema", "GetTaskPayloadRequestSchema", "GetTaskPayloadResultSchema", "GetTaskRequestSchema", "GetTaskResultSchema", "IconSchema", "IconsSchema", "ImageContentSchema", "ImplementationSchema", "InitializedNotificationSchema", "InitializeRequestSchema", "InitializeRequestParamsSchema", "InitializeResultSchema", "JSONArraySchema", "JSONObjectSchema", "JSONRPCErrorResponseSchema", "JSONRPCMessageSchema", "JSONRPCNotificationSchema", "JSONRPCRequestSchema", "JSONRPCResponseSchema", "JSONRPCResultResponseSchema", "JSONValueSchema", "LegacyTitledEnumSchemaSchema", "ListPromptsRequestSchema", "ListPromptsResultSchema", "ListResourcesRequestSchema", "ListResourcesResultSchema", "ListResourceTemplatesRequestSchema", "ListResourceTemplatesResultSchema", "ListRootsRequestSchema", "ListRootsResultSchema", "ListTasksRequestSchema", "ListTasksResultSchema", "ListToolsRequestSchema", "ListToolsResultSchema", "LoggingLevelSchema", "LoggingMessageNotificationSchema", "LoggingMessageNotificationParamsSchema", "ModelHintSchema", "ModelPreferencesSchema", "MultiSelectEnumSchemaSchema", "NotificationSchema", "NumberSchemaSchema", "PaginatedRequestSchema", "PaginatedRequestParamsSchema", "PaginatedResultSchema", "PingRequestSchema", "PrimitiveSchemaDefinitionSchema", "ProgressSchema", "ProgressNotificationSchema", "ProgressNotificationParamsSchema", "ProgressTokenSchema", "PromptSchema", "PromptArgumentSchema", "PromptListChangedNotificationSchema", "PromptMessageSchema", "PromptReferenceSchema", "ReadResourceRequestSchema", "ReadResourceRequestParamsSchema", "ReadResourceResultSchema", "RelatedTaskMetadataSchema", "RequestSchema", "RequestIdSchema", "RequestMetaEnvelopeSchema", "RequestMetaSchema", "ResourceSchema", "ResourceContentsSchema", "ResourceLinkSchema", "ResourceListChangedNotificationSchema", "ResourceRequestParamsSchema", "ResourceTemplateSchema", "ResourceTemplateReferenceSchema", "ResourceUpdatedNotificationSchema", "ResourceUpdatedNotificationParamsSchema", "ResultSchema", "RoleSchema", "RootSchema", "RootsListChangedNotificationSchema", "SamplingContentSchema", "SamplingMessageSchema", "SamplingMessageContentBlockSchema", "ServerCapabilitiesSchema", "ServerNotificationSchema", "ServerRequestSchema", "ServerResultSchema", "SetLevelRequestSchema", "SetLevelRequestParamsSchema", "SingleSelectEnumSchemaSchema", "StringSchemaSchema", "SubscribeRequestSchema", "SubscribeRequestParamsSchema", "TaskSchema", "TaskAugmentedRequestParamsSchema", "TaskCreationParamsSchema", "TaskMetadataSchema", "TaskStatusSchema", "TaskStatusNotificationSchema", "TaskStatusNotificationParamsSchema", "TextContentSchema", "TextResourceContentsSchema", "TitledMultiSelectEnumSchemaSchema", "TitledSingleSelectEnumSchemaSchema", "ToolSchema", "ToolAnnotationsSchema", "ToolChoiceSchema", "ToolExecutionSchema", "ToolListChangedNotificationSchema", "ToolResultContentSchema", "ToolUseContentSchema", "UnsubscribeRequestSchema", "UnsubscribeRequestParamsSchema", "UntitledMultiSelectEnumSchemaSchema", "UntitledSingleSelectEnumSchemaSchema"];
|
|
714
|
+
declare const authSchemas: {
|
|
715
|
+
readonly IdJagTokenExchangeResponseSchema: z.ZodObject<{
|
|
716
|
+
issued_token_type: z.ZodLiteral<"urn:ietf:params:oauth:token-type:id-jag">;
|
|
717
|
+
access_token: z.ZodString;
|
|
718
|
+
token_type: z.ZodOptional<z.ZodString>;
|
|
719
|
+
expires_in: z.ZodOptional<z.ZodNumber>;
|
|
720
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
721
|
+
}, z.core.$strip>;
|
|
722
|
+
readonly OAuthClientInformationFullSchema: z.ZodObject<{
|
|
723
|
+
redirect_uris: z.ZodArray<z.ZodURL>;
|
|
724
|
+
token_endpoint_auth_method: z.ZodOptional<z.ZodString>;
|
|
725
|
+
grant_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
726
|
+
response_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
727
|
+
client_name: z.ZodOptional<z.ZodString>;
|
|
728
|
+
client_uri: z.ZodOptional<z.ZodURL>;
|
|
729
|
+
logo_uri: z.ZodUnion<[z.ZodOptional<z.ZodURL>, z.ZodPipe<z.ZodLiteral<"">, z.ZodTransform<undefined, "">>]>;
|
|
730
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
731
|
+
contacts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
732
|
+
tos_uri: z.ZodUnion<[z.ZodOptional<z.ZodURL>, z.ZodPipe<z.ZodLiteral<"">, z.ZodTransform<undefined, "">>]>;
|
|
733
|
+
policy_uri: z.ZodOptional<z.ZodString>;
|
|
734
|
+
jwks_uri: z.ZodOptional<z.ZodURL>;
|
|
735
|
+
jwks: z.ZodOptional<z.ZodAny>;
|
|
736
|
+
software_id: z.ZodOptional<z.ZodString>;
|
|
737
|
+
software_version: z.ZodOptional<z.ZodString>;
|
|
738
|
+
software_statement: z.ZodOptional<z.ZodString>;
|
|
739
|
+
client_id: z.ZodString;
|
|
740
|
+
client_secret: z.ZodOptional<z.ZodString>;
|
|
741
|
+
client_id_issued_at: z.ZodOptional<z.ZodNumber>;
|
|
742
|
+
client_secret_expires_at: z.ZodOptional<z.ZodNumber>;
|
|
743
|
+
}, z.core.$strip>;
|
|
744
|
+
readonly OAuthClientInformationSchema: z.ZodObject<{
|
|
745
|
+
client_id: z.ZodString;
|
|
746
|
+
client_secret: z.ZodOptional<z.ZodString>;
|
|
747
|
+
client_id_issued_at: z.ZodOptional<z.ZodNumber>;
|
|
748
|
+
client_secret_expires_at: z.ZodOptional<z.ZodNumber>;
|
|
749
|
+
}, z.core.$strip>;
|
|
750
|
+
readonly OAuthClientMetadataSchema: z.ZodObject<{
|
|
751
|
+
redirect_uris: z.ZodArray<z.ZodURL>;
|
|
752
|
+
token_endpoint_auth_method: z.ZodOptional<z.ZodString>;
|
|
753
|
+
grant_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
754
|
+
response_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
755
|
+
client_name: z.ZodOptional<z.ZodString>;
|
|
756
|
+
client_uri: z.ZodOptional<z.ZodURL>;
|
|
757
|
+
logo_uri: z.ZodUnion<[z.ZodOptional<z.ZodURL>, z.ZodPipe<z.ZodLiteral<"">, z.ZodTransform<undefined, "">>]>;
|
|
758
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
759
|
+
contacts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
760
|
+
tos_uri: z.ZodUnion<[z.ZodOptional<z.ZodURL>, z.ZodPipe<z.ZodLiteral<"">, z.ZodTransform<undefined, "">>]>;
|
|
761
|
+
policy_uri: z.ZodOptional<z.ZodString>;
|
|
762
|
+
jwks_uri: z.ZodOptional<z.ZodURL>;
|
|
763
|
+
jwks: z.ZodOptional<z.ZodAny>;
|
|
764
|
+
software_id: z.ZodOptional<z.ZodString>;
|
|
765
|
+
software_version: z.ZodOptional<z.ZodString>;
|
|
766
|
+
software_statement: z.ZodOptional<z.ZodString>;
|
|
767
|
+
}, z.core.$strip>;
|
|
768
|
+
readonly OAuthClientRegistrationErrorSchema: z.ZodObject<{
|
|
769
|
+
error: z.ZodString;
|
|
770
|
+
error_description: z.ZodOptional<z.ZodString>;
|
|
771
|
+
}, z.core.$strip>;
|
|
772
|
+
readonly OAuthErrorResponseSchema: z.ZodObject<{
|
|
773
|
+
error: z.ZodString;
|
|
774
|
+
error_description: z.ZodOptional<z.ZodString>;
|
|
775
|
+
error_uri: z.ZodOptional<z.ZodString>;
|
|
776
|
+
}, z.core.$strip>;
|
|
777
|
+
readonly OAuthMetadataSchema: z.ZodObject<{
|
|
778
|
+
issuer: z.ZodString;
|
|
779
|
+
authorization_endpoint: z.ZodURL;
|
|
780
|
+
token_endpoint: z.ZodURL;
|
|
781
|
+
registration_endpoint: z.ZodOptional<z.ZodURL>;
|
|
782
|
+
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
783
|
+
response_types_supported: z.ZodArray<z.ZodString>;
|
|
784
|
+
response_modes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
785
|
+
grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
786
|
+
token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
787
|
+
token_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
788
|
+
service_documentation: z.ZodOptional<z.ZodURL>;
|
|
789
|
+
revocation_endpoint: z.ZodOptional<z.ZodURL>;
|
|
790
|
+
revocation_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
791
|
+
revocation_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
792
|
+
introspection_endpoint: z.ZodOptional<z.ZodString>;
|
|
793
|
+
introspection_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
794
|
+
introspection_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
795
|
+
code_challenge_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
796
|
+
client_id_metadata_document_supported: z.ZodOptional<z.ZodBoolean>;
|
|
797
|
+
}, z.core.$loose>;
|
|
798
|
+
readonly OAuthProtectedResourceMetadataSchema: z.ZodObject<{
|
|
799
|
+
resource: z.ZodString;
|
|
800
|
+
authorization_servers: z.ZodOptional<z.ZodArray<z.ZodURL>>;
|
|
801
|
+
jwks_uri: z.ZodOptional<z.ZodString>;
|
|
802
|
+
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
803
|
+
bearer_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
804
|
+
resource_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
805
|
+
resource_name: z.ZodOptional<z.ZodString>;
|
|
806
|
+
resource_documentation: z.ZodOptional<z.ZodString>;
|
|
807
|
+
resource_policy_uri: z.ZodOptional<z.ZodString>;
|
|
808
|
+
resource_tos_uri: z.ZodOptional<z.ZodString>;
|
|
809
|
+
tls_client_certificate_bound_access_tokens: z.ZodOptional<z.ZodBoolean>;
|
|
810
|
+
authorization_details_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
811
|
+
dpop_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
812
|
+
dpop_bound_access_tokens_required: z.ZodOptional<z.ZodBoolean>;
|
|
813
|
+
}, z.core.$loose>;
|
|
814
|
+
readonly OAuthTokenRevocationRequestSchema: z.ZodObject<{
|
|
815
|
+
token: z.ZodString;
|
|
816
|
+
token_type_hint: z.ZodOptional<z.ZodString>;
|
|
817
|
+
}, z.core.$strip>;
|
|
818
|
+
readonly OAuthTokensSchema: z.ZodObject<{
|
|
819
|
+
access_token: z.ZodString;
|
|
820
|
+
id_token: z.ZodOptional<z.ZodString>;
|
|
821
|
+
token_type: z.ZodString;
|
|
822
|
+
expires_in: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
823
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
824
|
+
refresh_token: z.ZodOptional<z.ZodString>;
|
|
825
|
+
}, z.core.$strip>;
|
|
826
|
+
readonly OpenIdProviderDiscoveryMetadataSchema: z.ZodObject<{
|
|
827
|
+
code_challenge_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
828
|
+
issuer: z.ZodString;
|
|
829
|
+
authorization_endpoint: z.ZodURL;
|
|
830
|
+
token_endpoint: z.ZodURL;
|
|
831
|
+
userinfo_endpoint: z.ZodOptional<z.ZodURL>;
|
|
832
|
+
jwks_uri: z.ZodURL;
|
|
833
|
+
registration_endpoint: z.ZodOptional<z.ZodURL>;
|
|
834
|
+
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
835
|
+
response_types_supported: z.ZodArray<z.ZodString>;
|
|
836
|
+
response_modes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
837
|
+
grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
838
|
+
acr_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
839
|
+
subject_types_supported: z.ZodArray<z.ZodString>;
|
|
840
|
+
id_token_signing_alg_values_supported: z.ZodArray<z.ZodString>;
|
|
841
|
+
id_token_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
842
|
+
id_token_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
843
|
+
userinfo_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
844
|
+
userinfo_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
845
|
+
userinfo_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
846
|
+
request_object_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
847
|
+
request_object_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
848
|
+
request_object_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
849
|
+
token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
850
|
+
token_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
851
|
+
display_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
852
|
+
claim_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
853
|
+
claims_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
854
|
+
service_documentation: z.ZodOptional<z.ZodString>;
|
|
855
|
+
claims_locales_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
856
|
+
ui_locales_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
857
|
+
claims_parameter_supported: z.ZodOptional<z.ZodBoolean>;
|
|
858
|
+
request_parameter_supported: z.ZodOptional<z.ZodBoolean>;
|
|
859
|
+
request_uri_parameter_supported: z.ZodOptional<z.ZodBoolean>;
|
|
860
|
+
require_request_uri_registration: z.ZodOptional<z.ZodBoolean>;
|
|
861
|
+
op_policy_uri: z.ZodOptional<z.ZodURL>;
|
|
862
|
+
op_tos_uri: z.ZodOptional<z.ZodURL>;
|
|
863
|
+
client_id_metadata_document_supported: z.ZodOptional<z.ZodBoolean>;
|
|
864
|
+
}, z.core.$strip>;
|
|
865
|
+
readonly OpenIdProviderMetadataSchema: z.ZodObject<{
|
|
866
|
+
issuer: z.ZodString;
|
|
867
|
+
authorization_endpoint: z.ZodURL;
|
|
868
|
+
token_endpoint: z.ZodURL;
|
|
869
|
+
userinfo_endpoint: z.ZodOptional<z.ZodURL>;
|
|
870
|
+
jwks_uri: z.ZodURL;
|
|
871
|
+
registration_endpoint: z.ZodOptional<z.ZodURL>;
|
|
872
|
+
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
873
|
+
response_types_supported: z.ZodArray<z.ZodString>;
|
|
874
|
+
response_modes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
875
|
+
grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
876
|
+
acr_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
877
|
+
subject_types_supported: z.ZodArray<z.ZodString>;
|
|
878
|
+
id_token_signing_alg_values_supported: z.ZodArray<z.ZodString>;
|
|
879
|
+
id_token_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
880
|
+
id_token_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
881
|
+
userinfo_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
882
|
+
userinfo_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
883
|
+
userinfo_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
884
|
+
request_object_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
885
|
+
request_object_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
886
|
+
request_object_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
887
|
+
token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
888
|
+
token_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
889
|
+
display_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
890
|
+
claim_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
891
|
+
claims_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
892
|
+
service_documentation: z.ZodOptional<z.ZodString>;
|
|
893
|
+
claims_locales_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
894
|
+
ui_locales_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
895
|
+
claims_parameter_supported: z.ZodOptional<z.ZodBoolean>;
|
|
896
|
+
request_parameter_supported: z.ZodOptional<z.ZodBoolean>;
|
|
897
|
+
request_uri_parameter_supported: z.ZodOptional<z.ZodBoolean>;
|
|
898
|
+
require_request_uri_registration: z.ZodOptional<z.ZodBoolean>;
|
|
899
|
+
op_policy_uri: z.ZodOptional<z.ZodURL>;
|
|
900
|
+
op_tos_uri: z.ZodOptional<z.ZodURL>;
|
|
901
|
+
client_id_metadata_document_supported: z.ZodOptional<z.ZodBoolean>;
|
|
902
|
+
}, z.core.$loose>;
|
|
903
|
+
};
|
|
904
|
+
type ProtocolSchemaKey = (typeof SPEC_SCHEMA_KEYS)[number];
|
|
905
|
+
type AuthSchemaKey = keyof typeof authSchemas;
|
|
906
|
+
type SchemaKey = ProtocolSchemaKey | AuthSchemaKey;
|
|
907
|
+
type SchemaFor<K$1 extends SchemaKey> = K$1 extends ProtocolSchemaKey ? (typeof schemas_d_exports)[K$1] : K$1 extends AuthSchemaKey ? (typeof authSchemas)[K$1] : never;
|
|
908
|
+
type StripSchemaSuffix<K$1> = K$1 extends `${infer N}Schema` ? N : never;
|
|
909
|
+
/**
|
|
910
|
+
* Union of every named type in the SDK's protocol and OAuth schemas (e.g. `'CallToolResult'`,
|
|
911
|
+
* `'ContentBlock'`, `'Tool'`, `'OAuthTokens'`). Derived from the internal Zod schemas, so it stays
|
|
912
|
+
* in sync with the spec.
|
|
913
|
+
*/
|
|
914
|
+
type SpecTypeName = StripSchemaSuffix<SchemaKey>;
|
|
915
|
+
/**
|
|
916
|
+
* Maps each {@linkcode SpecTypeName} to its TypeScript type.
|
|
917
|
+
*
|
|
918
|
+
* `SpecTypes['CallToolResult']` is equivalent to importing the `CallToolResult` type directly.
|
|
919
|
+
*/
|
|
920
|
+
type SpecTypes = { [K in SchemaKey as StripSchemaSuffix<K>]: SchemaFor<K> extends z.ZodType ? z.output<SchemaFor<K>> : never };
|
|
921
|
+
/**
|
|
922
|
+
* Input shape for each {@linkcode SpecTypeName}. For most types this equals {@linkcode SpecTypes},
|
|
923
|
+
* but a few schemas apply defaults/preprocessing, so the accepted input may be looser than the
|
|
924
|
+
* resulting output type.
|
|
925
|
+
*/
|
|
926
|
+
type SpecTypeInputs = { [K in SchemaKey as StripSchemaSuffix<K>]: SchemaFor<K> extends z.ZodType ? z.input<SchemaFor<K>> : never };
|
|
927
|
+
type SchemaRecord = { readonly [K in SpecTypeName]: StandardSchemaV1Sync<SpecTypeInputs[K], SpecTypes[K]> };
|
|
928
|
+
type GuardRecord = { readonly [K in SpecTypeName]: (value: unknown) => value is SpecTypeInputs[K] };
|
|
929
|
+
/**
|
|
930
|
+
* Runtime validators for every MCP spec type, keyed by type name.
|
|
931
|
+
*
|
|
932
|
+
* Use this when you need to validate a spec-defined shape at a boundary the SDK does not own, for
|
|
933
|
+
* example an extension's custom-method payload that embeds a `CallToolResult`, or a value read from
|
|
934
|
+
* storage that should be a `Tool`.
|
|
935
|
+
*
|
|
936
|
+
* Each entry implements the Standard Schema interface, so it composes with any
|
|
937
|
+
* Standard-Schema-aware library. For a simple boolean check, use {@linkcode isSpecType} instead.
|
|
938
|
+
*
|
|
939
|
+
* @example
|
|
940
|
+
* ```ts source="./specTypeSchema.examples.ts#specTypeSchemas_basicUsage"
|
|
941
|
+
* const result = specTypeSchemas.CallToolResult['~standard'].validate(untrusted);
|
|
942
|
+
* if (result.issues === undefined) {
|
|
943
|
+
* // result.value is CallToolResult
|
|
944
|
+
* }
|
|
165
945
|
* ```
|
|
946
|
+
*/
|
|
947
|
+
declare const specTypeSchemas: SchemaRecord;
|
|
948
|
+
/**
|
|
949
|
+
* Type predicates for every MCP spec type, keyed by type name.
|
|
950
|
+
*
|
|
951
|
+
* Returns `true` if the value satisfies the schema's input type (`z.input<>`, before defaults and
|
|
952
|
+
* transforms are applied), and narrows to that input type. For schemas with `.default()` or
|
|
953
|
+
* `.preprocess()`, this may accept values that do not structurally match the named output type;
|
|
954
|
+
* for example `isSpecType.CallToolResult({})` is `true` because `content` has a default. Use
|
|
955
|
+
* `specTypeSchemas.X['~standard'].validate(value)` when you need the validated output value.
|
|
166
956
|
*
|
|
167
|
-
*
|
|
957
|
+
* Each guard is a standalone function, so it can be passed directly as a callback.
|
|
958
|
+
*
|
|
959
|
+
* @example
|
|
960
|
+
* ```ts source="./specTypeSchema.examples.ts#isSpecType_basicUsage"
|
|
961
|
+
* if (isSpecType.ContentBlock(value)) {
|
|
962
|
+
* // value is ContentBlock
|
|
963
|
+
* }
|
|
168
964
|
*
|
|
169
|
-
*
|
|
965
|
+
* const blocks = mixed.filter(isSpecType.ContentBlock);
|
|
966
|
+
* ```
|
|
967
|
+
*/
|
|
968
|
+
declare const isSpecType: GuardRecord;
|
|
969
|
+
//#endregion
|
|
970
|
+
//#region ../core-internal/src/shared/metadataUtils.d.ts
|
|
971
|
+
/**
|
|
972
|
+
* Utilities for working with {@linkcode BaseMetadata} objects.
|
|
973
|
+
*/
|
|
974
|
+
/**
|
|
975
|
+
* Gets the display name for an object with {@linkcode BaseMetadata}.
|
|
976
|
+
* For tools, the precedence is: `title` → {@linkcode index.ToolAnnotations | annotations}.`title` → `name`
|
|
977
|
+
* For other objects: `title` → `name`
|
|
978
|
+
* This implements the spec requirement: "if no title is provided, name should be used for display purposes"
|
|
979
|
+
*/
|
|
980
|
+
declare function getDisplayName(metadata: BaseMetadata | (BaseMetadata & {
|
|
981
|
+
annotations?: {
|
|
982
|
+
title?: string;
|
|
983
|
+
};
|
|
984
|
+
})): string;
|
|
985
|
+
//#endregion
|
|
986
|
+
//#region ../core-internal/src/shared/protocol.d.ts
|
|
987
|
+
/**
|
|
988
|
+
* Callback for progress notifications.
|
|
170
989
|
*/
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
990
|
+
type ProgressCallback = (progress: Progress) => void;
|
|
991
|
+
/**
|
|
992
|
+
* Additional initialization options.
|
|
993
|
+
*/
|
|
994
|
+
type ProtocolOptions = {
|
|
175
995
|
/**
|
|
176
|
-
*
|
|
177
|
-
*
|
|
996
|
+
* Protocol versions supported. First version is preferred (sent by client,
|
|
997
|
+
* used as fallback by server). Passed to transport during {@linkcode Protocol.connect | connect()}.
|
|
178
998
|
*
|
|
179
|
-
*
|
|
180
|
-
|
|
999
|
+
* @default {@linkcode SUPPORTED_PROTOCOL_VERSIONS}
|
|
1000
|
+
*/
|
|
1001
|
+
supportedProtocolVersions?: string[];
|
|
1002
|
+
/**
|
|
1003
|
+
* Whether to restrict emitted requests to only those that the remote side has indicated that they can handle, through their advertised capabilities.
|
|
181
1004
|
*
|
|
182
|
-
*
|
|
183
|
-
* @param options - Optional request options (timeout, signal, task creation params, etc.)
|
|
184
|
-
* @returns AsyncGenerator that yields {@linkcode ResponseMessage} objects
|
|
1005
|
+
* Note that this DOES NOT affect checking of _local_ side capabilities, as it is considered a logic error to mis-specify those.
|
|
185
1006
|
*
|
|
186
|
-
*
|
|
1007
|
+
* Currently this defaults to `false`, for backwards compatibility with SDK versions that did not advertise capabilities correctly. In future, this will default to `true`.
|
|
187
1008
|
*/
|
|
188
|
-
|
|
189
|
-
method: M;
|
|
190
|
-
params?: Record<string, unknown>;
|
|
191
|
-
}, options?: RequestOptions): AsyncGenerator<ResponseMessage<ResultTypeMap[M]>, void, void>;
|
|
1009
|
+
enforceStrictCapabilities?: boolean;
|
|
192
1010
|
/**
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
|
|
1011
|
+
* An array of notification method names that should be automatically debounced.
|
|
1012
|
+
* Any notifications with a method in this list will be coalesced if they
|
|
1013
|
+
* occur in the same tick of the event loop.
|
|
1014
|
+
* e.g., `['notifications/tools/list_changed']`
|
|
1015
|
+
*/
|
|
1016
|
+
debouncedNotificationMethods?: string[];
|
|
1017
|
+
};
|
|
1018
|
+
/**
|
|
1019
|
+
* The default request timeout, in milliseconds.
|
|
1020
|
+
*/
|
|
1021
|
+
declare const DEFAULT_REQUEST_TIMEOUT_MSEC = 60000;
|
|
1022
|
+
/**
|
|
1023
|
+
* Options that can be given per request.
|
|
1024
|
+
*/
|
|
1025
|
+
type RequestOptions = {
|
|
1026
|
+
/**
|
|
1027
|
+
* If set, requests progress notifications from the remote end (if supported). When progress notifications are received, this callback will be invoked.
|
|
1028
|
+
*/
|
|
1029
|
+
onprogress?: ProgressCallback;
|
|
1030
|
+
/**
|
|
1031
|
+
* Can be used to cancel an in-flight request. This will cause an `AbortError` to be raised from {@linkcode Protocol.request | request()}.
|
|
1032
|
+
*/
|
|
1033
|
+
signal?: AbortSignal;
|
|
1034
|
+
/**
|
|
1035
|
+
* A timeout (in milliseconds) for this request. If exceeded, an {@linkcode SdkError} with code {@linkcode SdkErrorCode.RequestTimeout} will be raised from {@linkcode Protocol.request | request()}.
|
|
198
1036
|
*
|
|
199
|
-
* @
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
*
|
|
1037
|
+
* If not specified, {@linkcode DEFAULT_REQUEST_TIMEOUT_MSEC} will be used as the timeout.
|
|
1038
|
+
*/
|
|
1039
|
+
timeout?: number;
|
|
1040
|
+
/**
|
|
1041
|
+
* If `true`, receiving a progress notification will reset the request timeout.
|
|
1042
|
+
* This is useful for long-running operations that send periodic progress updates.
|
|
1043
|
+
* Default: `false`
|
|
1044
|
+
*/
|
|
1045
|
+
resetTimeoutOnProgress?: boolean;
|
|
1046
|
+
/**
|
|
1047
|
+
* Maximum total time (in milliseconds) to wait for a response.
|
|
1048
|
+
* If exceeded, an {@linkcode SdkError} with code {@linkcode SdkErrorCode.RequestTimeout} will be raised, regardless of progress notifications.
|
|
1049
|
+
* If not specified, there is no maximum total timeout.
|
|
1050
|
+
*/
|
|
1051
|
+
maxTotalTimeout?: number;
|
|
1052
|
+
} & TransportSendOptions;
|
|
1053
|
+
/**
|
|
1054
|
+
* Options that can be given per notification.
|
|
1055
|
+
*/
|
|
1056
|
+
type NotificationOptions = {
|
|
1057
|
+
/**
|
|
1058
|
+
* May be used to indicate to the transport which incoming request to associate this outgoing notification with.
|
|
1059
|
+
*/
|
|
1060
|
+
relatedRequestId?: RequestId;
|
|
1061
|
+
};
|
|
1062
|
+
/**
|
|
1063
|
+
* Base context provided to all request handlers.
|
|
1064
|
+
*/
|
|
1065
|
+
type BaseContext = {
|
|
1066
|
+
/**
|
|
1067
|
+
* The session ID from the transport, if available.
|
|
1068
|
+
*/
|
|
1069
|
+
sessionId?: string;
|
|
1070
|
+
/**
|
|
1071
|
+
* Information about the MCP request being handled.
|
|
1072
|
+
*/
|
|
1073
|
+
mcpReq: {
|
|
1074
|
+
/**
|
|
1075
|
+
* The JSON-RPC ID of the request being handled.
|
|
1076
|
+
*/
|
|
1077
|
+
id: RequestId;
|
|
1078
|
+
/**
|
|
1079
|
+
* The method name of the request (e.g., 'tools/call', 'ping').
|
|
1080
|
+
*/
|
|
1081
|
+
method: string;
|
|
1082
|
+
/**
|
|
1083
|
+
* Metadata from the original request.
|
|
1084
|
+
*/
|
|
1085
|
+
_meta?: RequestMeta;
|
|
1086
|
+
/**
|
|
1087
|
+
* An abort signal used to communicate if the request was cancelled from the sender's side.
|
|
1088
|
+
*/
|
|
1089
|
+
signal: AbortSignal;
|
|
1090
|
+
/**
|
|
1091
|
+
* Sends a request that relates to the current request being handled.
|
|
1092
|
+
*
|
|
1093
|
+
* This is used by certain transports to correctly associate related messages.
|
|
1094
|
+
*
|
|
1095
|
+
* For spec methods the result type is inferred from the method name.
|
|
1096
|
+
* For custom (non-spec) methods, pass a result schema as the second argument.
|
|
1097
|
+
*/
|
|
1098
|
+
send: {
|
|
1099
|
+
<M extends RequestMethod>(request: {
|
|
1100
|
+
method: M;
|
|
1101
|
+
params?: Record<string, unknown>;
|
|
1102
|
+
}, options?: RequestOptions): Promise<ResultTypeMap[M]>;
|
|
1103
|
+
<T extends StandardSchemaV1>(request: Request$1, resultSchema: T, options?: RequestOptions): Promise<StandardSchemaV1.InferOutput<T>>;
|
|
1104
|
+
};
|
|
1105
|
+
/**
|
|
1106
|
+
* Sends a notification that relates to the current request being handled.
|
|
1107
|
+
*
|
|
1108
|
+
* This is used by certain transports to correctly associate related messages.
|
|
1109
|
+
*/
|
|
1110
|
+
notify: (notification: Notification) => Promise<void>;
|
|
1111
|
+
};
|
|
1112
|
+
/**
|
|
1113
|
+
* HTTP transport information, only available when using an HTTP-based transport.
|
|
1114
|
+
*/
|
|
1115
|
+
http?: {
|
|
1116
|
+
/**
|
|
1117
|
+
* Information about a validated access token, provided to request handlers.
|
|
1118
|
+
*/
|
|
1119
|
+
authInfo?: AuthInfo;
|
|
1120
|
+
};
|
|
1121
|
+
};
|
|
1122
|
+
/**
|
|
1123
|
+
* Context provided to server-side request handlers, extending {@linkcode BaseContext} with server-specific fields.
|
|
1124
|
+
*/
|
|
1125
|
+
type ServerContext = BaseContext & {
|
|
1126
|
+
mcpReq: {
|
|
1127
|
+
/**
|
|
1128
|
+
* Send a log message notification to the client.
|
|
1129
|
+
* Respects the client's log level filter set via logging/setLevel.
|
|
1130
|
+
*
|
|
1131
|
+
* @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
|
|
1132
|
+
* Remains functional during the deprecation window (at least twelve months).
|
|
1133
|
+
* Migrate to stderr logging (STDIO servers) or OpenTelemetry.
|
|
1134
|
+
*/
|
|
1135
|
+
log: (level: LoggingLevel, data: unknown, logger?: string) => Promise<void>;
|
|
1136
|
+
/**
|
|
1137
|
+
* Send an elicitation request to the client, requesting user input.
|
|
1138
|
+
*/
|
|
1139
|
+
elicitInput: (params: ElicitRequestFormParams | ElicitRequestURLParams, options?: RequestOptions) => Promise<ElicitResult>;
|
|
1140
|
+
/**
|
|
1141
|
+
* Request LLM sampling from the client.
|
|
1142
|
+
*
|
|
1143
|
+
* @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
|
|
1144
|
+
* Remains functional during the deprecation window (at least twelve months).
|
|
1145
|
+
* Migrate to calling LLM provider APIs directly.
|
|
1146
|
+
*/
|
|
1147
|
+
requestSampling: (params: CreateMessageRequest['params'], options?: RequestOptions) => Promise<CreateMessageResult | CreateMessageResultWithTools>;
|
|
1148
|
+
};
|
|
1149
|
+
http?: {
|
|
1150
|
+
/**
|
|
1151
|
+
* The original HTTP request.
|
|
1152
|
+
*/
|
|
1153
|
+
req?: globalThis.Request;
|
|
1154
|
+
/**
|
|
1155
|
+
* Closes the SSE stream for this request, triggering client reconnection.
|
|
1156
|
+
* Only available when using a StreamableHTTPServerTransport with eventStore configured.
|
|
1157
|
+
*/
|
|
1158
|
+
closeSSE?: () => void;
|
|
1159
|
+
/**
|
|
1160
|
+
* Closes the standalone GET SSE stream, triggering client reconnection.
|
|
1161
|
+
* Only available when using a StreamableHTTPServerTransport with eventStore configured.
|
|
1162
|
+
*/
|
|
1163
|
+
closeStandaloneSSE?: () => void;
|
|
1164
|
+
};
|
|
1165
|
+
};
|
|
1166
|
+
/**
|
|
1167
|
+
* Context provided to client-side request handlers.
|
|
1168
|
+
*/
|
|
1169
|
+
type ClientContext = BaseContext;
|
|
1170
|
+
/**
|
|
1171
|
+
* Implements MCP protocol framing on top of a pluggable transport, including
|
|
1172
|
+
* features like request/response linking, notifications, and progress.
|
|
1173
|
+
*
|
|
1174
|
+
* `Protocol` is abstract; `Client` and `Server` are the concrete role-specific
|
|
1175
|
+
* implementations most code should use.
|
|
1176
|
+
*/
|
|
1177
|
+
declare abstract class Protocol<ContextT extends BaseContext> {
|
|
1178
|
+
private _options?;
|
|
1179
|
+
private _transport?;
|
|
1180
|
+
private _requestMessageId;
|
|
1181
|
+
private _requestHandlers;
|
|
1182
|
+
private _requestHandlerAbortControllers;
|
|
1183
|
+
private _notificationHandlers;
|
|
1184
|
+
private _responseHandlers;
|
|
1185
|
+
private _progressHandlers;
|
|
1186
|
+
private _timeoutInfo;
|
|
1187
|
+
private _pendingDebouncedNotifications;
|
|
1188
|
+
protected _supportedProtocolVersions: string[];
|
|
1189
|
+
/**
|
|
1190
|
+
* Callback for when the connection is closed for any reason.
|
|
210
1191
|
*
|
|
211
|
-
*
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
*
|
|
216
|
-
* case 'taskStatus':
|
|
217
|
-
* console.log('Task status:', message.task.status);
|
|
218
|
-
* break;
|
|
219
|
-
* case 'result':
|
|
220
|
-
* console.log('Final result:', message.result);
|
|
221
|
-
* break;
|
|
222
|
-
* case 'error':
|
|
223
|
-
* console.error('Error:', message.error);
|
|
224
|
-
* break;
|
|
225
|
-
* }
|
|
226
|
-
* }
|
|
227
|
-
* ```
|
|
1192
|
+
* This is invoked when {@linkcode Protocol.close | close()} is called as well.
|
|
1193
|
+
*/
|
|
1194
|
+
onclose?: () => void;
|
|
1195
|
+
/**
|
|
1196
|
+
* Callback for when an error occurs.
|
|
228
1197
|
*
|
|
229
|
-
*
|
|
230
|
-
|
|
231
|
-
|
|
1198
|
+
* Note that errors are not necessarily fatal; they are used for reporting any kind of exceptional condition out of band.
|
|
1199
|
+
*/
|
|
1200
|
+
onerror?: (error: Error) => void;
|
|
1201
|
+
/**
|
|
1202
|
+
* A handler to invoke for any request types that do not have their own handler installed.
|
|
1203
|
+
*/
|
|
1204
|
+
fallbackRequestHandler?: (request: JSONRPCRequest, ctx: ContextT) => Promise<Result$1>;
|
|
1205
|
+
/**
|
|
1206
|
+
* A handler to invoke for any notification types that do not have their own handler installed.
|
|
1207
|
+
*/
|
|
1208
|
+
fallbackNotificationHandler?: (notification: Notification) => Promise<void>;
|
|
1209
|
+
constructor(_options?: ProtocolOptions | undefined);
|
|
1210
|
+
/**
|
|
1211
|
+
* Builds the context object for request handlers. Subclasses must override
|
|
1212
|
+
* to return the appropriate context type (e.g., ServerContext adds HTTP request info).
|
|
1213
|
+
*/
|
|
1214
|
+
protected abstract buildContext(ctx: BaseContext, transportInfo?: MessageExtraInfo): ContextT;
|
|
1215
|
+
private _oncancel;
|
|
1216
|
+
private _setupTimeout;
|
|
1217
|
+
private _resetTimeout;
|
|
1218
|
+
private _cleanupTimeout;
|
|
1219
|
+
/**
|
|
1220
|
+
* Attaches to the given transport, starts it, and starts listening for messages.
|
|
232
1221
|
*
|
|
233
|
-
* @
|
|
1222
|
+
* The caller assumes ownership of the {@linkcode Transport}, replacing any callbacks that have already been set, and expects that it is the only user of the {@linkcode Transport} instance going forward.
|
|
234
1223
|
*/
|
|
235
|
-
|
|
1224
|
+
connect(transport: Transport): Promise<void>;
|
|
1225
|
+
private _onclose;
|
|
1226
|
+
private _onerror;
|
|
1227
|
+
private _onnotification;
|
|
1228
|
+
private _onrequest;
|
|
1229
|
+
private _onprogress;
|
|
1230
|
+
private _onresponse;
|
|
1231
|
+
get transport(): Transport | undefined;
|
|
236
1232
|
/**
|
|
237
|
-
*
|
|
238
|
-
|
|
1233
|
+
* Closes the connection.
|
|
1234
|
+
*/
|
|
1235
|
+
close(): Promise<void>;
|
|
1236
|
+
/**
|
|
1237
|
+
* A method to check if a capability is supported by the remote side, for the given method to be called.
|
|
239
1238
|
*
|
|
240
|
-
*
|
|
241
|
-
|
|
1239
|
+
* This should be implemented by subclasses.
|
|
1240
|
+
*/
|
|
1241
|
+
protected abstract assertCapabilityForMethod(method: RequestMethod | string): void;
|
|
1242
|
+
/**
|
|
1243
|
+
* A method to check if a notification is supported by the local side, for the given method to be sent.
|
|
242
1244
|
*
|
|
243
|
-
*
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
*
|
|
248
|
-
* elicitationId: 'auth-123',
|
|
249
|
-
* url: 'https://example.com/auth'
|
|
250
|
-
* }, {
|
|
251
|
-
* task: { ttl: 300000 } // Task-augmented for long-running auth flow
|
|
252
|
-
* });
|
|
1245
|
+
* This should be implemented by subclasses.
|
|
1246
|
+
*/
|
|
1247
|
+
protected abstract assertNotificationCapability(method: NotificationMethod | string): void;
|
|
1248
|
+
/**
|
|
1249
|
+
* A method to check if a request handler is supported by the local side, for the given method to be handled.
|
|
253
1250
|
*
|
|
254
|
-
*
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
*
|
|
259
|
-
* case 'taskStatus':
|
|
260
|
-
* console.log('Task status:', message.task.status);
|
|
261
|
-
* break;
|
|
262
|
-
* case 'result':
|
|
263
|
-
* console.log('User action:', message.result.action);
|
|
264
|
-
* break;
|
|
265
|
-
* case 'error':
|
|
266
|
-
* console.error('Error:', message.error);
|
|
267
|
-
* break;
|
|
268
|
-
* }
|
|
269
|
-
* }
|
|
270
|
-
* ```
|
|
1251
|
+
* This should be implemented by subclasses.
|
|
1252
|
+
*/
|
|
1253
|
+
protected abstract assertRequestHandlerCapability(method: string): void;
|
|
1254
|
+
/**
|
|
1255
|
+
* Sends a request and waits for a response.
|
|
271
1256
|
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
1257
|
+
* For spec methods the result schema is resolved automatically from the method name
|
|
1258
|
+
* and the return type is method-keyed. For custom (non-spec) methods, pass a
|
|
1259
|
+
* `resultSchema` as the second argument; the response is validated against it and
|
|
1260
|
+
* the return type is inferred from the schema.
|
|
275
1261
|
*
|
|
276
|
-
* @
|
|
1262
|
+
* Do not use this method to emit notifications! Use {@linkcode Protocol.notification | notification()} instead.
|
|
277
1263
|
*/
|
|
278
|
-
|
|
1264
|
+
request<M extends RequestMethod>(request: {
|
|
1265
|
+
method: M;
|
|
1266
|
+
params?: Record<string, unknown>;
|
|
1267
|
+
}, options?: RequestOptions): Promise<ResultTypeMap[M]>;
|
|
1268
|
+
request<T extends StandardSchemaV1>(request: Request$1, resultSchema: T, options?: RequestOptions): Promise<StandardSchemaV1.InferOutput<T>>;
|
|
279
1269
|
/**
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
* @param taskId - The task identifier
|
|
283
|
-
* @param options - Optional request options
|
|
284
|
-
* @returns The task status
|
|
1270
|
+
* Sends a request and waits for a response, using the provided schema for validation.
|
|
285
1271
|
*
|
|
286
|
-
*
|
|
1272
|
+
* This is the internal implementation used by SDK methods that need to specify
|
|
1273
|
+
* a particular result schema (e.g., for compatibility schemas).
|
|
287
1274
|
*/
|
|
288
|
-
|
|
1275
|
+
protected _requestWithSchema<T extends StandardSchemaV1>(request: Request$1, resultSchema: T, options?: RequestOptions): Promise<StandardSchemaV1.InferOutput<T>>;
|
|
289
1276
|
/**
|
|
290
|
-
*
|
|
1277
|
+
* Emits a notification, which is a one-way message that does not expect a response.
|
|
1278
|
+
*/
|
|
1279
|
+
notification(notification: Notification, options?: NotificationOptions): Promise<void>;
|
|
1280
|
+
/**
|
|
1281
|
+
* Registers a handler to invoke when this protocol object receives a request with the given method.
|
|
1282
|
+
*
|
|
1283
|
+
* Note that this will replace any previous request handler for the same method.
|
|
1284
|
+
*
|
|
1285
|
+
* For spec methods, pass `(method, handler)`; the request is parsed with the spec
|
|
1286
|
+
* schema and the handler receives the typed `Request`. For custom (non-spec)
|
|
1287
|
+
* methods, pass `(method, schemas, handler)`; `params` are validated against
|
|
1288
|
+
* `schemas.params` and the handler receives the parsed params object directly.
|
|
1289
|
+
* Supplying `schemas.result` types the handler's return value.
|
|
291
1290
|
*
|
|
292
|
-
* @
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
*
|
|
1291
|
+
* @example Custom request method
|
|
1292
|
+
* ```ts source="./protocol.examples.ts#Protocol_setRequestHandler_customMethod"
|
|
1293
|
+
* const SearchParams = z.object({ query: z.string(), limit: z.number().optional() });
|
|
1294
|
+
* const SearchResult = z.object({ hits: z.array(z.string()) });
|
|
296
1295
|
*
|
|
297
|
-
*
|
|
1296
|
+
* protocol.setRequestHandler('acme/search', { params: SearchParams, result: SearchResult }, async (params, _ctx) => {
|
|
1297
|
+
* return { hits: [`result for ${params.query}`] };
|
|
1298
|
+
* });
|
|
1299
|
+
* ```
|
|
298
1300
|
*/
|
|
299
|
-
|
|
1301
|
+
setRequestHandler<M extends RequestMethod>(method: M, handler: (request: RequestTypeMap[M], ctx: ContextT) => ResultTypeMap[M] | Promise<ResultTypeMap[M]>): void;
|
|
1302
|
+
setRequestHandler<P extends StandardSchemaV1, R extends StandardSchemaV1 | undefined = undefined>(method: string, schemas: {
|
|
1303
|
+
params: P;
|
|
1304
|
+
result?: R;
|
|
1305
|
+
}, handler: (params: StandardSchemaV1.InferOutput<P>, ctx: ContextT) => InferHandlerResult<R> | Promise<InferHandlerResult<R>>): void;
|
|
300
1306
|
/**
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
* @returns List of tasks with optional next cursor
|
|
1307
|
+
* Hook for subclasses to wrap a registered request handler with role-specific
|
|
1308
|
+
* validation or behavior (e.g. `Server` validates `tools/call` results, `Client`
|
|
1309
|
+
* validates `elicitation/create` mode and result). Runs for both the 2-arg and
|
|
1310
|
+
* 3-arg registration paths. The default implementation is identity.
|
|
306
1311
|
*
|
|
307
|
-
*
|
|
1312
|
+
* Subclasses overriding this hook avoid redeclaring `setRequestHandler`'s overload set.
|
|
308
1313
|
*/
|
|
309
|
-
|
|
1314
|
+
protected _wrapHandler(_method: string, handler: (request: JSONRPCRequest, ctx: ContextT) => Promise<Result$1>): (request: JSONRPCRequest, ctx: ContextT) => Promise<Result$1>;
|
|
310
1315
|
/**
|
|
311
|
-
*
|
|
1316
|
+
* Removes the request handler for the given method.
|
|
1317
|
+
*/
|
|
1318
|
+
removeRequestHandler(method: RequestMethod | string): void;
|
|
1319
|
+
/**
|
|
1320
|
+
* Asserts that a request handler has not already been set for the given method, in preparation for a new one being automatically installed.
|
|
1321
|
+
*/
|
|
1322
|
+
assertCanSetRequestHandler(method: RequestMethod | string): void;
|
|
1323
|
+
/**
|
|
1324
|
+
* Registers a handler to invoke when this protocol object receives a notification with the given method.
|
|
312
1325
|
*
|
|
313
|
-
*
|
|
314
|
-
* @param options - Optional request options
|
|
1326
|
+
* Note that this will replace any previous notification handler for the same method.
|
|
315
1327
|
*
|
|
316
|
-
*
|
|
1328
|
+
* For spec methods, pass `(method, handler)`; the notification is parsed with the
|
|
1329
|
+
* spec schema. For custom (non-spec) methods, pass `(method, schemas, handler)`;
|
|
1330
|
+
* `params` are validated against `schemas.params` and the handler receives the
|
|
1331
|
+
* parsed params object directly. The raw notification is passed as the second
|
|
1332
|
+
* argument; `_meta` is recoverable via `notification.params?._meta`.
|
|
317
1333
|
*/
|
|
318
|
-
|
|
1334
|
+
setNotificationHandler<M extends NotificationMethod>(method: M, handler: (notification: NotificationTypeMap[M]) => void | Promise<void>): void;
|
|
1335
|
+
setNotificationHandler<P extends StandardSchemaV1>(method: string, schemas: {
|
|
1336
|
+
params: P;
|
|
1337
|
+
}, handler: (params: StandardSchemaV1.InferOutput<P>, notification: Notification) => void | Promise<void>): void;
|
|
1338
|
+
/**
|
|
1339
|
+
* Removes the notification handler for the given method.
|
|
1340
|
+
*/
|
|
1341
|
+
removeNotificationHandler(method: NotificationMethod | string): void;
|
|
319
1342
|
}
|
|
1343
|
+
/**
|
|
1344
|
+
* Schema bundle accepted by {@linkcode Protocol.setRequestHandler | setRequestHandler}'s 3-arg form.
|
|
1345
|
+
*
|
|
1346
|
+
* `params` is required and validates the inbound `request.params`. `result` is optional;
|
|
1347
|
+
* when supplied it types the handler's return value (no runtime validation is performed
|
|
1348
|
+
* on the result).
|
|
1349
|
+
*/
|
|
1350
|
+
interface RequestHandlerSchemas<P extends StandardSchemaV1 = StandardSchemaV1, R extends StandardSchemaV1 | undefined = StandardSchemaV1 | undefined> {
|
|
1351
|
+
params: P;
|
|
1352
|
+
result?: R;
|
|
1353
|
+
}
|
|
1354
|
+
type InferHandlerResult<R extends StandardSchemaV1 | undefined> = R extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<R> : Result$1;
|
|
320
1355
|
//#endregion
|
|
321
|
-
//#region src/
|
|
1356
|
+
//#region ../core-internal/src/shared/stdio.d.ts
|
|
1357
|
+
declare const STDIO_DEFAULT_MAX_BUFFER_SIZE: number;
|
|
322
1358
|
/**
|
|
323
|
-
*
|
|
324
|
-
* The runtime-only fields are stripped before advertising capabilities to clients.
|
|
1359
|
+
* Buffers a continuous stdio stream into discrete JSON-RPC messages.
|
|
325
1360
|
*/
|
|
326
|
-
|
|
1361
|
+
declare class ReadBuffer {
|
|
1362
|
+
private _buffer?;
|
|
1363
|
+
private _maxBufferSize;
|
|
1364
|
+
constructor(options?: {
|
|
1365
|
+
maxBufferSize?: number;
|
|
1366
|
+
});
|
|
1367
|
+
append(chunk: Buffer): void;
|
|
1368
|
+
readMessage(): JSONRPCMessage | null;
|
|
1369
|
+
clear(): void;
|
|
1370
|
+
}
|
|
1371
|
+
declare function deserializeMessage(line: string): JSONRPCMessage;
|
|
1372
|
+
declare function serializeMessage(message: JSONRPCMessage): string;
|
|
1373
|
+
//#endregion
|
|
1374
|
+
//#region ../core-internal/src/shared/uriTemplate.d.ts
|
|
1375
|
+
type Variables = Record<string, string | string[]>;
|
|
1376
|
+
declare class UriTemplate {
|
|
1377
|
+
/**
|
|
1378
|
+
* Returns true if the given string contains any URI template expressions.
|
|
1379
|
+
* A template expression is a sequence of characters enclosed in curly braces,
|
|
1380
|
+
* like `{foo}` or `{?bar}`.
|
|
1381
|
+
*/
|
|
1382
|
+
static isTemplate(str: string): boolean;
|
|
1383
|
+
private static validateLength;
|
|
1384
|
+
private readonly template;
|
|
1385
|
+
private readonly parts;
|
|
1386
|
+
get variableNames(): string[];
|
|
1387
|
+
constructor(template: string);
|
|
1388
|
+
toString(): string;
|
|
1389
|
+
private parse;
|
|
1390
|
+
private getOperator;
|
|
1391
|
+
private getNames;
|
|
1392
|
+
private encodeValue;
|
|
1393
|
+
private expandPart;
|
|
1394
|
+
expand(variables: Variables): string;
|
|
1395
|
+
private escapeRegExp;
|
|
1396
|
+
private partToRegExp;
|
|
1397
|
+
match(uri: string): Variables | null;
|
|
1398
|
+
}
|
|
1399
|
+
//#endregion
|
|
1400
|
+
//#region ../core-internal/src/util/inMemory.d.ts
|
|
1401
|
+
/**
|
|
1402
|
+
* In-memory transport for creating clients and servers that talk to each other within the same process.
|
|
1403
|
+
*
|
|
1404
|
+
* Intended for testing and development. For production in-process connections, use
|
|
1405
|
+
* `StreamableHTTPClientTransport` against a local server URL.
|
|
1406
|
+
*/
|
|
1407
|
+
declare class InMemoryTransport implements Transport {
|
|
1408
|
+
private _otherTransport?;
|
|
1409
|
+
private _messageQueue;
|
|
1410
|
+
private _closed;
|
|
1411
|
+
onclose?: () => void;
|
|
1412
|
+
onerror?: (error: Error) => void;
|
|
1413
|
+
onmessage?: (message: JSONRPCMessage, extra?: {
|
|
1414
|
+
authInfo?: AuthInfo;
|
|
1415
|
+
}) => void;
|
|
1416
|
+
sessionId?: string;
|
|
1417
|
+
/**
|
|
1418
|
+
* Creates a pair of linked in-memory transports that can communicate with each other. One should be passed to a {@linkcode @modelcontextprotocol/client!client/client.Client | Client} and one to a {@linkcode @modelcontextprotocol/server!server/server.Server | Server}.
|
|
1419
|
+
*/
|
|
1420
|
+
static createLinkedPair(): [InMemoryTransport, InMemoryTransport];
|
|
1421
|
+
start(): Promise<void>;
|
|
1422
|
+
close(): Promise<void>;
|
|
1423
|
+
/**
|
|
1424
|
+
* Sends a message with optional auth info.
|
|
1425
|
+
* This is useful for testing authentication scenarios.
|
|
1426
|
+
*/
|
|
1427
|
+
send(message: JSONRPCMessage, options?: {
|
|
1428
|
+
relatedRequestId?: RequestId;
|
|
1429
|
+
authInfo?: AuthInfo;
|
|
1430
|
+
}): Promise<void>;
|
|
1431
|
+
}
|
|
1432
|
+
//#endregion
|
|
1433
|
+
//#region src/server/completable.d.ts
|
|
1434
|
+
declare const COMPLETABLE_SYMBOL: unique symbol;
|
|
1435
|
+
type CompleteCallback<T extends StandardSchemaV1 = StandardSchemaV1> = (value: StandardSchemaV1.InferInput<T>, context?: {
|
|
1436
|
+
arguments?: Record<string, string>;
|
|
1437
|
+
}) => StandardSchemaV1.InferInput<T>[] | Promise<StandardSchemaV1.InferInput<T>[]>;
|
|
1438
|
+
type CompletableMeta<T extends StandardSchemaV1 = StandardSchemaV1> = {
|
|
1439
|
+
complete: CompleteCallback<T>;
|
|
1440
|
+
};
|
|
1441
|
+
type CompletableSchema<T extends StandardSchemaV1> = T & {
|
|
1442
|
+
[COMPLETABLE_SYMBOL]: CompletableMeta<T>;
|
|
1443
|
+
};
|
|
1444
|
+
/**
|
|
1445
|
+
* Wraps a schema to provide autocompletion capabilities. Useful for, e.g., prompt arguments in MCP.
|
|
1446
|
+
*
|
|
1447
|
+
* @example
|
|
1448
|
+
* ```ts source="./completable.examples.ts#completable_basicUsage"
|
|
1449
|
+
* server.registerPrompt(
|
|
1450
|
+
* 'review-code',
|
|
1451
|
+
* {
|
|
1452
|
+
* title: 'Code Review',
|
|
1453
|
+
* argsSchema: z.object({
|
|
1454
|
+
* language: completable(z.string().describe('Programming language'), value =>
|
|
1455
|
+
* ['typescript', 'javascript', 'python', 'rust', 'go'].filter(lang => lang.startsWith(value))
|
|
1456
|
+
* )
|
|
1457
|
+
* })
|
|
1458
|
+
* },
|
|
1459
|
+
* ({ language }) => ({
|
|
1460
|
+
* messages: [
|
|
1461
|
+
* {
|
|
1462
|
+
* role: 'user' as const,
|
|
1463
|
+
* content: {
|
|
1464
|
+
* type: 'text' as const,
|
|
1465
|
+
* text: `Review this ${language} code.`
|
|
1466
|
+
* }
|
|
1467
|
+
* }
|
|
1468
|
+
* ]
|
|
1469
|
+
* })
|
|
1470
|
+
* );
|
|
1471
|
+
* ```
|
|
1472
|
+
*
|
|
1473
|
+
* @see {@linkcode server/mcp.McpServer.registerPrompt | McpServer.registerPrompt} for using completable schemas in prompt argument definitions
|
|
1474
|
+
*/
|
|
1475
|
+
declare function completable<T extends StandardSchemaV1>(schema: T, complete: CompleteCallback<T>): CompletableSchema<T>;
|
|
1476
|
+
/**
|
|
1477
|
+
* Checks if a schema is completable (has completion metadata).
|
|
1478
|
+
*/
|
|
1479
|
+
declare function isCompletable(schema: unknown): schema is CompletableSchema<StandardSchemaV1>;
|
|
1480
|
+
//#endregion
|
|
1481
|
+
//#region src/server/server.d.ts
|
|
327
1482
|
type ServerOptions = ProtocolOptions & {
|
|
328
1483
|
/**
|
|
329
1484
|
* Capabilities to advertise as being supported by this server.
|
|
1485
|
+
*
|
|
1486
|
+
* Note: per the MCP spec, a server that declares a capability MUST respond to that
|
|
1487
|
+
* capability's requests (e.g. `tools/list` for `tools`) — potentially with an empty
|
|
1488
|
+
* result — rather than with a "Method not found" error. {@linkcode server/mcp.McpServer | McpServer}
|
|
1489
|
+
* handles this automatically for capabilities declared here; when using the low-level
|
|
1490
|
+
* {@linkcode Server} directly, you are responsible for registering a request handler for
|
|
1491
|
+
* every capability you declare.
|
|
330
1492
|
*/
|
|
331
|
-
capabilities?:
|
|
332
|
-
tasks?: ServerTasksCapabilityWithRuntime;
|
|
333
|
-
};
|
|
1493
|
+
capabilities?: ServerCapabilities;
|
|
334
1494
|
/**
|
|
335
1495
|
* Optional instructions describing how to use the server and its features.
|
|
336
1496
|
*/
|
|
@@ -341,7 +1501,7 @@ type ServerOptions = ProtocolOptions & {
|
|
|
341
1501
|
* The validator is used to validate user input returned from elicitation
|
|
342
1502
|
* requests against the requested schema.
|
|
343
1503
|
*
|
|
344
|
-
* @default
|
|
1504
|
+
* @default Runtime-selected validator (AJV-backed on Node.js, `@cfworker/json-schema`-backed on browser/workerd runtimes)
|
|
345
1505
|
*/
|
|
346
1506
|
jsonSchemaValidator?: jsonSchemaValidator;
|
|
347
1507
|
};
|
|
@@ -356,10 +1516,10 @@ declare class Server extends Protocol<ServerContext> {
|
|
|
356
1516
|
private _serverInfo;
|
|
357
1517
|
private _clientCapabilities?;
|
|
358
1518
|
private _clientVersion?;
|
|
1519
|
+
private _negotiatedProtocolVersion?;
|
|
359
1520
|
private _capabilities;
|
|
360
1521
|
private _instructions?;
|
|
361
1522
|
private _jsonSchemaValidator;
|
|
362
|
-
private _experimental?;
|
|
363
1523
|
/**
|
|
364
1524
|
* Callback for when initialization has fully completed (i.e., the client has sent an `notifications/initialized` notification).
|
|
365
1525
|
*/
|
|
@@ -368,18 +1528,15 @@ declare class Server extends Protocol<ServerContext> {
|
|
|
368
1528
|
* Initializes this server with the given name and version information.
|
|
369
1529
|
*/
|
|
370
1530
|
constructor(_serverInfo: Implementation, options?: ServerOptions);
|
|
371
|
-
private _registerLoggingHandler;
|
|
372
|
-
protected buildContext(ctx: BaseContext, transportInfo?: MessageExtraInfo): ServerContext;
|
|
373
1531
|
/**
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
* WARNING: These APIs are experimental and may change without notice.
|
|
1532
|
+
* Registers the built-in `logging/setLevel` request handler.
|
|
377
1533
|
*
|
|
378
|
-
* @
|
|
1534
|
+
* @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
|
|
1535
|
+
* Remains functional during the deprecation window (at least twelve months).
|
|
1536
|
+
* Migrate to stderr logging (STDIO servers) or OpenTelemetry.
|
|
379
1537
|
*/
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
};
|
|
1538
|
+
private _registerLoggingHandler;
|
|
1539
|
+
protected buildContext(ctx: BaseContext, transportInfo?: MessageExtraInfo): ServerContext;
|
|
383
1540
|
private _loggingLevels;
|
|
384
1541
|
private readonly LOG_LEVEL_SEVERITY;
|
|
385
1542
|
private isMessageIgnored;
|
|
@@ -390,14 +1547,13 @@ declare class Server extends Protocol<ServerContext> {
|
|
|
390
1547
|
*/
|
|
391
1548
|
registerCapabilities(capabilities: ServerCapabilities): void;
|
|
392
1549
|
/**
|
|
393
|
-
*
|
|
1550
|
+
* Enforces server-side validation for `tools/call` results regardless of how the
|
|
1551
|
+
* handler was registered.
|
|
394
1552
|
*/
|
|
395
|
-
|
|
396
|
-
protected assertCapabilityForMethod(method: RequestMethod): void;
|
|
397
|
-
protected assertNotificationCapability(method: NotificationMethod): void;
|
|
1553
|
+
protected _wrapHandler(method: string, handler: (request: JSONRPCRequest, ctx: ServerContext) => Promise<Result$1>): (request: JSONRPCRequest, ctx: ServerContext) => Promise<Result$1>;
|
|
1554
|
+
protected assertCapabilityForMethod(method: RequestMethod | string): void;
|
|
1555
|
+
protected assertNotificationCapability(method: NotificationMethod | string): void;
|
|
398
1556
|
protected assertRequestHandlerCapability(method: string): void;
|
|
399
|
-
protected assertTaskCapability(method: string): void;
|
|
400
|
-
protected assertTaskHandlerCapability(method: string): void;
|
|
401
1557
|
private _oninitialize;
|
|
402
1558
|
/**
|
|
403
1559
|
* After initialization has completed, this will be populated with the client's reported capabilities.
|
|
@@ -407,6 +1563,12 @@ declare class Server extends Protocol<ServerContext> {
|
|
|
407
1563
|
* After initialization has completed, this will be populated with information about the client's name and version.
|
|
408
1564
|
*/
|
|
409
1565
|
getClientVersion(): Implementation | undefined;
|
|
1566
|
+
/**
|
|
1567
|
+
* After initialization has completed, this will be populated with the protocol version negotiated
|
|
1568
|
+
* with the client (the version the server responded with during the initialize handshake), or
|
|
1569
|
+
* `undefined` before initialization.
|
|
1570
|
+
*/
|
|
1571
|
+
getNegotiatedProtocolVersion(): string | undefined;
|
|
410
1572
|
/**
|
|
411
1573
|
* Returns the current server capabilities.
|
|
412
1574
|
*/
|
|
@@ -419,20 +1581,33 @@ declare class Server extends Protocol<ServerContext> {
|
|
|
419
1581
|
taskId: string;
|
|
420
1582
|
} | undefined;
|
|
421
1583
|
} | undefined;
|
|
1584
|
+
resultType?: string | undefined;
|
|
422
1585
|
}>;
|
|
423
1586
|
/**
|
|
424
1587
|
* Request LLM sampling from the client (without tools).
|
|
425
1588
|
* Returns single content block for backwards compatibility.
|
|
1589
|
+
*
|
|
1590
|
+
* @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
|
|
1591
|
+
* Remains functional during the deprecation window (at least twelve months).
|
|
1592
|
+
* Migrate to calling LLM provider APIs directly.
|
|
426
1593
|
*/
|
|
427
1594
|
createMessage(params: CreateMessageRequestParamsBase, options?: RequestOptions): Promise<CreateMessageResult>;
|
|
428
1595
|
/**
|
|
429
1596
|
* Request LLM sampling from the client with tool support.
|
|
430
1597
|
* Returns content that may be a single block or array (for parallel tool calls).
|
|
1598
|
+
*
|
|
1599
|
+
* @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
|
|
1600
|
+
* Remains functional during the deprecation window (at least twelve months).
|
|
1601
|
+
* Migrate to calling LLM provider APIs directly.
|
|
431
1602
|
*/
|
|
432
1603
|
createMessage(params: CreateMessageRequestParamsWithTools, options?: RequestOptions): Promise<CreateMessageResultWithTools>;
|
|
433
1604
|
/**
|
|
434
1605
|
* Request LLM sampling from the client.
|
|
435
1606
|
* When tools may or may not be present, returns the union type.
|
|
1607
|
+
*
|
|
1608
|
+
* @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
|
|
1609
|
+
* Remains functional during the deprecation window (at least twelve months).
|
|
1610
|
+
* Migrate to calling LLM provider APIs directly.
|
|
436
1611
|
*/
|
|
437
1612
|
createMessage(params: CreateMessageRequest['params'], options?: RequestOptions): Promise<CreateMessageResult | CreateMessageResultWithTools>;
|
|
438
1613
|
/**
|
|
@@ -452,6 +1627,13 @@ declare class Server extends Protocol<ServerContext> {
|
|
|
452
1627
|
* @returns A function that emits the completion notification when awaited.
|
|
453
1628
|
*/
|
|
454
1629
|
createElicitationCompletionNotifier(elicitationId: string, options?: NotificationOptions): () => Promise<void>;
|
|
1630
|
+
/**
|
|
1631
|
+
* Requests the list of roots from the client.
|
|
1632
|
+
*
|
|
1633
|
+
* @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
|
|
1634
|
+
* Remains functional during the deprecation window (at least twelve months).
|
|
1635
|
+
* Migrate to passing paths via tool parameters, resource URIs, or configuration.
|
|
1636
|
+
*/
|
|
455
1637
|
listRoots(params?: ListRootsRequest['params'], options?: RequestOptions): Promise<{
|
|
456
1638
|
[x: string]: unknown;
|
|
457
1639
|
roots: {
|
|
@@ -466,6 +1648,7 @@ declare class Server extends Protocol<ServerContext> {
|
|
|
466
1648
|
taskId: string;
|
|
467
1649
|
} | undefined;
|
|
468
1650
|
} | undefined;
|
|
1651
|
+
resultType?: string | undefined;
|
|
469
1652
|
}>;
|
|
470
1653
|
/**
|
|
471
1654
|
* Sends a logging message to the client, if connected.
|
|
@@ -473,6 +1656,10 @@ declare class Server extends Protocol<ServerContext> {
|
|
|
473
1656
|
* @see {@linkcode LoggingMessageNotification}
|
|
474
1657
|
* @param params
|
|
475
1658
|
* @param sessionId Optional for stateless transports and backward compatibility.
|
|
1659
|
+
*
|
|
1660
|
+
* @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
|
|
1661
|
+
* Remains functional during the deprecation window (at least twelve months).
|
|
1662
|
+
* Migrate to stderr logging (STDIO servers) or OpenTelemetry.
|
|
476
1663
|
*/
|
|
477
1664
|
sendLoggingMessage(params: LoggingMessageNotification['params'], sessionId?: string): Promise<void>;
|
|
478
1665
|
sendResourceUpdated(params: ResourceUpdatedNotification['params']): Promise<void>;
|
|
@@ -504,18 +1691,7 @@ declare class McpServer {
|
|
|
504
1691
|
private _registeredResourceTemplates;
|
|
505
1692
|
private _registeredTools;
|
|
506
1693
|
private _registeredPrompts;
|
|
507
|
-
private _experimental?;
|
|
508
1694
|
constructor(serverInfo: Implementation, options?: ServerOptions);
|
|
509
|
-
/**
|
|
510
|
-
* Access experimental features.
|
|
511
|
-
*
|
|
512
|
-
* WARNING: These APIs are experimental and may change without notice.
|
|
513
|
-
*
|
|
514
|
-
* @experimental
|
|
515
|
-
*/
|
|
516
|
-
get experimental(): {
|
|
517
|
-
tasks: ExperimentalMcpServerTasks;
|
|
518
|
-
};
|
|
519
1695
|
/**
|
|
520
1696
|
* Attaches to the given transport, starts it, and starts listening for messages.
|
|
521
1697
|
*
|
|
@@ -551,13 +1727,9 @@ declare class McpServer {
|
|
|
551
1727
|
*/
|
|
552
1728
|
private validateToolOutput;
|
|
553
1729
|
/**
|
|
554
|
-
* Executes a tool handler
|
|
1730
|
+
* Executes a tool handler.
|
|
555
1731
|
*/
|
|
556
1732
|
private executeToolHandler;
|
|
557
|
-
/**
|
|
558
|
-
* Handles automatic task polling for tools with `taskSupport` `'optional'`.
|
|
559
|
-
*/
|
|
560
|
-
private handleAutomaticTaskPolling;
|
|
561
1733
|
private _completionHandlerInitialized;
|
|
562
1734
|
private setCompletionRequestHandler;
|
|
563
1735
|
private handlePromptCompletion;
|
|
@@ -623,8 +1795,19 @@ declare class McpServer {
|
|
|
623
1795
|
inputSchema?: InputArgs;
|
|
624
1796
|
outputSchema?: OutputArgs;
|
|
625
1797
|
annotations?: ToolAnnotations;
|
|
1798
|
+
icons?: Icon[];
|
|
626
1799
|
_meta?: Record<string, unknown>;
|
|
627
1800
|
}, cb: ToolCallback<InputArgs>): RegisteredTool;
|
|
1801
|
+
/** @deprecated Wrap with `z.object({...})` instead. Raw-shape form: `inputSchema`/`outputSchema` may be a plain `{ field: z.string() }` record; it is auto-wrapped with `z.object()`. */
|
|
1802
|
+
registerTool<InputArgs extends ZodRawShape, OutputArgs extends ZodRawShape | StandardSchemaWithJSON | undefined = undefined>(name: string, config: {
|
|
1803
|
+
title?: string;
|
|
1804
|
+
description?: string;
|
|
1805
|
+
inputSchema?: InputArgs;
|
|
1806
|
+
outputSchema?: OutputArgs;
|
|
1807
|
+
annotations?: ToolAnnotations;
|
|
1808
|
+
icons?: Icon[];
|
|
1809
|
+
_meta?: Record<string, unknown>;
|
|
1810
|
+
}, cb: LegacyToolCallback<InputArgs>): RegisteredTool;
|
|
628
1811
|
/**
|
|
629
1812
|
* Registers a prompt with a config object and callback.
|
|
630
1813
|
*
|
|
@@ -655,8 +1838,17 @@ declare class McpServer {
|
|
|
655
1838
|
title?: string;
|
|
656
1839
|
description?: string;
|
|
657
1840
|
argsSchema?: Args;
|
|
1841
|
+
icons?: Icon[];
|
|
658
1842
|
_meta?: Record<string, unknown>;
|
|
659
1843
|
}, cb: PromptCallback<Args>): RegisteredPrompt;
|
|
1844
|
+
/** @deprecated Wrap with `z.object({...})` instead. Raw-shape form: `argsSchema` may be a plain `{ field: z.string() }` record; it is auto-wrapped with `z.object()`. */
|
|
1845
|
+
registerPrompt<Args extends ZodRawShape>(name: string, config: {
|
|
1846
|
+
title?: string;
|
|
1847
|
+
description?: string;
|
|
1848
|
+
argsSchema?: Args;
|
|
1849
|
+
icons?: Icon[];
|
|
1850
|
+
_meta?: Record<string, unknown>;
|
|
1851
|
+
}, cb: LegacyPromptCallback<Args>): RegisteredPrompt;
|
|
660
1852
|
/**
|
|
661
1853
|
* Checks if the server is connected to a transport.
|
|
662
1854
|
* @returns `true` if the server is connected
|
|
@@ -676,6 +1868,10 @@ declare class McpServer {
|
|
|
676
1868
|
* data: 'Processing complete'
|
|
677
1869
|
* });
|
|
678
1870
|
* ```
|
|
1871
|
+
*
|
|
1872
|
+
* @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
|
|
1873
|
+
* Remains functional during the deprecation window (at least twelve months).
|
|
1874
|
+
* Migrate to stderr logging (STDIO servers) or OpenTelemetry.
|
|
679
1875
|
*/
|
|
680
1876
|
sendLoggingMessage(params: LoggingMessageNotification['params'], sessionId?: string): Promise<void>;
|
|
681
1877
|
/**
|
|
@@ -729,25 +1925,38 @@ declare class ResourceTemplate {
|
|
|
729
1925
|
*/
|
|
730
1926
|
completeCallback(variable: string): CompleteResourceTemplateCallback | undefined;
|
|
731
1927
|
}
|
|
732
|
-
|
|
1928
|
+
/**
|
|
1929
|
+
* A plain record of Zod field schemas, e.g. `{ name: z.string() }`. Accepted by
|
|
1930
|
+
* `registerTool`/`registerPrompt` as a shorthand; auto-wrapped with `z.object()`.
|
|
1931
|
+
* Zod schemas only — `z.object()` cannot wrap other Standard Schema libraries.
|
|
1932
|
+
*/
|
|
1933
|
+
type ZodRawShape = Record<string, z.ZodType>;
|
|
1934
|
+
/** Infers the parsed-output type of a {@linkcode ZodRawShape}. */
|
|
1935
|
+
type InferRawShape<S extends ZodRawShape> = z.infer<z.ZodObject<S>>;
|
|
1936
|
+
/** {@linkcode ToolCallback} variant used when `inputSchema` is a {@linkcode ZodRawShape}. */
|
|
1937
|
+
type LegacyToolCallback<Args extends ZodRawShape | undefined> = Args extends ZodRawShape ? (args: InferRawShape<Args>, ctx: ServerContext) => CallToolResult | Promise<CallToolResult> : (ctx: ServerContext) => CallToolResult | Promise<CallToolResult>;
|
|
1938
|
+
/** {@linkcode PromptCallback} variant used when `argsSchema` is a {@linkcode ZodRawShape}. */
|
|
1939
|
+
type LegacyPromptCallback<Args extends ZodRawShape | undefined> = Args extends ZodRawShape ? (args: InferRawShape<Args>, ctx: ServerContext) => GetPromptResult | Promise<GetPromptResult> : (ctx: ServerContext) => GetPromptResult | Promise<GetPromptResult>;
|
|
1940
|
+
type BaseToolCallback<SendResultT extends Result$1, Ctx extends ServerContext, Args extends StandardSchemaWithJSON | undefined> = Args extends StandardSchemaWithJSON ? (args: StandardSchemaWithJSON.InferOutput<Args>, ctx: Ctx) => SendResultT | Promise<SendResultT> : (ctx: Ctx) => SendResultT | Promise<SendResultT>;
|
|
733
1941
|
/**
|
|
734
1942
|
* Callback for a tool handler registered with {@linkcode McpServer.registerTool}.
|
|
735
1943
|
*/
|
|
736
1944
|
type ToolCallback<Args extends StandardSchemaWithJSON | undefined = undefined> = BaseToolCallback<CallToolResult, ServerContext, Args>;
|
|
737
1945
|
/**
|
|
738
|
-
*
|
|
1946
|
+
* Tool handler callback type.
|
|
739
1947
|
*/
|
|
740
|
-
type AnyToolHandler<Args extends StandardSchemaWithJSON | undefined = undefined> = ToolCallback<Args
|
|
1948
|
+
type AnyToolHandler<Args extends StandardSchemaWithJSON | undefined = undefined> = ToolCallback<Args>;
|
|
741
1949
|
/**
|
|
742
1950
|
* Internal executor type that encapsulates handler invocation with proper types.
|
|
743
1951
|
*/
|
|
744
|
-
type ToolExecutor = (args: unknown, ctx: ServerContext) => Promise<CallToolResult
|
|
1952
|
+
type ToolExecutor = (args: unknown, ctx: ServerContext) => Promise<CallToolResult>;
|
|
745
1953
|
type RegisteredTool = {
|
|
746
1954
|
title?: string;
|
|
747
1955
|
description?: string;
|
|
748
1956
|
inputSchema?: StandardSchemaWithJSON;
|
|
749
1957
|
outputSchema?: StandardSchemaWithJSON;
|
|
750
1958
|
annotations?: ToolAnnotations;
|
|
1959
|
+
icons?: Icon[];
|
|
751
1960
|
execution?: ToolExecution;
|
|
752
1961
|
_meta?: Record<string, unknown>;
|
|
753
1962
|
handler: AnyToolHandler<StandardSchemaWithJSON | undefined>;
|
|
@@ -763,6 +1972,7 @@ type RegisteredTool = {
|
|
|
763
1972
|
paramsSchema?: StandardSchemaWithJSON;
|
|
764
1973
|
outputSchema?: StandardSchemaWithJSON;
|
|
765
1974
|
annotations?: ToolAnnotations;
|
|
1975
|
+
icons?: Icon[];
|
|
766
1976
|
_meta?: Record<string, unknown>;
|
|
767
1977
|
callback?: ToolCallback<StandardSchemaWithJSON>;
|
|
768
1978
|
enabled?: boolean;
|
|
@@ -831,6 +2041,7 @@ type RegisteredPrompt = {
|
|
|
831
2041
|
title?: string;
|
|
832
2042
|
description?: string;
|
|
833
2043
|
argsSchema?: StandardSchemaWithJSON;
|
|
2044
|
+
icons?: Icon[];
|
|
834
2045
|
_meta?: Record<string, unknown>;
|
|
835
2046
|
/** @hidden */
|
|
836
2047
|
handler: PromptHandler;
|
|
@@ -842,6 +2053,7 @@ type RegisteredPrompt = {
|
|
|
842
2053
|
title?: string;
|
|
843
2054
|
description?: string;
|
|
844
2055
|
argsSchema?: Args;
|
|
2056
|
+
icons?: Icon[];
|
|
845
2057
|
_meta?: Record<string, unknown>;
|
|
846
2058
|
callback?: PromptCallback<Args>;
|
|
847
2059
|
enabled?: boolean;
|
|
@@ -880,41 +2092,6 @@ declare function localhostAllowedHostnames(): string[];
|
|
|
880
2092
|
*/
|
|
881
2093
|
declare function hostHeaderValidationResponse(req: Request, allowedHostnames: string[]): Response | undefined;
|
|
882
2094
|
//#endregion
|
|
883
|
-
//#region src/server/stdio.d.ts
|
|
884
|
-
/**
|
|
885
|
-
* Server transport for stdio: this communicates with an MCP client by reading from the current process' `stdin` and writing to `stdout`.
|
|
886
|
-
*
|
|
887
|
-
* This transport is only available in Node.js environments.
|
|
888
|
-
*
|
|
889
|
-
* @example
|
|
890
|
-
* ```ts source="./stdio.examples.ts#StdioServerTransport_basicUsage"
|
|
891
|
-
* const server = new McpServer({ name: 'my-server', version: '1.0.0' });
|
|
892
|
-
* const transport = new StdioServerTransport();
|
|
893
|
-
* await server.connect(transport);
|
|
894
|
-
* ```
|
|
895
|
-
*/
|
|
896
|
-
declare class StdioServerTransport implements Transport {
|
|
897
|
-
private _stdin;
|
|
898
|
-
private _stdout;
|
|
899
|
-
private _readBuffer;
|
|
900
|
-
private _started;
|
|
901
|
-
private _closed;
|
|
902
|
-
constructor(_stdin?: Readable, _stdout?: Writable);
|
|
903
|
-
onclose?: () => void;
|
|
904
|
-
onerror?: (error: Error) => void;
|
|
905
|
-
onmessage?: (message: JSONRPCMessage) => void;
|
|
906
|
-
_ondata: (chunk: Buffer) => void;
|
|
907
|
-
_onerror: (error: Error) => void;
|
|
908
|
-
_onstdouterror: (error: Error) => void;
|
|
909
|
-
/**
|
|
910
|
-
* Starts listening for messages on `stdin`.
|
|
911
|
-
*/
|
|
912
|
-
start(): Promise<void>;
|
|
913
|
-
private processReadBuffer;
|
|
914
|
-
close(): Promise<void>;
|
|
915
|
-
send(message: JSONRPCMessage): Promise<void>;
|
|
916
|
-
}
|
|
917
|
-
//#endregion
|
|
918
2095
|
//#region src/server/streamableHttp.d.ts
|
|
919
2096
|
type StreamId = string;
|
|
920
2097
|
type EventId = string;
|
|
@@ -954,7 +2131,7 @@ interface WebStandardStreamableHTTPServerTransportOptions {
|
|
|
954
2131
|
*
|
|
955
2132
|
* If not provided, session management is disabled (stateless mode).
|
|
956
2133
|
*/
|
|
957
|
-
sessionIdGenerator?: () => string;
|
|
2134
|
+
sessionIdGenerator?: (() => string) | undefined;
|
|
958
2135
|
/**
|
|
959
2136
|
* A callback for session initialization events
|
|
960
2137
|
* This is called when the server initializes a new session.
|
|
@@ -962,7 +2139,7 @@ interface WebStandardStreamableHTTPServerTransportOptions {
|
|
|
962
2139
|
* and need to keep track of them.
|
|
963
2140
|
* @param sessionId The generated session ID
|
|
964
2141
|
*/
|
|
965
|
-
onsessioninitialized?: (sessionId: string) => void | Promise<void
|
|
2142
|
+
onsessioninitialized?: ((sessionId: string) => void | Promise<void>) | undefined;
|
|
966
2143
|
/**
|
|
967
2144
|
* A callback for session close events
|
|
968
2145
|
* This is called when the server closes a session due to a `DELETE` request.
|
|
@@ -973,7 +2150,7 @@ interface WebStandardStreamableHTTPServerTransportOptions {
|
|
|
973
2150
|
* session open/running.
|
|
974
2151
|
* @param sessionId The session ID that was closed
|
|
975
2152
|
*/
|
|
976
|
-
onsessionclosed?: (sessionId: string) => void | Promise<void
|
|
2153
|
+
onsessionclosed?: ((sessionId: string) => void | Promise<void>) | undefined;
|
|
977
2154
|
/**
|
|
978
2155
|
* If `true`, the server will return JSON responses instead of starting an SSE stream.
|
|
979
2156
|
* This can be useful for simple request/response scenarios without streaming.
|
|
@@ -1089,6 +2266,7 @@ interface HandleRequestOptions {
|
|
|
1089
2266
|
declare class WebStandardStreamableHTTPServerTransport implements Transport {
|
|
1090
2267
|
private sessionIdGenerator;
|
|
1091
2268
|
private _started;
|
|
2269
|
+
private _closed;
|
|
1092
2270
|
private _streamMapping;
|
|
1093
2271
|
private _requestToStreamMapping;
|
|
1094
2272
|
private _requestResponseMap;
|
|
@@ -1132,10 +2310,24 @@ declare class WebStandardStreamableHTTPServerTransport implements Transport {
|
|
|
1132
2310
|
* Returns a `Response` object (Web Standard)
|
|
1133
2311
|
*/
|
|
1134
2312
|
handleRequest(req: Request, options?: HandleRequestOptions): Promise<Response>;
|
|
2313
|
+
/**
|
|
2314
|
+
* Returns true if the client's protocol version supports empty SSE data in
|
|
2315
|
+
* priming events (the fix shipped with protocol version `2025-11-25`).
|
|
2316
|
+
*
|
|
2317
|
+
* The version is checked for membership in this transport instance's
|
|
2318
|
+
* supported protocol versions rather than with an open-ended
|
|
2319
|
+
* `>= '2025-11-25'` comparison: the value may come from an `initialize`
|
|
2320
|
+
* request body, which (unlike the `MCP-Protocol-Version` header) is not
|
|
2321
|
+
* validated against `supportedProtocolVersions` before reaching this
|
|
2322
|
+
* check. An unknown future version string must not silently enable
|
|
2323
|
+
* behavior reserved for versions this transport actually supports.
|
|
2324
|
+
*/
|
|
2325
|
+
private supportsEmptySSEData;
|
|
1135
2326
|
/**
|
|
1136
2327
|
* Writes a priming event to establish resumption capability.
|
|
1137
2328
|
* Only sends if `eventStore` is configured (opt-in for resumability) and
|
|
1138
|
-
* the client's protocol version supports empty SSE data (
|
|
2329
|
+
* the client's protocol version supports empty SSE data (a supported
|
|
2330
|
+
* version that is >= `2025-11-25`).
|
|
1139
2331
|
*/
|
|
1140
2332
|
private writePrimingEvent;
|
|
1141
2333
|
/**
|
|
@@ -1202,5 +2394,5 @@ declare class WebStandardStreamableHTTPServerTransport implements Transport {
|
|
|
1202
2394
|
//#region src/fromJsonSchema.d.ts
|
|
1203
2395
|
declare function fromJsonSchema<T = unknown>(schema: JsonSchemaType, validator?: jsonSchemaValidator): StandardSchemaWithJSON<T, T>;
|
|
1204
2396
|
//#endregion
|
|
1205
|
-
export { AjvJsonSchemaValidator, Annotations, type AnyToolHandler, AudioContent, AuthInfo,
|
|
2397
|
+
export { AjvJsonSchemaValidator, Annotations, type AnyToolHandler, AudioContent, AuthInfo, AuthorizationServerMetadata, BAGGAGE_META_KEY, BaseContext, BaseMetadata, type BaseToolCallback, BlobResourceContents, BooleanSchema, CLIENT_CAPABILITIES_META_KEY, CLIENT_INFO_META_KEY, CallToolRequest, CallToolRequestParams, CallToolResult, CancelTaskRequest, CancelTaskResult, CancelledNotification, CancelledNotificationParams, CfWorkerJsonSchemaValidator, CfWorkerSchemaDraft, ClientCapabilities, ClientContext, ClientNotification, ClientRequest, ClientResult, CompatibilityCallToolResult, type CompletableSchema, type CompleteCallback, CompleteRequest, CompleteRequestParams, CompleteRequestPrompt, CompleteRequestResourceTemplate, type CompleteResourceTemplateCallback, CompleteResult, ContentBlock, CreateMessageRequest, CreateMessageRequestParams, CreateMessageRequestParamsBase, CreateMessageRequestParamsWithTools, CreateMessageResult, CreateMessageResultWithTools, CreateTaskResult, Cursor, DEFAULT_NEGOTIATED_PROTOCOL_VERSION, DEFAULT_REQUEST_TIMEOUT_MSEC, DiscoverRequest, DiscoverResult, ElicitRequest, ElicitRequestFormParams, ElicitRequestParams, ElicitRequestURLParams, ElicitResult, ElicitationCompleteNotification, ElicitationCompleteNotificationParams, EmbeddedResource, EmptyResult, EnumSchema, type EventId, type EventStore, FetchLike, GetPromptRequest, GetPromptRequestParams, GetPromptResult, GetTaskPayloadRequest, GetTaskPayloadResult, GetTaskRequest, GetTaskResult, type HandleRequestOptions, type HostHeaderValidationResult, INTERNAL_ERROR, INVALID_PARAMS, INVALID_REQUEST, Icon, Icons, IdJagTokenExchangeResponse, ImageContent, Implementation, InMemoryTransport, InitializeRequest, InitializeRequestParams, InitializeResult, InitializedNotification, InternalError, InvalidParamsError, InvalidRequestError, JSONArray, JSONObject, JSONRPCErrorResponse, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONRPCResultResponse, JSONRPC_VERSION, JSONValue, JsonSchemaType, JsonSchemaValidator, JsonSchemaValidatorResult, LATEST_PROTOCOL_VERSION, LOG_LEVEL_META_KEY, LegacyTitledEnumSchema, ListChangedCallback, ListChangedHandlers, ListChangedOptions, ListPromptsRequest, ListPromptsResult, ListResourceTemplatesRequest, ListResourceTemplatesResult, type ListResourcesCallback, ListResourcesRequest, ListResourcesResult, ListRootsRequest, ListRootsResult, ListTasksRequest, ListTasksResult, ListToolsRequest, ListToolsResult, LoggingLevel, LoggingMessageNotification, LoggingMessageNotificationParams, METHOD_NOT_FOUND, McpServer, MessageExtraInfo, MetaObject, MethodNotFoundError, ModelHint, ModelPreferences, MultiSelectEnumSchema, Notification, NotificationMethod, NotificationOptions, NotificationParams, NotificationTypeMap, NumberSchema, OAuthClientInformation, OAuthClientInformationFull, OAuthClientInformationMixed, OAuthClientMetadata, OAuthClientRegistrationError, OAuthError, OAuthErrorCode, OAuthErrorResponse, OAuthMetadata, OAuthProtectedResourceMetadata, OAuthTokenRevocationRequest, OAuthTokens, OpenIdProviderDiscoveryMetadata, OpenIdProviderMetadata, PARSE_ERROR, PROTOCOL_VERSION_META_KEY, PaginatedRequest, PaginatedRequestParams, PaginatedResult, ParseError, PingRequest, PrimitiveSchemaDefinition, Progress, ProgressCallback, ProgressNotification, ProgressNotificationParams, ProgressToken, Prompt, PromptArgument, type PromptCallback, PromptListChangedNotification, PromptMessage, PromptReference, ProtocolError, ProtocolErrorCode, ProtocolOptions, RELATED_TASK_META_KEY, ReadBuffer, type ReadResourceCallback, ReadResourceRequest, ReadResourceRequestParams, ReadResourceResult, type ReadResourceTemplateCallback, type RegisteredPrompt, type RegisteredResource, type RegisteredResourceTemplate, type RegisteredTool, RelatedTaskMetadata, Request$1 as Request, RequestHandlerSchemas, RequestId, RequestMeta, RequestMetaEnvelope, RequestMetaObject, RequestMethod, RequestOptions, RequestParams, RequestTypeMap, Resource, ResourceContents, ResourceLink, ResourceListChangedNotification, type ResourceMetadata, ResourceRequestParams, ResourceTemplate, ResourceTemplateReference, ResourceTemplateType, ResourceUpdatedNotification, ResourceUpdatedNotificationParams, Result$1 as Result, ResultTypeMap, Role, Root, RootsListChangedNotification, STDIO_DEFAULT_MAX_BUFFER_SIZE, SUPPORTED_PROTOCOL_VERSIONS, SamplingContent, SamplingMessage, SamplingMessageContentBlock, SdkError, SdkErrorCode, SdkHttpError, SdkHttpErrorData, Server, ServerCapabilities, ServerContext, ServerNotification, type ServerOptions, ServerRequest, ServerResult, SetLevelRequest, SetLevelRequestParams, SingleSelectEnumSchema, SpecTypeName, SpecTypes, StandardSchemaV1, StandardSchemaV1Sync, StandardSchemaWithJSON, type StreamId, StringSchema, SubscribeRequest, SubscribeRequestParams, TRACEPARENT_META_KEY, TRACESTATE_META_KEY, Task, TaskAugmentedRequestParams, TaskCreationParams, TaskMetadata, TaskStatus, TaskStatusNotification, TaskStatusNotificationParams, TextContent, TextResourceContents, TitledMultiSelectEnumSchema, TitledSingleSelectEnumSchema, Tool, ToolAnnotations, type ToolCallback, ToolChoice, ToolExecution, ToolListChangedNotification, ToolResultContent, ToolUseContent, Transport, TransportSendOptions, UnsubscribeRequest, UnsubscribeRequestParams, UnsupportedProtocolVersionError, UnsupportedProtocolVersionErrorData, UntitledMultiSelectEnumSchema, UntitledSingleSelectEnumSchema, UriTemplate, UrlElicitationRequiredError, Variables, WebStandardStreamableHTTPServerTransport, type WebStandardStreamableHTTPServerTransportOptions, assertCompleteRequestPrompt, assertCompleteRequestResourceTemplate, checkResourceAllowed, completable, createFetchWithInit, deserializeMessage, fromJsonSchema, getDisplayName, hostHeaderValidationResponse, isCallToolResult, isCompletable, isInitializeRequest, isInitializedNotification, isJSONRPCErrorResponse, isJSONRPCNotification, isJSONRPCRequest, isJSONRPCResponse, isJSONRPCResultResponse, isSpecType, isTaskAugmentedRequestParams, jsonSchemaValidator, localhostAllowedHostnames, parseJSONRPCMessage, resourceUrlFromServerUrl, serializeMessage, specTypeSchemas, validateHostHeader };
|
|
1206
2398
|
//# sourceMappingURL=index.d.mts.map
|