mcp-use 1.11.0-canary.13 → 1.11.0-canary.14

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 (34) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/{chunk-LHNWYWSI.js → chunk-2IMIUODV.js} +482 -5
  3. package/dist/{chunk-TZKOAITC.js → chunk-7TS5EJ4T.js} +1 -1
  4. package/dist/{chunk-5OHAUR7E.js → chunk-AEHNVFZG.js} +1 -1
  5. package/dist/{chunk-T7V3VOS2.js → chunk-JYFYHDYK.js} +4 -4
  6. package/dist/{chunk-P4TBZOPX.js → chunk-MIKDMUFS.js} +2 -2
  7. package/dist/{chunk-C5YF5MPR.js → chunk-PO6UGK4I.js} +2 -2
  8. package/dist/{chunk-ZFZPZ4GE.js → chunk-SBMQ4QZJ.js} +9 -0
  9. package/dist/{chunk-HPAS2BOZ.js → chunk-U7JXQZVH.js} +197 -8
  10. package/dist/index.cjs +2 -2
  11. package/dist/index.js +26 -30
  12. package/dist/src/agents/index.cjs +2 -2
  13. package/dist/src/agents/index.d.ts +1 -1
  14. package/dist/src/agents/index.d.ts.map +1 -1
  15. package/dist/src/agents/index.js +7 -11
  16. package/dist/src/{client/prompts.d.ts → agents/prompts/index.d.ts} +3 -3
  17. package/dist/src/agents/prompts/index.d.ts.map +1 -0
  18. package/dist/src/browser.cjs +1 -1
  19. package/dist/src/browser.js +13 -16
  20. package/dist/src/client.cjs +1 -1
  21. package/dist/src/client.js +3 -5
  22. package/dist/src/react/index.cjs +1 -1
  23. package/dist/src/react/index.js +7 -8
  24. package/dist/src/server/index.cjs +1 -1
  25. package/dist/src/server/index.js +10 -10
  26. package/dist/src/version.d.ts +1 -1
  27. package/dist/{tool-execution-helpers-CBMJLW7M.js → tool-execution-helpers-RRECKMIN.js} +2 -2
  28. package/package.json +31 -31
  29. package/dist/chunk-2RSYU23F.js +0 -12
  30. package/dist/chunk-6I4P5WXY.js +0 -491
  31. package/dist/chunk-AQVGN2CI.js +0 -204
  32. package/dist/src/client/prompts.cjs +0 -407
  33. package/dist/src/client/prompts.d.ts.map +0 -1
  34. package/dist/src/client/prompts.js +0 -11
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mcp-use",
3
3
  "type": "module",
4
- "version": "1.11.0-canary.13",
4
+ "version": "1.11.0-canary.14",
5
5
  "description": "Opinionated MCP Framework for TypeScript (@modelcontextprotocol/sdk compatible) - Build MCP Agents, Clients and Servers with support for ChatGPT Apps, Code Mode, OAuth, Notifications, Sampling, Observability and more.",
6
6
  "author": "mcp-use, Inc.",
7
7
  "license": "MIT",
@@ -137,8 +137,8 @@
137
137
  "posthog-node": "^5.17.2",
138
138
  "ws": "^8.18.3",
139
139
  "zod": "^4.2.0",
140
- "@mcp-use/cli": "2.6.0-canary.13",
141
- "@mcp-use/inspector": "0.13.0-canary.13"
140
+ "@mcp-use/cli": "2.6.0-canary.14",
141
+ "@mcp-use/inspector": "0.13.0-canary.14"
142
142
  },
