You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(core): Protocol composes Dispatcher and StreamDriver; dispatch() public
Protocol now holds a private Dispatcher (handler registry, middleware) and constructs a StreamDriver per connect(). Public methods delegate; protocol.ts shrinks from ~1011 to ~393 LOC.
dispatch(req, env): AsyncIterable<JSONRPCMessage> is now a public method: any per-request driver (HTTP, FaaS) can iterate it directly without a transport.
Behavior unchanged: protocol.test.ts is unmodified, conformance 40/40.
* Whether to restrict emitted requests to only those that the remote side has indicated that they can handle, through their advertised capabilities.
43
+
*
44
+
* Note that this DOES NOT affect checking of _local_ side capabilities, as it is considered a logic error to mis-specify those.
45
+
*
46
+
* Currently this defaults to `false`, for backwards compatibility with SDK versions that did not advertise capabilities correctly. In future, this will default to `true`.
47
+
*/
48
+
enforceStrictCapabilities?: boolean;
49
+
/**
50
+
* An array of notification method names that should be automatically debounced.
51
+
* Any notifications with a method in this list will be coalesced if they
52
+
* occur in the same tick of the event loop.
53
+
* e.g., `['notifications/tools/list_changed']`
54
+
*/
55
+
debouncedNotificationMethods?: string[];
56
+
};
57
+
58
+
/**
59
+
* The default request timeout, in milliseconds.
60
+
*/
61
+
exportconstDEFAULT_REQUEST_TIMEOUT_MSEC=60_000;
62
+
63
+
/**
64
+
* Options that can be given per request.
65
+
*/
66
+
exporttypeRequestOptions={
67
+
/**
68
+
* If set, requests progress notifications from the remote end (if supported). When progress notifications are received, this callback will be invoked.
69
+
*/
70
+
onprogress?: ProgressCallback;
71
+
72
+
/**
73
+
* Can be used to cancel an in-flight request. This will cause an `AbortError` to be raised from {@linkcode Protocol.request | request()}.
74
+
*/
75
+
signal?: AbortSignal;
76
+
77
+
/**
78
+
* 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()}.
79
+
*
80
+
* If not specified, {@linkcode DEFAULT_REQUEST_TIMEOUT_MSEC} will be used as the timeout.
81
+
*/
82
+
timeout?: number;
83
+
84
+
/**
85
+
* If `true`, receiving a progress notification will reset the request timeout.
86
+
* This is useful for long-running operations that send periodic progress updates.
87
+
* Default: `false`
88
+
*/
89
+
resetTimeoutOnProgress?: boolean;
90
+
91
+
/**
92
+
* Maximum total time (in milliseconds) to wait for a response.
93
+
* If exceeded, an {@linkcode SdkError} with code {@linkcode SdkErrorCode.RequestTimeout} will be raised, regardless of progress notifications.
94
+
* If not specified, there is no maximum total timeout.
95
+
*/
96
+
maxTotalTimeout?: number;
97
+
}&TransportSendOptions;
98
+
99
+
/**
100
+
* Options that can be given per notification.
101
+
*/
102
+
exporttypeNotificationOptions={
103
+
/**
104
+
* May be used to indicate to the transport which incoming request to associate this outgoing notification with.
105
+
*/
106
+
relatedRequestId?: RequestId;
107
+
};
108
+
109
+
/**
110
+
* Base context provided to all request handlers.
111
+
*/
112
+
exporttypeBaseContext={
113
+
/**
114
+
* The session ID from the transport, if available.
115
+
*/
116
+
sessionId?: string;
117
+
118
+
/**
119
+
* Information about the MCP request being handled.
120
+
*/
121
+
mcpReq: {
122
+
/**
123
+
* The JSON-RPC ID of the request being handled.
124
+
*/
125
+
id: RequestId;
126
+
127
+
/**
128
+
* The method name of the request (e.g., 'tools/call', 'ping').
129
+
*/
130
+
method: string;
131
+
132
+
/**
133
+
* Metadata from the original request.
134
+
*/
135
+
_meta?: RequestMeta;
136
+
137
+
/**
138
+
* An abort signal used to communicate if the request was cancelled from the sender's side.
139
+
*/
140
+
signal: AbortSignal;
141
+
142
+
/**
143
+
* Sends a request that relates to the current request being handled.
144
+
*
145
+
* This is used by certain transports to correctly associate related messages.
146
+
*
147
+
* For spec methods the result type is inferred from the method name.
148
+
* For custom (non-spec) methods, pass a result schema as the second argument.
0 commit comments