toolcraft 0.0.713 → 0.0.715
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/composition.json +3 -3
- package/dist/composition.json +3 -3
- package/node_modules/tiny-http-mcp-server/dist/composition.json +1 -1
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/authorization-error.d.ts +7 -0
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/authorization-error.js +16 -0
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/loopback-authorization.d.ts +1 -7
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/loopback-authorization.js +2 -16
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/index.browser.d.ts +12 -0
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/index.browser.js +18 -0
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/package.json +7 -1
- package/node_modules/tiny-http-mcp-server/package.json +1 -1
- package/node_modules/tiny-mcp-client/dist/index.browser.d.ts +888 -0
- package/node_modules/tiny-mcp-client/dist/index.browser.js +6689 -0
- package/node_modules/tiny-mcp-client/dist/index.js +18 -17
- package/node_modules/tiny-mcp-client/package.json +12 -0
- package/node_modules/tiny-stdio-mcp-server/dist/composition.json +1 -1
- package/node_modules/toolcraft-schema/package.json +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,888 @@
|
|
|
1
|
+
import { SpawnOptions, ChildProcessWithoutNullStreams } from 'node:child_process';
|
|
2
|
+
import { Readable, Writable } from 'node:stream';
|
|
3
|
+
import http from 'node:http';
|
|
4
|
+
import { ContentItem as ContentItem$1, ResourceContents as ResourceContents$1, Implementation, Tool as Tool$1, Resource, ResourceTemplate, Prompt, Server } from 'tiny-stdio-mcp-server';
|
|
5
|
+
export { ContentAnnotations, Icon, Implementation, Prompt, PromptArgument, Resource, ResourceLink, ResourceTemplate, ToolAnnotations, ToolExecution } from 'tiny-stdio-mcp-server';
|
|
6
|
+
|
|
7
|
+
interface NotificationFilter {
|
|
8
|
+
toolsListChanged?: boolean;
|
|
9
|
+
promptsListChanged?: boolean;
|
|
10
|
+
resourcesListChanged?: boolean;
|
|
11
|
+
resourceSubscriptions?: string[];
|
|
12
|
+
}
|
|
13
|
+
interface SubscriptionOptions {
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
}
|
|
16
|
+
interface McpSubscription {
|
|
17
|
+
readonly id: RequestId;
|
|
18
|
+
readonly notifications: NotificationFilter;
|
|
19
|
+
readonly closed: Promise<void>;
|
|
20
|
+
cancel(): void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface SecretStoreLockFileSystem {
|
|
24
|
+
mkdir(path: string, options?: {
|
|
25
|
+
recursive?: boolean;
|
|
26
|
+
mode?: number;
|
|
27
|
+
}): Promise<unknown>;
|
|
28
|
+
readdir(path: string): Promise<string[]>;
|
|
29
|
+
readFile(path: string, encoding: BufferEncoding): Promise<string>;
|
|
30
|
+
writeFile(path: string, value: string, options: {
|
|
31
|
+
encoding: BufferEncoding;
|
|
32
|
+
flag: string;
|
|
33
|
+
mode: number;
|
|
34
|
+
}): Promise<void>;
|
|
35
|
+
rename(from: string, to: string): Promise<void>;
|
|
36
|
+
unlink(path: string): Promise<void>;
|
|
37
|
+
lstat(path: string): Promise<{
|
|
38
|
+
isSymbolicLink(): boolean;
|
|
39
|
+
}>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface MachineIdentity {
|
|
43
|
+
hostname: string;
|
|
44
|
+
username: string;
|
|
45
|
+
}
|
|
46
|
+
interface EncryptedFileStoreFileSystem {
|
|
47
|
+
readdir?(path: string): Promise<string[]>;
|
|
48
|
+
readFile(path: string, encoding: BufferEncoding): Promise<string>;
|
|
49
|
+
writeFile(path: string, data: string | NodeJS.ArrayBufferView, options?: {
|
|
50
|
+
encoding?: BufferEncoding;
|
|
51
|
+
flag?: string;
|
|
52
|
+
mode?: number;
|
|
53
|
+
}): Promise<void>;
|
|
54
|
+
mkdir(path: string, options?: {
|
|
55
|
+
recursive?: boolean;
|
|
56
|
+
}): Promise<void | string | undefined>;
|
|
57
|
+
rename(oldPath: string, newPath: string): Promise<void>;
|
|
58
|
+
lstat(path: string): Promise<{
|
|
59
|
+
isSymbolicLink(): boolean;
|
|
60
|
+
}>;
|
|
61
|
+
unlink(path: string): Promise<void>;
|
|
62
|
+
chmod(path: string, mode: number): Promise<void>;
|
|
63
|
+
}
|
|
64
|
+
interface EncryptedFileStoreInput {
|
|
65
|
+
fs?: EncryptedFileStoreFileSystem;
|
|
66
|
+
filePath?: string;
|
|
67
|
+
salt: string;
|
|
68
|
+
defaultDirectory?: string;
|
|
69
|
+
defaultFileName?: string;
|
|
70
|
+
getMachineIdentity?: () => MachineIdentity | Promise<MachineIdentity>;
|
|
71
|
+
getHomeDirectory?: () => string;
|
|
72
|
+
getRandomBytes?: (size: number) => Buffer;
|
|
73
|
+
/** Fail closed instead of treating malformed or unauthenticated documents as absent. */
|
|
74
|
+
throwOnInvalidDocument?: boolean;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
interface KeychainCommandResult {
|
|
78
|
+
stdout: string;
|
|
79
|
+
stderr: string;
|
|
80
|
+
exitCode: number;
|
|
81
|
+
}
|
|
82
|
+
interface KeychainCommandOptions {
|
|
83
|
+
stdin?: string;
|
|
84
|
+
}
|
|
85
|
+
type KeychainCommandRunner = (command: string, args: string[], options?: KeychainCommandOptions) => Promise<KeychainCommandResult>;
|
|
86
|
+
interface KeychainStoreInput {
|
|
87
|
+
runCommand?: KeychainCommandRunner;
|
|
88
|
+
service: string;
|
|
89
|
+
account: string;
|
|
90
|
+
lock?: {
|
|
91
|
+
fs?: SecretStoreLockFileSystem;
|
|
92
|
+
directory?: string;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
type StoreBackend = "file" | "keychain";
|
|
97
|
+
interface CreateSecretStoreInput {
|
|
98
|
+
backend?: StoreBackend;
|
|
99
|
+
env?: NodeJS.ProcessEnv;
|
|
100
|
+
platform?: NodeJS.Platform;
|
|
101
|
+
backendEnvVar?: string;
|
|
102
|
+
fileStore?: EncryptedFileStoreInput;
|
|
103
|
+
keychainStore?: KeychainStoreInput;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
type OAuthMetadataFetch = (input: string | URL, init?: RequestInit) => Promise<Response>;
|
|
107
|
+
interface OAuthProtectedResourceMetadata extends Record<string, unknown> {
|
|
108
|
+
resource: string;
|
|
109
|
+
authorization_servers: string[];
|
|
110
|
+
}
|
|
111
|
+
interface OAuthAuthorizationServerMetadata extends Record<string, unknown> {
|
|
112
|
+
issuer: string;
|
|
113
|
+
authorization_endpoint: string;
|
|
114
|
+
token_endpoint: string;
|
|
115
|
+
registration_endpoint?: string;
|
|
116
|
+
response_types_supported: string[];
|
|
117
|
+
code_challenge_methods_supported: string[];
|
|
118
|
+
authorization_response_iss_parameter_supported?: boolean;
|
|
119
|
+
}
|
|
120
|
+
interface OAuthDiscoveryResult {
|
|
121
|
+
resource: string;
|
|
122
|
+
resourceMetadataUrl: string;
|
|
123
|
+
resourceMetadata: OAuthProtectedResourceMetadata;
|
|
124
|
+
authorizationServer: string;
|
|
125
|
+
authorizationServerMetadataUrl: string;
|
|
126
|
+
authorizationServerMetadata: OAuthAuthorizationServerMetadata;
|
|
127
|
+
}
|
|
128
|
+
interface OAuthUnauthorizedChallenge {
|
|
129
|
+
scheme: "Bearer";
|
|
130
|
+
params: Record<string, string>;
|
|
131
|
+
raw: string;
|
|
132
|
+
}
|
|
133
|
+
interface OAuthClientProvider {
|
|
134
|
+
/** Establish a grant explicitly, including when resource initialization is public. */
|
|
135
|
+
authenticate?(input: {
|
|
136
|
+
requestUrl: URL;
|
|
137
|
+
fetch: OAuthMetadataFetch;
|
|
138
|
+
/** Lazy validated discovery. Without it, recover/reuse known grants only. */
|
|
139
|
+
discover?: () => Promise<OAuthDiscoveryResult>;
|
|
140
|
+
signal?: AbortSignal;
|
|
141
|
+
}): Promise<StoredOAuthTokens | void>;
|
|
142
|
+
authorizeRequest?(input: {
|
|
143
|
+
requestUrl: URL;
|
|
144
|
+
headers: Headers;
|
|
145
|
+
fetch: OAuthMetadataFetch;
|
|
146
|
+
signal?: AbortSignal;
|
|
147
|
+
}): Promise<StoredOAuthTokens | void> | StoredOAuthTokens | void;
|
|
148
|
+
handleUnauthorized(input: {
|
|
149
|
+
requestUrl: URL;
|
|
150
|
+
response: Response;
|
|
151
|
+
challenge: OAuthUnauthorizedChallenge | null;
|
|
152
|
+
/** Validated metadata supplied by direct callers, if already available. */
|
|
153
|
+
discovery?: OAuthDiscoveryResult;
|
|
154
|
+
/** Lazy validated metadata; invoke only when OAuth recovery needs it. */
|
|
155
|
+
discover?: () => Promise<OAuthDiscoveryResult>;
|
|
156
|
+
fetch: OAuthMetadataFetch;
|
|
157
|
+
signal?: AbortSignal;
|
|
158
|
+
/** Headers actually attached to this rejected request. */
|
|
159
|
+
requestHeaders?: Headers;
|
|
160
|
+
/** Owned snapshot returned when this request was authorized, or null if absent. */
|
|
161
|
+
presentedTokens?: StoredOAuthTokens | null;
|
|
162
|
+
}): Promise<{
|
|
163
|
+
action: "retry";
|
|
164
|
+
} | {
|
|
165
|
+
action: "fail";
|
|
166
|
+
error?: Error;
|
|
167
|
+
}> | {
|
|
168
|
+
action: "retry";
|
|
169
|
+
} | {
|
|
170
|
+
action: "fail";
|
|
171
|
+
error?: Error;
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
interface OAuthClientMetadata {
|
|
175
|
+
clientName?: string;
|
|
176
|
+
scope?: string;
|
|
177
|
+
softwareId?: string;
|
|
178
|
+
softwareVersion?: string;
|
|
179
|
+
}
|
|
180
|
+
interface StoredOAuthTokens {
|
|
181
|
+
accessToken: string;
|
|
182
|
+
refreshToken?: string;
|
|
183
|
+
tokenType: "Bearer";
|
|
184
|
+
expiresAt: number | null;
|
|
185
|
+
scope?: string;
|
|
186
|
+
}
|
|
187
|
+
/** Import-time lifetimes are normalized once into persisted epoch milliseconds. */
|
|
188
|
+
interface ImportedOAuthTokens extends Omit<StoredOAuthTokens, "expiresAt"> {
|
|
189
|
+
expiresAt?: number | null;
|
|
190
|
+
/** Remaining lifetime at import, or total lifetime when issuedAt is provided. */
|
|
191
|
+
expiresIn?: number;
|
|
192
|
+
/** Original issuance time in Unix epoch milliseconds. */
|
|
193
|
+
issuedAt?: number;
|
|
194
|
+
}
|
|
195
|
+
/** Full RFC 7591 response, including JSON provider extensions. */
|
|
196
|
+
interface OAuthClientRegistration extends Record<string, unknown> {
|
|
197
|
+
client_id: string;
|
|
198
|
+
client_secret?: string | null;
|
|
199
|
+
redirect_uris?: string[] | null;
|
|
200
|
+
grant_types?: string[] | null;
|
|
201
|
+
response_types?: string[] | null;
|
|
202
|
+
contacts?: string[] | null;
|
|
203
|
+
client_id_issued_at?: number | null;
|
|
204
|
+
client_secret_expires_at?: number | null;
|
|
205
|
+
token_endpoint_auth_method?: string | null;
|
|
206
|
+
}
|
|
207
|
+
interface StoredOAuthClient {
|
|
208
|
+
clientId: string;
|
|
209
|
+
/** Externally registered apps must never be replaced by native DCR on reload. */
|
|
210
|
+
registrationOwnership?: "caller";
|
|
211
|
+
/** Actual listener URI submitted when this native client was registered. */
|
|
212
|
+
requestedRedirectUri?: string;
|
|
213
|
+
clientSecret?: string;
|
|
214
|
+
registration?: OAuthClientRegistration;
|
|
215
|
+
tokenEndpointAuthMethod?: OAuthTokenEndpointAuthMethod;
|
|
216
|
+
}
|
|
217
|
+
type OAuthTokenEndpointAuthMethod = "none" | "client_secret_post" | "client_secret_basic";
|
|
218
|
+
interface StoredOAuthSession {
|
|
219
|
+
resource: string;
|
|
220
|
+
authorizationServer: string;
|
|
221
|
+
client: StoredOAuthClient;
|
|
222
|
+
tokens?: StoredOAuthTokens;
|
|
223
|
+
/** A refresh was begun; its winning response may not have been persisted. */
|
|
224
|
+
refreshState?: "pending";
|
|
225
|
+
/** Canonical explicitly requested scope set when the server omits token scope. */
|
|
226
|
+
requestedScope?: string;
|
|
227
|
+
discovery: {
|
|
228
|
+
resourceMetadataUrl: string;
|
|
229
|
+
resourceMetadata: Record<string, unknown>;
|
|
230
|
+
authorizationServerMetadata: Record<string, unknown>;
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
interface OAuthSessionStore {
|
|
234
|
+
load(resource: string): Promise<StoredOAuthSession | null>;
|
|
235
|
+
save(resource: string, session: StoredOAuthSession): Promise<void>;
|
|
236
|
+
clear(resource: string): Promise<void>;
|
|
237
|
+
/** Backend-wide lock covering a complete read/redeem/write transaction. */
|
|
238
|
+
withLock?<T>(resource: string, operation: () => Promise<T>, options: {
|
|
239
|
+
signal?: AbortSignal;
|
|
240
|
+
timeoutMs: number;
|
|
241
|
+
}): Promise<T>;
|
|
242
|
+
}
|
|
243
|
+
/** Configuration values are captured at creation; selected host dependencies remain live. */
|
|
244
|
+
interface DefaultOAuthClientProviderOptions {
|
|
245
|
+
client: {
|
|
246
|
+
mode: "dynamic";
|
|
247
|
+
clientId?: string;
|
|
248
|
+
clientSecret?: string;
|
|
249
|
+
metadata?: OAuthClientMetadata;
|
|
250
|
+
/** Import a complete registration owned by the caller. */
|
|
251
|
+
registration?: OAuthClientRegistration;
|
|
252
|
+
tokenEndpointAuthMethod?: OAuthTokenEndpointAuthMethod;
|
|
253
|
+
} | {
|
|
254
|
+
mode: "static";
|
|
255
|
+
clientId: string;
|
|
256
|
+
clientSecret?: string;
|
|
257
|
+
metadata?: OAuthClientMetadata;
|
|
258
|
+
registration?: OAuthClientRegistration;
|
|
259
|
+
tokenEndpointAuthMethod?: OAuthTokenEndpointAuthMethod;
|
|
260
|
+
};
|
|
261
|
+
/** Disable interactive authorization while allowing cached tokens and silent refresh. */
|
|
262
|
+
allowInteractive?: boolean;
|
|
263
|
+
/** Maximum wait to acquire a session transaction lock (default 30,000 ms). */
|
|
264
|
+
sessionLockTimeoutMs?: number;
|
|
265
|
+
/** Isolate native persisted sessions and registrations for a named profile. */
|
|
266
|
+
persistenceNamespace?: string;
|
|
267
|
+
/** Native-owned durable logical server identity; changing URL retires its credentials. */
|
|
268
|
+
resourceIdentity?: string;
|
|
269
|
+
/** Import an existing grant for one resource. Persisted sessions take precedence. */
|
|
270
|
+
initialGrant?: {
|
|
271
|
+
resource: string;
|
|
272
|
+
tokens: ImportedOAuthTokens;
|
|
273
|
+
};
|
|
274
|
+
browser: {
|
|
275
|
+
openBrowser?(url: string): Promise<void>;
|
|
276
|
+
/** Exact registered HTTP loopback redirect URI. */
|
|
277
|
+
redirectUri?: string;
|
|
278
|
+
signal?: AbortSignal;
|
|
279
|
+
timeoutMs?: number;
|
|
280
|
+
readLine?: () => Promise<string>;
|
|
281
|
+
createServer?: () => http.Server;
|
|
282
|
+
landingPage?: {
|
|
283
|
+
title: string;
|
|
284
|
+
body: string;
|
|
285
|
+
};
|
|
286
|
+
};
|
|
287
|
+
sessionStore?: OAuthSessionStore;
|
|
288
|
+
authStore?: CreateSecretStoreInput;
|
|
289
|
+
now?: () => number;
|
|
290
|
+
}
|
|
291
|
+
type OAuthClientProviderOptions = {
|
|
292
|
+
provider: OAuthClientProvider;
|
|
293
|
+
} | DefaultOAuthClientProviderOptions;
|
|
294
|
+
|
|
295
|
+
declare function fetchMcpResponse(fetchImplementation: (input: string | URL, init?: RequestInit) => Promise<Response>, input: string | URL, init?: RequestInit): Promise<Response>;
|
|
296
|
+
|
|
297
|
+
interface OAuthDiscoveryCache {
|
|
298
|
+
get(resourceUrl: string): OAuthDiscoveryResult | null | undefined | Promise<OAuthDiscoveryResult | null | undefined>;
|
|
299
|
+
set(resourceUrl: string, value: OAuthDiscoveryResult): void | Promise<void>;
|
|
300
|
+
delete?(resourceUrl: string): void | Promise<void>;
|
|
301
|
+
}
|
|
302
|
+
interface OAuthMetadataDiscoveryOptions {
|
|
303
|
+
fetch?: OAuthMetadataFetch;
|
|
304
|
+
cache?: OAuthDiscoveryCache;
|
|
305
|
+
}
|
|
306
|
+
interface OAuthMetadataLookupOptions {
|
|
307
|
+
resourceMetadataUrl?: string | URL;
|
|
308
|
+
signal?: AbortSignal;
|
|
309
|
+
}
|
|
310
|
+
/** Native metadata failure with complete SDK diagnostics and a safe phase. */
|
|
311
|
+
declare class OAuthMetadataError extends Error {
|
|
312
|
+
readonly phase: "protected-resource" | "authorization-server";
|
|
313
|
+
readonly status?: number | undefined;
|
|
314
|
+
static is(value: unknown): value is OAuthMetadataError;
|
|
315
|
+
constructor(phase: "protected-resource" | "authorization-server", message: string, status?: number | undefined);
|
|
316
|
+
}
|
|
317
|
+
declare class OAuthMetadataDiscovery {
|
|
318
|
+
private readonly fetchImpl;
|
|
319
|
+
private readonly cache;
|
|
320
|
+
private readonly memoryCache;
|
|
321
|
+
constructor({ fetch, cache }?: OAuthMetadataDiscoveryOptions);
|
|
322
|
+
private discoverProtectedResource;
|
|
323
|
+
discover(resourceUrl: string | URL, { resourceMetadataUrl, signal }?: OAuthMetadataLookupOptions): Promise<OAuthDiscoveryResult>;
|
|
324
|
+
}
|
|
325
|
+
declare function discoverOAuthMetadata(resourceUrl: string | URL, options?: OAuthMetadataDiscoveryOptions & OAuthMetadataLookupOptions): Promise<OAuthDiscoveryResult>;
|
|
326
|
+
|
|
327
|
+
type RequestId = number | string;
|
|
328
|
+
interface ClientCapabilities {
|
|
329
|
+
extensions?: Record<string, Record<string, unknown>>;
|
|
330
|
+
elicitation?: {
|
|
331
|
+
form?: Record<string, unknown>;
|
|
332
|
+
url?: Record<string, unknown>;
|
|
333
|
+
};
|
|
334
|
+
roots?: {
|
|
335
|
+
listChanged?: boolean;
|
|
336
|
+
[key: string]: unknown;
|
|
337
|
+
};
|
|
338
|
+
sampling?: {
|
|
339
|
+
[key: string]: unknown;
|
|
340
|
+
};
|
|
341
|
+
experimental?: Record<string, unknown>;
|
|
342
|
+
}
|
|
343
|
+
interface ServerCapabilities {
|
|
344
|
+
extensions?: Record<string, Record<string, unknown>>;
|
|
345
|
+
prompts?: {
|
|
346
|
+
listChanged?: boolean;
|
|
347
|
+
[key: string]: unknown;
|
|
348
|
+
};
|
|
349
|
+
resources?: {
|
|
350
|
+
subscribe?: boolean;
|
|
351
|
+
listChanged?: boolean;
|
|
352
|
+
[key: string]: unknown;
|
|
353
|
+
};
|
|
354
|
+
tools?: {
|
|
355
|
+
listChanged?: boolean;
|
|
356
|
+
[key: string]: unknown;
|
|
357
|
+
};
|
|
358
|
+
logging?: {
|
|
359
|
+
[key: string]: unknown;
|
|
360
|
+
};
|
|
361
|
+
completions?: {
|
|
362
|
+
[key: string]: unknown;
|
|
363
|
+
};
|
|
364
|
+
experimental?: Record<string, unknown>;
|
|
365
|
+
}
|
|
366
|
+
interface InitializeParams {
|
|
367
|
+
protocolVersion: string;
|
|
368
|
+
capabilities: ClientCapabilities;
|
|
369
|
+
clientInfo: Implementation;
|
|
370
|
+
}
|
|
371
|
+
interface InitializeResult {
|
|
372
|
+
protocolVersion: string;
|
|
373
|
+
capabilities: ServerCapabilities;
|
|
374
|
+
serverInfo: Implementation;
|
|
375
|
+
instructions?: string;
|
|
376
|
+
}
|
|
377
|
+
interface ConnectResult {
|
|
378
|
+
protocolVersion: string;
|
|
379
|
+
capabilities: ServerCapabilities;
|
|
380
|
+
serverInfo?: Implementation;
|
|
381
|
+
instructions?: string;
|
|
382
|
+
}
|
|
383
|
+
type ElicitationParams = {
|
|
384
|
+
mode?: "form";
|
|
385
|
+
message: string;
|
|
386
|
+
requestedSchema: Record<string, unknown>;
|
|
387
|
+
} | {
|
|
388
|
+
mode: "url";
|
|
389
|
+
message: string;
|
|
390
|
+
url: string;
|
|
391
|
+
elicitationId: string;
|
|
392
|
+
};
|
|
393
|
+
interface ElicitationResult {
|
|
394
|
+
_meta?: Record<string, unknown>;
|
|
395
|
+
action: "accept" | "decline" | "cancel";
|
|
396
|
+
content?: Record<string, string | number | boolean | string[]>;
|
|
397
|
+
}
|
|
398
|
+
declare const MCP_PROTOCOL_VERSIONS: readonly ["2025-03-26", "2025-06-18", "2025-11-25", "2026-07-28"];
|
|
399
|
+
type McpProtocolVersion = typeof MCP_PROTOCOL_VERSIONS[number];
|
|
400
|
+
interface McpClientOptions {
|
|
401
|
+
clientInfo: Implementation;
|
|
402
|
+
requestTimeoutMs?: number;
|
|
403
|
+
maxConcurrentRequests?: number;
|
|
404
|
+
protocolVersion?: McpProtocolVersion;
|
|
405
|
+
capabilities?: ClientCapabilities;
|
|
406
|
+
onToolsChanged?: () => void | Promise<void>;
|
|
407
|
+
onResourcesChanged?: () => void | Promise<void>;
|
|
408
|
+
onResourceUpdated?: (uri: string) => void | Promise<void>;
|
|
409
|
+
onPromptsChanged?: () => void | Promise<void>;
|
|
410
|
+
onLog?: (message: LogMessage) => void | Promise<void>;
|
|
411
|
+
onProgress?: (params: ProgressParams) => void | Promise<void>;
|
|
412
|
+
onSamplingRequest?: (params: CreateMessageParams, context: McpRequestContext) => CreateMessageResult | Promise<CreateMessageResult>;
|
|
413
|
+
onRootsList?: (context: McpRequestContext) => Root[] | Promise<Root[]>;
|
|
414
|
+
onElicitationRequest?: (params: ElicitationParams, context: McpRequestContext) => ElicitationResult | Promise<ElicitationResult>;
|
|
415
|
+
}
|
|
416
|
+
declare class McpClient {
|
|
417
|
+
private currentState;
|
|
418
|
+
private currentServerCapabilities;
|
|
419
|
+
private currentClientCapabilities;
|
|
420
|
+
private currentServerInfo;
|
|
421
|
+
private currentInstructions;
|
|
422
|
+
private readonly subscribedResourceUris;
|
|
423
|
+
private readonly activeProgressTokens;
|
|
424
|
+
private readonly options;
|
|
425
|
+
private transport;
|
|
426
|
+
private messageLayer;
|
|
427
|
+
private subscriptions;
|
|
428
|
+
private readonly resourceSubscriptions;
|
|
429
|
+
constructor(options: McpClientOptions);
|
|
430
|
+
get state(): "disconnected" | "initializing" | "ready" | "closed";
|
|
431
|
+
get serverCapabilities(): ServerCapabilities | null;
|
|
432
|
+
get serverInfo(): Implementation | null;
|
|
433
|
+
get instructions(): string | undefined;
|
|
434
|
+
private getMessageLayerOrThrow;
|
|
435
|
+
connect(transport: McpTransport, options?: {
|
|
436
|
+
signal?: AbortSignal;
|
|
437
|
+
}): Promise<ConnectResult>;
|
|
438
|
+
private getServerCapabilitiesOrThrow;
|
|
439
|
+
listTools(params?: PaginatedParams, options?: {
|
|
440
|
+
signal?: AbortSignal;
|
|
441
|
+
}): Promise<PaginatedResult & {
|
|
442
|
+
tools: Tool[];
|
|
443
|
+
}>;
|
|
444
|
+
callTool(params: CallToolParams, options?: CallToolOptions): Promise<CallToolResult>;
|
|
445
|
+
listResources(params?: PaginatedParams, options?: {
|
|
446
|
+
signal?: AbortSignal;
|
|
447
|
+
}): Promise<PaginatedResult & {
|
|
448
|
+
resources: Resource[];
|
|
449
|
+
}>;
|
|
450
|
+
listResourceTemplates(params?: PaginatedParams, options?: {
|
|
451
|
+
signal?: AbortSignal;
|
|
452
|
+
}): Promise<PaginatedResult & {
|
|
453
|
+
resourceTemplates: ResourceTemplate[];
|
|
454
|
+
}>;
|
|
455
|
+
readResource(params: ReadResourceParams, options?: {
|
|
456
|
+
signal?: AbortSignal;
|
|
457
|
+
}): Promise<CacheableResultMetadata & {
|
|
458
|
+
contents: ResourceContents[];
|
|
459
|
+
}>;
|
|
460
|
+
listenNotifications(filter: NotificationFilter, options?: SubscriptionOptions): Promise<McpSubscription>;
|
|
461
|
+
subscribe(uri: string, options?: {
|
|
462
|
+
signal?: AbortSignal;
|
|
463
|
+
}): Promise<void>;
|
|
464
|
+
unsubscribe(uri: string, options?: {
|
|
465
|
+
signal?: AbortSignal;
|
|
466
|
+
}): Promise<void>;
|
|
467
|
+
listPrompts(params?: PaginatedParams, options?: {
|
|
468
|
+
signal?: AbortSignal;
|
|
469
|
+
}): Promise<PaginatedResult & {
|
|
470
|
+
prompts: Prompt[];
|
|
471
|
+
}>;
|
|
472
|
+
getPrompt(params: GetPromptParams, options?: {
|
|
473
|
+
signal?: AbortSignal;
|
|
474
|
+
}): Promise<GetPromptResult>;
|
|
475
|
+
complete(params: CompleteParams, options?: {
|
|
476
|
+
signal?: AbortSignal;
|
|
477
|
+
}): Promise<CompleteResult>;
|
|
478
|
+
setLogLevel(level: LogLevel, options?: {
|
|
479
|
+
signal?: AbortSignal;
|
|
480
|
+
}): Promise<void>;
|
|
481
|
+
cancel(requestId: RequestId, reason?: string): Promise<void>;
|
|
482
|
+
sendRootsChanged(): Promise<void>;
|
|
483
|
+
ping(options?: {
|
|
484
|
+
signal?: AbortSignal;
|
|
485
|
+
}): Promise<void>;
|
|
486
|
+
close(): Promise<void>;
|
|
487
|
+
}
|
|
488
|
+
interface Tool extends Omit<Tool$1, "inputSchema" | "outputSchema"> {
|
|
489
|
+
inputSchema: Record<string, unknown>;
|
|
490
|
+
outputSchema?: Record<string, unknown>;
|
|
491
|
+
}
|
|
492
|
+
interface CallToolParams {
|
|
493
|
+
name: string;
|
|
494
|
+
arguments?: Record<string, unknown>;
|
|
495
|
+
}
|
|
496
|
+
interface CallToolOptions {
|
|
497
|
+
signal?: AbortSignal;
|
|
498
|
+
progressToken?: ProgressToken;
|
|
499
|
+
}
|
|
500
|
+
interface ReadResourceParams {
|
|
501
|
+
uri: string;
|
|
502
|
+
}
|
|
503
|
+
interface PaginatedParams {
|
|
504
|
+
cursor?: string;
|
|
505
|
+
}
|
|
506
|
+
interface ResultMetadata {
|
|
507
|
+
resultType?: "complete";
|
|
508
|
+
_meta?: Record<string, unknown>;
|
|
509
|
+
}
|
|
510
|
+
interface CacheableResultMetadata extends ResultMetadata {
|
|
511
|
+
ttlMs?: number;
|
|
512
|
+
cacheScope?: "public" | "private";
|
|
513
|
+
}
|
|
514
|
+
interface PaginatedResult extends CacheableResultMetadata {
|
|
515
|
+
nextCursor?: string;
|
|
516
|
+
}
|
|
517
|
+
type TextResourceContents = Extract<ResourceContents$1, {
|
|
518
|
+
text: string;
|
|
519
|
+
}>;
|
|
520
|
+
type BlobResourceContents = Extract<ResourceContents$1, {
|
|
521
|
+
blob: string;
|
|
522
|
+
}>;
|
|
523
|
+
type ResourceContents = ResourceContents$1;
|
|
524
|
+
type TextContent = Extract<ContentItem$1, {
|
|
525
|
+
type: "text";
|
|
526
|
+
}>;
|
|
527
|
+
type ImageContent = Extract<ContentItem$1, {
|
|
528
|
+
type: "image";
|
|
529
|
+
}>;
|
|
530
|
+
type AudioContent = Extract<ContentItem$1, {
|
|
531
|
+
type: "audio";
|
|
532
|
+
}>;
|
|
533
|
+
type EmbeddedResource = Extract<ContentItem$1, {
|
|
534
|
+
type: "resource";
|
|
535
|
+
}>;
|
|
536
|
+
type ContentItem = ContentItem$1;
|
|
537
|
+
interface PromptMessage {
|
|
538
|
+
role: "user" | "assistant";
|
|
539
|
+
content: ContentItem;
|
|
540
|
+
}
|
|
541
|
+
interface GetPromptResult extends ResultMetadata {
|
|
542
|
+
description?: string;
|
|
543
|
+
messages: PromptMessage[];
|
|
544
|
+
}
|
|
545
|
+
interface GetPromptParams {
|
|
546
|
+
name: string;
|
|
547
|
+
arguments?: Record<string, string>;
|
|
548
|
+
}
|
|
549
|
+
interface CallToolResult extends ResultMetadata {
|
|
550
|
+
content: ContentItem[];
|
|
551
|
+
structuredContent?: unknown;
|
|
552
|
+
isError?: boolean;
|
|
553
|
+
}
|
|
554
|
+
interface Root {
|
|
555
|
+
_meta?: Record<string, unknown>;
|
|
556
|
+
uri: string;
|
|
557
|
+
name?: string;
|
|
558
|
+
}
|
|
559
|
+
type LogLevel = "debug" | "info" | "notice" | "warning" | "error" | "critical" | "alert" | "emergency";
|
|
560
|
+
interface LogMessage {
|
|
561
|
+
level: LogLevel;
|
|
562
|
+
logger?: string;
|
|
563
|
+
data: unknown;
|
|
564
|
+
}
|
|
565
|
+
type ProgressToken = RequestId;
|
|
566
|
+
interface ProgressParams {
|
|
567
|
+
progressToken: ProgressToken;
|
|
568
|
+
progress: number;
|
|
569
|
+
total?: number;
|
|
570
|
+
message?: string;
|
|
571
|
+
}
|
|
572
|
+
interface ModelHint {
|
|
573
|
+
name?: string;
|
|
574
|
+
}
|
|
575
|
+
interface ModelPreferences {
|
|
576
|
+
hints?: ModelHint[];
|
|
577
|
+
costPriority?: number;
|
|
578
|
+
speedPriority?: number;
|
|
579
|
+
intelligencePriority?: number;
|
|
580
|
+
}
|
|
581
|
+
interface ToolUseContent {
|
|
582
|
+
_meta?: Record<string, unknown>;
|
|
583
|
+
type: "tool_use";
|
|
584
|
+
id: string;
|
|
585
|
+
name: string;
|
|
586
|
+
input: Record<string, unknown>;
|
|
587
|
+
}
|
|
588
|
+
interface ToolResultContent {
|
|
589
|
+
_meta?: Record<string, unknown>;
|
|
590
|
+
type: "tool_result";
|
|
591
|
+
toolUseId: string;
|
|
592
|
+
content: ContentItem[];
|
|
593
|
+
structuredContent?: unknown;
|
|
594
|
+
isError?: boolean;
|
|
595
|
+
}
|
|
596
|
+
type SamplingContent = TextContent | ImageContent | AudioContent | ToolUseContent | ToolResultContent;
|
|
597
|
+
interface SamplingMessage {
|
|
598
|
+
_meta?: Record<string, unknown>;
|
|
599
|
+
role: "user" | "assistant";
|
|
600
|
+
content: SamplingContent | SamplingContent[];
|
|
601
|
+
}
|
|
602
|
+
type IncludeContext = "none" | "thisServer" | "allServers";
|
|
603
|
+
interface CreateMessageParams {
|
|
604
|
+
messages: SamplingMessage[];
|
|
605
|
+
modelPreferences?: ModelPreferences;
|
|
606
|
+
systemPrompt?: string;
|
|
607
|
+
includeContext?: IncludeContext;
|
|
608
|
+
temperature?: number;
|
|
609
|
+
maxTokens: number;
|
|
610
|
+
tools?: Tool[];
|
|
611
|
+
toolChoice?: {
|
|
612
|
+
mode: "auto" | "required" | "none";
|
|
613
|
+
};
|
|
614
|
+
stopSequences?: string[];
|
|
615
|
+
metadata?: Record<string, unknown>;
|
|
616
|
+
}
|
|
617
|
+
interface CreateMessageResult {
|
|
618
|
+
_meta?: Record<string, unknown>;
|
|
619
|
+
model: string;
|
|
620
|
+
content: SamplingContent | SamplingContent[];
|
|
621
|
+
role: "user" | "assistant";
|
|
622
|
+
stopReason?: string;
|
|
623
|
+
}
|
|
624
|
+
interface PromptReference {
|
|
625
|
+
type: "ref/prompt";
|
|
626
|
+
name: string;
|
|
627
|
+
}
|
|
628
|
+
interface ResourceReference {
|
|
629
|
+
type: "ref/resource";
|
|
630
|
+
uri: string;
|
|
631
|
+
}
|
|
632
|
+
interface CompleteArgument {
|
|
633
|
+
name: string;
|
|
634
|
+
value: string;
|
|
635
|
+
}
|
|
636
|
+
interface CompleteParams {
|
|
637
|
+
context?: {
|
|
638
|
+
arguments?: Record<string, string>;
|
|
639
|
+
};
|
|
640
|
+
ref: PromptReference | ResourceReference;
|
|
641
|
+
argument: CompleteArgument;
|
|
642
|
+
}
|
|
643
|
+
interface Completion {
|
|
644
|
+
values: string[];
|
|
645
|
+
hasMore?: boolean;
|
|
646
|
+
total?: number;
|
|
647
|
+
}
|
|
648
|
+
interface CompleteResult extends ResultMetadata {
|
|
649
|
+
completion: Completion;
|
|
650
|
+
}
|
|
651
|
+
declare const ERROR_PARSE = -32700;
|
|
652
|
+
declare const ERROR_INVALID_REQUEST = -32600;
|
|
653
|
+
declare const ERROR_METHOD_NOT_FOUND = -32601;
|
|
654
|
+
declare const ERROR_INVALID_PARAMS = -32602;
|
|
655
|
+
declare const ERROR_INTERNAL = -32603;
|
|
656
|
+
interface McpTransportClosedEvent {
|
|
657
|
+
reason: Error;
|
|
658
|
+
code?: number;
|
|
659
|
+
signal?: NodeJS.Signals;
|
|
660
|
+
}
|
|
661
|
+
interface McpTransport {
|
|
662
|
+
readable: Readable;
|
|
663
|
+
writable: Writable;
|
|
664
|
+
closed: Promise<McpTransportClosedEvent>;
|
|
665
|
+
/** Primary close reason, available before asynchronous transport cleanup finishes. */
|
|
666
|
+
readonly closeReason?: Promise<Error>;
|
|
667
|
+
dispose(reason?: Error): void;
|
|
668
|
+
filterTools?(tools: Tool[], reset?: boolean): Tool[];
|
|
669
|
+
/** Complete a legacy initialization handshake before the client reports ready. */
|
|
670
|
+
completeInitialization?(options: {
|
|
671
|
+
signal?: AbortSignal;
|
|
672
|
+
timeoutMs: number;
|
|
673
|
+
protocolVersion?: string;
|
|
674
|
+
}): Promise<void>;
|
|
675
|
+
}
|
|
676
|
+
interface InMemoryServerTransport {
|
|
677
|
+
readable: Readable;
|
|
678
|
+
writable: Writable;
|
|
679
|
+
}
|
|
680
|
+
interface InMemoryTransportPair {
|
|
681
|
+
clientTransport: McpTransport;
|
|
682
|
+
serverTransport: InMemoryServerTransport;
|
|
683
|
+
}
|
|
684
|
+
declare function createInMemoryTransportPair(): InMemoryTransportPair;
|
|
685
|
+
interface McpClientConnection {
|
|
686
|
+
connect(transport: McpTransport): Promise<void>;
|
|
687
|
+
close(): Promise<void>;
|
|
688
|
+
}
|
|
689
|
+
interface SdkServerConnection {
|
|
690
|
+
connect(transport: unknown): Promise<void>;
|
|
691
|
+
}
|
|
692
|
+
interface SdkTestPair<TClient extends McpClientConnection> {
|
|
693
|
+
client: TClient;
|
|
694
|
+
cleanup: () => Promise<void>;
|
|
695
|
+
}
|
|
696
|
+
declare function createSdkTestPair<TClient extends McpClientConnection>(server: SdkServerConnection, createClient: () => TClient): Promise<SdkTestPair<TClient>>;
|
|
697
|
+
declare function createTestPair<TClient extends McpClientConnection>(server: Server, createClient: () => TClient): Promise<SdkTestPair<TClient>>;
|
|
698
|
+
type StdioSpawn = (command: string, args: ReadonlyArray<string>, options: SpawnOptions) => ChildProcessWithoutNullStreams;
|
|
699
|
+
interface StdioTransportOptions {
|
|
700
|
+
command: string;
|
|
701
|
+
args?: string[];
|
|
702
|
+
cwd?: string;
|
|
703
|
+
env?: NodeJS.ProcessEnv;
|
|
704
|
+
spawn?: StdioSpawn;
|
|
705
|
+
}
|
|
706
|
+
type HttpTransportFetch = (input: string | URL, init?: RequestInit) => Promise<Response>;
|
|
707
|
+
declare class HttpTransportError extends Error {
|
|
708
|
+
readonly status: number;
|
|
709
|
+
readonly method: "GET" | "POST" | "DELETE";
|
|
710
|
+
readonly rpcMethod?: string | undefined;
|
|
711
|
+
constructor(message: string, status: number, method: "GET" | "POST" | "DELETE", rpcMethod?: string | undefined);
|
|
712
|
+
}
|
|
713
|
+
interface HttpTransportOptions {
|
|
714
|
+
url: string;
|
|
715
|
+
/** Legacy SSE uses a GET stream that announces the RPC POST endpoint. */
|
|
716
|
+
mode?: "streamable-http" | "sse";
|
|
717
|
+
headers?: RequestInit["headers"];
|
|
718
|
+
fetch?: HttpTransportFetch;
|
|
719
|
+
oauth?: OAuthClientProviderOptions;
|
|
720
|
+
oauthDiscoveryCache?: OAuthDiscoveryCache;
|
|
721
|
+
onWarning?: (message: string) => void;
|
|
722
|
+
/** Maximum JSON response bytes or individual SSE event bytes; not a stream lifetime cap. */
|
|
723
|
+
maxResponseBytes?: number;
|
|
724
|
+
}
|
|
725
|
+
declare class StdioTransport implements McpTransport {
|
|
726
|
+
readonly readable: Readable;
|
|
727
|
+
readonly writable: Writable;
|
|
728
|
+
readonly closed: Promise<McpTransportClosedEvent>;
|
|
729
|
+
private readonly child;
|
|
730
|
+
private disposed;
|
|
731
|
+
private stderrOutput;
|
|
732
|
+
private static readonly STDERR_MAX_LENGTH;
|
|
733
|
+
constructor({ command, args, cwd, env, spawn: spawnProcess, }: StdioTransportOptions);
|
|
734
|
+
getStderrOutput(): string;
|
|
735
|
+
private appendStderrOutput;
|
|
736
|
+
dispose(reason?: Error): void;
|
|
737
|
+
}
|
|
738
|
+
/** Own and validate static HTTP headers without reflecting malformed values. */
|
|
739
|
+
declare function snapshotHttpTransportHeaders(headers?: RequestInit["headers"]): Headers;
|
|
740
|
+
declare class HttpTransport implements McpTransport {
|
|
741
|
+
readonly readable: Readable;
|
|
742
|
+
readonly writable: Writable;
|
|
743
|
+
readonly closed: Promise<McpTransportClosedEvent>;
|
|
744
|
+
readonly closeReason: Promise<Error>;
|
|
745
|
+
private resolveCloseReason;
|
|
746
|
+
private readonly url;
|
|
747
|
+
private readonly mode;
|
|
748
|
+
private legacyEndpoint;
|
|
749
|
+
private legacyEndpointReady;
|
|
750
|
+
private resolveLegacyEndpoint;
|
|
751
|
+
private rejectLegacyEndpoint;
|
|
752
|
+
private readonly headers;
|
|
753
|
+
private readonly fetchImpl;
|
|
754
|
+
private readonly readStream;
|
|
755
|
+
private readonly writeStream;
|
|
756
|
+
private resolveClosed;
|
|
757
|
+
private sessionId;
|
|
758
|
+
private legacyProtocolVersion;
|
|
759
|
+
private initializationRequestId;
|
|
760
|
+
private lastEventId;
|
|
761
|
+
private getSseStreamStarted;
|
|
762
|
+
private disposed;
|
|
763
|
+
private readonly oauthProvider;
|
|
764
|
+
private readonly oauthMetadataDiscovery;
|
|
765
|
+
private readonly inFlightFetchAbortControllers;
|
|
766
|
+
private readonly inFlightOAuthAbortControllers;
|
|
767
|
+
private readonly oauthRequestTokens;
|
|
768
|
+
private readonly openResponseReaders;
|
|
769
|
+
private readonly modernRequests;
|
|
770
|
+
private modernMode;
|
|
771
|
+
private readonly maxResponseBytes;
|
|
772
|
+
private readonly toolParameterHeaders;
|
|
773
|
+
private readonly onWarning;
|
|
774
|
+
constructor({ url, mode, headers, fetch: fetchImpl, oauth, oauthDiscoveryCache, onWarning, maxResponseBytes, }: HttpTransportOptions);
|
|
775
|
+
completeInitialization(options: {
|
|
776
|
+
signal?: AbortSignal;
|
|
777
|
+
timeoutMs: number;
|
|
778
|
+
protocolVersion?: string;
|
|
779
|
+
}): Promise<void>;
|
|
780
|
+
filterTools(tools: Tool[], reset?: boolean): Tool[];
|
|
781
|
+
dispose(reason?: Error): void;
|
|
782
|
+
private closeWithSessionTermination;
|
|
783
|
+
private abortInFlightFetches;
|
|
784
|
+
private cancelOpenResponseReaders;
|
|
785
|
+
private fetchWithAbort;
|
|
786
|
+
private consumeWrittenLines;
|
|
787
|
+
private sendPost;
|
|
788
|
+
private createPostHeaders;
|
|
789
|
+
private createGetHeaders;
|
|
790
|
+
private createDeleteHeaders;
|
|
791
|
+
private authorizeRequestHeaders;
|
|
792
|
+
private captureSessionId;
|
|
793
|
+
private maybeOpenGetSseStream;
|
|
794
|
+
private ensureLegacyEndpoint;
|
|
795
|
+
private sendSessionTerminationRequest;
|
|
796
|
+
private consumeGetSseStream;
|
|
797
|
+
private throwForPostHttpError;
|
|
798
|
+
private maybeHandleUnauthorizedResponse;
|
|
799
|
+
private forwardResponseMessages;
|
|
800
|
+
private forwardSseResponseMessages;
|
|
801
|
+
private forwardJsonResponseMessage;
|
|
802
|
+
private writeSseMessages;
|
|
803
|
+
private writeReadableLine;
|
|
804
|
+
private fetchWithOAuthRetry;
|
|
805
|
+
private readOAuthChallengeError;
|
|
806
|
+
}
|
|
807
|
+
interface JsonRpcRequest {
|
|
808
|
+
jsonrpc: "2.0";
|
|
809
|
+
id: RequestId;
|
|
810
|
+
method: string;
|
|
811
|
+
params?: unknown;
|
|
812
|
+
}
|
|
813
|
+
interface JsonRpcNotification {
|
|
814
|
+
jsonrpc: "2.0";
|
|
815
|
+
method: string;
|
|
816
|
+
params?: unknown;
|
|
817
|
+
}
|
|
818
|
+
interface JsonRpcErrorObject {
|
|
819
|
+
code: number;
|
|
820
|
+
message: string;
|
|
821
|
+
data?: unknown;
|
|
822
|
+
}
|
|
823
|
+
declare class McpError extends Error {
|
|
824
|
+
readonly code: number;
|
|
825
|
+
readonly data?: unknown;
|
|
826
|
+
constructor(code: number, message: string, data?: unknown);
|
|
827
|
+
}
|
|
828
|
+
interface JsonRpcSuccessResponse {
|
|
829
|
+
jsonrpc: "2.0";
|
|
830
|
+
id: RequestId;
|
|
831
|
+
result: unknown;
|
|
832
|
+
}
|
|
833
|
+
interface JsonRpcErrorResponse {
|
|
834
|
+
jsonrpc: "2.0";
|
|
835
|
+
id: RequestId;
|
|
836
|
+
error: JsonRpcErrorObject;
|
|
837
|
+
}
|
|
838
|
+
type JsonRpcResponse = JsonRpcSuccessResponse | JsonRpcErrorResponse;
|
|
839
|
+
type JsonRpcMessage = JsonRpcRequest | JsonRpcNotification | JsonRpcResponse;
|
|
840
|
+
interface JsonRpcRequestOptions {
|
|
841
|
+
signal?: AbortSignal;
|
|
842
|
+
timeoutMs?: number | null;
|
|
843
|
+
onRequestId?: (requestId: RequestId) => void;
|
|
844
|
+
onTimeout?: (requestId: RequestId) => void;
|
|
845
|
+
}
|
|
846
|
+
interface McpRequestContext {
|
|
847
|
+
readonly id: RequestId;
|
|
848
|
+
readonly method: string;
|
|
849
|
+
readonly signal: AbortSignal;
|
|
850
|
+
}
|
|
851
|
+
type JsonRpcRequestHandler = (params: unknown, context: McpRequestContext) => unknown | Promise<unknown>;
|
|
852
|
+
interface JsonRpcNotificationContext {
|
|
853
|
+
method: string;
|
|
854
|
+
}
|
|
855
|
+
type JsonRpcNotificationHandler = (params: unknown, context: JsonRpcNotificationContext) => unknown | Promise<unknown>;
|
|
856
|
+
declare class JsonRpcMessageLayer {
|
|
857
|
+
private readonly maxConcurrentRequests;
|
|
858
|
+
requestMetadata?: Record<string, unknown>;
|
|
859
|
+
readonly requestTimeoutMs: number;
|
|
860
|
+
private readonly input;
|
|
861
|
+
private readonly output;
|
|
862
|
+
private readonly inputClosedReason;
|
|
863
|
+
private nextRequestId;
|
|
864
|
+
private readonly exchangeControllers;
|
|
865
|
+
private disposedError;
|
|
866
|
+
private readonly pendingRequests;
|
|
867
|
+
private readonly activeIncomingRequests;
|
|
868
|
+
private readonly requestHandlers;
|
|
869
|
+
private readonly inputRequestHandlers;
|
|
870
|
+
private readonly notificationHandlers;
|
|
871
|
+
constructor(input: Readable, output: Writable, requestTimeoutMs?: number, inputClosedReason?: Promise<Error>, maxConcurrentRequests?: number);
|
|
872
|
+
sendNotification(method: string, params?: unknown): void;
|
|
873
|
+
onRequest(method: string, handler: JsonRpcRequestHandler): void;
|
|
874
|
+
onNotification(method: string, handler: JsonRpcNotificationHandler): void;
|
|
875
|
+
onInputRequest(method: string, handler: JsonRpcRequestHandler): void;
|
|
876
|
+
sendRequest(method: string, params?: unknown, options?: JsonRpcRequestOptions): Promise<unknown>;
|
|
877
|
+
private sendRequestOnce;
|
|
878
|
+
cancelRequest(requestId: RequestId, reason: unknown): boolean;
|
|
879
|
+
dispose(reason?: Error): void;
|
|
880
|
+
private consumeInput;
|
|
881
|
+
private resolveInputStreamClosedReason;
|
|
882
|
+
private processParsedMessage;
|
|
883
|
+
private handleIncomingRequest;
|
|
884
|
+
private handleCancellationNotification;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
export { ERROR_INTERNAL, ERROR_INVALID_PARAMS, ERROR_INVALID_REQUEST, ERROR_METHOD_NOT_FOUND, ERROR_PARSE, HttpTransport, HttpTransportError, JsonRpcMessageLayer, MCP_PROTOCOL_VERSIONS, McpClient, McpError, OAuthMetadataDiscovery, OAuthMetadataError, StdioTransport, createInMemoryTransportPair, createSdkTestPair, createTestPair, discoverOAuthMetadata, fetchMcpResponse, snapshotHttpTransportHeaders };
|
|
888
|
+
export type { AudioContent, BlobResourceContents, CacheableResultMetadata, CallToolOptions, CallToolParams, CallToolResult, ClientCapabilities, CompleteArgument, CompleteParams, CompleteResult, Completion, ConnectResult, ContentItem, CreateMessageParams, CreateMessageResult, ElicitationParams, ElicitationResult, EmbeddedResource, GetPromptParams, GetPromptResult, HttpTransportFetch, HttpTransportOptions, ImageContent, InMemoryTransportPair, IncludeContext, InitializeParams, InitializeResult, JsonRpcErrorObject, JsonRpcErrorResponse, JsonRpcMessage, JsonRpcNotification, JsonRpcRequest, JsonRpcRequestOptions, JsonRpcResponse, JsonRpcSuccessResponse, LogLevel, LogMessage, McpClientConnection, McpClientOptions, McpProtocolVersion, McpRequestContext, McpSubscription, McpTransport, McpTransportClosedEvent, ModelHint, ModelPreferences, NotificationFilter, OAuthAuthorizationServerMetadata, OAuthClientProvider, OAuthClientProviderOptions, OAuthDiscoveryCache, OAuthDiscoveryResult, OAuthMetadataFetch, OAuthProtectedResourceMetadata, OAuthSessionStore, OAuthUnauthorizedChallenge, PaginatedParams, PaginatedResult, ProgressParams, ProgressToken, PromptMessage, PromptReference, ReadResourceParams, RequestId, ResourceContents, ResourceReference, ResultMetadata, Root, SamplingContent, SamplingMessage, SdkTestPair, ServerCapabilities, StdioSpawn, StdioTransportOptions, StoredOAuthSession, SubscriptionOptions, TextContent, TextResourceContents, Tool, ToolResultContent, ToolUseContent };
|