@mcp-use/client 0.0.0-bootstrap.0 → 2.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/README.md +127 -4
  2. package/dist/.tsbuildinfo +1 -0
  3. package/dist/auth/browser.d.ts +149 -0
  4. package/dist/auth/browser.d.ts.map +1 -0
  5. package/dist/auth/callback.d.ts +9 -0
  6. package/dist/auth/callback.d.ts.map +1 -0
  7. package/dist/auth/flow.d.ts +23 -0
  8. package/dist/auth/flow.d.ts.map +1 -0
  9. package/dist/auth/node.d.ts +100 -0
  10. package/dist/auth/node.d.ts.map +1 -0
  11. package/dist/auth/popup.d.ts +67 -0
  12. package/dist/auth/popup.d.ts.map +1 -0
  13. package/dist/auth/session-store.d.ts +114 -0
  14. package/dist/auth/session-store.d.ts.map +1 -0
  15. package/dist/auth/storage-file.d.ts +18 -0
  16. package/dist/auth/storage-file.d.ts.map +1 -0
  17. package/dist/auth/storage.d.ts +25 -0
  18. package/dist/auth/storage.d.ts.map +1 -0
  19. package/dist/auth/url.d.ts +17 -0
  20. package/dist/auth/url.d.ts.map +1 -0
  21. package/dist/code-mode/connector.d.ts +27 -0
  22. package/dist/code-mode/connector.d.ts.map +1 -0
  23. package/dist/code-mode/executor-e2b.d.ts +46 -0
  24. package/dist/code-mode/executor-e2b.d.ts.map +1 -0
  25. package/dist/code-mode/executor-vm.d.ts +39 -0
  26. package/dist/code-mode/executor-vm.d.ts.map +1 -0
  27. package/dist/code-mode/executor.d.ts +66 -0
  28. package/dist/code-mode/executor.d.ts.map +1 -0
  29. package/dist/core/base.d.ts +418 -0
  30. package/dist/core/base.d.ts.map +1 -0
  31. package/dist/core/browser.d.ts +20 -0
  32. package/dist/core/browser.d.ts.map +1 -0
  33. package/dist/core/config.d.ts +149 -0
  34. package/dist/core/config.d.ts.map +1 -0
  35. package/dist/core/node.d.ts +441 -0
  36. package/dist/core/node.d.ts.map +1 -0
  37. package/dist/core/session.d.ts +683 -0
  38. package/dist/core/session.d.ts.map +1 -0
  39. package/dist/index-browser.d.ts +25 -0
  40. package/dist/index-browser.d.ts.map +1 -0
  41. package/dist/index-browser.js +4150 -0
  42. package/dist/index-browser.js.map +1 -0
  43. package/dist/index.d.ts +23 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +5598 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/react/McpClientProvider.d.ts +242 -0
  48. package/dist/react/McpClientProvider.d.ts.map +1 -0
  49. package/dist/react/index.d.ts +33 -0
  50. package/dist/react/index.d.ts.map +1 -0
  51. package/dist/react/index.js +7922 -0
  52. package/dist/react/index.js.map +1 -0
  53. package/dist/react/rpc-logger.d.ts +42 -0
  54. package/dist/react/rpc-logger.d.ts.map +1 -0
  55. package/dist/react/storage.d.ts +51 -0
  56. package/dist/react/storage.d.ts.map +1 -0
  57. package/dist/react/types.d.ts +596 -0
  58. package/dist/react/types.d.ts.map +1 -0
  59. package/dist/react/useMcp-helpers.d.ts +99 -0
  60. package/dist/react/useMcp-helpers.d.ts.map +1 -0
  61. package/dist/react/useMcp-operations.d.ts +156 -0
  62. package/dist/react/useMcp-operations.d.ts.map +1 -0
  63. package/dist/react/useMcp.d.ts +48 -0
  64. package/dist/react/useMcp.d.ts.map +1 -0
  65. package/dist/react/useMcpServerQueues.d.ts +376 -0
  66. package/dist/react/useMcpServerQueues.d.ts.map +1 -0
  67. package/dist/react/view/ViewRenderer.d.ts +12 -0
  68. package/dist/react/view/ViewRenderer.d.ts.map +1 -0
  69. package/dist/react/view/ext-apps-bridge.d.ts +3 -0
  70. package/dist/react/view/ext-apps-bridge.d.ts.map +1 -0
  71. package/dist/react/view/parse-custom-props.d.ts +2 -0
  72. package/dist/react/view/parse-custom-props.d.ts.map +1 -0
  73. package/dist/react/view/resolve-view-resource.d.ts +12 -0
  74. package/dist/react/view/resolve-view-resource.d.ts.map +1 -0
  75. package/dist/react/view/sandbox-blob-url.d.ts +25 -0
  76. package/dist/react/view/sandbox-blob-url.d.ts.map +1 -0
  77. package/dist/react/view/types.d.ts +97 -0
  78. package/dist/react/view/types.d.ts.map +1 -0
  79. package/dist/react/view/use-display-mode.d.ts +18 -0
  80. package/dist/react/view/use-display-mode.d.ts.map +1 -0
  81. package/dist/react/view/view-detection.d.ts +4 -0
  82. package/dist/react/view/view-detection.d.ts.map +1 -0
  83. package/dist/telemetry/client-telemetry.d.ts +13 -0
  84. package/dist/telemetry/client-telemetry.d.ts.map +1 -0
  85. package/dist/telemetry/configure-browser.d.ts +2 -0
  86. package/dist/telemetry/configure-browser.d.ts.map +1 -0
  87. package/dist/telemetry/configure-node.d.ts +2 -0
  88. package/dist/telemetry/configure-node.d.ts.map +1 -0
  89. package/dist/telemetry/connector-telemetry.d.ts +8 -0
  90. package/dist/telemetry/connector-telemetry.d.ts.map +1 -0
  91. package/dist/telemetry/events.d.ts +91 -0
  92. package/dist/telemetry/events.d.ts.map +1 -0
  93. package/dist/telemetry/index.d.ts +3 -0
  94. package/dist/telemetry/index.d.ts.map +1 -0
  95. package/dist/telemetry/tel-fetch.d.ts +25 -0
  96. package/dist/telemetry/tel-fetch.d.ts.map +1 -0
  97. package/dist/telemetry/telemetry-browser.d.ts +6 -0
  98. package/dist/telemetry/telemetry-browser.d.ts.map +1 -0
  99. package/dist/telemetry/telemetry-node.d.ts +8 -0
  100. package/dist/telemetry/telemetry-node.d.ts.map +1 -0
  101. package/dist/telemetry/telemetry.d.ts +79 -0
  102. package/dist/telemetry/telemetry.d.ts.map +1 -0
  103. package/dist/transport/base.d.ts +505 -0
  104. package/dist/transport/base.d.ts.map +1 -0
  105. package/dist/transport/connection-manager.d.ts +55 -0
  106. package/dist/transport/connection-manager.d.ts.map +1 -0
  107. package/dist/transport/http.d.ts +74 -0
  108. package/dist/transport/http.d.ts.map +1 -0
  109. package/dist/transport/stdio.d.ts +48 -0
  110. package/dist/transport/stdio.d.ts.map +1 -0
  111. package/dist/utils/elicitation.d.ts +52 -0
  112. package/dist/utils/elicitation.d.ts.map +1 -0
  113. package/dist/utils/favicon.d.ts +6 -0
  114. package/dist/utils/favicon.d.ts.map +1 -0
  115. package/dist/utils/json-schema-validator.d.ts +13 -0
  116. package/dist/utils/json-schema-validator.d.ts.map +1 -0
  117. package/dist/utils/logging.d.ts +32 -0
  118. package/dist/utils/logging.d.ts.map +1 -0
  119. package/dist/utils/version.d.ts +3 -0
  120. package/dist/utils/version.d.ts.map +1 -0
  121. package/package.json +77 -8
