agents 0.3.9 → 0.4.0

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 (67) hide show
  1. package/README.md +2 -2
  2. package/dist/{index-N6791tVt.d.ts → agent-DY6QmSI_.d.ts} +3 -25
  3. package/dist/ai-types.js +1 -1
  4. package/dist/client-connection-CGMuV62J.js +472 -0
  5. package/dist/client-connection-CGMuV62J.js.map +1 -0
  6. package/dist/client-storage-Cvy5r9FG.d.ts +355 -0
  7. package/dist/client.d.ts +11 -7
  8. package/dist/client.js +6 -2
  9. package/dist/client.js.map +1 -1
  10. package/dist/email.d.ts +146 -16
  11. package/dist/email.js +222 -2
  12. package/dist/email.js.map +1 -0
  13. package/dist/index.d.ts +139 -41
  14. package/dist/index.js +2317 -6
  15. package/dist/index.js.map +1 -0
  16. package/dist/internal_context.d.ts +28 -5
  17. package/dist/internal_context.js +7 -2
  18. package/dist/internal_context.js.map +1 -0
  19. package/dist/mcp/client.d.ts +516 -2
  20. package/dist/mcp/client.js +662 -3
  21. package/dist/mcp/client.js.map +1 -0
  22. package/dist/mcp/do-oauth-client-provider.d.ts +61 -2
  23. package/dist/mcp/do-oauth-client-provider.js +154 -2
  24. package/dist/mcp/do-oauth-client-provider.js.map +1 -0
  25. package/dist/mcp/index.d.ts +3 -5
  26. package/dist/mcp/index.js +8 -7
  27. package/dist/mcp/index.js.map +1 -1
  28. package/dist/mcp/x402.d.ts +34 -14
  29. package/dist/mcp/x402.js +128 -66
  30. package/dist/mcp/x402.js.map +1 -1
  31. package/dist/{mcp-BwPscEiF.d.ts → mcp-Dw5vDrY8.d.ts} +1 -1
  32. package/dist/observability/index.d.ts +23 -2
  33. package/dist/observability/index.js +25 -6
  34. package/dist/observability/index.js.map +1 -0
  35. package/dist/react.d.ts +16 -10
  36. package/dist/react.js +34 -16
  37. package/dist/react.js.map +1 -1
  38. package/dist/types.d.ts +14 -1
  39. package/dist/types.js +16 -2
  40. package/dist/types.js.map +1 -0
  41. package/dist/utils.js +15 -2
  42. package/dist/utils.js.map +1 -0
  43. package/dist/workflow-types.d.ts +235 -23
  44. package/dist/workflows.d.ts +22 -24
  45. package/dist/workflows.js +2 -5
  46. package/dist/workflows.js.map +1 -1
  47. package/package.json +26 -23
  48. package/dist/client-BA8NJB6l.js +0 -1124
  49. package/dist/client-BA8NJB6l.js.map +0 -1
  50. package/dist/client-Ba-xntmv.d.ts +0 -963
  51. package/dist/do-oauth-client-provider-BqnOQzjy.d.ts +0 -70
  52. package/dist/do-oauth-client-provider-DDg8QrEA.js +0 -155
  53. package/dist/do-oauth-client-provider-DDg8QrEA.js.map +0 -1
  54. package/dist/email-8ljcpvwV.d.ts +0 -157
  55. package/dist/email-XHsSYsTO.js +0 -223
  56. package/dist/email-XHsSYsTO.js.map +0 -1
  57. package/dist/internal_context-CEu5ji80.d.ts +0 -29
  58. package/dist/internal_context-D9eKFth1.js +0 -8
  59. package/dist/internal_context-D9eKFth1.js.map +0 -1
  60. package/dist/src-CqnVUbg1.js +0 -2146
  61. package/dist/src-CqnVUbg1.js.map +0 -1
  62. package/dist/types-BITaDFf-.js +0 -16
  63. package/dist/types-BITaDFf-.js.map +0 -1
  64. package/dist/types-DSSHBW6w.d.ts +0 -14
  65. package/dist/utils-B49TmLCI.js +0 -16
  66. package/dist/utils-B49TmLCI.js.map +0 -1
  67. package/dist/workflow-types-Z_Oem1FJ.d.ts +0 -260
