@mcpjam/sdk 0.1.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.
package/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # @mcpjam/sdk
2
+
3
+ The MCPJam SDK gathers utilities for the testing and development of MCP clients and servers
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @mcpjam/sdk @modelcontextprotocol/sdk
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { MCPClientManager } from "@mcpjam/sdk";
15
+ // or import specific helpers
16
+ import { MCPClientManager } from "@mcpjam/sdk/mcp-client-manager";
17
+ ```
18
+
19
+ ## Building locally
20
+
21
+ Run the build once to compile every package in the `sdk/` workspace:
22
+
23
+ ```bash
24
+ npm run build
25
+ ```
26
+
27
+ This command also builds individual sub-packages (such as `mcp-client-manager`) so they are ready to publish independently if needed.
@@ -0,0 +1,10 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ export {
8
+ __export
9
+ };
10
+ //# sourceMappingURL=chunk-PZ5AY32C.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/index.cjs ADDED
@@ -0,0 +1,485 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ MCPClientManager: () => MCPClientManager,
24
+ mcpClientManager: () => mcp_client_manager_exports
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+
28
+ // mcp-client-manager/index.js
29
+ var mcp_client_manager_exports = {};
30
+ __export(mcp_client_manager_exports, {
31
+ MCPClientManager: () => MCPClientManager
32
+ });
33
+ var import_client = require("@modelcontextprotocol/sdk/client/index.js");
34
+ var import_sse = require("@modelcontextprotocol/sdk/client/sse.js");
35
+ var import_stdio = require("@modelcontextprotocol/sdk/client/stdio.js");
36
+ var import_streamableHttp = require("@modelcontextprotocol/sdk/client/streamableHttp.js");
37
+ var import_protocol = require("@modelcontextprotocol/sdk/shared/protocol.js");
38
+ var import_types = require("@modelcontextprotocol/sdk/types.js");
39
+ var MCPClientManager = class {
40
+ constructor(servers = {}, options = {}) {
41
+ this.clientStates = /* @__PURE__ */ new Map();
42
+ this.pendingConnections = /* @__PURE__ */ new Map();
43
+ this.serverConfigs = /* @__PURE__ */ new Map();
44
+ this.notificationHandlers = /* @__PURE__ */ new Map();
45
+ this.elicitationHandlers = /* @__PURE__ */ new Map();
46
+ var _a, _b, _c;
47
+ this.defaultClientVersion = (_a = options.defaultClientVersion) != null ? _a : "1.0.0";
48
+ this.defaultCapabilities = {
49
+ ...(_b = options.defaultCapabilities) != null ? _b : {}
50
+ };
51
+ this.defaultTimeout = (_c = options.defaultTimeout) != null ? _c : import_protocol.DEFAULT_REQUEST_TIMEOUT_MSEC;
52
+ for (const [name, config] of Object.entries(servers)) {
53
+ void this.connectToServer(name, config);
54
+ }
55
+ }
56
+ listServers() {
57
+ return Array.from(this.serverConfigs.keys());
58
+ }
59
+ hasServer(name) {
60
+ const serverName = this.normalizeName(name);
61
+ return this.serverConfigs.has(serverName);
62
+ }
63
+ async connectToServer(name, config) {
64
+ const serverName = this.normalizeName(name);
65
+ this.serverConfigs.set(serverName, config);
66
+ const timeout = this.getTimeout(config);
67
+ const existingState = this.clientStates.get(serverName);
68
+ if (existingState) {
69
+ existingState.config = config;
70
+ existingState.timeout = timeout;
71
+ this.clientStates.set(serverName, existingState);
72
+ return existingState.client;
73
+ }
74
+ const pendingState = this.pendingConnections.get(serverName);
75
+ if (pendingState) {
76
+ pendingState.config = config;
77
+ pendingState.timeout = timeout;
78
+ return pendingState.promise;
79
+ }
80
+ const connectionPromise = (async () => {
81
+ var _a;
82
+ const client = new import_client.Client(
83
+ {
84
+ name: serverName,
85
+ version: (_a = config.version) != null ? _a : this.defaultClientVersion
86
+ },
87
+ {
88
+ capabilities: this.buildCapabilities(config)
89
+ }
90
+ );
91
+ this.applyNotificationHandlers(serverName, client);
92
+ this.applyElicitationHandler(serverName, client);
93
+ if (config.onError) {
94
+ client.onerror = (error) => {
95
+ var _a2;
96
+ (_a2 = config.onError) == null ? void 0 : _a2.call(config, error);
97
+ };
98
+ }
99
+ client.onclose = () => {
100
+ this.resetState(serverName, { preserveConfig: true });
101
+ };
102
+ let transport;
103
+ if (this.isStdioConfig(config)) {
104
+ transport = await this.connectViaStdio(client, config, timeout);
105
+ } else {
106
+ transport = await this.connectViaHttp(
107
+ serverName,
108
+ client,
109
+ config,
110
+ timeout
111
+ );
112
+ }
113
+ const managedState = {
114
+ config,
115
+ client,
116
+ transport,
117
+ timeout
118
+ };
119
+ this.clientStates.set(serverName, managedState);
120
+ this.pendingConnections.delete(serverName);
121
+ return client;
122
+ })().catch((error) => {
123
+ this.pendingConnections.delete(serverName);
124
+ this.clientStates.delete(serverName);
125
+ throw error;
126
+ });
127
+ this.pendingConnections.set(serverName, {
128
+ config,
129
+ timeout,
130
+ promise: connectionPromise
131
+ });
132
+ return connectionPromise;
133
+ }
134
+ async disconnectServer(name) {
135
+ const serverName = this.normalizeName(name);
136
+ const pending = this.pendingConnections.get(serverName);
137
+ if (pending) {
138
+ try {
139
+ await pending.promise;
140
+ } catch {
141
+ }
142
+ }
143
+ const state = this.clientStates.get(serverName);
144
+ if (!state) {
145
+ this.resetState(serverName, { preserveConfig: true });
146
+ return;
147
+ }
148
+ try {
149
+ await state.client.close();
150
+ } finally {
151
+ await this.safeCloseTransport(state.transport);
152
+ this.resetState(serverName, { preserveConfig: true });
153
+ }
154
+ }
155
+ async disconnectAllServers() {
156
+ const serverNames = this.listServers();
157
+ await Promise.all(serverNames.map((name) => this.disconnectServer(name)));
158
+ for (const name of serverNames) {
159
+ const serverName = this.normalizeName(name);
160
+ this.resetState(serverName, { preserveConfig: false });
161
+ this.notificationHandlers.delete(serverName);
162
+ this.elicitationHandlers.delete(serverName);
163
+ }
164
+ }
165
+ async listTools(name, params, options) {
166
+ const serverName = this.normalizeName(name);
167
+ await this.ensureConnected(serverName);
168
+ const client = this.getClientByName(serverName);
169
+ return client.listTools(params, this.withTimeout(serverName, options));
170
+ }
171
+ async getTools(names) {
172
+ const targetNames = names && names.length > 0 ? names.map((name) => this.normalizeName(name)) : this.listServers();
173
+ const uniqueNames = Array.from(new Set(targetNames));
174
+ const toolLists = await Promise.all(
175
+ uniqueNames.map(async (serverName) => {
176
+ await this.ensureConnected(serverName);
177
+ const client = this.getClientByName(serverName);
178
+ const result = await client.listTools(
179
+ void 0,
180
+ this.withTimeout(serverName)
181
+ );
182
+ return result.tools;
183
+ })
184
+ );
185
+ return { tools: toolLists.flat() };
186
+ }
187
+ async executeTool(name, toolName, args = {}, options) {
188
+ const serverName = this.normalizeName(name);
189
+ await this.ensureConnected(serverName);
190
+ const client = this.getClientByName(serverName);
191
+ return client.callTool(
192
+ {
193
+ name: toolName,
194
+ arguments: args
195
+ },
196
+ import_types.CallToolResultSchema,
197
+ this.withTimeout(serverName, options)
198
+ );
199
+ }
200
+ async listResources(name, params, options) {
201
+ const serverName = this.normalizeName(name);
202
+ await this.ensureConnected(serverName);
203
+ const client = this.getClientByName(serverName);
204
+ return client.listResources(params, this.withTimeout(serverName, options));
205
+ }
206
+ async readResource(name, params, options) {
207
+ const serverName = this.normalizeName(name);
208
+ await this.ensureConnected(serverName);
209
+ const client = this.getClientByName(serverName);
210
+ return client.readResource(params, this.withTimeout(serverName, options));
211
+ }
212
+ async subscribeResource(name, params, options) {
213
+ const serverName = this.normalizeName(name);
214
+ await this.ensureConnected(serverName);
215
+ const client = this.getClientByName(serverName);
216
+ return client.subscribeResource(
217
+ params,
218
+ this.withTimeout(serverName, options)
219
+ );
220
+ }
221
+ async unsubscribeResource(name, params, options) {
222
+ const serverName = this.normalizeName(name);
223
+ await this.ensureConnected(serverName);
224
+ const client = this.getClientByName(serverName);
225
+ return client.unsubscribeResource(
226
+ params,
227
+ this.withTimeout(serverName, options)
228
+ );
229
+ }
230
+ async listResourceTemplates(name, params, options) {
231
+ const serverName = this.normalizeName(name);
232
+ await this.ensureConnected(serverName);
233
+ const client = this.getClientByName(serverName);
234
+ return client.listResourceTemplates(
235
+ params,
236
+ this.withTimeout(serverName, options)
237
+ );
238
+ }
239
+ async listPrompts(name, params, options) {
240
+ const serverName = this.normalizeName(name);
241
+ await this.ensureConnected(serverName);
242
+ const client = this.getClientByName(serverName);
243
+ return client.listPrompts(params, this.withTimeout(serverName, options));
244
+ }
245
+ async getPrompt(name, params, options) {
246
+ const serverName = this.normalizeName(name);
247
+ await this.ensureConnected(serverName);
248
+ const client = this.getClientByName(serverName);
249
+ return client.getPrompt(params, this.withTimeout(serverName, options));
250
+ }
251
+ getSessionIdByServer(name) {
252
+ const state = this.clientStates.get(this.normalizeName(name));
253
+ if (!(state == null ? void 0 : state.transport)) {
254
+ throw new Error(`Unknown MCP server "${name}".`);
255
+ }
256
+ if (state.transport instanceof import_streamableHttp.StreamableHTTPClientTransport) {
257
+ return state.transport.sessionId;
258
+ }
259
+ throw new Error(
260
+ `Server "${name}" must be Streamable HTTP to get the session ID.`
261
+ );
262
+ }
263
+ addNotificationHandler(name, schema, handler) {
264
+ var _a, _b;
265
+ const serverName = this.normalizeName(name);
266
+ const handlers = (_a = this.notificationHandlers.get(serverName)) != null ? _a : [];
267
+ handlers.push({ schema, handler });
268
+ this.notificationHandlers.set(serverName, handlers);
269
+ const client = (_b = this.clientStates.get(serverName)) == null ? void 0 : _b.client;
270
+ if (client) {
271
+ client.setNotificationHandler(schema, handler);
272
+ }
273
+ }
274
+ onResourceListChanged(name, handler) {
275
+ this.addNotificationHandler(
276
+ name,
277
+ import_types.ResourceListChangedNotificationSchema,
278
+ handler
279
+ );
280
+ }
281
+ onResourceUpdated(name, handler) {
282
+ this.addNotificationHandler(
283
+ name,
284
+ import_types.ResourceUpdatedNotificationSchema,
285
+ handler
286
+ );
287
+ }
288
+ onPromptListChanged(name, handler) {
289
+ this.addNotificationHandler(
290
+ name,
291
+ import_types.PromptListChangedNotificationSchema,
292
+ handler
293
+ );
294
+ }
295
+ getClient(name) {
296
+ var _a;
297
+ return (_a = this.clientStates.get(this.normalizeName(name))) == null ? void 0 : _a.client;
298
+ }
299
+ setElicitationHandler(name, handler) {
300
+ var _a;
301
+ const serverName = this.normalizeName(name);
302
+ if (!this.serverConfigs.has(serverName)) {
303
+ throw new Error(`Unknown MCP server "${serverName}".`);
304
+ }
305
+ this.elicitationHandlers.set(serverName, handler);
306
+ const client = (_a = this.clientStates.get(serverName)) == null ? void 0 : _a.client;
307
+ if (client) {
308
+ this.applyElicitationHandler(serverName, client);
309
+ }
310
+ }
311
+ clearElicitationHandler(name) {
312
+ var _a;
313
+ const serverName = this.normalizeName(name);
314
+ this.elicitationHandlers.delete(serverName);
315
+ const client = (_a = this.clientStates.get(serverName)) == null ? void 0 : _a.client;
316
+ if (client) {
317
+ client.removeRequestHandler("elicitation/create");
318
+ }
319
+ }
320
+ async connectViaStdio(client, config, timeout) {
321
+ var _a;
322
+ const transport = new import_stdio.StdioClientTransport({
323
+ command: config.command,
324
+ args: config.args,
325
+ env: {
326
+ ...(0, import_stdio.getDefaultEnvironment)(),
327
+ ...(_a = config.env) != null ? _a : {}
328
+ }
329
+ });
330
+ await client.connect(transport, { timeout });
331
+ return transport;
332
+ }
333
+ async connectViaHttp(serverName, client, config, timeout) {
334
+ var _a;
335
+ const preferSSE = (_a = config.preferSSE) != null ? _a : config.url.pathname.endsWith("/sse");
336
+ let streamableError;
337
+ if (!preferSSE) {
338
+ const streamableTransport = new import_streamableHttp.StreamableHTTPClientTransport(
339
+ config.url,
340
+ {
341
+ requestInit: config.requestInit,
342
+ reconnectionOptions: config.reconnectionOptions,
343
+ authProvider: config.authProvider,
344
+ sessionId: config.sessionId
345
+ }
346
+ );
347
+ try {
348
+ await client.connect(streamableTransport, {
349
+ timeout: Math.min(timeout, 3e3)
350
+ });
351
+ return streamableTransport;
352
+ } catch (error) {
353
+ streamableError = error;
354
+ await this.safeCloseTransport(streamableTransport);
355
+ }
356
+ }
357
+ const sseTransport = new import_sse.SSEClientTransport(config.url, {
358
+ requestInit: config.requestInit,
359
+ eventSourceInit: config.eventSourceInit,
360
+ authProvider: config.authProvider
361
+ });
362
+ try {
363
+ await client.connect(sseTransport, { timeout });
364
+ return sseTransport;
365
+ } catch (error) {
366
+ await this.safeCloseTransport(sseTransport);
367
+ const streamableMessage = streamableError ? ` Streamable HTTP error: ${this.formatError(streamableError)}.` : "";
368
+ throw new Error(
369
+ `Failed to connect to MCP server "${serverName}" using HTTP transports.${streamableMessage} SSE error: ${this.formatError(error)}.`
370
+ );
371
+ }
372
+ }
373
+ async safeCloseTransport(transport) {
374
+ try {
375
+ await transport.close();
376
+ } catch {
377
+ }
378
+ }
379
+ applyNotificationHandlers(serverName, client) {
380
+ const handlers = this.notificationHandlers.get(serverName);
381
+ if (!handlers) {
382
+ return;
383
+ }
384
+ for (const { schema, handler } of handlers) {
385
+ client.setNotificationHandler(schema, handler);
386
+ }
387
+ }
388
+ applyElicitationHandler(serverName, client) {
389
+ const handler = this.elicitationHandlers.get(serverName);
390
+ if (!handler) {
391
+ return;
392
+ }
393
+ client.setRequestHandler(
394
+ import_types.ElicitRequestSchema,
395
+ async (request) => handler(request.params)
396
+ );
397
+ }
398
+ async ensureConnected(name) {
399
+ const serverName = this.normalizeName(name);
400
+ if (this.clientStates.has(serverName)) {
401
+ return;
402
+ }
403
+ const pending = this.pendingConnections.get(serverName);
404
+ if (pending) {
405
+ await pending.promise;
406
+ return;
407
+ }
408
+ const config = this.serverConfigs.get(serverName);
409
+ if (!config) {
410
+ throw new Error(`Unknown MCP server "${serverName}".`);
411
+ }
412
+ await this.connectToServer(serverName, config);
413
+ }
414
+ resetState(name, options) {
415
+ const serverName = this.normalizeName(name);
416
+ this.pendingConnections.delete(serverName);
417
+ this.clientStates.delete(serverName);
418
+ if (!options.preserveConfig) {
419
+ this.serverConfigs.delete(serverName);
420
+ }
421
+ }
422
+ withTimeout(name, options) {
423
+ var _a;
424
+ const serverName = this.normalizeName(name);
425
+ const connectedState = this.clientStates.get(serverName);
426
+ const serverConfig = this.serverConfigs.get(serverName);
427
+ const timeout = (_a = connectedState == null ? void 0 : connectedState.timeout) != null ? _a : serverConfig ? this.getTimeout(serverConfig) : this.defaultTimeout;
428
+ if (!options) {
429
+ return { timeout };
430
+ }
431
+ if (options.timeout === void 0) {
432
+ return { ...options, timeout };
433
+ }
434
+ return options;
435
+ }
436
+ buildCapabilities(config) {
437
+ var _a;
438
+ const capabilities = {
439
+ ...this.defaultCapabilities,
440
+ ...(_a = config.capabilities) != null ? _a : {}
441
+ };
442
+ if (!capabilities.elicitation) {
443
+ capabilities.elicitation = {};
444
+ }
445
+ return capabilities;
446
+ }
447
+ formatError(error) {
448
+ if (error instanceof Error) {
449
+ return error.message;
450
+ }
451
+ try {
452
+ return JSON.stringify(error);
453
+ } catch {
454
+ return String(error);
455
+ }
456
+ }
457
+ getTimeout(config) {
458
+ var _a;
459
+ return (_a = config.timeout) != null ? _a : this.defaultTimeout;
460
+ }
461
+ isStdioConfig(config) {
462
+ return "command" in config;
463
+ }
464
+ normalizeName(name) {
465
+ const normalized = name.trim();
466
+ if (!normalized) {
467
+ throw new Error("Server name must be a non-empty string.");
468
+ }
469
+ return normalized;
470
+ }
471
+ getClientByName(name) {
472
+ const serverName = this.normalizeName(name);
473
+ const state = this.clientStates.get(serverName);
474
+ if (!state) {
475
+ throw new Error(`MCP server "${serverName}" is not connected.`);
476
+ }
477
+ return state.client;
478
+ }
479
+ };
480
+ // Annotate the CommonJS export names for ESM import in node:
481
+ 0 && (module.exports = {
482
+ MCPClientManager,
483
+ mcpClientManager
484
+ });
485
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../index.ts","../mcp-client-manager/index.js"],"sourcesContent":["export * from \"./mcp-client-manager/index.js\";\nexport * as mcpClientManager from \"./mcp-client-manager/index.js\";\n","// index.ts\nimport { Client } from \"@modelcontextprotocol/sdk/client/index.js\";\nimport { SSEClientTransport } from \"@modelcontextprotocol/sdk/client/sse.js\";\nimport {\n getDefaultEnvironment,\n StdioClientTransport,\n} from \"@modelcontextprotocol/sdk/client/stdio.js\";\nimport { StreamableHTTPClientTransport } from \"@modelcontextprotocol/sdk/client/streamableHttp.js\";\nimport { DEFAULT_REQUEST_TIMEOUT_MSEC } from \"@modelcontextprotocol/sdk/shared/protocol.js\";\nimport {\n CallToolResultSchema,\n ElicitRequestSchema,\n ResourceListChangedNotificationSchema,\n ResourceUpdatedNotificationSchema,\n PromptListChangedNotificationSchema,\n} from \"@modelcontextprotocol/sdk/types.js\";\nvar MCPClientManager = class {\n constructor(servers = {}, options = {}) {\n this.clientStates = /* @__PURE__ */ new Map();\n this.pendingConnections = /* @__PURE__ */ new Map();\n this.serverConfigs = /* @__PURE__ */ new Map();\n this.notificationHandlers = /* @__PURE__ */ new Map();\n this.elicitationHandlers = /* @__PURE__ */ new Map();\n var _a, _b, _c;\n this.defaultClientVersion =\n (_a = options.defaultClientVersion) != null ? _a : \"1.0.0\";\n this.defaultCapabilities = {\n ...((_b = options.defaultCapabilities) != null ? _b : {}),\n };\n this.defaultTimeout =\n (_c = options.defaultTimeout) != null ? _c : DEFAULT_REQUEST_TIMEOUT_MSEC;\n for (const [name, config] of Object.entries(servers)) {\n void this.connectToServer(name, config);\n }\n }\n listServers() {\n return Array.from(this.serverConfigs.keys());\n }\n hasServer(name) {\n const serverName = this.normalizeName(name);\n return this.serverConfigs.has(serverName);\n }\n async connectToServer(name, config) {\n const serverName = this.normalizeName(name);\n this.serverConfigs.set(serverName, config);\n const timeout = this.getTimeout(config);\n const existingState = this.clientStates.get(serverName);\n if (existingState) {\n existingState.config = config;\n existingState.timeout = timeout;\n this.clientStates.set(serverName, existingState);\n return existingState.client;\n }\n const pendingState = this.pendingConnections.get(serverName);\n if (pendingState) {\n pendingState.config = config;\n pendingState.timeout = timeout;\n return pendingState.promise;\n }\n const connectionPromise = (async () => {\n var _a;\n const client = new Client(\n {\n name: serverName,\n version:\n (_a = config.version) != null ? _a : this.defaultClientVersion,\n },\n {\n capabilities: this.buildCapabilities(config),\n },\n );\n this.applyNotificationHandlers(serverName, client);\n this.applyElicitationHandler(serverName, client);\n if (config.onError) {\n client.onerror = (error) => {\n var _a2;\n (_a2 = config.onError) == null ? void 0 : _a2.call(config, error);\n };\n }\n client.onclose = () => {\n this.resetState(serverName, { preserveConfig: true });\n };\n let transport;\n if (this.isStdioConfig(config)) {\n transport = await this.connectViaStdio(client, config, timeout);\n } else {\n transport = await this.connectViaHttp(\n serverName,\n client,\n config,\n timeout,\n );\n }\n const managedState = {\n config,\n client,\n transport,\n timeout,\n };\n this.clientStates.set(serverName, managedState);\n this.pendingConnections.delete(serverName);\n return client;\n })().catch((error) => {\n this.pendingConnections.delete(serverName);\n this.clientStates.delete(serverName);\n throw error;\n });\n this.pendingConnections.set(serverName, {\n config,\n timeout,\n promise: connectionPromise,\n });\n return connectionPromise;\n }\n async disconnectServer(name) {\n const serverName = this.normalizeName(name);\n const pending = this.pendingConnections.get(serverName);\n if (pending) {\n try {\n await pending.promise;\n } catch {}\n }\n const state = this.clientStates.get(serverName);\n if (!state) {\n this.resetState(serverName, { preserveConfig: true });\n return;\n }\n try {\n await state.client.close();\n } finally {\n await this.safeCloseTransport(state.transport);\n this.resetState(serverName, { preserveConfig: true });\n }\n }\n async disconnectAllServers() {\n const serverNames = this.listServers();\n await Promise.all(serverNames.map((name) => this.disconnectServer(name)));\n for (const name of serverNames) {\n const serverName = this.normalizeName(name);\n this.resetState(serverName, { preserveConfig: false });\n this.notificationHandlers.delete(serverName);\n this.elicitationHandlers.delete(serverName);\n }\n }\n async listTools(name, params, options) {\n const serverName = this.normalizeName(name);\n await this.ensureConnected(serverName);\n const client = this.getClientByName(serverName);\n return client.listTools(params, this.withTimeout(serverName, options));\n }\n async getTools(names) {\n const targetNames =\n names && names.length > 0\n ? names.map((name) => this.normalizeName(name))\n : this.listServers();\n const uniqueNames = Array.from(new Set(targetNames));\n const toolLists = await Promise.all(\n uniqueNames.map(async (serverName) => {\n await this.ensureConnected(serverName);\n const client = this.getClientByName(serverName);\n const result = await client.listTools(\n void 0,\n this.withTimeout(serverName),\n );\n return result.tools;\n }),\n );\n return { tools: toolLists.flat() };\n }\n async executeTool(name, toolName, args = {}, options) {\n const serverName = this.normalizeName(name);\n await this.ensureConnected(serverName);\n const client = this.getClientByName(serverName);\n return client.callTool(\n {\n name: toolName,\n arguments: args,\n },\n CallToolResultSchema,\n this.withTimeout(serverName, options),\n );\n }\n async listResources(name, params, options) {\n const serverName = this.normalizeName(name);\n await this.ensureConnected(serverName);\n const client = this.getClientByName(serverName);\n return client.listResources(params, this.withTimeout(serverName, options));\n }\n async readResource(name, params, options) {\n const serverName = this.normalizeName(name);\n await this.ensureConnected(serverName);\n const client = this.getClientByName(serverName);\n return client.readResource(params, this.withTimeout(serverName, options));\n }\n async subscribeResource(name, params, options) {\n const serverName = this.normalizeName(name);\n await this.ensureConnected(serverName);\n const client = this.getClientByName(serverName);\n return client.subscribeResource(\n params,\n this.withTimeout(serverName, options),\n );\n }\n async unsubscribeResource(name, params, options) {\n const serverName = this.normalizeName(name);\n await this.ensureConnected(serverName);\n const client = this.getClientByName(serverName);\n return client.unsubscribeResource(\n params,\n this.withTimeout(serverName, options),\n );\n }\n async listResourceTemplates(name, params, options) {\n const serverName = this.normalizeName(name);\n await this.ensureConnected(serverName);\n const client = this.getClientByName(serverName);\n return client.listResourceTemplates(\n params,\n this.withTimeout(serverName, options),\n );\n }\n async listPrompts(name, params, options) {\n const serverName = this.normalizeName(name);\n await this.ensureConnected(serverName);\n const client = this.getClientByName(serverName);\n return client.listPrompts(params, this.withTimeout(serverName, options));\n }\n async getPrompt(name, params, options) {\n const serverName = this.normalizeName(name);\n await this.ensureConnected(serverName);\n const client = this.getClientByName(serverName);\n return client.getPrompt(params, this.withTimeout(serverName, options));\n }\n getSessionIdByServer(name) {\n const state = this.clientStates.get(this.normalizeName(name));\n if (!(state == null ? void 0 : state.transport)) {\n throw new Error(`Unknown MCP server \"${name}\".`);\n }\n if (state.transport instanceof StreamableHTTPClientTransport) {\n return state.transport.sessionId;\n }\n throw new Error(\n `Server \"${name}\" must be Streamable HTTP to get the session ID.`,\n );\n }\n addNotificationHandler(name, schema, handler) {\n var _a, _b;\n const serverName = this.normalizeName(name);\n const handlers =\n (_a = this.notificationHandlers.get(serverName)) != null ? _a : [];\n handlers.push({ schema, handler });\n this.notificationHandlers.set(serverName, handlers);\n const client =\n (_b = this.clientStates.get(serverName)) == null ? void 0 : _b.client;\n if (client) {\n client.setNotificationHandler(schema, handler);\n }\n }\n onResourceListChanged(name, handler) {\n this.addNotificationHandler(\n name,\n ResourceListChangedNotificationSchema,\n handler,\n );\n }\n onResourceUpdated(name, handler) {\n this.addNotificationHandler(\n name,\n ResourceUpdatedNotificationSchema,\n handler,\n );\n }\n onPromptListChanged(name, handler) {\n this.addNotificationHandler(\n name,\n PromptListChangedNotificationSchema,\n handler,\n );\n }\n getClient(name) {\n var _a;\n return (_a = this.clientStates.get(this.normalizeName(name))) == null\n ? void 0\n : _a.client;\n }\n setElicitationHandler(name, handler) {\n var _a;\n const serverName = this.normalizeName(name);\n if (!this.serverConfigs.has(serverName)) {\n throw new Error(`Unknown MCP server \"${serverName}\".`);\n }\n this.elicitationHandlers.set(serverName, handler);\n const client =\n (_a = this.clientStates.get(serverName)) == null ? void 0 : _a.client;\n if (client) {\n this.applyElicitationHandler(serverName, client);\n }\n }\n clearElicitationHandler(name) {\n var _a;\n const serverName = this.normalizeName(name);\n this.elicitationHandlers.delete(serverName);\n const client =\n (_a = this.clientStates.get(serverName)) == null ? void 0 : _a.client;\n if (client) {\n client.removeRequestHandler(\"elicitation/create\");\n }\n }\n async connectViaStdio(client, config, timeout) {\n var _a;\n const transport = new StdioClientTransport({\n command: config.command,\n args: config.args,\n env: {\n ...getDefaultEnvironment(),\n ...((_a = config.env) != null ? _a : {}),\n },\n });\n await client.connect(transport, { timeout });\n return transport;\n }\n async connectViaHttp(serverName, client, config, timeout) {\n var _a;\n const preferSSE =\n (_a = config.preferSSE) != null\n ? _a\n : config.url.pathname.endsWith(\"/sse\");\n let streamableError;\n if (!preferSSE) {\n const streamableTransport = new StreamableHTTPClientTransport(\n config.url,\n {\n requestInit: config.requestInit,\n reconnectionOptions: config.reconnectionOptions,\n authProvider: config.authProvider,\n sessionId: config.sessionId,\n },\n );\n try {\n await client.connect(streamableTransport, {\n timeout: Math.min(timeout, 3e3),\n });\n return streamableTransport;\n } catch (error) {\n streamableError = error;\n await this.safeCloseTransport(streamableTransport);\n }\n }\n const sseTransport = new SSEClientTransport(config.url, {\n requestInit: config.requestInit,\n eventSourceInit: config.eventSourceInit,\n authProvider: config.authProvider,\n });\n try {\n await client.connect(sseTransport, { timeout });\n return sseTransport;\n } catch (error) {\n await this.safeCloseTransport(sseTransport);\n const streamableMessage = streamableError\n ? ` Streamable HTTP error: ${this.formatError(streamableError)}.`\n : \"\";\n throw new Error(\n `Failed to connect to MCP server \"${serverName}\" using HTTP transports.${streamableMessage} SSE error: ${this.formatError(error)}.`,\n );\n }\n }\n async safeCloseTransport(transport) {\n try {\n await transport.close();\n } catch {}\n }\n applyNotificationHandlers(serverName, client) {\n const handlers = this.notificationHandlers.get(serverName);\n if (!handlers) {\n return;\n }\n for (const { schema, handler } of handlers) {\n client.setNotificationHandler(schema, handler);\n }\n }\n applyElicitationHandler(serverName, client) {\n const handler = this.elicitationHandlers.get(serverName);\n if (!handler) {\n return;\n }\n client.setRequestHandler(ElicitRequestSchema, async (request) =>\n handler(request.params),\n );\n }\n async ensureConnected(name) {\n const serverName = this.normalizeName(name);\n if (this.clientStates.has(serverName)) {\n return;\n }\n const pending = this.pendingConnections.get(serverName);\n if (pending) {\n await pending.promise;\n return;\n }\n const config = this.serverConfigs.get(serverName);\n if (!config) {\n throw new Error(`Unknown MCP server \"${serverName}\".`);\n }\n await this.connectToServer(serverName, config);\n }\n resetState(name, options) {\n const serverName = this.normalizeName(name);\n this.pendingConnections.delete(serverName);\n this.clientStates.delete(serverName);\n if (!options.preserveConfig) {\n this.serverConfigs.delete(serverName);\n }\n }\n withTimeout(name, options) {\n var _a;\n const serverName = this.normalizeName(name);\n const connectedState = this.clientStates.get(serverName);\n const serverConfig = this.serverConfigs.get(serverName);\n const timeout =\n (_a = connectedState == null ? void 0 : connectedState.timeout) != null\n ? _a\n : serverConfig\n ? this.getTimeout(serverConfig)\n : this.defaultTimeout;\n if (!options) {\n return { timeout };\n }\n if (options.timeout === void 0) {\n return { ...options, timeout };\n }\n return options;\n }\n buildCapabilities(config) {\n var _a;\n const capabilities = {\n ...this.defaultCapabilities,\n ...((_a = config.capabilities) != null ? _a : {}),\n };\n if (!capabilities.elicitation) {\n capabilities.elicitation = {};\n }\n return capabilities;\n }\n formatError(error) {\n if (error instanceof Error) {\n return error.message;\n }\n try {\n return JSON.stringify(error);\n } catch {\n return String(error);\n }\n }\n getTimeout(config) {\n var _a;\n return (_a = config.timeout) != null ? _a : this.defaultTimeout;\n }\n isStdioConfig(config) {\n return \"command\" in config;\n }\n normalizeName(name) {\n const normalized = name.trim();\n if (!normalized) {\n throw new Error(\"Server name must be a non-empty string.\");\n }\n return normalized;\n }\n getClientByName(name) {\n const serverName = this.normalizeName(name);\n const state = this.clientStates.get(serverName);\n if (!state) {\n throw new Error(`MCP server \"${serverName}\" is not connected.`);\n }\n return state.client;\n }\n};\nexport { MCPClientManager };\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AACA,oBAAuB;AACvB,iBAAmC;AACnC,mBAGO;AACP,4BAA8C;AAC9C,sBAA6C;AAC7C,mBAMO;AACP,IAAI,mBAAmB,MAAM;AAAA,EAC3B,YAAY,UAAU,CAAC,GAAG,UAAU,CAAC,GAAG;AACtC,SAAK,eAA+B,oBAAI,IAAI;AAC5C,SAAK,qBAAqC,oBAAI,IAAI;AAClD,SAAK,gBAAgC,oBAAI,IAAI;AAC7C,SAAK,uBAAuC,oBAAI,IAAI;AACpD,SAAK,sBAAsC,oBAAI,IAAI;AACnD,QAAI,IAAI,IAAI;AACZ,SAAK,wBACF,KAAK,QAAQ,yBAAyB,OAAO,KAAK;AACrD,SAAK,sBAAsB;AAAA,MACzB,IAAK,KAAK,QAAQ,wBAAwB,OAAO,KAAK,CAAC;AAAA,IACzD;AACA,SAAK,kBACF,KAAK,QAAQ,mBAAmB,OAAO,KAAK;AAC/C,eAAW,CAAC,MAAM,MAAM,KAAK,OAAO,QAAQ,OAAO,GAAG;AACpD,WAAK,KAAK,gBAAgB,MAAM,MAAM;AAAA,IACxC;AAAA,EACF;AAAA,EACA,cAAc;AACZ,WAAO,MAAM,KAAK,KAAK,cAAc,KAAK,CAAC;AAAA,EAC7C;AAAA,EACA,UAAU,MAAM;AACd,UAAM,aAAa,KAAK,cAAc,IAAI;AAC1C,WAAO,KAAK,cAAc,IAAI,UAAU;AAAA,EAC1C;AAAA,EACA,MAAM,gBAAgB,MAAM,QAAQ;AAClC,UAAM,aAAa,KAAK,cAAc,IAAI;AAC1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O,iBAAiB,OAAO,KAAK,CAAC;AAAA,IACjD;AACA,QAAI,CAAC,aAAa,aAAa;AAC7B,mBAAa,cAAc,CAAC;AAAA,IAC9B;AACA,WAAO;AAAA,EACT;AAAA,EACA,YAAY,OAAO;AACjB,QAAI,iBAAiB,OAAO;AAC1B,aAAO,MAAM;AAAA,IACf;AACA,QAAI;AACF,aAAO,KAAK,UAAU,KAAK;AAAA,IAC7B,QAAQ;AACN,aAAO,OAAO,KAAK;AAAA,IACrB;AAAA,EACF;AAAA,EACA,WAAW,QAAQ;AACjB,QAAI;AACJ,YAAQ,KAAK,OAAO,YAAY,OAAO,KAAK,KAAK;AAAA,EACnD;AAAA,EACA,cAAc,QAAQ;AACpB,WAAO,aAAa;AAAA,EACtB;AAAA,EACA,cAAc,MAAM;AAClB,UAAM,aAAa,KAAK,KAAK;AAC7B,QAAI,CAAC,YAAY;AACf,YAAM,IAAI,MAAM,yCAAyC;AAAA,IAC3D;AACA,WAAO;AAAA,EACT;AAAA,EACA,gBAAgB,MAAM;AACpB,UAAM,aAAa,KAAK,cAAc,IAAI;AAC1C,UAAM,QAAQ,KAAK,aAAa,IAAI,UAAU;AAC9C,QAAI,CAAC,OAAO;AACV,YAAM,IAAI,MAAM,eAAe,UAAU,qBAAqB;AAAA,IAChE;AACA,WAAO,MAAM;AAAA,EACf;AACF;","names":[]}
@@ -0,0 +1,9 @@
1
+ export { ElicitationHandler, ExecuteToolArguments, MCPClientManager, MCPClientManagerConfig, MCPConnectionStatus, MCPConvertedToolSet, MCPGetPromptResult, MCPPrompt, MCPPromptListResult, MCPReadResourceResult, MCPResource, MCPResourceListResult, MCPServerConfig, MCPServerSummary, MCPToolSchemaOverrides, i as mcpClientManager } from './mcp-client-manager/index.cjs';
2
+ import 'zod';
3
+ import '@modelcontextprotocol/sdk/client/index.js';
4
+ import '@modelcontextprotocol/sdk/client/sse.js';
5
+ import '@modelcontextprotocol/sdk/client/streamableHttp.js';
6
+ import '@modelcontextprotocol/sdk/shared/protocol.js';
7
+ import '@modelcontextprotocol/sdk/types.js';
8
+ import 'ai';
9
+ import '@ai-sdk/provider-utils';
@@ -0,0 +1,9 @@
1
+ export { ElicitationHandler, ExecuteToolArguments, MCPClientManager, MCPClientManagerConfig, MCPConnectionStatus, MCPConvertedToolSet, MCPGetPromptResult, MCPPrompt, MCPPromptListResult, MCPReadResourceResult, MCPResource, MCPResourceListResult, MCPServerConfig, MCPServerSummary, MCPToolSchemaOverrides, i as mcpClientManager } from './mcp-client-manager/index.js';
2
+ import 'zod';
3
+ import '@modelcontextprotocol/sdk/client/index.js';
4
+ import '@modelcontextprotocol/sdk/client/sse.js';
5
+ import '@modelcontextprotocol/sdk/client/streamableHttp.js';
6
+ import '@modelcontextprotocol/sdk/shared/protocol.js';
7
+ import '@modelcontextprotocol/sdk/types.js';
8
+ import 'ai';
9
+ import '@ai-sdk/provider-utils';