agents 0.3.10 → 0.4.1

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