@@ -1,963 +0,0 @@
1
- import { t as MCPObservabilityEvent } from "./mcp-BwPscEiF.js";
2
- import { t as AgentsOAuthProvider } from "./do-oauth-client-provider-BqnOQzjy.js";
3
- import { Client } from "@modelcontextprotocol/sdk/client/index.js";
4
- import {
5
- SSEClientTransport,
6
- SSEClientTransportOptions
7
- } from "@modelcontextprotocol/sdk/client/sse.js";
8
- import {
9
- StreamableHTTPClientTransport,
10
- StreamableHTTPClientTransportOptions
11
- } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
12
- import {
13
- CallToolRequest,
14
- CallToolResultSchema,
15
- CompatibilityCallToolResultSchema,
16
- ElicitRequest,
17
- ElicitResult,
18
- GetPromptRequest,
19
- Prompt,
20
- ReadResourceRequest,
21
- Resource,
22
- ResourceTemplate,
23
- ServerCapabilities,
24
- Tool
25
- } from "@modelcontextprotocol/sdk/types.js";
26
- import * as ai0 from "ai";
27
- import { ToolSet } from "ai";
28
- import { RequestOptions } from "@modelcontextprotocol/sdk/shared/protocol.js";
29
-
30
- //#region src/core/events.d.ts
31
- interface Disposable {
32
- dispose(): void;
33
- }
34
- type Event<T> = (listener: (e: T) => void) => Disposable;
35
- declare class Emitter<T> implements Disposable {
36
- private _listeners;
37
- readonly event: Event<T>;
38
- fire(data: T): void;
39
- dispose(): void;
40
- }
41
- //#endregion
42
- //#region src/mcp/types.d.ts
43
- type MaybePromise<T> = T | Promise<T>;
44
- type BaseTransportType = "sse" | "streamable-http";
45
- type TransportType = BaseTransportType | "auto";
46
- interface CORSOptions {
47
- origin?: string;
48
- methods?: string;
49
- headers?: string;
50
- maxAge?: number;
51
- exposeHeaders?: string;
52
- }
53
- interface ServeOptions {
54
- binding?: string;
55
- corsOptions?: CORSOptions;
56
- transport?: BaseTransportType;
57
- jurisdiction?: DurableObjectJurisdiction;
58
- }
59
- //#endregion
60
- //#region src/mcp/client-connection.d.ts
61
- /**
62
- * Connection state machine for MCP client connections.
63
- *
64
- * State transitions:
65
- * - Non-OAuth: init() → CONNECTING → DISCOVERING → READY
66
- * - OAuth: init() → AUTHENTICATING → (callback) → CONNECTING → DISCOVERING → READY
67
- * - Any state can transition to FAILED on error
68
- */
69
- declare const MCPConnectionState: {
70
- /** Waiting for OAuth authorization to complete */ readonly AUTHENTICATING: "authenticating"; /** Establishing transport connection to MCP server */
71
- readonly CONNECTING: "connecting"; /** Transport connection established */
72
- readonly CONNECTED: "connected"; /** Discovering server capabilities (tools, resources, prompts) */
73
- readonly DISCOVERING: "discovering"; /** Fully connected and ready to use */
74
- readonly READY: "ready"; /** Connection failed at some point */
75
- readonly FAILED: "failed";
76
- };
77
- /**
78
- * Connection state type for MCP client connections.
79
- */
80
- type MCPConnectionState =
81
- (typeof MCPConnectionState)[keyof typeof MCPConnectionState];
82
- type MCPTransportOptions = (
83
- | SSEClientTransportOptions
84
- | StreamableHTTPClientTransportOptions
85
- ) & {
86
- authProvider?: AgentsOAuthProvider;
87
- type?: TransportType;
88
- };
89
- /**
90
- * Result of a discovery operation.
91
- * success indicates whether discovery completed successfully.
92
- * error is present when success is false.
93
- */
94
- type MCPDiscoveryResult = {
95
- success: boolean;
96
- error?: string;
97
- };
98
- declare class MCPClientConnection {
99
- url: URL;
100
- options: {
101
- transport: MCPTransportOptions;
102
- client: ConstructorParameters<typeof Client>[1];
103
- };
104
- client: Client;
105
- connectionState: MCPConnectionState;
106
- lastConnectedTransport: BaseTransportType | undefined;
107
- instructions?: string;
108
- tools: Tool[];
109
- prompts: Prompt[];
110
- resources: Resource[];
111
- resourceTemplates: ResourceTemplate[];
112
- serverCapabilities: ServerCapabilities | undefined;
113
- /** Tracks in-flight discovery to allow cancellation */
114
- private _discoveryAbortController;
115
- private readonly _onObservabilityEvent;
116
- readonly onObservabilityEvent: Event<MCPObservabilityEvent>;
117
- constructor(
118
- url: URL,
119
- info: ConstructorParameters<typeof Client>[0],
120
- options?: {
121
- transport: MCPTransportOptions;
122
- client: ConstructorParameters<typeof Client>[1];
123
- }
124
- );
125
- /**
126
- * Initialize a client connection, if authentication is required, the connection will be in the AUTHENTICATING state
127
- * Sets connection state based on the result and emits observability events
128
- *
129
- * @returns Error message if connection failed, undefined otherwise
130
- */
131
- init(): Promise<string | undefined>;
132
- /**
133
- * Finish OAuth by probing transports based on configured type.
134
- * - Explicit: finish on that transport
135
- * - Auto: try streamable-http, then sse on 404/405/Not Implemented
136
- */
137
- private finishAuthProbe;
138
- /**
139
- * Complete OAuth authorization
140
- */
141
- completeAuthorization(code: string): Promise<void>;
142
- /**
143
- * Discover server capabilities and register tools, resources, prompts, and templates.
144
- * This method does the work but does not manage connection state - that's handled by discover().
145
- */
146
- discoverAndRegister(): Promise<void>;
147
- /**
148
- * Discover server capabilities with timeout and cancellation support.
149
- * If called while a previous discovery is in-flight, the previous discovery will be aborted.
150
- *
151
- * @param options Optional configuration
152
- * @param options.timeoutMs Timeout in milliseconds (default: 15000)
153
- * @returns Result indicating success/failure with optional error message
154
- */
155
- discover(options?: { timeoutMs?: number }): Promise<MCPDiscoveryResult>;
156
- /**
157
- * Cancel any in-flight discovery operation.
158
- * Called when closing the connection.
159
- */
160
- cancelDiscovery(): void;
161
- /**
162
- * Notification handler registration for tools
163
- * Should only be called if serverCapabilities.tools exists
164
- */
165
- registerTools(): Promise<Tool[]>;
166
- /**
167
- * Notification handler registration for resources
168
- * Should only be called if serverCapabilities.resources exists
169
- */
170
- registerResources(): Promise<Resource[]>;
171
- /**
172
- * Notification handler registration for prompts
173
- * Should only be called if serverCapabilities.prompts exists
174
- */
175
- registerPrompts(): Promise<Prompt[]>;
176
- registerResourceTemplates(): Promise<ResourceTemplate[]>;
177
- fetchTools(): Promise<
178
- {
179
- inputSchema: {
180
- [x: string]: unknown;
181
- type: "object";
182
- properties?:
183
- | {
184
- [x: string]: object;
185
- }
186
- | undefined;
187
- required?: string[] | undefined;
188
- };
189
- name: string;
190
- description?: string | undefined;
191
- outputSchema?:
192
- | {
193
- [x: string]: unknown;
194
- type: "object";
195
- properties?:
196
- | {
197
- [x: string]: object;
198
- }
199
- | undefined;
200
- required?: string[] | undefined;
201
- }
202
- | undefined;
203
- annotations?:
204
- | {
205
- title?: string | undefined;
206
- readOnlyHint?: boolean | undefined;
207
- destructiveHint?: boolean | undefined;
208
- idempotentHint?: boolean | undefined;
209
- openWorldHint?: boolean | undefined;
210
- }
211
- | undefined;
212
- execution?:
213
- | {
214
- taskSupport?: "optional" | "required" | "forbidden" | undefined;
215
- }
216
- | undefined;
217
- _meta?:
218
- | {
219
- [x: string]: unknown;
220
- }
221
- | undefined;
222
- icons?:
223
- | {
224
- src: string;
225
- mimeType?: string | undefined;
226
- sizes?: string[] | undefined;
227
- theme?: "light" | "dark" | undefined;
228
- }[]
229
- | undefined;
230
- title?: string | undefined;
231
- }[]
232
- >;
233
- fetchResources(): Promise<
234
- {
235
- uri: string;
236
- name: string;
237
- description?: string | undefined;
238
- mimeType?: string | undefined;
239
- annotations?:
240
- | {
241
- audience?: ("user" | "assistant")[] | undefined;
242
- priority?: number | undefined;
243
- lastModified?: string | undefined;
244
- }
245
- | undefined;
246
- _meta?:
247
- | {
248
- [x: string]: unknown;
249
- }
250
- | undefined;
251
- icons?:
252
- | {
253
- src: string;
254
- mimeType?: string | undefined;
255
- sizes?: string[] | undefined;
256
- theme?: "light" | "dark" | undefined;
257
- }[]
258
- | undefined;
259
- title?: string | undefined;
260
- }[]
261
- >;
262
- fetchPrompts(): Promise<
263
- {
264
- name: string;
265
- description?: string | undefined;
266
- arguments?:
267
- | {
268
- name: string;
269
- description?: string | undefined;
270
- required?: boolean | undefined;
271
- }[]
272
- | undefined;
273
- _meta?:
274
- | {
275
- [x: string]: unknown;
276
- }
277
- | undefined;
278
- icons?:
279
- | {
280
- src: string;
281
- mimeType?: string | undefined;
282
- sizes?: string[] | undefined;
283
- theme?: "light" | "dark" | undefined;
284
- }[]
285
- | undefined;
286
- title?: string | undefined;
287
- }[]
288
- >;
289
- fetchResourceTemplates(): Promise<
290
- {
291
- uriTemplate: string;
292
- name: string;
293
- description?: string | undefined;
294
- mimeType?: string | undefined;
295
- annotations?:
296
- | {
297
- audience?: ("user" | "assistant")[] | undefined;
298
- priority?: number | undefined;
299
- lastModified?: string | undefined;
300
- }
301
- | undefined;
302
- _meta?:
303
- | {
304
- [x: string]: unknown;
305
- }
306
- | undefined;
307
- icons?:
308
- | {
309
- src: string;
310
- mimeType?: string | undefined;
311
- sizes?: string[] | undefined;
312
- theme?: "light" | "dark" | undefined;
313
- }[]
314
- | undefined;
315
- title?: string | undefined;
316
- }[]
317
- >;
318
- /**
319
- * Handle elicitation request from server
320
- * Automatically uses the Agent's built-in elicitation handling if available
321
- */
322
- handleElicitationRequest(_request: ElicitRequest): Promise<ElicitResult>;
323
- /**
324
- * Get the transport for the client
325
- * @param transportType - The transport type to get
326
- * @returns The transport for the client
327
- */
328
- getTransport(
329
- transportType: BaseTransportType
330
- ): SSEClientTransport | StreamableHTTPClientTransport;
331
- private tryConnect;
332
- private _capabilityErrorHandler;
333
- }
334
- //#endregion
335
- //#region src/mcp/client-storage.d.ts
336
- /**
337
- * Represents a row in the cf_agents_mcp_servers table
338
- */
339
- type MCPServerRow = {
340
- id: string;
341
- name: string;
342
- server_url: string;
343
- client_id: string | null;
344
- auth_url: string | null;
345
- callback_url: string;
346
- server_options: string | null;
347
- };
348
- //#endregion
349
- //#region src/mcp/client.d.ts
350
- /**
351
- * Options that can be stored in the server_options column
352
- * This is what gets JSON.stringify'd and stored in the database
353
- */
354
- type MCPServerOptions = {
355
- client?: ConstructorParameters<typeof Client>[1];
356
- transport?: {
357
- headers?: HeadersInit;
358
- type?: TransportType;
359
- };
360
- };
361
- /**
362
- * Options for registering an MCP server
363
- */
364
- type RegisterServerOptions = {
365
- url: string;
366
- name: string;
367
- callbackUrl: string;
368
- client?: ConstructorParameters<typeof Client>[1];
369
- transport?: MCPTransportOptions;
370
- authUrl?: string;
371
- clientId?: string;
372
- };
373
- /**
374
- * Result of attempting to connect to an MCP server.
375
- * Discriminated union ensures error is present only on failure.
376
- */
377
- type MCPConnectionResult =
378
- | {
379
- state: typeof MCPConnectionState.FAILED;
380
- error: string;
381
- }
382
- | {
383
- state: typeof MCPConnectionState.AUTHENTICATING;
384
- authUrl: string;
385
- clientId?: string;
386
- }
387
- | {
388
- state: typeof MCPConnectionState.CONNECTED;
389
- };
390
- /**
391
- * Result of discovering server capabilities.
392
- * success indicates whether discovery completed successfully.
393
- * state is the current connection state at time of return.
394
- * error is present when success is false.
395
- */
396
- type MCPDiscoverResult = {
397
- success: boolean;
398
- state: MCPConnectionState;
399
- error?: string;
400
- };
401
- type MCPClientOAuthCallbackConfig = {
402
- successRedirect?: string;
403
- errorRedirect?: string;
404
- customHandler?: (result: MCPClientOAuthResult) => Response;
405
- };
406
- type MCPClientOAuthResult = {
407
- serverId: string;
408
- authSuccess: boolean;
409
- authError?: string;
410
- };
411
- type MCPClientManagerOptions = {
412
- storage: DurableObjectStorage;
413
- };
414
- /**
415
- * Utility class that aggregates multiple MCP clients into one
416
- */
417
- declare class MCPClientManager {
418
- private _name;
419
- private _version;
420
- mcpConnections: Record<string, MCPClientConnection>;
421
- private _didWarnAboutUnstableGetAITools;
422
- private _oauthCallbackConfig?;
423
- private _connectionDisposables;
424
- private _storage;
425
- private _isRestored;
426
- /** @internal Protected for testing purposes. */
427
- protected readonly _onObservabilityEvent: Emitter<MCPObservabilityEvent>;
428
- readonly onObservabilityEvent: Event<MCPObservabilityEvent>;
429
- private readonly _onServerStateChanged;
430
- /**
431
- * Event that fires whenever any MCP server state changes (registered, connected, removed, etc.)
432
- * This is useful for broadcasting server state to clients.
433
- */
434
- readonly onServerStateChanged: Event<void>;
435
- /**
436
- * @param _name Name of the MCP client
437
- * @param _version Version of the MCP Client
438
- * @param options Storage adapter for persisting MCP server state
439
- */
440
- constructor(
441
- _name: string,
442
- _version: string,
443
- options: MCPClientManagerOptions
444
- );
445
- private sql;
446
- private saveServerToStorage;
447
- private removeServerFromStorage;
448
- private getServersFromStorage;
449
- private clearServerAuthUrl;
450
- jsonSchema: typeof ai0.jsonSchema | undefined;
451
- /**
452
- * Create an auth provider for a server
453
- * @internal
454
- */
455
- private createAuthProvider;
456
- /**
457
- * Restore MCP server connections from storage
458
- * This method is called on Agent initialization to restore previously connected servers
459
- *
460
- * @param clientName Name to use for OAuth client (typically the agent instance name)
461
- */
462
- restoreConnectionsFromStorage(clientName: string): Promise<void>;
463
- /**
464
- * Internal method to restore a single server connection and discovery
465
- */
466
- private _restoreServer;
467
- /**
468
- * Connect to and register an MCP server
469
- *
470
- * @deprecated This method is maintained for backward compatibility.
471
- * For new code, use registerServer() and connectToServer() separately.
472
- *
473
- * @param url Server URL
474
- * @param options Connection options
475
- * @returns Object with server ID, auth URL (if OAuth), and client ID (if OAuth)
476
- */
477
- connect(
478
- url: string,
479
- options?: {
480
- reconnect?: {
481
- id: string;
482
- oauthClientId?: string;
483
- oauthCode?: string;
484
- };
485
- transport?: MCPTransportOptions;
486
- client?: ConstructorParameters<typeof Client>[1];
487
- }
488
- ): Promise<{
489
- id: string;
490
- authUrl?: string;
491
- clientId?: string;
492
- }>;
493
- /**
494
- * Create an in-memory connection object and set up observability
495
- * Does NOT save to storage - use registerServer() for that
496
- * @returns The connection object (existing or newly created)
497
- */
498
- private createConnection;
499
- /**
500
- * Register an MCP server connection without connecting
501
- * Creates the connection object, sets up observability, and saves to storage
502
- *
503
- * @param id Server ID
504
- * @param options Registration options including URL, name, callback URL, and connection config
505
- * @returns Server ID
506
- */
507
- registerServer(id: string, options: RegisterServerOptions): Promise<string>;
508
- /**
509
- * Connect to an already registered MCP server and initialize the connection.
510
- *
511
- * For OAuth servers, returns `{ state: "authenticating", authUrl, clientId? }`.
512
- * The user must complete the OAuth flow via the authUrl, which triggers a
513
- * callback handled by `handleCallbackRequest()`.
514
- *
515
- * For non-OAuth servers, establishes the transport connection and returns
516
- * `{ state: "connected" }`. Call `discoverIfConnected()` afterwards to
517
- * discover capabilities and transition to "ready" state.
518
- *
519
- * @param id Server ID (must be registered first via registerServer())
520
- * @returns Connection result with current state and OAuth info (if applicable)
521
- */
522
- connectToServer(id: string): Promise<MCPConnectionResult>;
523
- private extractServerIdFromState;
524
- isCallbackRequest(req: Request): boolean;
525
- handleCallbackRequest(req: Request): Promise<
526
- | {
527
- serverId: string;
528
- authSuccess: boolean;
529
- authError: string;
530
- }
531
- | {
532
- serverId: string;
533
- authSuccess: boolean;
534
- authError?: undefined;
535
- }
536
- >;
537
- /**
538
- * Discover server capabilities if connection is in CONNECTED or READY state.
539
- * Transitions to DISCOVERING then READY (or CONNECTED on error).
540
- * Can be called to refresh server capabilities (e.g., from a UI refresh button).
541
- *
542
- * If called while a previous discovery is in-flight for the same server,
543
- * the previous discovery will be aborted.
544
- *
545
- * @param serverId The server ID to discover
546
- * @param options Optional configuration
547
- * @param options.timeoutMs Timeout in milliseconds (default: 30000)
548
- * @returns Result with current state and optional error, or undefined if connection not found
549
- */
550
- discoverIfConnected(
551
- serverId: string,
552
- options?: {
553
- timeoutMs?: number;
554
- }
555
- ): Promise<MCPDiscoverResult | undefined>;
556
- /**
557
- * Establish connection in the background after OAuth completion
558
- * This method connects to the server and discovers its capabilities
559
- * @param serverId The server ID to establish connection for
560
- */
561
- establishConnection(serverId: string): Promise<void>;
562
- /**
563
- * Configure OAuth callback handling
564
- * @param config OAuth callback configuration
565
- */
566
- configureOAuthCallback(config: MCPClientOAuthCallbackConfig): void;
567
- /**
568
- * Get the current OAuth callback configuration
569
- * @returns The current OAuth callback configuration
570
- */
571
- getOAuthCallbackConfig(): MCPClientOAuthCallbackConfig | undefined;
572
- /**
573
- * @returns namespaced list of tools
574
- */
575
- listTools(): NamespacedData["tools"];
576
- /**
577
- * Lazy-loads the jsonSchema function from the AI SDK.
578
- *
579
- * This defers importing the "ai" package until it's actually needed, which helps reduce
580
- * initial bundle size and startup time. The jsonSchema function is required for converting
581
- * MCP tools into AI SDK tool definitions via getAITools().
582
- *
583
- * @internal This method is for internal use only. It's automatically called before operations
584
- * that need jsonSchema (like getAITools() or OAuth flows). External consumers should not need
585
- * to call this directly.
586
- */
587
- ensureJsonSchema(): Promise<void>;
588
- /**
589
- * @returns a set of tools that you can use with the AI SDK
590
- */
591
- getAITools(): ToolSet;
592
- /**
593
- * @deprecated this has been renamed to getAITools(), and unstable_getAITools will be removed in the next major version
594
- * @returns a set of tools that you can use with the AI SDK
595
- */
596
- unstable_getAITools(): ToolSet;
597
- /**
598
- * Closes all active in-memory connections to MCP servers.
599
- *
600
- * Note: This only closes the transport connections - it does NOT remove
601
- * servers from storage. Servers will still be listed and their callback
602
- * URLs will still match incoming OAuth requests.
603
- *
604
- * Use removeServer() instead if you want to fully clean up a server
605
- * (closes connection AND removes from storage).
606
- */
607
- closeAllConnections(): Promise<void>;
608
- /**
609
- * Closes a connection to an MCP server
610
- * @param id The id of the connection to close
611
- */
612
- closeConnection(id: string): Promise<void>;
613
- /**
614
- * Remove an MCP server - closes connection if active and removes from storage.
615
- */
616
- removeServer(serverId: string): Promise<void>;
617
- /**
618
- * List all MCP servers from storage
619
- */
620
- listServers(): MCPServerRow[];
621
- /**
622
- * Dispose the manager and all resources.
623
- */
624
- dispose(): Promise<void>;
625
- /**
626
- * @returns namespaced list of prompts
627
- */
628
- listPrompts(): NamespacedData["prompts"];
629
- /**
630
- * @returns namespaced list of tools
631
- */
632
- listResources(): NamespacedData["resources"];
633
- /**
634
- * @returns namespaced list of resource templates
635
- */
636
- listResourceTemplates(): NamespacedData["resourceTemplates"];
637
- /**
638
- * Namespaced version of callTool
639
- */
640
- callTool(
641
- params: CallToolRequest["params"] & {
642
- serverId: string;
643
- },
644
- resultSchema?:
645
- | typeof CallToolResultSchema
646
- | typeof CompatibilityCallToolResultSchema,
647
- options?: RequestOptions
648
- ): Promise<
649
- | {
650
- [x: string]: unknown;
651
- content: (
652
- | {
653
- type: "text";
654
- text: string;
655
- annotations?:
656
- | {
657
- audience?: ("user" | "assistant")[] | undefined;
658
- priority?: number | undefined;
659
- lastModified?: string | undefined;
660
- }
661
- | undefined;
662
- _meta?: Record<string, unknown> | undefined;
663
- }
664
- | {
665
- type: "image";
666
- data: string;
667
- mimeType: string;
668
- annotations?:
669
- | {
670
- audience?: ("user" | "assistant")[] | undefined;
671
- priority?: number | undefined;
672
- lastModified?: string | undefined;
673
- }
674
- | undefined;
675
- _meta?: Record<string, unknown> | undefined;
676
- }
677
- | {
678
- type: "audio";
679
- data: string;
680
- mimeType: string;
681
- annotations?:
682
- | {
683
- audience?: ("user" | "assistant")[] | undefined;
684
- priority?: number | undefined;
685
- lastModified?: string | undefined;
686
- }
687
- | undefined;
688
- _meta?: Record<string, unknown> | undefined;
689
- }
690
- | {
691
- type: "resource";
692
- resource:
693
- | {
694
- uri: string;
695
- text: string;
696
- mimeType?: string | undefined;
697
- _meta?: Record<string, unknown> | undefined;
698
- }
699
- | {
700
- uri: string;
701
- blob: string;
702
- mimeType?: string | undefined;
703
- _meta?: Record<string, unknown> | undefined;
704
- };
705
- annotations?:
706
- | {
707
- audience?: ("user" | "assistant")[] | undefined;
708
- priority?: number | undefined;
709
- lastModified?: string | undefined;
710
- }
711
- | undefined;
712
- _meta?: Record<string, unknown> | undefined;
713
- }
714
- | {
715
- uri: string;
716
- name: string;
717
- type: "resource_link";
718
- description?: string | undefined;
719
- mimeType?: string | undefined;
720
- annotations?:
721
- | {
722
- audience?: ("user" | "assistant")[] | undefined;
723
- priority?: number | undefined;
724
- lastModified?: string | undefined;
725
- }
726
- | undefined;
727
- _meta?:
728
- | {
729
- [x: string]: unknown;
730
- }
731
- | undefined;
732
- icons?:
733
- | {
734
- src: string;
735
- mimeType?: string | undefined;
736
- sizes?: string[] | undefined;
737
- theme?: "light" | "dark" | undefined;
738
- }[]
739
- | undefined;
740
- title?: string | undefined;
741
- }
742
- )[];
743
- _meta?:
744
- | {
745
- [x: string]: unknown;
746
- progressToken?: string | number | undefined;
747
- "io.modelcontextprotocol/related-task"?:
748
- | {
749
- taskId: string;
750
- }
751
- | undefined;
752
- }
753
- | undefined;
754
- structuredContent?: Record<string, unknown> | undefined;
755
- isError?: boolean | undefined;
756
- }
757
- | {
758
- [x: string]: unknown;
759
- toolResult: unknown;
760
- _meta?:
761
- | {
762
- [x: string]: unknown;
763
- progressToken?: string | number | undefined;
764
- "io.modelcontextprotocol/related-task"?:
765
- | {
766
- taskId: string;
767
- }
768
- | undefined;
769
- }
770
- | undefined;
771
- }
772
- >;
773
- /**
774
- * Namespaced version of readResource
775
- */
776
- readResource(
777
- params: ReadResourceRequest["params"] & {
778
- serverId: string;
779
- },
780
- options: RequestOptions
781
- ): Promise<{
782
- [x: string]: unknown;
783
- contents: (
784
- | {
785
- uri: string;
786
- text: string;
787
- mimeType?: string | undefined;
788
- _meta?: Record<string, unknown> | undefined;
789
- }
790
- | {
791
- uri: string;
792
- blob: string;
793
- mimeType?: string | undefined;
794
- _meta?: Record<string, unknown> | undefined;
795
- }
796
- )[];
797
- _meta?:
798
- | {
799
- [x: string]: unknown;
800
- progressToken?: string | number | undefined;
801
- "io.modelcontextprotocol/related-task"?:
802
- | {
803
- taskId: string;
804
- }
805
- | undefined;
806
- }
807
- | undefined;
808
- }>;
809
- /**
810
- * Namespaced version of getPrompt
811
- */
812
- getPrompt(
813
- params: GetPromptRequest["params"] & {
814
- serverId: string;
815
- },
816
- options: RequestOptions
817
- ): Promise<{
818
- [x: string]: unknown;
819
- messages: {
820
- role: "user" | "assistant";
821
- content:
822
- | {
823
- type: "text";
824
- text: string;
825
- annotations?:
826
- | {
827
- audience?: ("user" | "assistant")[] | undefined;
828
- priority?: number | undefined;
829
- lastModified?: string | undefined;
830
- }
831
- | undefined;
832
- _meta?: Record<string, unknown> | undefined;
833
- }
834
- | {
835
- type: "image";
836
- data: string;
837
- mimeType: string;
838
- annotations?:
839
- | {
840
- audience?: ("user" | "assistant")[] | undefined;
841
- priority?: number | undefined;
842
- lastModified?: string | undefined;
843
- }
844
- | undefined;
845
- _meta?: Record<string, unknown> | undefined;
846
- }
847
- | {
848
- type: "audio";
849
- data: string;
850
- mimeType: string;
851
- annotations?:
852
- | {
853
- audience?: ("user" | "assistant")[] | undefined;
854
- priority?: number | undefined;
855
- lastModified?: string | undefined;
856
- }
857
- | undefined;
858
- _meta?: Record<string, unknown> | undefined;
859
- }
860
- | {
861
- type: "resource";
862
- resource:
863
- | {
864
- uri: string;
865
- text: string;
866
- mimeType?: string | undefined;
867
- _meta?: Record<string, unknown> | undefined;
868
- }
869
- | {
870
- uri: string;
871
- blob: string;
872
- mimeType?: string | undefined;
873
- _meta?: Record<string, unknown> | undefined;
874
- };
875
- annotations?:
876
- | {
877
- audience?: ("user" | "assistant")[] | undefined;
878
- priority?: number | undefined;
879
- lastModified?: string | undefined;
880
- }
881
- | undefined;
882
- _meta?: Record<string, unknown> | undefined;
883
- }
884
- | {
885
- uri: string;
886
- name: string;
887
- type: "resource_link";
888
- description?: string | undefined;
889
- mimeType?: string | undefined;
890
- annotations?:
891
- | {
892
- audience?: ("user" | "assistant")[] | undefined;
893
- priority?: number | undefined;
894
- lastModified?: string | undefined;
895
- }
896
- | undefined;
897
- _meta?:
898
- | {
899
- [x: string]: unknown;
900
- }
901
- | undefined;
902
- icons?:
903
- | {
904
- src: string;
905
- mimeType?: string | undefined;
906
- sizes?: string[] | undefined;
907
- theme?: "light" | "dark" | undefined;
908
- }[]
909
- | undefined;
910
- title?: string | undefined;
911
- };
912
- }[];
913
- _meta?:
914
- | {
915
- [x: string]: unknown;
916
- progressToken?: string | number | undefined;
917
- "io.modelcontextprotocol/related-task"?:
918
- | {
919
- taskId: string;
920
- }
921
- | undefined;
922
- }
923
- | undefined;
924
- description?: string | undefined;
925
- }>;
926
- }
927
- type NamespacedData = {
928
- tools: (Tool & {
929
- serverId: string;
930
- })[];
931
- prompts: (Prompt & {
932
- serverId: string;
933
- })[];
934
- resources: (Resource & {
935
- serverId: string;
936
- })[];
937
- resourceTemplates: (ResourceTemplate & {
938
- serverId: string;
939
- })[];
940
- };
941
- declare function getNamespacedData<T extends keyof NamespacedData>(
942
- mcpClients: Record<string, MCPClientConnection>,
943
- type: T
944
- ): NamespacedData[T];
945
- //#endregion
946
- export {
947
- MCPConnectionResult as a,
948
- RegisterServerOptions as c,
949
- BaseTransportType as d,
950
- CORSOptions as f,
951
- TransportType as h,
952
- MCPClientOAuthResult as i,
953
- getNamespacedData as l,
954
- ServeOptions as m,
955
- MCPClientManagerOptions as n,
956
- MCPDiscoverResult as o,
957
- MaybePromise as p,
958
- MCPClientOAuthCallbackConfig as r,
959
- MCPServerOptions as s,
960
- MCPClientManager as t,
961
- MCPConnectionState as u
962
- };
963
- //# sourceMappingURL=client-Ba-xntmv.d.ts.map