@@ -0,0 +1,683 @@
1
+ import type { CallToolResult, CompleteRequestParams, CompleteResult, MetaObject, Notification, ProtocolEra, RequestOptions, Root, Tool } from "@modelcontextprotocol/client";
2
+ import type { BaseConnector, NotificationHandler } from "../transport/base.js";
3
+ /** Negotiated protocol era — same as SDK {@link ProtocolEra} (`"legacy"` | `"modern"`). */
4
+ export type MCPProtocolEra = ProtocolEra;
5
+ /**
6
+ * Server information normalized across legacy sessionful and modern sessionless
7
+ * MCP protocols.
8
+ */
9
+ export interface MCPServerInfo {
10
+ name: string;
11
+ version?: string;
12
+ title?: string;
13
+ description?: string;
14
+ websiteUrl?: string;
15
+ icons?: Array<{
16
+ src: string;
17
+ mimeType?: string;
18
+ sizes?: string[];
19
+ }>;
20
+ }
21
+ /**
22
+ * Connection metadata available after the MCP SDK has negotiated a protocol.
23
+ *
24
+ * `extensions` retains protocol-specific extensions without requiring
25
+ * callers to branch on the negotiated era.
26
+ */
27
+ export interface MCPConnectionInfo {
28
+ protocolEra: MCPProtocolEra;
29
+ protocolVersion: string;
30
+ server: MCPServerInfo;
31
+ capabilities: Record<string, unknown>;
32
+ instructions?: string;
33
+ extensions: Record<string, unknown>;
34
+ }
35
+ /**
36
+ * A ready connection to an MCP server.
37
+ *
38
+ * The connection has the same public API for legacy, sessionful MCP servers
39
+ * and modern, sessionless MCP servers. The underlying SDK owns the lifecycle
40
+ * distinction and protocol negotiation.
41
+ *
42
+ * Sessions handle:
43
+ * - Connection lifecycle (connect, disconnect, initialize)
44
+ * - Tool invocation
45
+ * - Resource access
46
+ * - Prompt retrieval
47
+ * - Notification handling
48
+ * - Root directory management
49
+ *
50
+ * Sessions are typically created by {@link MCPClient.createSession} rather than
51
+ * being instantiated directly.
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * // Create via client
56
+ * const client = new MCPClient('./config.json');
57
+ * const session = await client.createSession('my-server');
58
+ *
59
+ * // Use the session
60
+ * const tools = await session.listTools();
61
+ * const result = await session.callTool('my-tool', { arg: 'value' });
62
+ * ```
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * // Manual creation (advanced)
67
+ * import { StdioConnector } from "@mcp-use/client";
68
+ *
69
+ * const connector = new StdioConnector({
70
+ * command: 'node',
71
+ * args: ['server.js']
72
+ * });
73
+ * const session = new MCPSession(connector);
74
+ * await session.initialize();
75
+ * ```
76
+ *
77
+ * @see {@link MCPClient} for managing multiple sessions
78
+ * @see {@link BaseConnector} for connector implementations
79
+ */
80
+ export declare class MCPConnection {
81
+ /**
82
+ * The underlying connector managing the transport layer.
83
+ * This is the Stdio, HTTP, or WebSocket connector handling actual communication.
84
+ */
85
+ readonly connector: BaseConnector;
86
+ /**
87
+ * Whether to automatically connect when initializing.
88
+ * @internal
89
+ */
90
+ private autoConnect;
91
+ /**
92
+ * Creates a new MCP session.
93
+ *
94
+ * @param connector - The connector to use for communication (Stdio, HTTP, WebSocket)
95
+ * @param autoConnect - Whether to automatically connect during initialization (default: true)
96
+ *
97
+ * @example
98
+ * ```typescript
99
+ * const connector = new HttpConnector({ url: 'http://localhost:3000/mcp' });
100
+ * const session = new MCPSession(connector);
101
+ * await session.initialize(); // Auto-connects and initializes
102
+ * ```
103
+ *
104
+ * @example
105
+ * ```typescript
106
+ * // Manual connection control
107
+ * const session = new MCPSession(connector, false);
108
+ * await session.connect();
109
+ * await session.initialize();
110
+ * ```
111
+ */
112
+ constructor(connector: BaseConnector, autoConnect?: boolean);
113
+ /**
114
+ * Establishes the connection to the MCP server.
115
+ *
116
+ * This method starts the underlying transport (spawns process for Stdio,
117
+ * opens WebSocket, etc.) but does not perform the MCP initialization
118
+ * handshake. Call {@link initialize} after connecting.
119
+ *
120
+ * @returns Promise that resolves when connected
121
+ *
122
+ * @example
123
+ * ```typescript
124
+ * await session.connect();
125
+ * await session.initialize();
126
+ * ```
127
+ *
128
+ * @see {@link initialize} for performing the MCP handshake
129
+ * @see {@link disconnect} for closing the connection
130
+ */
131
+ connect(): Promise<void>;
132
+ /**
133
+ * Closes the connection to the MCP server.
134
+ *
135
+ * This method gracefully shuts down the transport and cleans up resources.
136
+ * After disconnecting, the session cannot be used until reconnected.
137
+ *
138
+ * @returns Promise that resolves when disconnected
139
+ *
140
+ * @example
141
+ * ```typescript
142
+ * await session.disconnect();
143
+ * console.log('Session closed');
144
+ * ```
145
+ *
146
+ * @see {@link connect} for establishing connections
147
+ */
148
+ disconnect(): Promise<void>;
149
+ /**
150
+ * Initializes the MCP session with the server.
151
+ *
152
+ * This method performs the MCP initialization handshake, exchanging
153
+ * capabilities and metadata with the server. If `autoConnect` is true
154
+ * and the session is not yet connected, it will connect first.
155
+ *
156
+ * After initialization, you can list and call tools, read resources, etc.
157
+ *
158
+ * @returns Promise that resolves when initialized
159
+ *
160
+ * @example
161
+ * ```typescript
162
+ * const session = await client.createSession('my-server', false);
163
+ * await session.connect();
164
+ * await session.initialize();
165
+ * // Now ready to use
166
+ * const tools = await session.listTools();
167
+ * ```
168
+ *
169
+ * @see {@link connect} for establishing the connection first
170
+ */
171
+ initialize(): Promise<void>;
172
+ /**
173
+ * Checks if the session is currently connected to the server.
174
+ *
175
+ * @returns True if connected, false otherwise
176
+ *
177
+ * @example
178
+ * ```typescript
179
+ * if (session.isConnected) {
180
+ * const tools = await session.listTools();
181
+ * }
182
+ * ```
183
+ */
184
+ get isConnected(): boolean;
185
+ /**
186
+ * Register an event handler for session events
187
+ *
188
+ * @param event - The event type to listen for
189
+ * @param handler - The handler function to call when the event occurs
190
+ *
191
+ * @example
192
+ * ```typescript
193
+ * session.on("notification", async (notification) => {
194
+ * console.log(`Received: ${notification.method}`, notification.params);
195
+ *
196
+ * if (notification.method === "notifications/tools/list_changed") {
197
+ * // Refresh tools list
198
+ * }
199
+ * });
200
+ * ```
201
+ */
202
+ on(event: "notification", handler: NotificationHandler): void;
203
+ /**
204
+ * Set roots and notify the server.
205
+ * Roots represent directories or files that the client has access to.
206
+ *
207
+ * @param roots - Array of Root objects with `uri` (must start with "file://") and optional `name`
208
+ *
209
+ * @deprecated Roots are a v1 compatibility feature and are not part of the
210
+ * sessionless v2 protocol.
211
+ *
212
+ * @example
213
+ * ```typescript
214
+ * await session.setRoots([
215
+ * { uri: "file:///home/user/project", name: "My Project" },
216
+ * { uri: "file:///home/user/data" }
217
+ * ]);
218
+ * ```
219
+ */
220
+ setRoots(roots: Root[]): Promise<void>;
221
+ /**
222
+ * Gets the current roots advertised to the server.
223
+ *
224
+ * Roots represent directories or files that the client has provided access to.
225
+ * The server may use this information to scope its operations.
226
+ *
227
+ * @returns Array of Root objects
228
+ *
229
+ * @example
230
+ * ```typescript
231
+ * const roots = session.getRoots();
232
+ * console.log(`Current roots: ${roots.map(r => r.uri).join(', ')}`);
233
+ * ```
234
+ *
235
+ * @see {@link setRoots} for updating roots
236
+ */
237
+ getRoots(): Root[];
238
+ /**
239
+ * Get the cached list of tools from the server.
240
+ *
241
+ * @returns Array of available tools
242
+ *
243
+ * @example
244
+ * ```typescript
245
+ * const tools = session.tools;
246
+ * console.log(`Available tools: ${tools.map(t => t.name).join(", ")}`);
247
+ * ```
248
+ */
249
+ get tools(): Tool[];
250
+ /**
251
+ * List all available tools from the MCP server.
252
+ * This method fetches fresh tools from the server, unlike the `tools` getter which returns cached tools.
253
+ *
254
+ * @param options - Optional request options
255
+ * @returns Array of available tools
256
+ *
257
+ * @example
258
+ * ```typescript
259
+ * const tools = await session.listTools();
260
+ * console.log(`Available tools: ${tools.map(t => t.name).join(", ")}`);
261
+ * ```
262
+ */
263
+ listTools(options?: RequestOptions): Promise<Tool[]>;
264
+ /**
265
+ * Get the server capabilities advertised during initialization.
266
+ *
267
+ * @returns Server capabilities object
268
+ */
269
+ get serverCapabilities(): Record<string, unknown>;
270
+ /**
271
+ * Get the server information (name and version).
272
+ *
273
+ * @returns Server info object or null if not available
274
+ */
275
+ get serverInfo(): MCPServerInfo | null;
276
+ /**
277
+ * The negotiated protocol era for this session's connection:
278
+ * `"legacy"` (2025-era) or `"modern"` (2026-07-28-era).
279
+ * `undefined` before the connection has negotiated.
280
+ */
281
+ get protocolEra(): MCPProtocolEra | undefined;
282
+ /** The negotiated protocol version string for this session's connection. */
283
+ get negotiatedProtocolVersion(): string | undefined;
284
+ /**
285
+ * Normalized server metadata for this ready connection.
286
+ *
287
+ * @throws {Error} When called before protocol negotiation completes.
288
+ */
289
+ get info(): MCPConnectionInfo;
290
+ /**
291
+ * Whether the server advertised a named MCP capability.
292
+ *
293
+ * @param capability - A top-level capability name such as `"tools"` or
294
+ * `"resources"`.
295
+ */
296
+ supports(capability: string): boolean;
297
+ /**
298
+ * Call a tool on the server.
299
+ *
300
+ * @param name - Name of the tool to call
301
+ * @param args - Arguments to pass to the tool (defaults to empty object)
302
+ * @param options - Optional request options (timeout, progress handlers, etc.)
303
+ * @returns Result from the tool execution
304
+ *
305
+ * @example
306
+ * ```typescript
307
+ * const result = await session.callTool("add", { a: 5, b: 3 });
308
+ * console.log(`Result: ${result.content[0].text}`);
309
+ * ```
310
+ */
311
+ callTool(name: string, args?: Record<string, any>, options?: RequestOptions): Promise<CallToolResult>;
312
+ /**
313
+ * List resources from the server with optional pagination.
314
+ *
315
+ * @param cursor - Optional cursor for pagination
316
+ * @param options - Request options
317
+ * @returns Resource list with optional nextCursor for pagination
318
+ *
319
+ * @example
320
+ * ```typescript
321
+ * const result = await session.listResources();
322
+ * console.log(`Found ${result.resources.length} resources`);
323
+ * ```
324
+ */
325
+ listResources(cursor?: string, options?: RequestOptions): Promise<{
326
+ [x: string]: unknown;
327
+ resources: {
328
+ uri: string;
329
+ name: string;
330
+ description?: string | undefined;
331
+ mimeType?: string | undefined;
332
+ size?: number | undefined;
333
+ annotations?: {
334
+ audience?: ("user" | "assistant")[] | undefined;
335
+ priority?: number | undefined;
336
+ lastModified?: string | undefined;
337
+ } | undefined;
338
+ _meta?: {
339
+ [x: string]: unknown;
340
+ } | undefined;
341
+ icons?: {
342
+ src: string;
343
+ mimeType?: string | undefined;
344
+ sizes?: string[] | undefined;
345
+ theme?: "light" | "dark" | undefined;
346
+ }[] | undefined;
347
+ title?: string | undefined;
348
+ }[];
349
+ _meta?: {
350
+ [x: string]: unknown;
351
+ progressToken?: string | number | undefined;
352
+ "io.modelcontextprotocol/related-task"?: {
353
+ taskId: string;
354
+ } | undefined;
355
+ } | undefined;
356
+ nextCursor?: string | undefined;
357
+ }>;
358
+ /**
359
+ * List all resources from the server, automatically handling pagination.
360
+ *
361
+ * @param options - Request options
362
+ * @returns Complete list of all resources
363
+ *
364
+ * @example
365
+ * ```typescript
366
+ * const result = await session.listAllResources();
367
+ * console.log(`Total resources: ${result.resources.length}`);
368
+ * ```
369
+ */
370
+ listAllResources(options?: RequestOptions): Promise<{
371
+ resources: any[];
372
+ }>;
373
+ /**
374
+ * List resource templates from the server.
375
+ *
376
+ * @param options - Request options
377
+ * @returns List of available resource templates
378
+ *
379
+ * @example
380
+ * ```typescript
381
+ * const result = await session.listResourceTemplates();
382
+ * console.log(`Available templates: ${result.resourceTemplates.length}`);
383
+ * ```
384
+ */
385
+ listResourceTemplates(options?: RequestOptions): Promise<{
386
+ [x: string]: unknown;
387
+ resourceTemplates: {
388
+ uriTemplate: string;
389
+ name: string;
390
+ description?: string | undefined;
391
+ mimeType?: string | undefined;
392
+ annotations?: {
393
+ audience?: ("user" | "assistant")[] | undefined;
394
+ priority?: number | undefined;
395
+ lastModified?: string | undefined;
396
+ } | undefined;
397
+ _meta?: {
398
+ [x: string]: unknown;
399
+ } | undefined;
400
+ icons?: {
401
+ src: string;
402
+ mimeType?: string | undefined;
403
+ sizes?: string[] | undefined;
404
+ theme?: "light" | "dark" | undefined;
405
+ }[] | undefined;
406
+ title?: string | undefined;
407
+ }[];
408
+ _meta?: {
409
+ [x: string]: unknown;
410
+ progressToken?: string | number | undefined;
411
+ "io.modelcontextprotocol/related-task"?: {
412
+ taskId: string;
413
+ } | undefined;
414
+ } | undefined;
415
+ nextCursor?: string | undefined;
416
+ }>;
417
+ /**
418
+ * Request completion suggestions for a prompt or resource template argument.
419
+ *
420
+ * @param params - Completion request parameters
421
+ * @param options - Request options
422
+ * @returns Completion suggestions from the server
423
+ *
424
+ * @example
425
+ * ```typescript
426
+ * // Complete a prompt argument
427
+ * const result = await session.complete({
428
+ * ref: { type: "ref/prompt", name: "my-prompt" },
429
+ * argument: { name: "language", value: "py" }
430
+ * });
431
+ * console.log(result.completion.values); // ["python"]
432
+ * ```
433
+ */
434
+ complete(params: CompleteRequestParams, options?: RequestOptions): Promise<CompleteResult>;
435
+ /**
436
+ * Read a resource by URI.
437
+ *
438
+ * @param uri - URI of the resource to read
439
+ * @param options - Request options
440
+ * @returns Resource content
441
+ *
442
+ * @example
443
+ * ```typescript
444
+ * const resource = await session.readResource("file:///path/to/file.txt");
445
+ * console.log(resource.contents);
446
+ * ```
447
+ */
448
+ readResource(uri: string, options?: RequestOptions): Promise<{
449
+ [x: string]: unknown;
450
+ contents: ({
451
+ uri: string;
452
+ text: string;
453
+ mimeType?: string | undefined;
454
+ _meta?: {
455
+ [x: string]: unknown;
456
+ } | undefined;
457
+ } | {
458
+ uri: string;
459
+ blob: string;
460
+ mimeType?: string | undefined;
461
+ _meta?: {
462
+ [x: string]: unknown;
463
+ } | undefined;
464
+ })[];
465
+ _meta?: {
466
+ [x: string]: unknown;
467
+ progressToken?: string | number | undefined;
468
+ "io.modelcontextprotocol/related-task"?: {
469
+ taskId: string;
470
+ } | undefined;
471
+ } | undefined;
472
+ }>;
473
+ /**
474
+ * Subscribe to resource updates.
475
+ *
476
+ * @param uri - URI of the resource to subscribe to
477
+ * @param options - Request options
478
+ *
479
+ * @example
480
+ * ```typescript
481
+ * await session.subscribeToResource("file:///path/to/file.txt");
482
+ * // Now you'll receive notifications when this resource changes
483
+ * ```
484
+ */
485
+ subscribeToResource(uri: string, options?: RequestOptions): Promise<{
486
+ _meta?: {
487
+ [x: string]: unknown;
488
+ progressToken?: string | number | undefined;
489
+ "io.modelcontextprotocol/related-task"?: {
490
+ taskId: string;
491
+ } | undefined;
492
+ } | undefined;
493
+ }>;
494
+ /**
495
+ * Unsubscribe from resource updates.
496
+ *
497
+ * @param uri - URI of the resource to unsubscribe from
498
+ * @param options - Request options
499
+ *
500
+ * @example
501
+ * ```typescript
502
+ * await session.unsubscribeFromResource("file:///path/to/file.txt");
503
+ * ```
504
+ */
505
+ unsubscribeFromResource(uri: string, options?: RequestOptions): Promise<{
506
+ _meta?: {
507
+ [x: string]: unknown;
508
+ progressToken?: string | number | undefined;
509
+ "io.modelcontextprotocol/related-task"?: {
510
+ taskId: string;
511
+ } | undefined;
512
+ } | undefined;
513
+ }>;
514
+ /**
515
+ * List available prompts from the server.
516
+ *
517
+ * @returns List of available prompts
518
+ *
519
+ * @example
520
+ * ```typescript
521
+ * const result = await session.listPrompts();
522
+ * console.log(`Available prompts: ${result.prompts.length}`);
523
+ * ```
524
+ */
525
+ listPrompts(): Promise<{
526
+ [x: string]: unknown;
527
+ prompts: {
528
+ name: string;
529
+ description?: string | undefined;
530
+ arguments?: {
531
+ name: string;
532
+ description?: string | undefined;
533
+ required?: boolean | undefined;
534
+ }[] | undefined;
535
+ _meta?: {
536
+ [x: string]: unknown;
537
+ } | undefined;
538
+ icons?: {
539
+ src: string;
540
+ mimeType?: string | undefined;
541
+ sizes?: string[] | undefined;
542
+ theme?: "light" | "dark" | undefined;
543
+ }[] | undefined;
544
+ title?: string | undefined;
545
+ }[];
546
+ _meta?: {
547
+ [x: string]: unknown;
548
+ progressToken?: string | number | undefined;
549
+ "io.modelcontextprotocol/related-task"?: {
550
+ taskId: string;
551
+ } | undefined;
552
+ } | undefined;
553
+ nextCursor?: string | undefined;
554
+ }>;
555
+ /**
556
+ * Get a specific prompt with arguments.
557
+ *
558
+ * @param name - Name of the prompt to get
559
+ * @param args - Arguments for the prompt
560
+ * @returns Prompt result
561
+ *
562
+ * @example
563
+ * ```typescript
564
+ * const prompt = await session.getPrompt("greeting", { name: "Alice" });
565
+ * console.log(prompt.messages);
566
+ * ```
567
+ */
568
+ getPrompt(name: string, args: Record<string, any>): Promise<{
569
+ [x: string]: unknown;
570
+ messages: {
571
+ role: "user" | "assistant";
572
+ content: {
573
+ type: "text";
574
+ text: string;
575
+ annotations?: {
576
+ audience?: ("user" | "assistant")[] | undefined;
577
+ priority?: number | undefined;
578
+ lastModified?: string | undefined;
579
+ } | undefined;
580
+ _meta?: {
581
+ [x: string]: unknown;
582
+ } | undefined;
583
+ } | {
584
+ type: "image";
585
+ data: string;
586
+ mimeType: string;
587
+ annotations?: {
588
+ audience?: ("user" | "assistant")[] | undefined;
589
+ priority?: number | undefined;
590
+ lastModified?: string | undefined;
591
+ } | undefined;
592
+ _meta?: {
593
+ [x: string]: unknown;
594
+ } | undefined;
595
+ } | {
596
+ type: "audio";
597
+ data: string;
598
+ mimeType: string;
599
+ annotations?: {
600
+ audience?: ("user" | "assistant")[] | undefined;
601
+ priority?: number | undefined;
602
+ lastModified?: string | undefined;
603
+ } | undefined;
604
+ _meta?: {
605
+ [x: string]: unknown;
606
+ } | undefined;
607
+ } | {
608
+ uri: string;
609
+ name: string;
610
+ type: "resource_link";
611
+ description?: string | undefined;
612
+ mimeType?: string | undefined;
613
+ size?: number | undefined;
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
+ icons?: {
623
+ src: string;
624
+ mimeType?: string | undefined;
625
+ sizes?: string[] | undefined;
626
+ theme?: "light" | "dark" | undefined;
627
+ }[] | undefined;
628
+ title?: string | undefined;
629
+ } | {
630
+ type: "resource";
631
+ resource: {
632
+ uri: string;
633
+ text: string;
634
+ mimeType?: string | undefined;
635
+ _meta?: {
636
+ [x: string]: unknown;
637
+ } | undefined;
638
+ } | {
639
+ uri: string;
640
+ blob: string;
641
+ mimeType?: string | undefined;
642
+ _meta?: {
643
+ [x: string]: unknown;
644
+ } | undefined;
645
+ };
646
+ annotations?: {
647
+ audience?: ("user" | "assistant")[] | undefined;
648
+ priority?: number | undefined;
649
+ lastModified?: string | undefined;
650
+ } | undefined;
651
+ _meta?: {
652
+ [x: string]: unknown;
653
+ } | undefined;
654
+ };
655
+ }[];
656
+ _meta?: {
657
+ [x: string]: unknown;
658
+ progressToken?: string | number | undefined;
659
+ "io.modelcontextprotocol/related-task"?: {
660
+ taskId: string;
661
+ } | undefined;
662
+ } | undefined;
663
+ description?: string | undefined;
664
+ }>;
665
+ /**
666
+ * Send a raw request through the client.
667
+ *
668
+ * @param method - MCP method name
669
+ * @param params - Request parameters
670
+ * @param options - Request options
671
+ * @returns Response from the server
672
+ *
673
+ * @example
674
+ * ```typescript
675
+ * const result = await session.request("custom/method", { key: "value" });
676
+ * ```
677
+ */
678
+ request(method: string, params?: Record<string, any> | null, options?: RequestOptions): Promise<unknown>;
679
+ }
680
+ /** @deprecated Use {@link MCPConnection}. */
681
+ export { MCPConnection as MCPSession };
682
+ export type { CallToolResult, MetaObject, Notification, Root, Tool };
683
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/core/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,cAAc,EACd,UAAU,EACV,YAAY,EACZ,WAAW,EACX,cAAc,EACd,IAAI,EACJ,IAAI,EACL,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;A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