agents 0.0.0-d045755 → 0.0.0-d08612f

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