@mcp-use/client 2.2.4 → 2.2.5

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 (134) hide show
  1. package/dist/.tsbuildinfo +1 -0
  2. package/dist/auth/browser.d.ts +218 -0
  3. package/dist/auth/browser.d.ts.map +1 -0
  4. package/dist/auth/callback.d.ts +9 -0
  5. package/dist/auth/callback.d.ts.map +1 -0
  6. package/dist/auth/flow.d.ts +32 -0
  7. package/dist/auth/flow.d.ts.map +1 -0
  8. package/dist/auth/node.d.ts +212 -0
  9. package/dist/auth/node.d.ts.map +1 -0
  10. package/dist/auth/popup.d.ts +67 -0
  11. package/dist/auth/popup.d.ts.map +1 -0
  12. package/dist/auth/session-store.d.ts +125 -0
  13. package/dist/auth/session-store.d.ts.map +1 -0
  14. package/dist/auth/storage-file.d.ts +18 -0
  15. package/dist/auth/storage-file.d.ts.map +1 -0
  16. package/dist/auth/storage.d.ts +34 -0
  17. package/dist/auth/storage.d.ts.map +1 -0
  18. package/dist/auth/url.d.ts +17 -0
  19. package/dist/auth/url.d.ts.map +1 -0
  20. package/dist/code-mode/connector.d.ts +27 -0
  21. package/dist/code-mode/connector.d.ts.map +1 -0
  22. package/dist/code-mode/executor-e2b.d.ts +46 -0
  23. package/dist/code-mode/executor-e2b.d.ts.map +1 -0
  24. package/dist/code-mode/executor-vm.d.ts +39 -0
  25. package/dist/code-mode/executor-vm.d.ts.map +1 -0
  26. package/dist/code-mode/executor.d.ts +81 -0
  27. package/dist/code-mode/executor.d.ts.map +1 -0
  28. package/dist/core/base.d.ts +423 -0
  29. package/dist/core/base.d.ts.map +1 -0
  30. package/dist/core/browser.d.ts +32 -0
  31. package/dist/core/browser.d.ts.map +1 -0
  32. package/dist/core/config.d.ts +225 -0
  33. package/dist/core/config.d.ts.map +1 -0
  34. package/dist/core/node.d.ts +437 -0
  35. package/dist/core/node.d.ts.map +1 -0
  36. package/dist/core/session.d.ts +792 -0
  37. package/dist/core/session.d.ts.map +1 -0
  38. package/dist/core/skills.d.ts +47 -0
  39. package/dist/core/skills.d.ts.map +1 -0
  40. package/dist/index-browser.d.ts +26 -0
  41. package/dist/index-browser.d.ts.map +1 -0
  42. package/dist/index-browser.js +4767 -0
  43. package/dist/index-browser.js.map +1 -0
  44. package/dist/index.d.ts +23 -0
  45. package/dist/index.d.ts.map +1 -0
  46. package/dist/index.js +6113 -0
  47. package/dist/index.js.map +1 -0
  48. package/dist/react/McpClientProvider.d.ts +254 -0
  49. package/dist/react/McpClientProvider.d.ts.map +1 -0
  50. package/dist/react/index.d.ts +39 -0
  51. package/dist/react/index.d.ts.map +1 -0
  52. package/dist/react/index.js +9444 -0
  53. package/dist/react/index.js.map +1 -0
  54. package/dist/react/rpc-logger.d.ts +47 -0
  55. package/dist/react/rpc-logger.d.ts.map +1 -0
  56. package/dist/react/storage.d.ts +98 -0
  57. package/dist/react/storage.d.ts.map +1 -0
  58. package/dist/react/token-expiry.d.ts +9 -0
  59. package/dist/react/token-expiry.d.ts.map +1 -0
  60. package/dist/react/types.d.ts +727 -0
  61. package/dist/react/types.d.ts.map +1 -0
  62. package/dist/react/useMcp-helpers.d.ts +99 -0
  63. package/dist/react/useMcp-helpers.d.ts.map +1 -0
  64. package/dist/react/useMcp-operations.d.ts +180 -0
  65. package/dist/react/useMcp-operations.d.ts.map +1 -0
  66. package/dist/react/useMcp.d.ts +48 -0
  67. package/dist/react/useMcp.d.ts.map +1 -0
  68. package/dist/react/useMcpServerQueues.d.ts +403 -0
  69. package/dist/react/useMcpServerQueues.d.ts.map +1 -0
  70. package/dist/react/view/ViewRenderer.d.ts +20 -0
  71. package/dist/react/view/ViewRenderer.d.ts.map +1 -0
  72. package/dist/react/view/ext-apps-bridge.d.ts +3 -0
  73. package/dist/react/view/ext-apps-bridge.d.ts.map +1 -0
  74. package/dist/react/view/initialized-sync.d.ts +13 -0
  75. package/dist/react/view/initialized-sync.d.ts.map +1 -0
  76. package/dist/react/view/inject-openai-file-apis.d.ts +9 -0
  77. package/dist/react/view/inject-openai-file-apis.d.ts.map +1 -0
  78. package/dist/react/view/parse-custom-props.d.ts +10 -0
  79. package/dist/react/view/parse-custom-props.d.ts.map +1 -0
  80. package/dist/react/view/resolve-view-resource.d.ts +22 -0
  81. package/dist/react/view/resolve-view-resource.d.ts.map +1 -0
  82. package/dist/react/view/sandbox-blob-url.d.ts +27 -0
  83. package/dist/react/view/sandbox-blob-url.d.ts.map +1 -0
  84. package/dist/react/view/types.d.ts +220 -0
  85. package/dist/react/view/types.d.ts.map +1 -0
  86. package/dist/react/view/use-display-mode.d.ts +19 -0
  87. package/dist/react/view/use-display-mode.d.ts.map +1 -0
  88. package/dist/react/view/view-detection.d.ts +22 -0
  89. package/dist/react/view/view-detection.d.ts.map +1 -0
  90. package/dist/react/view/view-host-policy.d.ts +61 -0
  91. package/dist/react/view/view-host-policy.d.ts.map +1 -0
  92. package/dist/sandbox.d.ts +2 -0
  93. package/dist/sandbox.d.ts.map +1 -0
  94. package/dist/sandbox.js +288 -0
  95. package/dist/sandbox.js.map +1 -0
  96. package/dist/telemetry/client-telemetry.d.ts +13 -0
  97. package/dist/telemetry/client-telemetry.d.ts.map +1 -0
  98. package/dist/telemetry/configure-browser.d.ts +2 -0
  99. package/dist/telemetry/configure-browser.d.ts.map +1 -0
  100. package/dist/telemetry/configure-node.d.ts +2 -0
  101. package/dist/telemetry/configure-node.d.ts.map +1 -0
  102. package/dist/telemetry/connector-telemetry.d.ts +8 -0
  103. package/dist/telemetry/connector-telemetry.d.ts.map +1 -0
  104. package/dist/telemetry/events.d.ts +91 -0
  105. package/dist/telemetry/events.d.ts.map +1 -0
  106. package/dist/telemetry/index.d.ts +3 -0
  107. package/dist/telemetry/index.d.ts.map +1 -0
  108. package/dist/telemetry/tel-fetch.d.ts +19 -0
  109. package/dist/telemetry/tel-fetch.d.ts.map +1 -0
  110. package/dist/telemetry/telemetry-browser.d.ts +6 -0
  111. package/dist/telemetry/telemetry-browser.d.ts.map +1 -0
  112. package/dist/telemetry/telemetry-node.d.ts +8 -0
  113. package/dist/telemetry/telemetry-node.d.ts.map +1 -0
  114. package/dist/telemetry/telemetry.d.ts +75 -0
  115. package/dist/telemetry/telemetry.d.ts.map +1 -0
  116. package/dist/transport/base.d.ts +656 -0
  117. package/dist/transport/base.d.ts.map +1 -0
  118. package/dist/transport/connection-manager.d.ts +59 -0
  119. package/dist/transport/connection-manager.d.ts.map +1 -0
  120. package/dist/transport/http.d.ts +137 -0
  121. package/dist/transport/http.d.ts.map +1 -0
  122. package/dist/transport/stdio.d.ts +97 -0
  123. package/dist/transport/stdio.d.ts.map +1 -0
  124. package/dist/utils/elicitation.d.ts +54 -0
  125. package/dist/utils/elicitation.d.ts.map +1 -0
  126. package/dist/utils/favicon.d.ts +6 -0
  127. package/dist/utils/favicon.d.ts.map +1 -0
  128. package/dist/utils/json-schema-validator.d.ts +13 -0
  129. package/dist/utils/json-schema-validator.d.ts.map +1 -0
  130. package/dist/utils/logging.d.ts +33 -0
  131. package/dist/utils/logging.d.ts.map +1 -0
  132. package/dist/utils/version.d.ts +9 -0
  133. package/dist/utils/version.d.ts.map +1 -0
  134. package/package.json +1 -1
