agents 0.0.0-ed3f94d → 0.0.0-edd3357

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.
Files changed (60) hide show
  1. package/dist/ai-chat-agent.d.ts +1 -2
  2. package/dist/ai-chat-agent.js +57 -350
  3. package/dist/ai-chat-agent.js.map +1 -1
  4. package/dist/ai-chat-v5-migration.js +0 -1
  5. package/dist/ai-react.d.ts +1 -8
  6. package/dist/ai-react.js +111 -157
  7. package/dist/ai-react.js.map +1 -1
  8. package/dist/ai-types.d.ts +0 -1
  9. package/dist/ai-types.js +1 -2
  10. package/dist/{chunk-BER7KXUJ.js → chunk-AVYJQSLW.js} +1 -2
  11. package/dist/chunk-AVYJQSLW.js.map +1 -0
  12. package/dist/{chunk-Z44WASMA.js → chunk-LL2AFX7V.js} +2 -7
  13. package/dist/{chunk-Z44WASMA.js.map → chunk-LL2AFX7V.js.map} +1 -1
  14. package/dist/{chunk-3OT2NNEW.js → chunk-MH46VMM4.js} +67 -396
  15. package/dist/chunk-MH46VMM4.js.map +1 -0
  16. package/dist/{chunk-254F4GDT.js → chunk-YDUDMOL6.js} +50 -97
  17. package/dist/chunk-YDUDMOL6.js.map +1 -0
  18. package/dist/{client-DVoPb3-C.d.ts → client-CvaJdLQA.d.ts} +26 -131
  19. package/dist/client.js +1 -2
  20. package/dist/index.d.ts +32 -25
  21. package/dist/index.js +4 -5
  22. package/dist/mcp/client.d.ts +1 -2
  23. package/dist/mcp/client.js +1 -2
  24. package/dist/mcp/do-oauth-client-provider.js +1 -2
  25. package/dist/mcp/index.d.ts +31 -13
  26. package/dist/mcp/index.js +163 -233
  27. package/dist/mcp/index.js.map +1 -1
  28. package/dist/observability/index.d.ts +24 -12
  29. package/dist/observability/index.js +4 -5
  30. package/dist/react.d.ts +6 -10
  31. package/dist/react.js +3 -101
  32. package/dist/react.js.map +1 -1
  33. package/dist/schedule.js +0 -2
  34. package/dist/schedule.js.map +1 -1
  35. package/package.json +6 -19
  36. package/src/index.ts +57 -141
  37. package/dist/_esm-LV5FJ3HK.js +0 -3922
  38. package/dist/_esm-LV5FJ3HK.js.map +0 -1
  39. package/dist/ccip-CMBYN64O.js +0 -15
  40. package/dist/ccip-CMBYN64O.js.map +0 -1
  41. package/dist/chunk-254F4GDT.js.map +0 -1
  42. package/dist/chunk-3OT2NNEW.js.map +0 -1
  43. package/dist/chunk-5Y6BEZDY.js +0 -276
  44. package/dist/chunk-5Y6BEZDY.js.map +0 -1
  45. package/dist/chunk-BER7KXUJ.js.map +0 -1
  46. package/dist/chunk-JJBFIGUC.js +0 -5202
  47. package/dist/chunk-JJBFIGUC.js.map +0 -1
  48. package/dist/chunk-PR4QN5HX.js +0 -43
  49. package/dist/chunk-PR4QN5HX.js.map +0 -1
  50. package/dist/chunk-TYAY6AU6.js +0 -159
  51. package/dist/chunk-TYAY6AU6.js.map +0 -1
  52. package/dist/codemode/ai.d.ts +0 -25
  53. package/dist/codemode/ai.js +0 -5112
  54. package/dist/codemode/ai.js.map +0 -1
  55. package/dist/mcp/x402.d.ts +0 -39
  56. package/dist/mcp/x402.js +0 -3195
  57. package/dist/mcp/x402.js.map +0 -1
  58. package/dist/mcp-BH1fJeiU.d.ts +0 -58
  59. package/dist/secp256k1-M22GZP2U.js +0 -2193
  60. package/dist/secp256k1-M22GZP2U.js.map +0 -1