143
143
  "optionalDependencies": {
144
144
  "chalk": "^5.6.2",
@@ -200,36 +200,36 @@
200
200
  "release": "npm version patch --tag-version-prefix=v && git push --follow-tags",
201
201
  "release:minor": "npm version minor --tag-version-prefix=v && git push --follow-tags",
202
202
  "release:major": "npm version major --tag-version-prefix=v && git push --follow-tags",
203
- "example:airbnb": "tsx examples/client/airbnb_use.ts",
204
- "example:browser": "tsx examples/client/browser_use.ts",
205
- "example:chat": "tsx examples/client/chat_example.ts",
206
- "example:stream": "tsx examples/client/stream_example.ts",
203
+ "example:airbnb": "tsx examples/typescript/agent/integrations/airbnb_use.ts",
204
+ "example:browser": "tsx examples/typescript/agent/integrations/browser_use.ts",
205
+ "example:chat": "tsx examples/typescript/agent/basic/chat_example.ts",
206
+ "example:stream": "tsx examples/typescript/agent/advanced/stream_example.ts",
207
207
  "example:stream_events": "tsx examples/client/stream_events_example.ts",
208
- "example:ai_sdk": "tsx examples/client/ai_sdk_example.ts",
209
- "example:filesystem": "tsx examples/client/filesystem_use.ts",
210
- "example:http": "tsx examples/client/http_example.ts",
211
- "example:everything": "tsx examples/client/mcp_everything.ts",
212
- "example:multi": "tsx examples/client/multi_server_example.ts",
208
+ "example:ai_sdk": "tsx examples/typescript/agent/frameworks/ai_sdk_example.ts",
209
+ "example:filesystem": "tsx examples/typescript/agent/integrations/filesystem_use.ts",
210
+ "example:http": "tsx examples/typescript/client/basic/http_example.ts",
211
+ "example:everything": "tsx examples/typescript/agent/basic/mcp_everything.ts",
212
+ "example:multi": "tsx examples/typescript/agent/server-management/multi_server_example.ts",
213
213
  "example:sandbox": "tsx examples/client/sandbox_everything.ts",
214
214
  "example:oauth": "tsx examples/client/simple_oauth_example.ts",
215
- "example:blender": "tsx examples/client/blender_use.ts",
216
- "example:add_server": "tsx examples/client/add_server_tool.ts",
217
- "example:structured": "tsx examples/client/structured_output.ts",
218
- "example:observability": "tsx examples/client/observability.ts",
219
- "example:simplified": "tsx examples/client/simplified_agent_example.ts",
220
- "example:commonjs": "node examples/client/commonjs_example.cjs",
221
- "example:code_mode": "tsx examples/client/code_mode_example.ts",
222
- "example:code_mode_e2b": "source .env 2>/dev/null || true && tsx examples/client/code_mode_e2b_example.ts",
223
- "example:server:notification": "tsx examples/server/notification-example/src/server.ts",
224
- "example:client:notification": "tsx examples/client/notification-client.ts",
225
- "example:notifications": "lsof -ti:3000 | xargs kill -9 2>/dev/null; tsx examples/server/notifications/src/server.ts & sleep 3 && tsx examples/client/notification-client.ts",
226
- "example:server:sampling": "tsx examples/server/sampling/src/server.ts",
227
- "example:client:sampling": "tsx examples/client/sampling-client.ts",
228
- "example:server:elicitation": "tsx examples/server/elicitation/src/server.ts",
229
- "example:sampling": "lsof -ti:3000 | xargs kill -9 2>/dev/null; tsx examples/server/sampling/src/server.ts & sleep 3 && tsx examples/client/sampling-client.ts",
230
- "example:server:oauth:supabase": "tsx examples/server/oauth/supabase/src/server.ts",
231
- "example:client:oauth:auth0": "tsx examples/server/oauth/auth0/src/server.ts",
232
- "example:client:oauth:workos": "tsx examples/server/oauth/workos/src/server.ts",
233
- "example:client:oauth:keycloak": "tsx examples/server/oauth/keycloak/src/server.ts"
215
+ "example:blender": "tsx examples/typescript/agent/integrations/blender_use.ts",
216
+ "example:add_server": "tsx examples/typescript/agent/server-management/add_server_tool.ts",
217
+ "example:structured": "tsx examples/typescript/agent/advanced/structured_output.ts",
218
+ "example:observability": "tsx examples/typescript/agent/advanced/observability.ts",
219
+ "example:simplified": "tsx examples/typescript/agent/basic/simplified_agent_example.ts",
220
+ "example:commonjs": "node examples/typescript/client/basic/commonjs_example.cjs",
221
+ "example:code_mode": "tsx examples/typescript/agent/code-mode/code_mode_example.ts",
222
+ "example:code_mode_e2b": "source .env 2>/dev/null || true && tsx examples/typescript/agent/code-mode/code_mode_e2b_example.ts",
223
+ "example:server:notification": "tsx examples/typescript/server/features/notifications/src/server.ts",
224
+ "example:client:notification": "tsx examples/typescript/client/communication/notification-client.ts",
225
+ "example:notifications": "lsof -ti:3000 | xargs kill -9 2>/dev/null; tsx examples/typescript/server/features/notifications/src/server.ts & sleep 3 && tsx examples/typescript/client/communication/notification-client.ts",
226
+ "example:server:sampling": "tsx examples/typescript/server/features/sampling/src/server.ts",
227
+ "example:client:sampling": "tsx examples/typescript/client/communication/sampling-client.ts",
228
+ "example:server:elicitation": "tsx examples/typescript/server/features/elicitation/src/server.ts",
229
+ "example:sampling": "lsof -ti:3000 | xargs kill -9 2>/dev/null; tsx examples/typescript/server/features/sampling/src/server.ts & sleep 3 && tsx examples/typescript/client/communication/sampling-client.ts",
230
+ "example:server:oauth:supabase": "tsx examples/typescript/server/oauth/supabase/src/server.ts",
231
+ "example:client:oauth:auth0": "tsx examples/typescript/server/oauth/auth0/src/server.ts",
232
+ "example:client:oauth:workos": "tsx examples/typescript/server/oauth/workos/src/server.ts",
233
+ "example:client:oauth:keycloak": "tsx examples/typescript/server/oauth/keycloak/src/server.ts"
234
234
  }