@@ -0,0 +1,656 @@
1
+ import type { CallToolResult, Client, ClientOptions, CompleteRequestParams, CompleteResult, ElicitRequestFormParams, ElicitRequestURLParams, ElicitResult, AuthProvider, Notification, OAuthClientProvider, ProtocolEra, RequestOptions, Root, Tool } from "@modelcontextprotocol/client";
2
+ import type { SamplingCreateMessageParams, SamplingCreateMessageResult } from "../core/config.js";
3
+ import type { ConnectionManager } from "./connection-manager.js";
4
+ import type { ConnectorInitEventData } from "../telemetry/events.js";
5
+ import type { MCPAuthorizationInfo, MCPServerInfo } from "../core/session.js";
6
+ /**
7
+ * Handles a notification received from an MCP server.
8
+ *
9
+ * @param notification - Notification envelope supplied by the server.
10
+ */
11
+ export type NotificationHandler = (notification: Notification) => void | Promise<void>;
12
+ /** Shared initialization options for all connector transports. */
13
+ export interface ConnectorInitOptions {
14
+ /**
15
+ * Options forwarded to the underlying MCP `Client` instance.
16
+ *
17
+ * By default, all connectors (HTTP and stdio) use `DialectJsonSchemaValidator`
18
+ * to support common `$schema` dialects (draft-04, draft-07, 2019-09, 2020-12)
19
+ * for cross-version compatibility with v1-era servers. Override with
20
+ * `clientOptions.jsonSchemaValidator` if stricter validation is needed.
21
+ */
22
+ clientOptions?: ClientOptions;
23
+ /**
24
+ * Arbitrary request options (timeouts, cancellation, etc.) used by helper
25
+ * methods when they issue SDK requests. Can be overridden per‑call.
26
+ */
27
+ defaultRequestOptions?: RequestOptions;
28
+ /**
29
+ * OAuth client provider for automatic authentication
30
+ */
31
+ authProvider?: AuthProvider | OAuthClientProvider;
32
+ /**
33
+ * Optional callback to wrap the transport before passing it to the Client.
34
+ * Useful for logging, monitoring, or other transport-level interceptors.
35
+ */
36
+ wrapTransport?: (transport: any, serverId: string) => any;
37
+ /**
38
+ * Initial roots to provide to the server.
39
+ * Roots allow the server to know which directories/files the client has access to.
40
+ */
41
+ roots?: Root[];
42
+ /**
43
+ * Optional callback function to handle sampling requests from servers.
44
+ * When provided, the client will declare sampling capability and handle
45
+ * `sampling/createMessage` requests by calling this callback.
46
+ *
47
+ * @deprecated Sampling is deprecated by the 2026 protocol. Retained for v1
48
+ * push requests and v2 multi-round-trip compatibility.
49
+ */
50
+ onSampling?: (params: SamplingCreateMessageParams) => Promise<SamplingCreateMessageResult>;
51
+ /**
52
+ * Optional callback function to handle elicitation requests from servers.
53
+ * When provided, the client will declare elicitation capability and handle
54
+ * `elicitation/create` requests by calling this callback.
55
+ *
56
+ * Elicitation allows servers to request additional information from users:
57
+ * - Form mode: Collect structured data with JSON schema validation
58
+ * - URL mode: Direct users to external URLs for sensitive interactions
59
+ */
60
+ onElicitation?: (params: ElicitRequestFormParams | ElicitRequestURLParams) => Promise<ElicitResult>;
61
+ /**
62
+ * Optional callback for server notifications.
63
+ * When provided, registered as initial notification handler.
64
+ */
65
+ onNotification?: NotificationHandler;
66
+ /**
67
+ * Reconnection options for streamable HTTP transport.
68
+ * Controls retry behavior of the underlying `StreamableHTTPClientTransport`.
69
+ */
70
+ reconnectionOptions?: {
71
+ /** Maximum delay between reconnection attempts in milliseconds. */
72
+ maxReconnectionDelay?: number;
73
+ /** Delay before the first reconnection attempt in milliseconds. */
74
+ initialReconnectionDelay?: number;
75
+ /** Multiplier applied to the delay after each failed attempt. */
76
+ reconnectionDelayGrowFactor?: number;
77
+ /** Maximum number of reconnection attempts. */
78
+ maxRetries?: number;
79
+ };
80
+ }
81
+ /**
82
+ * Implements protocol operations shared by MCP transport connectors.
83
+ *
84
+ * Subclasses provide transport-specific connection setup and a public
85
+ * identifier. Call {@link BaseConnector.connect}, then
86
+ * {@link BaseConnector.initialize}, before invoking protocol operations.
87
+ */
88
+ export declare abstract class BaseConnector {
89
+ protected client: Client | null;
90
+ protected connectionManager: ConnectionManager<any> | null;
91
+ protected toolsCache: Tool[] | null;
92
+ protected capabilitiesCache: Record<string, unknown> | null;
93
+ protected serverInfoCache: MCPServerInfo | null;
94
+ protected authorizationCache: MCPAuthorizationInfo | undefined;
95
+ protected connected: boolean;
96
+ protected readonly opts: ConnectorInitOptions;
97
+ protected notificationHandlers: NotificationHandler[];
98
+ protected rootsCache: Root[];
99
+ private activeProgressHandlers;
100
+ /**
101
+ * Creates a connector with shared SDK and callback options.
102
+ *
103
+ * @param opts - Connector initialization options.
104
+ */
105
+ constructor(opts?: ConnectorInitOptions);
106
+ /**
107
+ * Track connector initialization event
108
+ * Should be called by subclasses after successful connection
109
+ */
110
+ protected trackConnectorInit(data: Omit<ConnectorInitEventData, "connectorType">): void;
111
+ /**
112
+ * Register a handler for server notifications
113
+ *
114
+ * @param handler - Function to call when a notification is received
115
+ *
116
+ * @example
117
+ * ```typescript
118
+ * connector.onNotification((notification) => {
119
+ * console.log(`Received: ${notification.method}`, notification.params);
120
+ * });
121
+ * ```
122
+ */
123
+ onNotification(handler: NotificationHandler): void;
124
+ /** Forward a normalized notification to every registered consumer. */
125
+ protected forwardNotification(notification: Notification): Promise<void>;
126
+ /** Handle SDK list-change callbacks identically on v1 and v2 connections. */
127
+ protected handleListChanged(method: "notifications/tools/list_changed" | "notifications/resources/list_changed" | "notifications/prompts/list_changed", error: Error | null, tools?: Tool[] | null): Promise<void>;
128
+ /**
129
+ * Internal: wire notification handlers to the SDK client
130
+ * Includes automatic handling for list_changed notifications per MCP spec
131
+ */
132
+ protected setupNotificationHandler(): void;
133
+ /**
134
+ * Forward v2 MRTR progress whose retry request IDs are not associated with
135
+ * the original call callback by the current SDK beta.
136
+ *
137
+ * ponytail: fallback is enabled only when exactly one progress-aware call is
138
+ * active; remove it when the upstream SDK propagates handlers to MRTR rounds.
139
+ */
140
+ protected setupRoundProgressForwarding(): void;
141
+ /** Forward progress parsed from a transport stream to the active call. */
142
+ protected forwardRoundProgress(params: unknown): void;
143
+ /**
144
+ * Auto-refresh tools cache when server sends tools/list_changed notification
145
+ */
146
+ protected refreshToolsCache(): Promise<void>;
147
+ /**
148
+ * Called when server sends resources/list_changed notification
149
+ * Resources aren't cached by default, but we log for user awareness
150
+ */
151
+ protected onResourcesListChanged(): Promise<void>;
152
+ /**
153
+ * Called when server sends prompts/list_changed notification
154
+ * Prompts aren't cached by default, but we log for user awareness
155
+ */
156
+ protected onPromptsListChanged(): Promise<void>;
157
+ /**
158
+ * Set roots and notify the server.
159
+ * Roots represent directories or files that the client has access to.
160
+ *
161
+ * @param roots - Array of Root objects with `uri` (must start with "file://") and optional `name`
162
+ *
163
+ * @deprecated Roots are retained only for v1 compatibility.
164
+ *
165
+ * @example
166
+ * ```typescript
167
+ * await connector.setRoots([
168
+ * { uri: "file:///home/user/project", name: "My Project" },
169
+ * { uri: "file:///home/user/data" }
170
+ * ]);
171
+ * ```
172
+ */
173
+ setRoots(roots: Root[]): Promise<void>;
174
+ /**
175
+ * Returns the roots currently advertised to the server.
176
+ *
177
+ * @returns A copy of the configured roots.
178
+ */
179
+ getRoots(): Root[];
180
+ /**
181
+ * Internal: set up roots/list request handler.
182
+ * Must be registered after Client construction and before connect() so the
183
+ * handler is available during initialize / reverse RPC for the full session.
184
+ */
185
+ protected setupRootsHandler(): void;
186
+ /**
187
+ * Internal: set up sampling/createMessage request handler.
188
+ * Must be registered after Client construction and before connect().
189
+ */
190
+ protected setupSamplingHandler(): void;
191
+ /**
192
+ * Internal: set up elicitation/create request handler.
193
+ * Must be registered after Client construction and before connect().
194
+ */
195
+ protected setupElicitationHandler(): void;
196
+ /**
197
+ * Establishes the transport connection and creates the SDK client.
198
+ *
199
+ * @returns A promise that resolves when the connector is connected.
200
+ */
201
+ abstract connect(): Promise<void>;
202
+ /**
203
+ * Returns transport-specific fields suitable for logs and telemetry.
204
+ *
205
+ * @returns A record identifying the connector without exposing credentials.
206
+ */
207
+ abstract get publicIdentifier(): Record<string, string>;
208
+ /**
209
+ * Run one logical MCP operation. HTTP connectors override this host seam to
210
+ * finish an SDK-started interactive OAuth flow and retry exactly once.
211
+ */
212
+ protected executeRequest<T>(operation: () => Promise<T>): Promise<T>;
213
+ /** OAuth state discovered for the active connection, when available. */
214
+ get authorization(): MCPAuthorizationInfo | undefined;
215
+ /**
216
+ * Discover optional authorization metadata without delaying connection
217
+ * readiness. HTTP connectors override this with RFC 9728 discovery.
218
+ */
219
+ discoverAuthorization(): Promise<MCPAuthorizationInfo | undefined>;
220
+ /** Start optional OAuth for a connected mixed-auth server. */
221
+ authenticate(): Promise<void>;
222
+ /**
223
+ * Disconnects the SDK client and releases transport resources.
224
+ *
225
+ * @returns A promise that resolves after cleanup completes.
226
+ */
227
+ disconnect(): Promise<void>;
228
+ /** Whether an SDK client currently exists for this connector. */
229
+ get isClientConnected(): boolean;
230
+ /**
231
+ * Initialise the MCP session **after** `connect()` has succeeded.
232
+ *
233
+ * In the SDK, `Client.connect(transport)` automatically performs the
234
+ * protocol‑level `initialize` handshake, so we only need to cache the list of
235
+ * tools and expose some server info.
236
+ *
237
+ * @param defaultRequestOptions - Options used while fetching the initial tool list.
238
+ * @returns The capabilities advertised by the server.
239
+ * @throws When {@link BaseConnector.connect} has not completed.
240
+ */
241
+ initialize(defaultRequestOptions?: RequestOptions): Promise<ReturnType<Client["getServerCapabilities"]>>;
242
+ /**
243
+ * Returns the tool list cached during initialization.
244
+ *
245
+ * @throws When {@link BaseConnector.initialize} has not completed.
246
+ */
247
+ get tools(): Tool[];
248
+ /** Capabilities cached during initialization, or an empty object. */
249
+ get serverCapabilities(): Record<string, unknown>;
250
+ /** Server identity cached during initialization, or `null`. */
251
+ get serverInfo(): MCPServerInfo | null;
252
+ /** Instructions supplied by the connected server, if any. */
253
+ get instructions(): string | undefined;
254
+ /**
255
+ * The negotiated protocol era for the active connection.
256
+ * - `"legacy"` — 2025-era server, sessionful `initialize` handshake.
257
+ * - `"modern"` — 2026-era server, stateless per-request.
258
+ * `undefined` before the connection has negotiated.
259
+ */
260
+ get protocolEra(): ProtocolEra | undefined;
261
+ /** The protocol version string negotiated for the active connection. */
262
+ get negotiatedProtocolVersion(): string | undefined;
263
+ /**
264
+ * Calls a tool on the connected server.
265
+ *
266
+ * @param name - Tool name.
267
+ * @param args - Tool arguments.
268
+ * @param options - Per-request timeout, cancellation, and progress options.
269
+ * @returns The tool result returned by the server.
270
+ * @throws When the connector is not connected or the tool call fails.
271
+ */
272
+ callTool(name: string, args: Record<string, any>, options?: RequestOptions): Promise<CallToolResult>;
273
+ /**
274
+ * List all available tools from the MCP server.
275
+ * This method fetches fresh tools from the server, unlike the `tools` getter which returns cached tools.
276
+ *
277
+ * @param options - Optional request options
278
+ * @returns Array of available tools
279
+ */
280
+ listTools(options?: RequestOptions): Promise<Tool[]>;
281
+ /**
282
+ * List resources from the server with optional pagination
283
+ *
284
+ * @param cursor - Optional cursor for pagination
285
+ * @param options - Request options
286
+ * @returns Resource list with optional nextCursor for pagination
287
+ */
288
+ listResources(cursor?: string, options?: RequestOptions): Promise<{
289
+ [x: string]: unknown;
290
+ resources: {
291
+ uri: string;
292
+ name: string;
293
+ description?: string | undefined;
294
+ mimeType?: string | undefined;
295
+ size?: number | undefined;
296
+ annotations?: {
297
+ audience?: ("user" | "assistant")[] | undefined;
298
+ priority?: number | undefined;
299
+ lastModified?: string | undefined;
300
+ } | undefined;
301
+ _meta?: {
302
+ [x: string]: unknown;
303
+ } | undefined;
304
+ icons?: {
305
+ src: string;
306
+ mimeType?: string | undefined;
307
+ sizes?: string[] | undefined;
308
+ theme?: "light" | "dark" | undefined;
309
+ }[] | undefined;
310
+ title?: string | undefined;
311
+ }[];
312
+ _meta?: {
313
+ [x: string]: unknown;
314
+ "io.modelcontextprotocol/serverInfo"?: {
315
+ version: string;
316
+ name: string;
317
+ websiteUrl?: string | undefined;
318
+ description?: string | undefined;
319
+ icons?: {
320
+ src: string;
321
+ mimeType?: string | undefined;
322
+ sizes?: string[] | undefined;
323
+ theme?: "light" | "dark" | undefined;
324
+ }[] | undefined;
325
+ title?: string | undefined;
326
+ } | undefined;
327
+ } | undefined;
328
+ nextCursor?: string | undefined;
329
+ }>;
330
+ /**
331
+ * List all resources from the server, automatically handling pagination
332
+ *
333
+ * @param options - Request options
334
+ * @returns Complete list of all resources
335
+ */
336
+ listAllResources(options?: RequestOptions): Promise<{
337
+ /** Resources returned across all result pages. */
338
+ resources: any[];
339
+ }>;
340
+ /**
341
+ * List resource templates from the server
342
+ *
343
+ * @param options - Request options
344
+ * @returns List of available resource templates
345
+ */
346
+ listResourceTemplates(options?: RequestOptions): Promise<{
347
+ [x: string]: unknown;
348
+ resourceTemplates: {
349
+ uriTemplate: string;
350
+ name: string;
351
+ description?: string | undefined;
352
+ mimeType?: string | undefined;
353
+ annotations?: {
354
+ audience?: ("user" | "assistant")[] | undefined;
355
+ priority?: number | undefined;
356
+ lastModified?: string | undefined;
357
+ } | undefined;
358
+ _meta?: {
359
+ [x: string]: unknown;
360
+ } | undefined;
361
+ icons?: {
362
+ src: string;
363
+ mimeType?: string | undefined;
364
+ sizes?: string[] | undefined;
365
+ theme?: "light" | "dark" | undefined;
366
+ }[] | undefined;
367
+ title?: string | undefined;
368
+ }[];
369
+ _meta?: {
370
+ [x: string]: unknown;
371
+ "io.modelcontextprotocol/serverInfo"?: {
372
+ version: string;
373
+ name: string;
374
+ websiteUrl?: string | undefined;
375
+ description?: string | undefined;
376
+ icons?: {
377
+ src: string;
378
+ mimeType?: string | undefined;
379
+ sizes?: string[] | undefined;
380
+ theme?: "light" | "dark" | undefined;
381
+ }[] | undefined;
382
+ title?: string | undefined;
383
+ } | undefined;
384
+ } | undefined;
385
+ nextCursor?: string | undefined;
386
+ }>;
387
+ /**
388
+ * Request completion suggestions for a prompt or resource template argument
389
+ *
390
+ * @param params - Completion request parameters
391
+ * @param options - Request options
392
+ * @returns Completion suggestions from the server
393
+ */
394
+ complete(params: CompleteRequestParams, options?: RequestOptions): Promise<CompleteResult>;
395
+ /**
396
+ * Reads a resource by URI.
397
+ *
398
+ * @param uri - Resource URI to read.
399
+ * @param options - Per-request options.
400
+ * @returns The resource contents returned by the server.
401
+ */
402
+ readResource(uri: string, options?: RequestOptions): Promise<{
403
+ [x: string]: unknown;
404
+ contents: ({
405
+ uri: string;
406
+ text: string;
407
+ mimeType?: string | undefined;
408
+ _meta?: {
409
+ [x: string]: unknown;
410
+ } | undefined;
411
+ } | {
412
+ uri: string;
413
+ blob: string;
414
+ mimeType?: string | undefined;
415
+ _meta?: {
416
+ [x: string]: unknown;
417
+ } | undefined;
418
+ })[];
419
+ _meta?: {
420
+ [x: string]: unknown;
421
+ "io.modelcontextprotocol/serverInfo"?: {
422
+ version: string;
423
+ name: string;
424
+ websiteUrl?: string | undefined;
425
+ description?: string | undefined;
426
+ icons?: {
427
+ src: string;
428
+ mimeType?: string | undefined;
429
+ sizes?: string[] | undefined;
430
+ theme?: "light" | "dark" | undefined;
431
+ }[] | undefined;
432
+ title?: string | undefined;
433
+ } | undefined;
434
+ } | undefined;
435
+ }>;
436
+ /**
437
+ * Subscribe to resource updates
438
+ *
439
+ * @param uri - URI of the resource to subscribe to
440
+ * @param options - Request options
441
+ */
442
+ subscribeToResource(uri: string, options?: RequestOptions): Promise<{
443
+ _meta?: {
444
+ [x: string]: unknown;
445
+ "io.modelcontextprotocol/serverInfo"?: {
446
+ version: string;
447
+ name: string;
448
+ websiteUrl?: string | undefined;
449
+ description?: string | undefined;
450
+ icons?: {
451
+ src: string;
452
+ mimeType?: string | undefined;
453
+ sizes?: string[] | undefined;
454
+ theme?: "light" | "dark" | undefined;
455
+ }[] | undefined;
456
+ title?: string | undefined;
457
+ } | undefined;
458
+ } | undefined;
459
+ }>;
460
+ /**
461
+ * Unsubscribe from resource updates
462
+ *
463
+ * @param uri - URI of the resource to unsubscribe from
464
+ * @param options - Request options
465
+ */
466
+ unsubscribeFromResource(uri: string, options?: RequestOptions): Promise<{
467
+ _meta?: {
468
+ [x: string]: unknown;
469
+ "io.modelcontextprotocol/serverInfo"?: {
470
+ version: string;
471
+ name: string;
472
+ websiteUrl?: string | undefined;
473
+ description?: string | undefined;
474
+ icons?: {
475
+ src: string;
476
+ mimeType?: string | undefined;
477
+ sizes?: string[] | undefined;
478
+ theme?: "light" | "dark" | undefined;
479
+ }[] | undefined;
480
+ title?: string | undefined;
481
+ } | undefined;
482
+ } | undefined;
483
+ }>;
484
+ /**
485
+ * Lists prompts exposed by the server.
486
+ *
487
+ * @returns The prompt list, or an empty list when prompts are unsupported.
488
+ */
489
+ listPrompts(): Promise<{
490
+ [x: string]: unknown;
491
+ prompts: {
492
+ name: string;
493
+ description?: string | undefined;
494
+ arguments?: {
495
+ name: string;
496
+ description?: string | undefined;
497
+ required?: boolean | undefined;
498
+ }[] | undefined;
499
+ _meta?: {
500
+ [x: string]: unknown;
501
+ } | undefined;
502
+ icons?: {
503
+ src: string;
504
+ mimeType?: string | undefined;
505
+ sizes?: string[] | undefined;
506
+ theme?: "light" | "dark" | undefined;
507
+ }[] | undefined;
508
+ title?: string | undefined;
509
+ }[];
510
+ _meta?: {
511
+ [x: string]: unknown;
512
+ "io.modelcontextprotocol/serverInfo"?: {
513
+ version: string;
514
+ name: string;
515
+ websiteUrl?: string | undefined;
516
+ description?: string | undefined;
517
+ icons?: {
518
+ src: string;
519
+ mimeType?: string | undefined;
520
+ sizes?: string[] | undefined;
521
+ theme?: "light" | "dark" | undefined;
522
+ }[] | undefined;
523
+ title?: string | undefined;
524
+ } | undefined;
525
+ } | undefined;
526
+ nextCursor?: string | undefined;
527
+ }>;
528
+ /**
529
+ * Gets a prompt with the supplied arguments.
530
+ *
531
+ * @param name - Prompt name.
532
+ * @param args - Prompt arguments.
533
+ * @param options - Per-request timeout, cancellation, and progress options.
534
+ * @returns The rendered prompt returned by the server.
535
+ */
536
+ getPrompt(name: string, args: Record<string, any>, options?: RequestOptions): Promise<{
537
+ [x: string]: unknown;
538
+ messages: {
539
+ role: "user" | "assistant";
540
+ content: {
541
+ type: "text";
542
+ text: string;
543
+ annotations?: {
544
+ audience?: ("user" | "assistant")[] | undefined;
545
+ priority?: number | undefined;
546
+ lastModified?: string | undefined;
547
+ } | undefined;
548
+ _meta?: {
549
+ [x: string]: unknown;
550
+ } | undefined;
551
+ } | {
552
+ type: "image";
553
+ data: string;
554
+ mimeType: string;
555
+ annotations?: {
556
+ audience?: ("user" | "assistant")[] | undefined;
557
+ priority?: number | undefined;
558
+ lastModified?: string | undefined;
559
+ } | undefined;
560
+ _meta?: {
561
+ [x: string]: unknown;
562
+ } | undefined;
563
+ } | {
564
+ type: "audio";
565
+ data: string;
566
+ mimeType: string;
567
+ annotations?: {
568
+ audience?: ("user" | "assistant")[] | undefined;
569
+ priority?: number | undefined;
570
+ lastModified?: string | undefined;
571
+ } | undefined;
572
+ _meta?: {
573
+ [x: string]: unknown;
574
+ } | undefined;
575
+ } | {
576
+ uri: string;
577
+ name: string;
578
+ type: "resource_link";
579
+ description?: string | undefined;
580
+ mimeType?: string | undefined;
581
+ size?: number | undefined;
582
+ annotations?: {
583
+ audience?: ("user" | "assistant")[] | undefined;
584
+ priority?: number | undefined;
585
+ lastModified?: string | undefined;
586
+ } | undefined;
587
+ _meta?: {
588
+ [x: string]: unknown;
589
+ } | undefined;
590
+ icons?: {
591
+ src: string;
592
+ mimeType?: string | undefined;
593
+ sizes?: string[] | undefined;
594
+ theme?: "light" | "dark" | undefined;
595
+ }[] | undefined;
596
+ title?: string | undefined;
597
+ } | {
598
+ type: "resource";
599
+ resource: {
600
+ uri: string;
601
+ text: string;
602
+ mimeType?: string | undefined;
603
+ _meta?: {
604
+ [x: string]: unknown;
605
+ } | undefined;
606
+ } | {
607
+ uri: string;
608
+ blob: string;
609
+ mimeType?: string | undefined;
610
+ _meta?: {
611
+ [x: string]: unknown;
612
+ } | undefined;
613
+ };
614
+ annotations?: {
615
+ audience?: ("user" | "assistant")[] | undefined;
616
+ priority?: number | undefined;
617
+ lastModified?: string | undefined;
618
+ } | undefined;
619
+ _meta?: {
620
+ [x: string]: unknown;
621
+ } | undefined;
622
+ };
623
+ }[];
624
+ _meta?: {
625
+ [x: string]: unknown;
626
+ "io.modelcontextprotocol/serverInfo"?: {
627
+ version: string;
628
+ name: string;
629
+ websiteUrl?: string | undefined;
630
+ description?: string | undefined;
631
+ icons?: {
632
+ src: string;
633
+ mimeType?: string | undefined;
634
+ sizes?: string[] | undefined;
635
+ theme?: "light" | "dark" | undefined;
636
+ }[] | undefined;
637
+ title?: string | undefined;
638
+ } | undefined;
639
+ } | undefined;
640
+ description?: string | undefined;
641
+ }>;
642
+ /**
643
+ * Sends a raw, potentially non-standard request through the SDK client.
644
+ *
645
+ * @param method - JSON-RPC method name.
646
+ * @param params - Request parameters. Defaults to an empty object.
647
+ * @param options - Per-request options.
648
+ * @returns The unvalidated result returned by the server.
649
+ */
650
+ request(method: string, params?: Record<string, any> | null, options?: RequestOptions): Promise<unknown>;
651
+ /**
652
+ * Helper to tear down the client & connection manager safely.
653
+ */
654
+ protected cleanupResources(): Promise<void>;
655
+ }
656
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","s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