@@ -1,72 +1,15 @@
1
1
  // src/mcp/client.ts
2
2
  import { jsonSchema } from "ai";
3
- import { nanoid as nanoid2 } from "nanoid";
4
-
5
- // src/core/events.ts
6
- function toDisposable(fn) {
7
- return { dispose: fn };
8
- }
9
- var DisposableStore = class {
10
- constructor() {
11
- this._items = [];
12
- }
13
- add(d) {
14
- this._items.push(d);
15
- return d;
16
- }
17
- dispose() {
18
- while (this._items.length) {
19
- try {
20
- this._items.pop().dispose();
21
- } catch {
22
- }
23
- }
24
- }
25
- };
26
- var Emitter = class {
27
- constructor() {
28
- this._listeners = /* @__PURE__ */ new Set();
29
- this.event = (listener) => {
30
- this._listeners.add(listener);
31
- return toDisposable(() => this._listeners.delete(listener));
32
- };
33
- }
34
- fire(data) {
35
- for (const listener of [...this._listeners]) {
36
- try {
37
- listener(data);
38
- } catch (err) {
39
- console.error("Emitter listener error:", err);
40
- }
41
- }
42
- }
43
- dispose() {
44
- this._listeners.clear();
45
- }
46
- };
3
+ import { nanoid } from "nanoid";
47
4
 
48
5
  // src/mcp/client-connection.ts
49
6
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
50
7
  import {
51
- ElicitRequestSchema,
52
8
  PromptListChangedNotificationSchema,
53
9
  ResourceListChangedNotificationSchema,
54
- ToolListChangedNotificationSchema
10
+ ToolListChangedNotificationSchema,
11
+ ElicitRequestSchema
55
12
  } from "@modelcontextprotocol/sdk/types.js";
56
- import { nanoid } from "nanoid";
57
-
58
- // src/mcp/errors.ts
59
- function toErrorMessage(error) {
60
- return error instanceof Error ? error.message : String(error);
61
- }
62
- function isUnauthorized(error) {
63
- const msg = toErrorMessage(error);
64
- return msg.includes("Unauthorized") || msg.includes("401");
65
- }
66
- function isTransportNotImplemented(error) {
67
- const msg = toErrorMessage(error);
68
- return msg.includes("404") || msg.includes("405") || msg.includes("Not Implemented") || msg.includes("not implemented");
69
- }
70
13
 
71
14
  // src/mcp/sse-edge.ts