235
235
  }
@@ -1,12 +0,0 @@
1
- import {
2
- CODE_MODE_AGENT_PROMPT
3
- } from "./chunk-AQVGN2CI.js";
4
-
5
- // src/client/prompts.ts
6
- var PROMPTS = {
7
- CODE_MODE: CODE_MODE_AGENT_PROMPT
8
- };
9
-
10
- export {
11
- PROMPTS
12
- };
@@ -1,491 +0,0 @@
1
- import {
2
- Telemetry
3
- } from "./chunk-TZKOAITC.js";
4
- import {
5
- logger
6
- } from "./chunk-FRUZDWXH.js";
7
- import {
8
- __name
9
- } from "./chunk-3GQAWCBQ.js";
10
-
11
- // src/connectors/base.ts
12
- import {
13
- ListRootsRequestSchema,
14
- CreateMessageRequestSchema,
15
- ElicitRequestSchema
16
- } from "@mcp-use/modelcontextprotocol-sdk/types.js";
17
- var BaseConnector = class {
18
- static {
19
- __name(this, "BaseConnector");
20
- }
21
- client = null;
22
- connectionManager = null;
23
- toolsCache = null;
24
- capabilitiesCache = null;
25
- serverInfoCache = null;
26
- connected = false;
27
- opts;
28
- notificationHandlers = [];
29
- rootsCache = [];
30
- constructor(opts = {}) {
31
- this.opts = opts;
32
- if (opts.roots) {
33
- this.rootsCache = [...opts.roots];
34
- }
35
- }
36
- /**
37
- * Track connector initialization event
38
- * Should be called by subclasses after successful connection
39
- */
40
- trackConnectorInit(data) {
41
- const connectorType = this.constructor.name;
42
- Telemetry.getInstance().trackConnectorInit({
43
- connectorType,
44
- ...data
45
- }).catch((e) => logger.debug(`Failed to track connector init: ${e}`));
46
- }
47
- /**
48
- * Register a handler for server notifications
49
- *
50
- * @param handler - Function to call when a notification is received
51
- *
52
- * @example
53
- * ```typescript
54
- * connector.onNotification((notification) => {
55
- * console.log(`Received: ${notification.method}`, notification.params);
56
- * });
57
- * ```
58
- */
59
- onNotification(handler) {
60
- this.notificationHandlers.push(handler);
61
- if (this.client) {
62
- this.setupNotificationHandler();
63
- }
64
- }
65
- /**
66
- * Internal: wire notification handlers to the SDK client
67
- * Includes automatic handling for list_changed notifications per MCP spec
68
- */
69
- setupNotificationHandler() {
70
- if (!this.client) return;
71
- this.client.fallbackNotificationHandler = async (notification) => {
72
- switch (notification.method) {
73
- case "notifications/tools/list_changed":
74
- await this.refreshToolsCache();
75
- break;
76
- case "notifications/resources/list_changed":
77
- await this.onResourcesListChanged();
78
- break;
79
- case "notifications/prompts/list_changed":
80
- await this.onPromptsListChanged();
81
- break;
82
- default:
83
- break;
84
- }
85
- for (const handler of this.notificationHandlers) {
86
- try {
87
- await handler(notification);
88
- } catch (err) {
89
- logger.error("Error in notification handler:", err);
90
- }
91
- }
92
- };
93
- }
94
- /**
95
- * Auto-refresh tools cache when server sends tools/list_changed notification
96
- */
97
- async refreshToolsCache() {
98
- if (!this.client) return;
99
- try {
100
- logger.debug(
101
- "[Auto] Refreshing tools cache due to list_changed notification"
102
- );
103
- const result = await this.client.listTools();
104
- this.toolsCache = result.tools ?? [];
105
- logger.debug(
106
- `[Auto] Refreshed tools cache: ${this.toolsCache.length} tools`
107
- );
108
- } catch (err) {
109
- logger.warn("[Auto] Failed to refresh tools cache:", err);
110
- }
111
- }
112
- /**
113
- * Called when server sends resources/list_changed notification
114
- * Resources aren't cached by default, but we log for user awareness
115
- */
116
- async onResourcesListChanged() {
117
- logger.debug(
118
- "[Auto] Resources list changed - clients should re-fetch if needed"
119
- );
120
- }
121
- /**
122
- * Called when server sends prompts/list_changed notification
123
- * Prompts aren't cached by default, but we log for user awareness
124
- */
125
- async onPromptsListChanged() {
126
- logger.debug(
127
- "[Auto] Prompts list changed - clients should re-fetch if needed"
128
- );
129
- }
130
- /**
131
- * Set roots and notify the server.
132
- * Roots represent directories or files that the client has access to.
133
- *
134
- * @param roots - Array of Root objects with `uri` (must start with "file://") and optional `name`
135
- *
136
- * @example
137
- * ```typescript
138
- * await connector.setRoots([
139
- * { uri: "file:///home/user/project", name: "My Project" },
140
- * { uri: "file:///home/user/data" }
141
- * ]);
142
- * ```
143
- */
144
- async setRoots(roots) {
145
- this.rootsCache = [...roots];
146
- if (this.client) {
147
- logger.debug(
148
- `Sending roots/list_changed notification with ${roots.length} root(s)`
149
- );
150
- await this.client.sendRootsListChanged();
151
- }
152
- }
153
- /**
154
- * Get the current roots.
155
- */
156
- getRoots() {
157
- return [...this.rootsCache];
158
- }
159
- /**
160
- * Internal: set up roots/list request handler.
161
- * This is called after the client connects to register the handler for server requests.
162
- */
163
- setupRootsHandler() {
164
- if (!this.client) return;
165
- this.client.setRequestHandler(
166
- ListRootsRequestSchema,
167
- async (_request, _extra) => {
168
- logger.debug(
169
- `Server requested roots list, returning ${this.rootsCache.length} root(s)`
170
- );
171
- return { roots: this.rootsCache };
172
- }
173
- );
174
- }
175
- /**
176
- * Internal: set up sampling/createMessage request handler.
177
- * This is called after the client connects to register the handler for sampling requests.
178
- */
179
- setupSamplingHandler() {
180
- if (!this.client) {
181
- logger.debug("setupSamplingHandler: No client available");
182
- return;
183
- }
184
- if (!this.opts.samplingCallback) {
185
- logger.debug("setupSamplingHandler: No sampling callback provided");
186
- return;
187
- }
188
- logger.debug("setupSamplingHandler: Setting up sampling request handler");
189
- this.client.setRequestHandler(
190
- CreateMessageRequestSchema,
191
- async (request, _extra) => {
192
- logger.debug("Server requested sampling, forwarding to callback");
193
- return await this.opts.samplingCallback(request.params);
194
- }
195
- );
196
- logger.debug(
197
- "setupSamplingHandler: Sampling handler registered successfully"
198
- );
199
- }
200
- /**
201
- * Internal: set up elicitation/create request handler.
202
- * This is called after the client connects to register the handler for elicitation requests.
203
- */
204
- setupElicitationHandler() {
205
- if (!this.client) {
206
- logger.debug("setupElicitationHandler: No client available");
207
- return;
208
- }
209
- if (!this.opts.elicitationCallback) {
210
- logger.debug("setupElicitationHandler: No elicitation callback provided");
211
- return;
212
- }
213
- logger.debug(
214
- "setupElicitationHandler: Setting up elicitation request handler"
215
- );
216
- this.client.setRequestHandler(
217
- ElicitRequestSchema,
218
- async (request, _extra) => {
219
- logger.debug("Server requested elicitation, forwarding to callback");
220
- return await this.opts.elicitationCallback(request.params);
221
- }
222
- );
223
- logger.debug(
224
- "setupElicitationHandler: Elicitation handler registered successfully"
225
- );
226
- }
227
- /** Disconnect and release resources. */
228
- async disconnect() {
229
- if (!this.connected) {
230
- logger.debug("Not connected to MCP implementation");
231
- return;
232
- }
233
- logger.debug("Disconnecting from MCP implementation");
234
- await this.cleanupResources();
235
- this.connected = false;
236
- logger.debug("Disconnected from MCP implementation");
237
- }
238
- /** Check if the client is connected */
239
- get isClientConnected() {
240
- return this.client != null;
241
- }
242
- /**
243
- * Initialise the MCP session **after** `connect()` has succeeded.
244
- *
245
- * In the SDK, `Client.connect(transport)` automatically performs the
246
- * protocol‑level `initialize` handshake, so we only need to cache the list of
247
- * tools and expose some server info.
248
- */
249
- async initialize(defaultRequestOptions = this.opts.defaultRequestOptions ?? {}) {
250
- if (!this.client) {
251
- throw new Error("MCP client is not connected");
252
- }
253
- logger.debug("Caching server capabilities & tools");
254
- const capabilities = this.client.getServerCapabilities();
255
- this.capabilitiesCache = capabilities || null;
256
- const serverInfo = this.client.getServerVersion();
257
- this.serverInfoCache = serverInfo || null;
258
- const listToolsRes = await this.client.listTools(
259
- void 0,
260
- defaultRequestOptions
261
- );
262
- this.toolsCache = listToolsRes.tools ?? [];
263
- logger.debug(`Fetched ${this.toolsCache.length} tools from server`);
264
- logger.debug("Server capabilities:", capabilities);
265
- logger.debug("Server info:", serverInfo);
266
- return capabilities;
267
- }
268
- /** Lazily expose the cached tools list. */
269
- get tools() {
270
- if (!this.toolsCache) {
271
- throw new Error("MCP client is not initialized; call initialize() first");
272
- }
273
- return this.toolsCache;
274
- }
275
- /** Expose cached server capabilities. */
276
- get serverCapabilities() {
277
- return this.capabilitiesCache || {};
278
- }
279
- /** Expose cached server info. */
280
- get serverInfo() {
281
- return this.serverInfoCache;
282
- }
283
- /** Call a tool on the server. */
284
- async callTool(name, args, options) {
285
- if (!this.client) {
286
- throw new Error("MCP client is not connected");
287
- }
288
- const enhancedOptions = options ? { ...options } : void 0;
289
- if (enhancedOptions?.resetTimeoutOnProgress && !enhancedOptions.onprogress) {
290
- enhancedOptions.onprogress = () => {
291
- };
292
- logger.debug(
293
- `[BaseConnector] Added onprogress callback for tool '${name}' to enable progressToken`
294
- );
295
- }
296
- logger.debug(`Calling tool '${name}' with args`, args);
297
- const res = await this.client.callTool(
298
- { name, arguments: args },
299
- void 0,
300
- enhancedOptions
301
- );
302
- logger.debug(`Tool '${name}' returned`, res);
303
- return res;
304
- }
305
- /**
306
- * List all available tools from the MCP server.
307
- * This method fetches fresh tools from the server, unlike the `tools` getter which returns cached tools.
308
- *
309
- * @param options - Optional request options
310
- * @returns Array of available tools
311
- */
312
- async listTools(options) {
313
- if (!this.client) {
314
- throw new Error("MCP client is not connected");
315
- }
316
- const result = await this.client.listTools(void 0, options);
317
- return result.tools ?? [];
318
- }
319
- /**
320
- * List resources from the server with optional pagination
321
- *
322
- * @param cursor - Optional cursor for pagination
323
- * @param options - Request options
324
- * @returns Resource list with optional nextCursor for pagination
325
- */
326
- async listResources(cursor, options) {
327
- if (!this.client) {
328
- throw new Error("MCP client is not connected");
329
- }
330
- logger.debug("Listing resources", cursor ? `with cursor: ${cursor}` : "");
331
- return await this.client.listResources({ cursor }, options);
332
- }
333
- /**
334
- * List all resources from the server, automatically handling pagination
335
- *
336
- * @param options - Request options
337
- * @returns Complete list of all resources
338
- */
339
- async listAllResources(options) {
340
- if (!this.client) {
341
- throw new Error("MCP client is not connected");
342
- }
343
- if (!this.capabilitiesCache?.resources) {
344
- logger.debug("Server does not advertise resources capability, skipping");
345
- return { resources: [] };
346
- }
347
- try {
348
- logger.debug("Listing all resources (with auto-pagination)");
349
- const allResources = [];
350
- let cursor = void 0;
351
- do {
352
- const result = await this.client.listResources({ cursor }, options);
353
- allResources.push(...result.resources || []);
354
- cursor = result.nextCursor;
355
- } while (cursor);
356
- return { resources: allResources };
357
- } catch (err) {
358
- const error = err;
359
- if (error.code === -32601) {
360
- logger.debug("Server advertised resources but method not found");
361
- return { resources: [] };
362
- }
363
- throw err;
364
- }
365
- }
366
- /**
367
- * List resource templates from the server
368
- *
369
- * @param options - Request options
370
- * @returns List of available resource templates
371
- */
372
- async listResourceTemplates(options) {
373
- if (!this.client) {
374
- throw new Error("MCP client is not connected");
375
- }
376
- logger.debug("Listing resource templates");
377
- return await this.client.listResourceTemplates(void 0, options);
378
- }
379
- /** Read a resource by URI. */
380
- async readResource(uri, options) {
381
- if (!this.client) {
382
- throw new Error("MCP client is not connected");
383
- }
384
- logger.debug(`Reading resource ${uri}`);
385
- const res = await this.client.readResource({ uri }, options);
386
- return res;
387
- }
388
- /**
389
- * Subscribe to resource updates
390
- *
391
- * @param uri - URI of the resource to subscribe to
392
- * @param options - Request options
393
- */
394
- async subscribeToResource(uri, options) {
395
- if (!this.client) {
396
- throw new Error("MCP client is not connected");
397
- }
398
- logger.debug(`Subscribing to resource: ${uri}`);
399
- return await this.client.subscribeResource({ uri }, options);
400
- }
401
- /**
402
- * Unsubscribe from resource updates
403
- *
404
- * @param uri - URI of the resource to unsubscribe from
405
- * @param options - Request options
406
- */
407
- async unsubscribeFromResource(uri, options) {
408
- if (!this.client) {
409
- throw new Error("MCP client is not connected");
410
- }
411
- logger.debug(`Unsubscribing from resource: ${uri}`);
412
- return await this.client.unsubscribeResource({ uri }, options);
413
- }
414
- async listPrompts() {
415
- if (!this.client) {
416
- throw new Error("MCP client is not connected");
417
- }
418
- if (!this.capabilitiesCache?.prompts) {
419
- logger.debug("Server does not advertise prompts capability, skipping");
420
- return { prompts: [] };
421
- }
422
- try {
423
- logger.debug("Listing prompts");
424
- return await this.client.listPrompts();
425
- } catch (err) {
426
- const error = err;
427
- if (error.code === -32601) {
428
- logger.debug("Server advertised prompts but method not found");
429
- return { prompts: [] };
430
- }
431
- throw err;
432
- }
433
- }
434
- async getPrompt(name, args) {
435
- if (!this.client) {
436
- throw new Error("MCP client is not connected");
437
- }
438
- logger.debug(`Getting prompt ${name}`);
439
- return await this.client.getPrompt({ name, arguments: args });
440
- }
441
- /** Send a raw request through the client. */
442
- async request(method, params = null, options) {
443
- if (!this.client) {
444
- throw new Error("MCP client is not connected");
445
- }
446
- logger.debug(`Sending raw request '${method}' with params`, params);
447
- return await this.client.request(
448
- { method, params: params ?? {} },
449
- void 0,
450
- options
451
- );
452
- }
453
- /**
454
- * Helper to tear down the client & connection manager safely.
455
- */
456
- async cleanupResources() {
457
- const issues = [];
458
- if (this.client) {
459
- try {
460
- if (typeof this.client.close === "function") {
461
- await this.client.close();
462
- }
463
- } catch (e) {
464
- const msg = `Error closing client: ${e}`;
465
- logger.warn(msg);
466
- issues.push(msg);
467
- } finally {
468
- this.client = null;
469
- }
470
- }
471
- if (this.connectionManager) {
472
- try {
473
- await this.connectionManager.stop();
474
- } catch (e) {
475
- const msg = `Error stopping connection manager: ${e}`;
476
- logger.warn(msg);
477
- issues.push(msg);
478
- } finally {
479
- this.connectionManager = null;
480
- }
481
- }
482
- this.toolsCache = null;
483
- if (issues.length) {
484
- logger.warn(`Resource cleanup finished with ${issues.length} issue(s)`);
485
- }
486
- }
487
- };
488
-
489
- export {
490
- BaseConnector
491
- };