agents 0.2.25 → 0.2.27

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.
@@ -1,1528 +0,0 @@
1
- import { t as MCPObservabilityEvent } from "./mcp-BwPscEiF.js";
2
- import { t as AgentsOAuthProvider } from "./do-oauth-client-provider-C2CHH5x-.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 * as zod0 from "zod";
29
- import { RequestOptions } from "@modelcontextprotocol/sdk/shared/protocol.js";
30
-
31
- //#region src/core/events.d.ts
32
- interface Disposable {
33
- dispose(): void;
34
- }
35
- type Event<T> = (listener: (e: T) => void) => Disposable;
36
- //#endregion
37
- //#region src/mcp/types.d.ts
38
- type MaybePromise<T> = T | Promise<T>;
39
- type BaseTransportType = "sse" | "streamable-http";
40
- type TransportType = BaseTransportType | "auto";
41
- interface CORSOptions {
42
- origin?: string;
43
- methods?: string;
44
- headers?: string;
45
- maxAge?: number;
46
- exposeHeaders?: string;
47
- }
48
- interface ServeOptions {
49
- binding?: string;
50
- corsOptions?: CORSOptions;
51
- transport?: BaseTransportType;
52
- jurisdiction?: DurableObjectJurisdiction;
53
- }
54
- //#endregion
55
- //#region src/mcp/client-connection.d.ts
56
- /**
57
- * Connection state machine for MCP client connections.
58
- *
59
- * State transitions:
60
- * - Non-OAuth: init() → CONNECTING → DISCOVERING → READY
61
- * - OAuth: init() → AUTHENTICATING → (callback) → CONNECTING → DISCOVERING → READY
62
- * - Any state can transition to FAILED on error
63
- */
64
- declare const MCPConnectionState: {
65
- /** Waiting for OAuth authorization to complete */
66
- readonly AUTHENTICATING: "authenticating";
67
- /** Establishing transport connection to MCP server */
68
- readonly CONNECTING: "connecting";
69
- /** Transport connection established */
70
- readonly CONNECTED: "connected";
71
- /** Discovering server capabilities (tools, resources, prompts) */
72
- readonly DISCOVERING: "discovering";
73
- /** Fully connected and ready to use */
74
- readonly READY: "ready";
75
- /** Connection failed at some point */
76
- readonly FAILED: "failed";
77
- };
78
- /**
79
- * Connection state type for MCP client connections.
80
- */
81
- type MCPConnectionState =
82
- (typeof MCPConnectionState)[keyof typeof MCPConnectionState];
83
- type MCPTransportOptions = (
84
- | SSEClientTransportOptions
85
- | StreamableHTTPClientTransportOptions
86
- ) & {
87
- authProvider?: AgentsOAuthProvider;
88
- type?: TransportType;
89
- };
90
- /**
91
- * Result of a discovery operation.
92
- * success indicates whether discovery completed successfully.
93
- * error is present when success is false.
94
- */
95
- type MCPDiscoveryResult = {
96
- success: boolean;
97
- error?: string;
98
- };
99
- declare class MCPClientConnection {
100
- url: URL;
101
- options: {
102
- transport: MCPTransportOptions;
103
- client: ConstructorParameters<typeof Client>[1];
104
- };
105
- client: Client;
106
- connectionState: MCPConnectionState;
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
- name: string;
181
- inputSchema: {
182
- type: "object";
183
- required?: string[] | undefined;
184
- properties?:
185
- | {
186
- [x: string]: object;
187
- }
188
- | undefined;
189
- };
190
- _meta?:
191
- | {
192
- [x: string]: unknown;
193
- }
194
- | undefined;
195
- icons?:
196
- | {
197
- src: string;
198
- mimeType?: string | undefined | undefined;
199
- sizes?: string[] | undefined;
200
- }[]
201
- | undefined;
202
- title?: string | undefined | undefined;
203
- description?: string | undefined | undefined;
204
- outputSchema?:
205
- | {
206
- type: "object";
207
- required?: string[] | undefined;
208
- properties?:
209
- | {
210
- [x: string]: object;
211
- }
212
- | undefined;
213
- additionalProperties?: boolean | undefined | undefined;
214
- }
215
- | undefined;
216
- annotations?:
217
- | {
218
- title?: string | undefined | undefined;
219
- readOnlyHint?: boolean | undefined | undefined;
220
- destructiveHint?: boolean | undefined | undefined;
221
- idempotentHint?: boolean | undefined | undefined;
222
- openWorldHint?: boolean | undefined | undefined;
223
- }
224
- | undefined;
225
- }[]
226
- >;
227
- fetchResources(): Promise<
228
- {
229
- name: string;
230
- uri: string;
231
- _meta?:
232
- | {
233
- [x: string]: unknown;
234
- }
235
- | undefined;
236
- mimeType?: string | undefined | undefined;
237
- icons?:
238
- | {
239
- src: string;
240
- mimeType?: string | undefined | undefined;
241
- sizes?: string[] | undefined;
242
- }[]
243
- | undefined;
244
- title?: string | undefined | undefined;
245
- description?: string | undefined | undefined;
246
- }[]
247
- >;
248
- fetchPrompts(): Promise<
249
- {
250
- name: string;
251
- _meta?:
252
- | {
253
- [x: string]: unknown;
254
- }
255
- | undefined;
256
- icons?:
257
- | {
258
- src: string;
259
- mimeType?: string | undefined | undefined;
260
- sizes?: string[] | undefined;
261
- }[]
262
- | undefined;
263
- title?: string | undefined | undefined;
264
- description?: string | undefined | undefined;
265
- arguments?:
266
- | {
267
- name: string;
268
- description?: string | undefined | undefined;
269
- required?: boolean | undefined | undefined;
270
- }[]
271
- | undefined;
272
- }[]
273
- >;
274
- fetchResourceTemplates(): Promise<
275
- {
276
- name: string;
277
- uriTemplate: string;
278
- _meta?:
279
- | {
280
- [x: string]: unknown;
281
- }
282
- | undefined;
283
- mimeType?: string | undefined | undefined;
284
- icons?:
285
- | {
286
- src: string;
287
- mimeType?: string | undefined | undefined;
288
- sizes?: string[] | undefined;
289
- }[]
290
- | undefined;
291
- title?: string | undefined | undefined;
292
- description?: string | undefined | undefined;
293
- }[]
294
- >;
295
- /**
296
- * Handle elicitation request from server
297
- * Automatically uses the Agent's built-in elicitation handling if available
298
- */
299
- handleElicitationRequest(_request: ElicitRequest): Promise<ElicitResult>;
300
- /**
301
- * Get the transport for the client
302
- * @param transportType - The transport type to get
303
- * @returns The transport for the client
304
- */
305
- getTransport(
306
- transportType: BaseTransportType
307
- ): SSEClientTransport | StreamableHTTPClientTransport;
308
- private tryConnect;
309
- private _capabilityErrorHandler;
310
- }
311
- //#endregion
312
- //#region src/mcp/client-storage.d.ts
313
- /**
314
- * Represents a row in the cf_agents_mcp_servers table
315
- */
316
- type MCPServerRow = {
317
- id: string;
318
- name: string;
319
- server_url: string;
320
- client_id: string | null;
321
- auth_url: string | null;
322
- callback_url: string;
323
- server_options: string | null;
324
- };
325
- //#endregion
326
- //#region src/mcp/client.d.ts
327
- /**
328
- * Options that can be stored in the server_options column
329
- * This is what gets JSON.stringify'd and stored in the database
330
- */
331
- type MCPServerOptions = {
332
- client?: ConstructorParameters<typeof Client>[1];
333
- transport?: {
334
- headers?: HeadersInit;
335
- type?: TransportType;
336
- };
337
- };
338
- /**
339
- * Options for registering an MCP server
340
- */
341
- type RegisterServerOptions = {
342
- url: string;
343
- name: string;
344
- callbackUrl: string;
345
- client?: ConstructorParameters<typeof Client>[1];
346
- transport?: MCPTransportOptions;
347
- authUrl?: string;
348
- clientId?: string;
349
- };
350
- /**
351
- * Result of attempting to connect to an MCP server.
352
- * Discriminated union ensures error is present only on failure.
353
- */
354
- type MCPConnectionResult =
355
- | {
356
- state: typeof MCPConnectionState.FAILED;
357
- error: string;
358
- }
359
- | {
360
- state: typeof MCPConnectionState.AUTHENTICATING;
361
- authUrl: string;
362
- clientId?: string;
363
- }
364
- | {
365
- state: typeof MCPConnectionState.CONNECTED;
366
- };
367
- /**
368
- * Result of discovering server capabilities.
369
- * success indicates whether discovery completed successfully.
370
- * state is the current connection state at time of return.
371
- * error is present when success is false.
372
- */
373
- type MCPDiscoverResult = {
374
- success: boolean;
375
- state: MCPConnectionState;
376
- error?: string;
377
- };
378
- type MCPClientOAuthCallbackConfig = {
379
- successRedirect?: string;
380
- errorRedirect?: string;
381
- customHandler?: (result: MCPClientOAuthResult) => Response;
382
- };
383
- type MCPClientOAuthResult = {
384
- serverId: string;
385
- authSuccess: boolean;
386
- authError?: string;
387
- };
388
- type MCPClientManagerOptions = {
389
- storage: DurableObjectStorage;
390
- };
391
- /**
392
- * Utility class that aggregates multiple MCP clients into one
393
- */
394
- declare class MCPClientManager {
395
- private _name;
396
- private _version;
397
- mcpConnections: Record<string, MCPClientConnection>;
398
- private _didWarnAboutUnstableGetAITools;
399
- private _oauthCallbackConfig?;
400
- private _connectionDisposables;
401
- private _storage;
402
- private _isRestored;
403
- private readonly _onObservabilityEvent;
404
- readonly onObservabilityEvent: Event<MCPObservabilityEvent>;
405
- private readonly _onServerStateChanged;
406
- /**
407
- * Event that fires whenever any MCP server state changes (registered, connected, removed, etc.)
408
- * This is useful for broadcasting server state to clients.
409
- */
410
- readonly onServerStateChanged: Event<void>;
411
- /**
412
- * @param _name Name of the MCP client
413
- * @param _version Version of the MCP Client
414
- * @param options Storage adapter for persisting MCP server state
415
- */
416
- constructor(
417
- _name: string,
418
- _version: string,
419
- options: MCPClientManagerOptions
420
- );
421
- private sql;
422
- private saveServerToStorage;
423
- private removeServerFromStorage;
424
- private getServersFromStorage;
425
- private clearServerAuthUrl;
426
- jsonSchema: typeof ai0.jsonSchema | undefined;
427
- /**
428
- * Create an auth provider for a server
429
- * @internal
430
- */
431
- private createAuthProvider;
432
- /**
433
- * Restore MCP server connections from storage
434
- * This method is called on Agent initialization to restore previously connected servers
435
- *
436
- * @param clientName Name to use for OAuth client (typically the agent instance name)
437
- */
438
- restoreConnectionsFromStorage(clientName: string): Promise<void>;
439
- /**
440
- * Internal method to restore a single server connection and discovery
441
- */
442
- private _restoreServer;
443
- /**
444
- * Connect to and register an MCP server
445
- *
446
- * @deprecated This method is maintained for backward compatibility.
447
- * For new code, use registerServer() and connectToServer() separately.
448
- *
449
- * @param url Server URL
450
- * @param options Connection options
451
- * @returns Object with server ID, auth URL (if OAuth), and client ID (if OAuth)
452
- */
453
- connect(
454
- url: string,
455
- options?: {
456
- reconnect?: {
457
- id: string;
458
- oauthClientId?: string;
459
- oauthCode?: string;
460
- };
461
- transport?: MCPTransportOptions;
462
- client?: ConstructorParameters<typeof Client>[1];
463
- }
464
- ): Promise<{
465
- id: string;
466
- authUrl?: string;
467
- clientId?: string;
468
- }>;
469
- /**
470
- * Create an in-memory connection object and set up observability
471
- * Does NOT save to storage - use registerServer() for that
472
- * @returns The connection object (existing or newly created)
473
- */
474
- private createConnection;
475
- /**
476
- * Register an MCP server connection without connecting
477
- * Creates the connection object, sets up observability, and saves to storage
478
- *
479
- * @param id Server ID
480
- * @param options Registration options including URL, name, callback URL, and connection config
481
- * @returns Server ID
482
- */
483
- registerServer(id: string, options: RegisterServerOptions): Promise<string>;
484
- /**
485
- * Connect to an already registered MCP server and initialize the connection.
486
- *
487
- * For OAuth servers, returns `{ state: "authenticating", authUrl, clientId? }`.
488
- * The user must complete the OAuth flow via the authUrl, which triggers a
489
- * callback handled by `handleCallbackRequest()`.
490
- *
491
- * For non-OAuth servers, establishes the transport connection and returns
492
- * `{ state: "connected" }`. Call `discoverIfConnected()` afterwards to
493
- * discover capabilities and transition to "ready" state.
494
- *
495
- * @param id Server ID (must be registered first via registerServer())
496
- * @returns Connection result with current state and OAuth info (if applicable)
497
- */
498
- connectToServer(id: string): Promise<MCPConnectionResult>;
499
- isCallbackRequest(req: Request): boolean;
500
- handleCallbackRequest(req: Request): Promise<
501
- | {
502
- serverId: string;
503
- authSuccess: boolean;
504
- authError: string;
505
- }
506
- | {
507
- serverId: string;
508
- authSuccess: boolean;
509
- authError?: undefined;
510
- }
511
- >;
512
- /**
513
- * Discover server capabilities if connection is in CONNECTED or READY state.
514
- * Transitions to DISCOVERING then READY (or CONNECTED on error).
515
- * Can be called to refresh server capabilities (e.g., from a UI refresh button).
516
- *
517
- * If called while a previous discovery is in-flight for the same server,
518
- * the previous discovery will be aborted.
519
- *
520
- * @param serverId The server ID to discover
521
- * @param options Optional configuration
522
- * @param options.timeoutMs Timeout in milliseconds (default: 30000)
523
- * @returns Result with current state and optional error, or undefined if connection not found
524
- */
525
- discoverIfConnected(
526
- serverId: string,
527
- options?: {
528
- timeoutMs?: number;
529
- }
530
- ): Promise<MCPDiscoverResult | undefined>;
531
- /**
532
- * Establish connection in the background after OAuth completion
533
- * This method connects to the server and discovers its capabilities
534
- * @param serverId The server ID to establish connection for
535
- */
536
- establishConnection(serverId: string): Promise<void>;
537
- /**
538
- * Configure OAuth callback handling
539
- * @param config OAuth callback configuration
540
- */
541
- configureOAuthCallback(config: MCPClientOAuthCallbackConfig): void;
542
- /**
543
- * Get the current OAuth callback configuration
544
- * @returns The current OAuth callback configuration
545
- */
546
- getOAuthCallbackConfig(): MCPClientOAuthCallbackConfig | undefined;
547
- /**
548
- * @returns namespaced list of tools
549
- */
550
- listTools(): NamespacedData["tools"];
551
- /**
552
- * Lazy-loads the jsonSchema function from the AI SDK.
553
- *
554
- * This defers importing the "ai" package until it's actually needed, which helps reduce
555
- * initial bundle size and startup time. The jsonSchema function is required for converting
556
- * MCP tools into AI SDK tool definitions via getAITools().
557
- *
558
- * @internal This method is for internal use only. It's automatically called before operations
559
- * that need jsonSchema (like getAITools() or OAuth flows). External consumers should not need
560
- * to call this directly.
561
- */
562
- ensureJsonSchema(): Promise<void>;
563
- /**
564
- * @returns a set of tools that you can use with the AI SDK
565
- */
566
- getAITools(): ToolSet;
567
- /**
568
- * @deprecated this has been renamed to getAITools(), and unstable_getAITools will be removed in the next major version
569
- * @returns a set of tools that you can use with the AI SDK
570
- */
571
- unstable_getAITools(): ToolSet;
572
- /**
573
- * Closes all active in-memory connections to MCP servers.
574
- *
575
- * Note: This only closes the transport connections - it does NOT remove
576
- * servers from storage. Servers will still be listed and their callback
577
- * URLs will still match incoming OAuth requests.
578
- *
579
- * Use removeServer() instead if you want to fully clean up a server
580
- * (closes connection AND removes from storage).
581
- */
582
- closeAllConnections(): Promise<void>;
583
- /**
584
- * Closes a connection to an MCP server
585
- * @param id The id of the connection to close
586
- */
587
- closeConnection(id: string): Promise<void>;
588
- /**
589
- * Remove an MCP server - closes connection if active and removes from storage.
590
- */
591
- removeServer(serverId: string): Promise<void>;
592
- /**
593
- * List all MCP servers from storage
594
- */
595
- listServers(): MCPServerRow[];
596
- /**
597
- * Dispose the manager and all resources.
598
- */
599
- dispose(): Promise<void>;
600
- /**
601
- * @returns namespaced list of prompts
602
- */
603
- listPrompts(): NamespacedData["prompts"];
604
- /**
605
- * @returns namespaced list of tools
606
- */
607
- listResources(): NamespacedData["resources"];
608
- /**
609
- * @returns namespaced list of resource templates
610
- */
611
- listResourceTemplates(): NamespacedData["resourceTemplates"];
612
- /**
613
- * Namespaced version of callTool
614
- */
615
- callTool(
616
- params: CallToolRequest["params"] & {
617
- serverId: string;
618
- },
619
- resultSchema?:
620
- | typeof CallToolResultSchema
621
- | typeof CompatibilityCallToolResultSchema,
622
- options?: RequestOptions
623
- ): Promise<
624
- | zod0.objectOutputType<
625
- {
626
- _meta: zod0.ZodOptional<
627
- zod0.ZodRecord<zod0.ZodString, zod0.ZodUnknown>
628
- >;
629
- } & {
630
- content: zod0.ZodDefault<
631
- zod0.ZodArray<
632
- zod0.ZodUnion<
633
- [
634
- zod0.ZodObject<
635
- {
636
- type: zod0.ZodLiteral<"text">;
637
- text: zod0.ZodString;
638
- _meta: zod0.ZodOptional<
639
- zod0.ZodRecord<zod0.ZodString, zod0.ZodUnknown>
640
- >;
641
- },
642
- "strip",
643
- zod0.ZodTypeAny,
644
- {
645
- type: "text";
646
- text: string;
647
- _meta?: Record<string, unknown> | undefined;
648
- },
649
- {
650
- type: "text";
651
- text: string;
652
- _meta?: Record<string, unknown> | undefined;
653
- }
654
- >,
655
- zod0.ZodObject<
656
- {
657
- type: zod0.ZodLiteral<"image">;
658
- data: zod0.ZodEffects<zod0.ZodString, string, string>;
659
- mimeType: zod0.ZodString;
660
- _meta: zod0.ZodOptional<
661
- zod0.ZodRecord<zod0.ZodString, zod0.ZodUnknown>
662
- >;
663
- },
664
- "strip",
665
- zod0.ZodTypeAny,
666
- {
667
- type: "image";
668
- data: string;
669
- mimeType: string;
670
- _meta?: Record<string, unknown> | undefined;
671
- },
672
- {
673
- type: "image";
674
- data: string;
675
- mimeType: string;
676
- _meta?: Record<string, unknown> | undefined;
677
- }
678
- >,
679
- zod0.ZodObject<
680
- {
681
- type: zod0.ZodLiteral<"audio">;
682
- data: zod0.ZodEffects<zod0.ZodString, string, string>;
683
- mimeType: zod0.ZodString;
684
- _meta: zod0.ZodOptional<
685
- zod0.ZodRecord<zod0.ZodString, zod0.ZodUnknown>
686
- >;
687
- },
688
- "strip",
689
- zod0.ZodTypeAny,
690
- {
691
- type: "audio";
692
- data: string;
693
- mimeType: string;
694
- _meta?: Record<string, unknown> | undefined;
695
- },
696
- {
697
- type: "audio";
698
- data: string;
699
- mimeType: string;
700
- _meta?: Record<string, unknown> | undefined;
701
- }
702
- >,
703
- zod0.ZodObject<
704
- zod0.objectUtil.extendShape<
705
- zod0.objectUtil.extendShape<
706
- zod0.objectUtil.extendShape<
707
- {
708
- name: zod0.ZodString;
709
- title: zod0.ZodOptional<zod0.ZodString>;
710
- },
711
- {
712
- uri: zod0.ZodString;
713
- description: zod0.ZodOptional<zod0.ZodString>;
714
- mimeType: zod0.ZodOptional<zod0.ZodString>;
715
- _meta: zod0.ZodOptional<
716
- zod0.ZodObject<
717
- {},
718
- "passthrough",
719
- zod0.ZodTypeAny,
720
- zod0.objectOutputType<
721
- {},
722
- zod0.ZodTypeAny,
723
- "passthrough"
724
- >,
725
- zod0.objectInputType<
726
- {},
727
- zod0.ZodTypeAny,
728
- "passthrough"
729
- >
730
- >
731
- >;
732
- }
733
- >,
734
- {
735
- icons: zod0.ZodOptional<
736
- zod0.ZodArray<
737
- zod0.ZodObject<
738
- {
739
- src: zod0.ZodString;
740
- mimeType: zod0.ZodOptional<zod0.ZodString>;
741
- sizes: zod0.ZodOptional<
742
- zod0.ZodArray<zod0.ZodString, "many">
743
- >;
744
- },
745
- "strip",
746
- zod0.ZodTypeAny,
747
- {
748
- src: string;
749
- mimeType?: string | undefined;
750
- sizes?: string[] | undefined;
751
- },
752
- {
753
- src: string;
754
- mimeType?: string | undefined;
755
- sizes?: string[] | undefined;
756
- }
757
- >,
758
- "many"
759
- >
760
- >;
761
- }
762
- >,
763
- {
764
- type: zod0.ZodLiteral<"resource_link">;
765
- }
766
- >,
767
- "strip",
768
- zod0.ZodTypeAny,
769
- {
770
- type: "resource_link";
771
- name: string;
772
- uri: string;
773
- _meta?:
774
- | zod0.objectOutputType<
775
- {},
776
- zod0.ZodTypeAny,
777
- "passthrough"
778
- >
779
- | undefined;
780
- mimeType?: string | undefined;
781
- icons?:
782
- | {
783
- src: string;
784
- mimeType?: string | undefined;
785
- sizes?: string[] | undefined;
786
- }[]
787
- | undefined;
788
- title?: string | undefined;
789
- description?: string | undefined;
790
- },
791
- {
792
- type: "resource_link";
793
- name: string;
794
- uri: string;
795
- _meta?:
796
- | zod0.objectInputType<
797
- {},
798
- zod0.ZodTypeAny,
799
- "passthrough"
800
- >
801
- | undefined;
802
- mimeType?: string | undefined;
803
- icons?:
804
- | {
805
- src: string;
806
- mimeType?: string | undefined;
807
- sizes?: string[] | undefined;
808
- }[]
809
- | undefined;
810
- title?: string | undefined;
811
- description?: string | undefined;
812
- }
813
- >,
814
- zod0.ZodObject<
815
- {
816
- type: zod0.ZodLiteral<"resource">;
817
- resource: zod0.ZodUnion<
818
- [
819
- zod0.ZodObject<
820
- zod0.objectUtil.extendShape<
821
- {
822
- uri: zod0.ZodString;
823
- mimeType: zod0.ZodOptional<zod0.ZodString>;
824
- _meta: zod0.ZodOptional<
825
- zod0.ZodRecord<
826
- zod0.ZodString,
827
- zod0.ZodUnknown
828
- >
829
- >;
830
- },
831
- {
832
- text: zod0.ZodString;
833
- }
834
- >,
835
- "strip",
836
- zod0.ZodTypeAny,
837
- {
838
- uri: string;
839
- text: string;
840
- _meta?: Record<string, unknown> | undefined;
841
- mimeType?: string | undefined;
842
- },
843
- {
844
- uri: string;
845
- text: string;
846
- _meta?: Record<string, unknown> | undefined;
847
- mimeType?: string | undefined;
848
- }
849
- >,
850
- zod0.ZodObject<
851
- zod0.objectUtil.extendShape<
852
- {
853
- uri: zod0.ZodString;
854
- mimeType: zod0.ZodOptional<zod0.ZodString>;
855
- _meta: zod0.ZodOptional<
856
- zod0.ZodRecord<
857
- zod0.ZodString,
858
- zod0.ZodUnknown
859
- >
860
- >;
861
- },
862
- {
863
- blob: zod0.ZodEffects<
864
- zod0.ZodString,
865
- string,
866
- string
867
- >;
868
- }
869
- >,
870
- "strip",
871
- zod0.ZodTypeAny,
872
- {
873
- uri: string;
874
- blob: string;
875
- _meta?: Record<string, unknown> | undefined;
876
- mimeType?: string | undefined;
877
- },
878
- {
879
- uri: string;
880
- blob: string;
881
- _meta?: Record<string, unknown> | undefined;
882
- mimeType?: string | undefined;
883
- }
884
- >
885
- ]
886
- >;
887
- _meta: zod0.ZodOptional<
888
- zod0.ZodRecord<zod0.ZodString, zod0.ZodUnknown>
889
- >;
890
- },
891
- "strip",
892
- zod0.ZodTypeAny,
893
- {
894
- type: "resource";
895
- resource:
896
- | {
897
- uri: string;
898
- text: string;
899
- _meta?: Record<string, unknown> | undefined;
900
- mimeType?: string | undefined;
901
- }
902
- | {
903
- uri: string;
904
- blob: string;
905
- _meta?: Record<string, unknown> | undefined;
906
- mimeType?: string | undefined;
907
- };
908
- _meta?: Record<string, unknown> | undefined;
909
- },
910
- {
911
- type: "resource";
912
- resource:
913
- | {
914
- uri: string;
915
- text: string;
916
- _meta?: Record<string, unknown> | undefined;
917
- mimeType?: string | undefined;
918
- }
919
- | {
920
- uri: string;
921
- blob: string;
922
- _meta?: Record<string, unknown> | undefined;
923
- mimeType?: string | undefined;
924
- };
925
- _meta?: Record<string, unknown> | undefined;
926
- }
927
- >
928
- ]
929
- >,
930
- "many"
931
- >
932
- >;
933
- structuredContent: zod0.ZodOptional<
934
- zod0.ZodRecord<zod0.ZodString, zod0.ZodUnknown>
935
- >;
936
- isError: zod0.ZodOptional<zod0.ZodBoolean>;
937
- },
938
- zod0.ZodTypeAny,
939
- "passthrough"
940
- >
941
- | zod0.objectOutputType<
942
- {
943
- _meta: zod0.ZodOptional<
944
- zod0.ZodRecord<zod0.ZodString, zod0.ZodUnknown>
945
- >;
946
- } & {
947
- toolResult: zod0.ZodUnknown;
948
- },
949
- zod0.ZodTypeAny,
950
- "passthrough"
951
- >
952
- >;
953
- /**
954
- * Namespaced version of readResource
955
- */
956
- readResource(
957
- params: ReadResourceRequest["params"] & {
958
- serverId: string;
959
- },
960
- options: RequestOptions
961
- ): Promise<
962
- zod0.objectOutputType<
963
- {
964
- _meta: zod0.ZodOptional<
965
- zod0.ZodRecord<zod0.ZodString, zod0.ZodUnknown>
966
- >;
967
- } & {
968
- contents: zod0.ZodArray<
969
- zod0.ZodUnion<
970
- [
971
- zod0.ZodObject<
972
- zod0.objectUtil.extendShape<
973
- {
974
- uri: zod0.ZodString;
975
- mimeType: zod0.ZodOptional<zod0.ZodString>;
976
- _meta: zod0.ZodOptional<
977
- zod0.ZodRecord<zod0.ZodString, zod0.ZodUnknown>
978
- >;
979
- },
980
- {
981
- text: zod0.ZodString;
982
- }
983
- >,
984
- "strip",
985
- zod0.ZodTypeAny,
986
- {
987
- uri: string;
988
- text: string;
989
- _meta?: Record<string, unknown> | undefined;
990
- mimeType?: string | undefined;
991
- },
992
- {
993
- uri: string;
994
- text: string;
995
- _meta?: Record<string, unknown> | undefined;
996
- mimeType?: string | undefined;
997
- }
998
- >,
999
- zod0.ZodObject<
1000
- zod0.objectUtil.extendShape<
1001
- {
1002
- uri: zod0.ZodString;
1003
- mimeType: zod0.ZodOptional<zod0.ZodString>;
1004
- _meta: zod0.ZodOptional<
1005
- zod0.ZodRecord<zod0.ZodString, zod0.ZodUnknown>
1006
- >;
1007
- },
1008
- {
1009
- blob: zod0.ZodEffects<zod0.ZodString, string, string>;
1010
- }
1011
- >,
1012
- "strip",
1013
- zod0.ZodTypeAny,
1014
- {
1015
- uri: string;
1016
- blob: string;
1017
- _meta?: Record<string, unknown> | undefined;
1018
- mimeType?: string | undefined;
1019
- },
1020
- {
1021
- uri: string;
1022
- blob: string;
1023
- _meta?: Record<string, unknown> | undefined;
1024
- mimeType?: string | undefined;
1025
- }
1026
- >
1027
- ]
1028
- >,
1029
- "many"
1030
- >;
1031
- },
1032
- zod0.ZodTypeAny,
1033
- "passthrough"
1034
- >
1035
- >;
1036
- /**
1037
- * Namespaced version of getPrompt
1038
- */
1039
- getPrompt(
1040
- params: GetPromptRequest["params"] & {
1041
- serverId: string;
1042
- },
1043
- options: RequestOptions
1044
- ): Promise<
1045
- zod0.objectOutputType<
1046
- {
1047
- _meta: zod0.ZodOptional<
1048
- zod0.ZodRecord<zod0.ZodString, zod0.ZodUnknown>
1049
- >;
1050
- } & {
1051
- description: zod0.ZodOptional<zod0.ZodString>;
1052
- messages: zod0.ZodArray<
1053
- zod0.ZodObject<
1054
- {
1055
- role: zod0.ZodEnum<["user", "assistant"]>;
1056
- content: zod0.ZodUnion<
1057
- [
1058
- zod0.ZodObject<
1059
- {
1060
- type: zod0.ZodLiteral<"text">;
1061
- text: zod0.ZodString;
1062
- _meta: zod0.ZodOptional<
1063
- zod0.ZodRecord<zod0.ZodString, zod0.ZodUnknown>
1064
- >;
1065
- },
1066
- "strip",
1067
- zod0.ZodTypeAny,
1068
- {
1069
- type: "text";
1070
- text: string;
1071
- _meta?: Record<string, unknown> | undefined;
1072
- },
1073
- {
1074
- type: "text";
1075
- text: string;
1076
- _meta?: Record<string, unknown> | undefined;
1077
- }
1078
- >,
1079
- zod0.ZodObject<
1080
- {
1081
- type: zod0.ZodLiteral<"image">;
1082
- data: zod0.ZodEffects<zod0.ZodString, string, string>;
1083
- mimeType: zod0.ZodString;
1084
- _meta: zod0.ZodOptional<
1085
- zod0.ZodRecord<zod0.ZodString, zod0.ZodUnknown>
1086
- >;
1087
- },
1088
- "strip",
1089
- zod0.ZodTypeAny,
1090
- {
1091
- type: "image";
1092
- data: string;
1093
- mimeType: string;
1094
- _meta?: Record<string, unknown> | undefined;
1095
- },
1096
- {
1097
- type: "image";
1098
- data: string;
1099
- mimeType: string;
1100
- _meta?: Record<string, unknown> | undefined;
1101
- }
1102
- >,
1103
- zod0.ZodObject<
1104
- {
1105
- type: zod0.ZodLiteral<"audio">;
1106
- data: zod0.ZodEffects<zod0.ZodString, string, string>;
1107
- mimeType: zod0.ZodString;
1108
- _meta: zod0.ZodOptional<
1109
- zod0.ZodRecord<zod0.ZodString, zod0.ZodUnknown>
1110
- >;
1111
- },
1112
- "strip",
1113
- zod0.ZodTypeAny,
1114
- {
1115
- type: "audio";
1116
- data: string;
1117
- mimeType: string;
1118
- _meta?: Record<string, unknown> | undefined;
1119
- },
1120
- {
1121
- type: "audio";
1122
- data: string;
1123
- mimeType: string;
1124
- _meta?: Record<string, unknown> | undefined;
1125
- }
1126
- >,
1127
- zod0.ZodObject<
1128
- zod0.objectUtil.extendShape<
1129
- zod0.objectUtil.extendShape<
1130
- zod0.objectUtil.extendShape<
1131
- {
1132
- name: zod0.ZodString;
1133
- title: zod0.ZodOptional<zod0.ZodString>;
1134
- },
1135
- {
1136
- uri: zod0.ZodString;
1137
- description: zod0.ZodOptional<zod0.ZodString>;
1138
- mimeType: zod0.ZodOptional<zod0.ZodString>;
1139
- _meta: zod0.ZodOptional<
1140
- zod0.ZodObject<
1141
- {},
1142
- "passthrough",
1143
- zod0.ZodTypeAny,
1144
- zod0.objectOutputType<
1145
- {},
1146
- zod0.ZodTypeAny,
1147
- "passthrough"
1148
- >,
1149
- zod0.objectInputType<
1150
- {},
1151
- zod0.ZodTypeAny,
1152
- "passthrough"
1153
- >
1154
- >
1155
- >;
1156
- }
1157
- >,
1158
- {
1159
- icons: zod0.ZodOptional<
1160
- zod0.ZodArray<
1161
- zod0.ZodObject<
1162
- {
1163
- src: zod0.ZodString;
1164
- mimeType: zod0.ZodOptional<zod0.ZodString>;
1165
- sizes: zod0.ZodOptional<
1166
- zod0.ZodArray<zod0.ZodString, "many">
1167
- >;
1168
- },
1169
- "strip",
1170
- zod0.ZodTypeAny,
1171
- {
1172
- src: string;
1173
- mimeType?: string | undefined;
1174
- sizes?: string[] | undefined;
1175
- },
1176
- {
1177
- src: string;
1178
- mimeType?: string | undefined;
1179
- sizes?: string[] | undefined;
1180
- }
1181
- >,
1182
- "many"
1183
- >
1184
- >;
1185
- }
1186
- >,
1187
- {
1188
- type: zod0.ZodLiteral<"resource_link">;
1189
- }
1190
- >,
1191
- "strip",
1192
- zod0.ZodTypeAny,
1193
- {
1194
- type: "resource_link";
1195
- name: string;
1196
- uri: string;
1197
- _meta?:
1198
- | zod0.objectOutputType<
1199
- {},
1200
- zod0.ZodTypeAny,
1201
- "passthrough"
1202
- >
1203
- | undefined;
1204
- mimeType?: string | undefined;
1205
- icons?:
1206
- | {
1207
- src: string;
1208
- mimeType?: string | undefined;
1209
- sizes?: string[] | undefined;
1210
- }[]
1211
- | undefined;
1212
- title?: string | undefined;
1213
- description?: string | undefined;
1214
- },
1215
- {
1216
- type: "resource_link";
1217
- name: string;
1218
- uri: string;
1219
- _meta? /**
1220
- * Connect to and register an MCP server
1221
- *
1222
- * @deprecated This method is maintained for backward compatibility.
1223
- * For new code, use registerServer() and connectToServer() separately.
1224
- *
1225
- * @param url Server URL
1226
- * @param options Connection options
1227
- * @returns Object with server ID, auth URL (if OAuth), and client ID (if OAuth)
1228
- */
1229
- :
1230
- | zod0.objectInputType<
1231
- {},
1232
- zod0.ZodTypeAny,
1233
- "passthrough"
1234
- >
1235
- | undefined;
1236
- mimeType?: string | undefined;
1237
- icons?:
1238
- | {
1239
- src: string;
1240
- mimeType?: string | undefined;
1241
- sizes?: string[] | undefined;
1242
- }[]
1243
- | undefined;
1244
- title?: string | undefined;
1245
- description?: string | undefined;
1246
- }
1247
- >,
1248
- zod0.ZodObject<
1249
- {
1250
- type: zod0.ZodLiteral<"resource">;
1251
- resource: zod0.ZodUnion<
1252
- [
1253
- zod0.ZodObject<
1254
- zod0.objectUtil.extendShape<
1255
- {
1256
- uri: zod0.ZodString;
1257
- mimeType: zod0.ZodOptional<zod0.ZodString>;
1258
- _meta: zod0.ZodOptional<
1259
- zod0.ZodRecord<
1260
- zod0.ZodString,
1261
- zod0.ZodUnknown
1262
- >
1263
- >;
1264
- },
1265
- {
1266
- text: zod0.ZodString;
1267
- }
1268
- >,
1269
- "strip",
1270
- zod0.ZodTypeAny,
1271
- {
1272
- uri: string;
1273
- text: string;
1274
- _meta?: Record<string, unknown> | undefined;
1275
- mimeType?: string | undefined;
1276
- },
1277
- {
1278
- uri: string;
1279
- text: string;
1280
- _meta?: Record<string, unknown> | undefined;
1281
- mimeType?: string | undefined;
1282
- }
1283
- >,
1284
- zod0.ZodObject<
1285
- zod0.objectUtil.extendShape<
1286
- {
1287
- uri: zod0.ZodString;
1288
- mimeType: zod0.ZodOptional<zod0.ZodString>;
1289
- _meta: zod0.ZodOptional<
1290
- zod0.ZodRecord<
1291
- zod0.ZodString,
1292
- zod0.ZodUnknown
1293
- >
1294
- >;
1295
- },
1296
- {
1297
- blob: zod0.ZodEffects<
1298
- zod0.ZodString,
1299
- string,
1300
- string
1301
- >;
1302
- }
1303
- >,
1304
- "strip",
1305
- zod0.ZodTypeAny,
1306
- {
1307
- uri: string;
1308
- blob: string;
1309
- _meta?: Record<string, unknown> | undefined;
1310
- mimeType?: string | undefined;
1311
- },
1312
- {
1313
- uri: string;
1314
- blob: string;
1315
- _meta?: Record<string, unknown> | undefined;
1316
- mimeType?: string | undefined;
1317
- }
1318
- >
1319
- ]
1320
- >;
1321
- _meta: zod0.ZodOptional<
1322
- zod0.ZodRecord<zod0.ZodString, zod0.ZodUnknown>
1323
- >;
1324
- },
1325
- "strip",
1326
- zod0.ZodTypeAny,
1327
- {
1328
- type: "resource";
1329
- resource:
1330
- | {
1331
- uri: string;
1332
- text: string;
1333
- _meta?: Record<string, unknown> | undefined;
1334
- mimeType?: string | undefined;
1335
- }
1336
- | {
1337
- uri: string;
1338
- blob: string;
1339
- _meta?: Record<string, unknown> | undefined;
1340
- mimeType?: string | undefined;
1341
- };
1342
- _meta?: Record<string, unknown> | undefined;
1343
- },
1344
- {
1345
- type: "resource";
1346
- resource:
1347
- | {
1348
- uri: string;
1349
- text: string;
1350
- _meta?: Record<string, unknown> | undefined;
1351
- mimeType?: string | undefined;
1352
- }
1353
- | {
1354
- uri: string;
1355
- blob: string;
1356
- _meta?: Record<string, unknown> | undefined;
1357
- mimeType?: string | undefined;
1358
- };
1359
- _meta?: Record<string, unknown> | undefined;
1360
- }
1361
- >
1362
- ]
1363
- >;
1364
- },
1365
- "strip",
1366
- zod0.ZodTypeAny,
1367
- {
1368
- role: "user" | "assistant";
1369
- content:
1370
- | {
1371
- type: "text";
1372
- text: string;
1373
- _meta?: Record<string, unknown> | undefined;
1374
- }
1375
- | {
1376
- type: "image";
1377
- data: string;
1378
- mimeType: string;
1379
- _meta?: Record<string, unknown> | undefined;
1380
- }
1381
- | {
1382
- type: "audio";
1383
- data: string;
1384
- mimeType: string;
1385
- _meta?: Record<string, unknown> | undefined;
1386
- }
1387
- | {
1388
- type: "resource";
1389
- resource:
1390
- | {
1391
- uri: string;
1392
- text: string;
1393
- _meta?: Record<string, unknown> | undefined;
1394
- mimeType?: string | undefined;
1395
- }
1396
- | {
1397
- uri: string;
1398
- blob: string;
1399
- _meta?: Record<string, unknown> | undefined;
1400
- mimeType?: string | undefined;
1401
- };
1402
- _meta?: Record<string, unknown> | undefined;
1403
- }
1404
- | {
1405
- type: "resource_link";
1406
- name: string;
1407
- uri: string;
1408
- _meta?:
1409
- | zod0.objectOutputType<
1410
- {},
1411
- zod0.ZodTypeAny,
1412
- "passthrough"
1413
- >
1414
- | undefined;
1415
- mimeType?: string | undefined;
1416
- icons?:
1417
- | {
1418
- src: string;
1419
- mimeType?: string | undefined;
1420
- sizes?: string[] | undefined;
1421
- }[]
1422
- | undefined;
1423
- title?: string | undefined;
1424
- description?: string | undefined;
1425
- };
1426
- },
1427
- {
1428
- role: "user" | "assistant";
1429
- content:
1430
- | {
1431
- type: "text";
1432
- text: string;
1433
- _meta?: Record<string, unknown> | undefined;
1434
- }
1435
- | {
1436
- type: "image";
1437
- data: string;
1438
- mimeType: string;
1439
- _meta?: Record<string, unknown> | undefined;
1440
- }
1441
- | {
1442
- type: "audio";
1443
- data: string;
1444
- mimeType: string;
1445
- _meta?: Record<string, unknown> | undefined;
1446
- }
1447
- | {
1448
- type: "resource";
1449
- resource:
1450
- | {
1451
- uri: string;
1452
- text: string;
1453
- _meta?: Record<string, unknown> | undefined;
1454
- mimeType?: string | undefined;
1455
- }
1456
- | {
1457
- uri: string;
1458
- blob: string;
1459
- _meta?: Record<string, unknown> | undefined;
1460
- mimeType?: string | undefined;
1461
- };
1462
- _meta?: Record<string, unknown> | undefined;
1463
- }
1464
- | {
1465
- type: "resource_link";
1466
- name: string;
1467
- uri: string;
1468
- _meta?:
1469
- | zod0.objectInputType<{}, zod0.ZodTypeAny, "passthrough">
1470
- | undefined;
1471
- mimeType?: string | undefined;
1472
- icons?:
1473
- | {
1474
- src: string;
1475
- mimeType?: string | undefined;
1476
- sizes?: string[] | undefined;
1477
- }[]
1478
- | undefined;
1479
- title?: string | undefined;
1480
- description?: string | undefined;
1481
- };
1482
- }
1483
- >,
1484
- "many"
1485
- >;
1486
- },
1487
- zod0.ZodTypeAny,
1488
- "passthrough"
1489
- >
1490
- >;
1491
- }
1492
- type NamespacedData = {
1493
- tools: (Tool & {
1494
- serverId: string;
1495
- })[];
1496
- prompts: (Prompt & {
1497
- serverId: string;
1498
- })[];
1499
- resources: (Resource & {
1500
- serverId: string;
1501
- })[];
1502
- resourceTemplates: (ResourceTemplate & {
1503
- serverId: string;
1504
- })[];
1505
- };
1506
- declare function getNamespacedData<T extends keyof NamespacedData>(
1507
- mcpClients: Record<string, MCPClientConnection>,
1508
- type: T
1509
- ): NamespacedData[T];
1510
- //#endregion
1511
- export {
1512
- MCPConnectionResult as a,
1513
- RegisterServerOptions as c,
1514
- BaseTransportType as d,
1515
- CORSOptions as f,
1516
- TransportType as h,
1517
- MCPClientOAuthResult as i,
1518
- getNamespacedData as l,
1519
- ServeOptions as m,
1520
- MCPClientManagerOptions as n,
1521
- MCPDiscoverResult as o,
1522
- MaybePromise as p,
1523
- MCPClientOAuthCallbackConfig as r,
1524
- MCPServerOptions as s,
1525
- MCPClientManager as t,
1526
- MCPConnectionState as u
1527
- };
1528
- //# sourceMappingURL=client-CsaP9Irq.d.ts.map