72
15
  import {
@@ -175,8 +118,6 @@ var MCPClientConnection = class {
175
118
  this.prompts = [];
176
119
  this.resources = [];
177
120
  this.resourceTemplates = [];
178
- this._onObservabilityEvent = new Emitter();
179
- this.onObservabilityEvent = this._onObservabilityEvent.event;
180
121
  const clientOptions = {
181
122
  ...options.client,
182
123
  capabilities: {
@@ -189,112 +130,23 @@ var MCPClientConnection = class {
189
130
  /**
190
131
  * Initialize a client connection
191
132
  *
133
+ * @param code Optional OAuth code to initialize the connection with if auth hasn't been initialized
192
134
  * @returns
193
135
  */
194
- async init() {
195
- const transportType = this.options.transport.type;
196
- if (!transportType) {
197
- throw new Error("Transport type must be specified");
198
- }
136
+ async init(code) {
199
137
  try {
200
- await this.tryConnect(transportType);
138
+ const transportType = this.options.transport.type || "streamable-http";
139
+ await this.tryConnect(transportType, code);
201
140
  } catch (e) {
202
- if (isUnauthorized(e)) {
141
+ if (e.toString().includes("Unauthorized")) {
203
142
  this.connectionState = "authenticating";
204
143
  return;
205
144
  }
206
- this._onObservabilityEvent.fire({
207
- type: "mcp:client:connect",
208
- displayMessage: `Connection initialization failed for ${this.url.toString()}`,
209
- payload: {
210
- url: this.url.toString(),
211
- transport: transportType,
212
- state: this.connectionState,
213
- error: toErrorMessage(e)
214
- },
215
- timestamp: Date.now(),
216
- id: nanoid()
217
- });
218
145
  this.connectionState = "failed";
219
- return;
220
- }
221
- await this.discoverAndRegister();
222
- }
223
- /**
224
- * Finish OAuth by probing transports based on configured type.
225
- * - Explicit: finish on that transport
226
- * - Auto: try streamable-http, then sse on 404/405/Not Implemented
227
- */
228
- async finishAuthProbe(code) {
229
- if (!this.options.transport.authProvider) {
230
- throw new Error("No auth provider configured");
231
- }
232
- const configuredType = this.options.transport.type;
233
- if (!configuredType) {
234
- throw new Error("Transport type must be specified");
235
- }
236
- const finishAuth = async (base) => {
237
- const transport = this.getTransport(base);
238
- await transport.finishAuth(code);
239
- };
240
- if (configuredType === "sse" || configuredType === "streamable-http") {
241
- await finishAuth(configuredType);
242
- return;
243
- }
244
- try {
245
- await finishAuth("streamable-http");
246
- } catch (e) {
247
- if (isTransportNotImplemented(e)) {
248
- await finishAuth("sse");
249
- return;
250
- }
251
146
  throw e;
252
147
  }
253
- }
254
- /**
255
- * Complete OAuth authorization
256
- */
257
- async completeAuthorization(code) {
258
- if (this.connectionState !== "authenticating") {
259
- throw new Error(
260
- "Connection must be in authenticating state to complete authorization"
261
- );
262
- }
263
- try {
264
- await this.finishAuthProbe(code);
265
- this.connectionState = "connecting";
266
- } catch (error) {
267
- this.connectionState = "failed";
268
- throw error;
269
- }
270
- }
271
- /**
272
- * Establish connection after successful authorization
273
- */
274
- async establishConnection() {
275
- if (this.connectionState !== "connecting") {
276
- throw new Error(
277
- "Connection must be in connecting state to establish connection"
278
- );
279
- }
280
- try {
281
- const transportType = this.options.transport.type;
282
- if (!transportType) {
283
- throw new Error("Transport type must be specified");
284
- }
285
- await this.tryConnect(transportType);
286
- await this.discoverAndRegister();
287
- } catch (error) {
288
- this.connectionState = "failed";
289
- throw error;
290
- }
291
- }
292
- /**
293
- * Discover server capabilities and register tools, resources, prompts, and templates
294
- */
295
- async discoverAndRegister() {
296
148
  this.connectionState = "discovering";
297
- this.serverCapabilities = this.client.getServerCapabilities();
149
+ this.serverCapabilities = await this.client.getServerCapabilities();
298
150
  if (!this.serverCapabilities) {
299
151
  throw new Error("The MCP Server failed to return server capabilities");
300
152
  }
@@ -320,18 +172,7 @@ var MCPClientConnection = class {
320
172
  ];
321
173
  for (const { name, result } of operations) {
322
174
  if (result.status === "rejected") {
323
- const url = this.url.toString();
324
- this._onObservabilityEvent.fire({
325
- type: "mcp:client:discover",
326
- displayMessage: `Failed to discover ${name} for ${url}`,
327
- payload: {
328
- url,
329
- capability: name,
330
- error: result.reason
331
- },
332
- timestamp: Date.now(),
333
- id: nanoid()
334
- });
175
+ console.error(`Failed to initialize ${name}:`, result.reason);
335
176
  }
336
177
  }
337
178
  this.instructions = instructionsResult.status === "fulfilled" ? instructionsResult.value : void 0;
@@ -398,7 +239,7 @@ var MCPClientConnection = class {
398
239
  do {
399
240
  toolsResult = await this.client.listTools({
400
241
  cursor: toolsResult.nextCursor
401
- }).catch(this._capabilityErrorHandler({ tools: [] }, "tools/list"));
242
+ }).catch(capabilityErrorHandler({ tools: [] }, "tools/list"));
402
243
  toolsAgg = toolsAgg.concat(toolsResult.tools);
403
244
  } while (toolsResult.nextCursor);
404
245
  return toolsAgg;
@@ -409,9 +250,7 @@ var MCPClientConnection = class {
409
250
  do {
410
251
  resourcesResult = await this.client.listResources({
411
252
  cursor: resourcesResult.nextCursor
412
- }).catch(
413
- this._capabilityErrorHandler({ resources: [] }, "resources/list")
414
- );
253
+ }).catch(capabilityErrorHandler({ resources: [] }, "resources/list"));
415
254
  resourcesAgg = resourcesAgg.concat(resourcesResult.resources);
416
255
  } while (resourcesResult.nextCursor);
417
256
  return resourcesAgg;
@@ -422,7 +261,7 @@ var MCPClientConnection = class {
422
261
  do {
423
262
  promptsResult = await this.client.listPrompts({
424
263
  cursor: promptsResult.nextCursor
425
- }).catch(this._capabilityErrorHandler({ prompts: [] }, "prompts/list"));
264
+ }).catch(capabilityErrorHandler({ prompts: [] }, "prompts/list"));
426
265
  promptsAgg = promptsAgg.concat(promptsResult.prompts);
427
266
  } while (promptsResult.nextCursor);
428
267
  return promptsAgg;
@@ -436,7 +275,7 @@ var MCPClientConnection = class {
436
275
  templatesResult = await this.client.listResourceTemplates({
437
276
  cursor: templatesResult.nextCursor
438
277
  }).catch(
439
- this._capabilityErrorHandler(
278
+ capabilityErrorHandler(
440
279
  { resourceTemplates: [] },
441
280
  "resources/templates/list"
442
281
  )
@@ -475,46 +314,21 @@ var MCPClientConnection = class {
475
314
  throw new Error(`Unsupported transport type: ${transportType}`);
476
315
  }
477
316
  }
478
- async tryConnect(transportType) {
317
+ async tryConnect(transportType, code) {
479
318
  const transports = transportType === "auto" ? ["streamable-http", "sse"] : [transportType];
480
319
  for (const currentTransportType of transports) {
481
320
  const isLastTransport = currentTransportType === transports[transports.length - 1];
482
321
  const hasFallback = transportType === "auto" && currentTransportType === "streamable-http" && !isLastTransport;
483
- const transport = this.getTransport(currentTransportType);
322
+ const transport = await this.getTransport(currentTransportType);
323
+ if (code) {
324
+ await transport.finishAuth(code);
325
+ }
484
326
  try {
485
327
  await this.client.connect(transport);
486
- this.lastConnectedTransport = currentTransportType;
487
- const url = this.url.toString();
488
- this._onObservabilityEvent.fire({
489
- type: "mcp:client:connect",
490
- displayMessage: `Connected successfully using ${currentTransportType} transport for ${url}`,
491
- payload: {
492
- url,
493
- transport: currentTransportType,
494
- state: this.connectionState
495
- },
496
- timestamp: Date.now(),
497
- id: nanoid()
498
- });
499
328
  break;
500
329
  } catch (e) {
501
330
  const error = e instanceof Error ? e : new Error(String(e));
502
- if (isUnauthorized(error)) {
503
- throw e;
504
- }
505
- if (hasFallback && isTransportNotImplemented(error)) {
506
- const url = this.url.toString();
507
- this._onObservabilityEvent.fire({
508
- type: "mcp:client:connect",
509
- displayMessage: `${currentTransportType} transport not available, trying ${transports[transports.indexOf(currentTransportType) + 1]} for ${url}`,
510
- payload: {
511
- url,
512
- transport: currentTransportType,
513
- state: this.connectionState
514
- },
515
- timestamp: Date.now(),
516
- id: nanoid()
517
- });
331
+ if (hasFallback && (error.message.includes("404") || error.message.includes("405"))) {
518
332
  continue;
519
333
  }
520
334
  throw e;
@@ -527,27 +341,18 @@ var MCPClientConnection = class {
527
341
  }
528
342
  );
529
343
  }
530
- _capabilityErrorHandler(empty, method) {
531
- return (e) => {
532
- if (e.code === -32601) {
533
- const url = this.url.toString();
534
- this._onObservabilityEvent.fire({
535
- type: "mcp:client:discover",
536
- displayMessage: `The server advertised support for the capability ${method.split("/")[0]}, but returned "Method not found" for '${method}' for ${url}`,
537
- payload: {
538
- url,
539
- capability: method.split("/")[0],
540
- error: toErrorMessage(e)
541
- },
542
- timestamp: Date.now(),
543
- id: nanoid()
544
- });
545
- return empty;
546
- }
547
- throw e;
548
- };
549
- }
550
344
  };
345
+ function capabilityErrorHandler(empty, method) {
346
+ return (e) => {
347
+ if (e.code === -32601) {
348
+ console.error(
349
+ `The server advertised support for the capability ${method.split("/")[0]}, but returned "Method not found" for '${method}'.`
350
+ );
351
+ return empty;
352
+ }
353
+ throw e;
354
+ };
355
+ }
551
356
 
552
357
  // src/mcp/client.ts
553
358
  var MCPClientManager = class {
@@ -562,11 +367,6 @@ var MCPClientManager = class {
562
367
  this.mcpConnections = {};
563
368
  this._callbackUrls = [];
564
369
  this._didWarnAboutUnstableGetAITools = false;
565
- this._connectionDisposables = /* @__PURE__ */ new Map();
566
- this._onObservabilityEvent = new Emitter();
567
- this.onObservabilityEvent = this._onObservabilityEvent.event;
568
- this._onConnected = new Emitter();
569
- this.onConnected = this._onConnected.event;
570
370
  }
571
371
  /**
572
372
  * Connect to and register an MCP server
@@ -576,64 +376,31 @@ var MCPClientManager = class {
576
376
  * @param capabilities Client capabilities (i.e. if the client supports roots/sampling)
577
377
  */
578
378
  async connect(url, options = {}) {
579
- const id = options.reconnect?.id ?? nanoid2(8);
580
- if (options.transport?.authProvider) {
379
+ const id = options.reconnect?.id ?? nanoid(8);
380
+ if (!options.transport?.authProvider) {
381
+ console.warn(
382
+ "No authProvider provided in the transport options. This client will only support unauthenticated remote MCP Servers"
383
+ );
384
+ } else {
581
385
  options.transport.authProvider.serverId = id;
582
386
  if (options.reconnect?.oauthClientId) {
583
387
  options.transport.authProvider.clientId = options.reconnect?.oauthClientId;
584
388
  }
585
389
  }
586
- if (!options.reconnect?.oauthCode || !this.mcpConnections[id]) {
587
- const normalizedTransport = {
588
- ...options.transport,
589
- type: options.transport?.type ?? "auto"
590
- };
591
- this.mcpConnections[id] = new MCPClientConnection(
592
- new URL(url),
593
- {
594
- name: this._name,
595
- version: this._version
596
- },
597
- {
598
- client: options.client ?? {},
599
- transport: normalizedTransport
600
- }
601
- );
602
- const store = new DisposableStore();
603
- const existing = this._connectionDisposables.get(id);
604
- if (existing) existing.dispose();
605
- this._connectionDisposables.set(id, store);
606
- store.add(
607
- this.mcpConnections[id].onObservabilityEvent((event) => {
608
- this._onObservabilityEvent.fire(event);
609
- })
610
- );
611
- }
612
- await this.mcpConnections[id].init();
613
- if (options.reconnect?.oauthCode) {
614
- try {
615
- await this.mcpConnections[id].completeAuthorization(
616
- options.reconnect.oauthCode
617
- );
618
- await this.mcpConnections[id].establishConnection();
619
- } catch (error) {
620
- this._onObservabilityEvent.fire({
621
- type: "mcp:client:connect",
622
- displayMessage: `Failed to complete OAuth reconnection for ${id} for ${url}`,
623
- payload: {
624
- url,
625
- transport: options.transport?.type ?? "auto",
626
- state: this.mcpConnections[id].connectionState,
627
- error: toErrorMessage(error)
628
- },
629
- timestamp: Date.now(),
630
- id
631
- });
632
- throw error;
390
+ this.mcpConnections[id] = new MCPClientConnection(
391
+ new URL(url),
392
+ {
393
+ name: this._name,
394
+ version: this._version
395
+ },
396
+ {
397
+ client: options.client ?? {},
398
+ transport: options.transport ?? {}
633
399
  }
634
- }
400
+ );
401
+ await this.mcpConnections[id].init(options.reconnect?.oauthCode);
635
402
  const authUrl = options.transport?.authProvider?.authUrl;
636
- if (this.mcpConnections[id].connectionState === "authenticating" && authUrl && options.transport?.authProvider?.redirectUrl) {
403
+ if (authUrl && options.transport?.authProvider?.redirectUrl) {
637
404
  this._callbackUrls.push(
638
405
  options.transport.authProvider.redirectUrl.toString()
639
406
  );
@@ -688,88 +455,19 @@ var MCPClientManager = class {
688
455
  }
689
456
  conn.options.transport.authProvider.clientId = clientId;
690
457
  conn.options.transport.authProvider.serverId = serverId;
691
- try {
692
- await conn.completeAuthorization(code);
693
- return {
694
- serverId,
695
- authSuccess: true
696
- };
697
- } catch (error) {
698
- const errorMessage = error instanceof Error ? error.message : String(error);
699
- return {
700
- serverId,
701
- authSuccess: false,
702
- authError: errorMessage
703
- };
704
- }
705
- }
706
- /**
707
- * Establish connection in the background after OAuth completion
708
- * This method is called asynchronously and doesn't block the OAuth callback response
709
- * @param serverId The server ID to establish connection for
710
- */
711
- async establishConnection(serverId) {
712
- const conn = this.mcpConnections[serverId];
713
- if (!conn) {
714
- this._onObservabilityEvent.fire({
715
- type: "mcp:client:preconnect",
716
- displayMessage: `Connection not found for serverId: ${serverId}`,
717
- payload: { serverId },
718
- timestamp: Date.now(),
719
- id: nanoid2()
720
- });
721
- return;
722
- }
723
- try {
724
- await conn.establishConnection();
725
- this._onConnected.fire(serverId);
726
- } catch (error) {
727
- const url = conn.url.toString();
728
- this._onObservabilityEvent.fire({
729
- type: "mcp:client:connect",
730
- displayMessage: `Failed to establish connection to server ${serverId} with url ${url}`,
731
- payload: {
732
- url,
733
- transport: conn.options.transport.type ?? "auto",
734
- state: conn.connectionState,
735
- error: toErrorMessage(error)
736
- },
737
- timestamp: Date.now(),
738
- id: nanoid2()
739
- });
740
- }
741
- }
742
- /**
743
- * Register a callback URL for OAuth handling
744
- * @param url The callback URL to register
745
- */
746
- registerCallbackUrl(url) {
747
- if (!this._callbackUrls.includes(url)) {
748
- this._callbackUrls.push(url);
458
+ const serverUrl = conn.url.toString();
459
+ await this.connect(serverUrl, {
460
+ reconnect: {
461
+ id: serverId,
462
+ oauthClientId: clientId,
463
+ oauthCode: code
464
+ },
465
+ ...conn.options
466
+ });
467
+ if (this.mcpConnections[serverId].connectionState === "authenticating") {
468
+ throw new Error("Failed to authenticate: client failed to initialize");
749
469
  }
750
- }
751
- /**
752
- * Unregister a callback URL
753
- * @param serverId The server ID whose callback URL should be removed
754
- */
755
- unregisterCallbackUrl(serverId) {
756
- this._callbackUrls = this._callbackUrls.filter(
757
- (url) => !url.endsWith(`/${serverId}`)
758
- );
759
- }
760
- /**
761
- * Configure OAuth callback handling
762
- * @param config OAuth callback configuration
763
- */
764
- configureOAuthCallback(config) {
765
- this._oauthCallbackConfig = config;
766
- }
767
- /**
768
- * Get the current OAuth callback configuration
769
- * @returns The current OAuth callback configuration
770
- */
771
- getOAuthCallbackConfig() {
772
- return this._oauthCallbackConfig;
470
+ return { serverId };
773
471
  }
774
472
  /**
775
473
  * @returns namespaced list of tools
@@ -798,12 +496,7 @@ var MCPClientManager = class {
798
496
  }
799
497
  return result;
800
498
  },
801
- // @ts-expect-error drift between ai and mcp types
802
- inputSchema: jsonSchema(tool.inputSchema),
803
- outputSchema: tool.outputSchema ? (
804
- // @ts-expect-error drift between ai and mcp types
805
- jsonSchema(tool.outputSchema)
806
- ) : void 0
499
+ inputSchema: jsonSchema(tool.inputSchema)
807
500
  }
808
501
  ];
809
502
  })
@@ -826,18 +519,11 @@ var MCPClientManager = class {
826
519
  * Closes all connections to MCP servers
827
520
  */
828
521
  async closeAllConnections() {
829
- const ids = Object.keys(this.mcpConnections);
830
- await Promise.all(
831
- ids.map(async (id) => {
832
- await this.mcpConnections[id].client.close();
522
+ return Promise.all(
523
+ Object.values(this.mcpConnections).map(async (connection) => {
524
+ await connection.client.close();
833
525
  })
834
526
  );
835
- for (const id of ids) {
836
- const store = this._connectionDisposables.get(id);
837
- if (store) store.dispose();
838
- this._connectionDisposables.delete(id);
839
- delete this.mcpConnections[id];
840
- }
841
527
  }
842
528
  /**
843
529
  * Closes a connection to an MCP server
@@ -849,20 +535,6 @@ var MCPClientManager = class {
849
535
  }
850
536
  await this.mcpConnections[id].client.close();
851
537
  delete this.mcpConnections[id];
852
- const store = this._connectionDisposables.get(id);
853
- if (store) store.dispose();
854
- this._connectionDisposables.delete(id);
855
- }
856
- /**
857
- * Dispose the manager and all resources.
858
- */
859
- async dispose() {
860
- try {
861
- await this.closeAllConnections();
862
- } finally {
863
- this._onConnected.dispose();
864
- this._onObservabilityEvent.dispose();
865
- }
866
538
  }
867
539
  /**
868
540
  * @returns namespaced list of prompts
@@ -885,7 +557,7 @@ var MCPClientManager = class {
885
557
  /**
886
558
  * Namespaced version of callTool
887
559
  */
888
- async callTool(params, resultSchema, options) {
560
+ callTool(params, resultSchema, options) {
889
561
  const unqualifiedName = params.name.replace(`${params.serverId}.`, "");
890
562
  return this.mcpConnections[params.serverId].client.callTool(
891
563
  {
@@ -932,10 +604,9 @@ function getNamespacedData(mcpClients, type) {
932
604
  }
933
605
 
934
606
  export {
935
- DisposableStore,
936
607
  SSEEdgeClientTransport,
937
608
  StreamableHTTPEdgeClientTransport,
938
609
  MCPClientManager,
939
610
  getNamespacedData
940
611
  };
941
- //# sourceMappingURL=chunk-3OT2NNEW.js.map
612
+ //# sourceMappingURL=chunk-MH46VMM4.js.map