@alfe.ai/mcp-bundler 0.3.2 → 0.4.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/dist/index.cjs +87 -26
- package/dist/index.d.cts +55 -5
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +55 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +87 -26
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -90,6 +90,9 @@ var Connection = class Connection {
|
|
|
90
90
|
static RECONNECT_BACKOFF_MAX_MS = 3e4;
|
|
91
91
|
onUnexpectedClose;
|
|
92
92
|
onStderrLine;
|
|
93
|
+
connectTimeoutMs;
|
|
94
|
+
/** Whether any connect has ever been attempted — drives the eager retry sweep. */
|
|
95
|
+
connectAttempted = false;
|
|
93
96
|
constructor(params) {
|
|
94
97
|
this.name = params.name;
|
|
95
98
|
this.config = params.config;
|
|
@@ -97,6 +100,7 @@ var Connection = class Connection {
|
|
|
97
100
|
this.logger = params.logger;
|
|
98
101
|
this.onUnexpectedClose = params.onUnexpectedClose;
|
|
99
102
|
this.onStderrLine = params.onStderrLine;
|
|
103
|
+
this.connectTimeoutMs = params.connectTimeoutMs ?? 0;
|
|
100
104
|
}
|
|
101
105
|
/** Returns the most recent known tool list. May be empty if the server hasn't connected yet. */
|
|
102
106
|
snapshotTools() {
|
|
@@ -118,6 +122,15 @@ var Connection = class Connection {
|
|
|
118
122
|
lastErrorMessage() {
|
|
119
123
|
return this.lastError;
|
|
120
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* Whether a connect was ever attempted (success or failure). A reconciled
|
|
127
|
+
* connection that was never warmed has neither a client nor a `lastError` —
|
|
128
|
+
* this flag lets an eager host's retry sweep find it without also
|
|
129
|
+
* resurrecting cleanly-closed (idle-reaped) connections.
|
|
130
|
+
*/
|
|
131
|
+
hasConnectAttempted() {
|
|
132
|
+
return this.connectAttempted;
|
|
133
|
+
}
|
|
121
134
|
/** Idle timestamp for reaping. */
|
|
122
135
|
idleSinceMs() {
|
|
123
136
|
return Date.now() - this.lastUsedAt;
|
|
@@ -136,23 +149,33 @@ var Connection = class Connection {
|
|
|
136
149
|
return this.connectInFlight;
|
|
137
150
|
}
|
|
138
151
|
async connectAndDiscover() {
|
|
152
|
+
this.connectAttempted = true;
|
|
139
153
|
const safeConfig = "command" in this.config ? {
|
|
140
154
|
...this.config,
|
|
141
155
|
env: sanitizeStdioEnv(this.config.env)
|
|
142
156
|
} : this.config;
|
|
143
157
|
this.logger?.debug(`[mcp-bundler] connecting server "${this.name}"`);
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
client = await this.deps.connect(safeConfig, {
|
|
158
|
+
const attempt = (async () => {
|
|
159
|
+
const c = await this.deps.connect(safeConfig, {
|
|
147
160
|
serverName: this.name,
|
|
148
161
|
onStderrLine: this.onStderrLine
|
|
149
162
|
});
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
163
|
+
try {
|
|
164
|
+
return {
|
|
165
|
+
client: c,
|
|
166
|
+
advertised: await c.listTools()
|
|
167
|
+
};
|
|
168
|
+
} catch (err) {
|
|
169
|
+
await c.close().catch(() => void 0);
|
|
170
|
+
throw err;
|
|
171
|
+
}
|
|
172
|
+
})();
|
|
173
|
+
try {
|
|
174
|
+
const { client, advertised } = await this.raceConnectTimeout(attempt);
|
|
175
|
+
this.client = client;
|
|
153
176
|
this.closing = false;
|
|
154
|
-
|
|
155
|
-
this.handleUnexpectedClose(
|
|
177
|
+
client.onClose?.(() => {
|
|
178
|
+
this.handleUnexpectedClose(client);
|
|
156
179
|
});
|
|
157
180
|
this.tools = advertised.map((t) => ({
|
|
158
181
|
prefixed: buildNamespacedToolName(this.name, t.name),
|
|
@@ -168,7 +191,7 @@ var Connection = class Connection {
|
|
|
168
191
|
this.reconnectBlockedUntilMs = 0;
|
|
169
192
|
this.logger?.info(`[mcp-bundler] server "${this.name}" connected, ${this.tools.length.toString()} tool(s)`);
|
|
170
193
|
} catch (err) {
|
|
171
|
-
|
|
194
|
+
attempt.then(({ client }) => client.close()).catch(() => void 0);
|
|
172
195
|
this.consecutiveFailures += 1;
|
|
173
196
|
this.lastError = err instanceof Error ? err.message : String(err);
|
|
174
197
|
const backoff = Math.min(Connection.RECONNECT_BACKOFF_BASE_MS * 2 ** (this.consecutiveFailures - 1), Connection.RECONNECT_BACKOFF_MAX_MS);
|
|
@@ -176,6 +199,23 @@ var Connection = class Connection {
|
|
|
176
199
|
throw err;
|
|
177
200
|
}
|
|
178
201
|
}
|
|
202
|
+
/** Race the attempt against `connectTimeoutMs`; 0 disables the bound. */
|
|
203
|
+
async raceConnectTimeout(attempt) {
|
|
204
|
+
const ms = this.connectTimeoutMs;
|
|
205
|
+
if (ms <= 0) return attempt;
|
|
206
|
+
let timer;
|
|
207
|
+
const timeout = new Promise((_, reject) => {
|
|
208
|
+
timer = setTimeout(() => {
|
|
209
|
+
reject(/* @__PURE__ */ new Error(`server "${this.name}" connect timed out after ${ms.toString()}ms — spawned but did not complete the MCP handshake/discovery`));
|
|
210
|
+
}, ms);
|
|
211
|
+
if (typeof timer === "object" && "unref" in timer) timer.unref();
|
|
212
|
+
});
|
|
213
|
+
try {
|
|
214
|
+
return await Promise.race([attempt, timeout]);
|
|
215
|
+
} finally {
|
|
216
|
+
clearTimeout(timer);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
179
219
|
/**
|
|
180
220
|
* Handle an unexpected transport close (crash / network drop). Clears the
|
|
181
221
|
* dead client + tools so the next `ensureConnected` re-spawns. No-op if we
|
|
@@ -336,6 +376,7 @@ async function defaultConnect(server, ctx) {
|
|
|
336
376
|
const DEFAULT_IDLE_TTL_MS = 600 * 1e3;
|
|
337
377
|
const DEFAULT_IDLE_SWEEP_INTERVAL_MS = 60 * 1e3;
|
|
338
378
|
const DEFAULT_RETRY_SWEEP_INTERVAL_MS = 60 * 1e3;
|
|
379
|
+
const DEFAULT_CONNECT_TIMEOUT_MS = 120 * 1e3;
|
|
339
380
|
/** First text content of an error result, for host error reporting. */
|
|
340
381
|
function extractErrorText(result) {
|
|
341
382
|
for (const item of result.content) if (item.type === "text" && typeof item.text === "string") return item.text.slice(0, 500);
|
|
@@ -359,6 +400,8 @@ var McpBundler = class {
|
|
|
359
400
|
retrySweepIntervalMs;
|
|
360
401
|
retrySweepTimer;
|
|
361
402
|
retrySweepInFlight = false;
|
|
403
|
+
connectTimeoutMs;
|
|
404
|
+
retryNeverConnected;
|
|
362
405
|
deps;
|
|
363
406
|
onToolError;
|
|
364
407
|
onServerCrash;
|
|
@@ -370,6 +413,8 @@ var McpBundler = class {
|
|
|
370
413
|
this.idleTtlMs = opts.idleTtlMs ?? DEFAULT_IDLE_TTL_MS;
|
|
371
414
|
this.idleSweepIntervalMs = opts.idleSweepIntervalMs ?? DEFAULT_IDLE_SWEEP_INTERVAL_MS;
|
|
372
415
|
this.retrySweepIntervalMs = opts.retrySweepIntervalMs ?? DEFAULT_RETRY_SWEEP_INTERVAL_MS;
|
|
416
|
+
this.connectTimeoutMs = opts.connectTimeoutMs ?? DEFAULT_CONNECT_TIMEOUT_MS;
|
|
417
|
+
this.retryNeverConnected = opts.retryNeverConnected ?? false;
|
|
373
418
|
this.deps = deps ?? { connect: defaultConnect };
|
|
374
419
|
this.onToolError = opts.onToolError;
|
|
375
420
|
this.onServerCrash = opts.onServerCrash;
|
|
@@ -386,6 +431,7 @@ var McpBundler = class {
|
|
|
386
431
|
config,
|
|
387
432
|
deps: this.deps,
|
|
388
433
|
logger: this.logger,
|
|
434
|
+
connectTimeoutMs: config.connectionTimeoutMs ?? this.connectTimeoutMs,
|
|
389
435
|
...crash ? { onUnexpectedClose: () => {
|
|
390
436
|
crash(name);
|
|
391
437
|
} } : {},
|
|
@@ -504,15 +550,20 @@ var McpBundler = class {
|
|
|
504
550
|
* 500ms → 30s cap). A server that keeps `exit(1)`-ing fast-fails while in
|
|
505
551
|
* backoff, so repeated sweeps are cheap and never become a tight crash-loop
|
|
506
552
|
* — the backoff widens with each failure. Servers that connect on their
|
|
507
|
-
* first warm
|
|
508
|
-
*
|
|
553
|
+
* first warm are left alone, as are cleanly-closed (idle-reaped) ones.
|
|
554
|
+
*
|
|
555
|
+
* Lazily-added servers that were NEVER attempted (no client, no
|
|
556
|
+
* `lastError`) are also left alone by default — but with
|
|
557
|
+
* `retryNeverConnected` (the daemon's eager mode) the sweep picks them up,
|
|
558
|
+
* so a server added after the host's warmup pass self-heals within one
|
|
559
|
+
* sweep instead of stranding its tools until a restart.
|
|
509
560
|
*
|
|
510
561
|
* Returns the statuses of the servers it attempted (empty if none needed a
|
|
511
562
|
* retry). Never throws — per-server failures are reflected in the status.
|
|
512
563
|
*/
|
|
513
564
|
async retryFailed() {
|
|
514
565
|
if (this.disposed) return [];
|
|
515
|
-
const targets = Array.from(this.connections.values()).filter((conn) => !conn.isConnected() && conn.lastErrorMessage() !== void 0);
|
|
566
|
+
const targets = Array.from(this.connections.values()).filter((conn) => !conn.isConnected() && (conn.lastErrorMessage() !== void 0 || this.retryNeverConnected && !conn.hasConnectAttempted()));
|
|
516
567
|
if (targets.length === 0) return [];
|
|
517
568
|
return (await Promise.allSettled(targets.map(async (conn) => {
|
|
518
569
|
try {
|
|
@@ -991,8 +1042,11 @@ var Manager = class {
|
|
|
991
1042
|
/**
|
|
992
1043
|
* Register or overwrite a server entry. Mutation lands in the store
|
|
993
1044
|
* synchronously; if a bundler has been attached via `loadIntoBundler`,
|
|
994
|
-
* it
|
|
995
|
-
* thrown — the store is the source of truth, the bundler is
|
|
1045
|
+
* it is re-reconciled BEFORE `onChange` listeners fire (errors logged,
|
|
1046
|
+
* never thrown — the store is the source of truth, the bundler is
|
|
1047
|
+
* derived). The ordering is load-bearing: the daemon's `onChange`
|
|
1048
|
+
* handler warms the bundler's current connections, so the just-added
|
|
1049
|
+
* server must already have its Connection object or it is never warmed.
|
|
996
1050
|
*/
|
|
997
1051
|
async addServer(config, opts) {
|
|
998
1052
|
if (!opts.id) throw new Error("Manager.addServer: id is required");
|
|
@@ -1013,9 +1067,8 @@ var Manager = class {
|
|
|
1013
1067
|
}
|
|
1014
1068
|
};
|
|
1015
1069
|
});
|
|
1016
|
-
this.
|
|
1070
|
+
await this.reconcileBundlerLogged();
|
|
1017
1071
|
this.fireChange();
|
|
1018
|
-
return Promise.resolve();
|
|
1019
1072
|
}
|
|
1020
1073
|
/**
|
|
1021
1074
|
* Remove a single server entry. No-op if the id isn't in the store.
|
|
@@ -1023,17 +1076,17 @@ var Manager = class {
|
|
|
1023
1076
|
* when supplied — the CLI uses this to guard `alfe mcp remove` from
|
|
1024
1077
|
* accidentally clobbering integration- or cli-owned entries.
|
|
1025
1078
|
*/
|
|
1026
|
-
removeServer(id, opts = {}) {
|
|
1079
|
+
async removeServer(id, opts = {}) {
|
|
1027
1080
|
const existing = lookupEntry(this.store.read().servers, id);
|
|
1028
|
-
if (!existing) return
|
|
1029
|
-
if (opts.expectedOwner && existing.owner !== opts.expectedOwner)
|
|
1081
|
+
if (!existing) return false;
|
|
1082
|
+
if (opts.expectedOwner && existing.owner !== opts.expectedOwner) throw new Error(`Manager.removeServer: server "${id}" is owned by "${existing.owner}", not "${opts.expectedOwner}"`);
|
|
1030
1083
|
this.store.update((cur) => ({
|
|
1031
1084
|
...cur,
|
|
1032
1085
|
servers: Object.fromEntries(Object.entries(cur.servers).filter(([k]) => k !== id))
|
|
1033
1086
|
}));
|
|
1034
|
-
this.
|
|
1087
|
+
await this.reconcileBundlerLogged();
|
|
1035
1088
|
this.fireChange();
|
|
1036
|
-
return
|
|
1089
|
+
return true;
|
|
1037
1090
|
}
|
|
1038
1091
|
/** Drop every entry whose owner matches — used by integration uninstall. */
|
|
1039
1092
|
async removeServersByOwner(owner) {
|
|
@@ -1049,10 +1102,10 @@ var Manager = class {
|
|
|
1049
1102
|
};
|
|
1050
1103
|
});
|
|
1051
1104
|
if (removed.length > 0) {
|
|
1052
|
-
this.
|
|
1105
|
+
await this.reconcileBundlerLogged();
|
|
1053
1106
|
this.fireChange();
|
|
1054
1107
|
}
|
|
1055
|
-
return
|
|
1108
|
+
return removed;
|
|
1056
1109
|
}
|
|
1057
1110
|
/** Read-only snapshot for `alfe mcp list` and similar UIs. */
|
|
1058
1111
|
listServers() {
|
|
@@ -1122,11 +1175,19 @@ var Manager = class {
|
|
|
1122
1175
|
this.bundler = void 0;
|
|
1123
1176
|
return Promise.resolve();
|
|
1124
1177
|
}
|
|
1125
|
-
|
|
1178
|
+
/**
|
|
1179
|
+
* Awaited by every mutator so `onChange` listeners observe a bundler
|
|
1180
|
+
* that already contains the mutation. Reconcile failures are logged,
|
|
1181
|
+
* never thrown — a mutation must not fail because the derived bundler
|
|
1182
|
+
* hiccuped.
|
|
1183
|
+
*/
|
|
1184
|
+
async reconcileBundlerLogged() {
|
|
1126
1185
|
if (!this.bundler) return;
|
|
1127
|
-
|
|
1186
|
+
try {
|
|
1187
|
+
await this.reconcileBundler();
|
|
1188
|
+
} catch (err) {
|
|
1128
1189
|
this.logger?.warn("[mcp-bundler/manager] bundler reconcile failed", { err: errMsg(err) });
|
|
1129
|
-
}
|
|
1190
|
+
}
|
|
1130
1191
|
}
|
|
1131
1192
|
async reconcileBundler() {
|
|
1132
1193
|
if (!this.bundler) return;
|
package/dist/index.d.cts
CHANGED
|
@@ -9,6 +9,8 @@ interface StdioServerConfig {
|
|
|
9
9
|
args?: string[];
|
|
10
10
|
env?: Record<string, string>;
|
|
11
11
|
cwd?: string;
|
|
12
|
+
/** Per-server connect+discovery bound (ms) — overrides `BundlerOptions.connectTimeoutMs`. */
|
|
13
|
+
connectionTimeoutMs?: number;
|
|
12
14
|
}
|
|
13
15
|
interface RemoteServerConfig {
|
|
14
16
|
url: string;
|
|
@@ -101,6 +103,24 @@ interface BundlerOptions {
|
|
|
101
103
|
* outer bound that keeps re-checking.
|
|
102
104
|
*/
|
|
103
105
|
retrySweepIntervalMs?: number;
|
|
106
|
+
/**
|
|
107
|
+
* Upper bound (ms) on one connect + tool-discovery attempt. A hung child —
|
|
108
|
+
* or a cold `npx` download that never completes the MCP handshake — throws
|
|
109
|
+
* past this bound, which records `lastError` and arms reconnect backoff so
|
|
110
|
+
* the retry sweep can re-attempt. Without a bound such a server has no
|
|
111
|
+
* error, no diagnostics, and no self-heal path. Per-server
|
|
112
|
+
* `connectionTimeoutMs` overrides. 0 disables. Default: 120_000 (generous
|
|
113
|
+
* enough for a cold `npx` package download).
|
|
114
|
+
*/
|
|
115
|
+
connectTimeoutMs?: number;
|
|
116
|
+
/**
|
|
117
|
+
* Also have the retry sweep attempt servers that have NEVER had a connect
|
|
118
|
+
* attempt (e.g. added after the host's warmup pass already ran). Off by
|
|
119
|
+
* default to preserve pure-lazy embedding semantics; the daemon — which
|
|
120
|
+
* eagerly warms everything — enables it so a missed warm self-heals within
|
|
121
|
+
* one sweep instead of stranding the server's tools until a restart.
|
|
122
|
+
*/
|
|
123
|
+
retryNeverConnected?: boolean;
|
|
104
124
|
/**
|
|
105
125
|
* Host hook fired when a tool call fails — thrown or `isError` result.
|
|
106
126
|
* Invoked best-effort (exceptions swallowed); must not block.
|
|
@@ -191,6 +211,9 @@ declare class Connection {
|
|
|
191
211
|
private static readonly RECONNECT_BACKOFF_MAX_MS;
|
|
192
212
|
private readonly onUnexpectedClose;
|
|
193
213
|
private readonly onStderrLine;
|
|
214
|
+
private readonly connectTimeoutMs;
|
|
215
|
+
/** Whether any connect has ever been attempted — drives the eager retry sweep. */
|
|
216
|
+
private connectAttempted;
|
|
194
217
|
constructor(params: {
|
|
195
218
|
name: string;
|
|
196
219
|
config: McpServerConfig;
|
|
@@ -200,6 +223,8 @@ declare class Connection {
|
|
|
200
223
|
onUnexpectedClose?: () => void;
|
|
201
224
|
/** Threaded to the connect factory — pipes stdio child stderr when set. */
|
|
202
225
|
onStderrLine?: (line: string) => void;
|
|
226
|
+
/** Bound (ms) on one connect + discovery attempt. 0/undefined disables. */
|
|
227
|
+
connectTimeoutMs?: number;
|
|
203
228
|
});
|
|
204
229
|
/** Returns the most recent known tool list. May be empty if the server hasn't connected yet. */
|
|
205
230
|
snapshotTools(): McpToolDescriptor[];
|
|
@@ -211,6 +236,13 @@ declare class Connection {
|
|
|
211
236
|
failureCount(): number;
|
|
212
237
|
/** Message from the most recent failed connect attempt, if any. */
|
|
213
238
|
lastErrorMessage(): string | undefined;
|
|
239
|
+
/**
|
|
240
|
+
* Whether a connect was ever attempted (success or failure). A reconciled
|
|
241
|
+
* connection that was never warmed has neither a client nor a `lastError` —
|
|
242
|
+
* this flag lets an eager host's retry sweep find it without also
|
|
243
|
+
* resurrecting cleanly-closed (idle-reaped) connections.
|
|
244
|
+
*/
|
|
245
|
+
hasConnectAttempted(): boolean;
|
|
214
246
|
/** Idle timestamp for reaping. */
|
|
215
247
|
idleSinceMs(): number;
|
|
216
248
|
/**
|
|
@@ -219,6 +251,8 @@ declare class Connection {
|
|
|
219
251
|
*/
|
|
220
252
|
ensureConnected(): Promise<void>;
|
|
221
253
|
private connectAndDiscover;
|
|
254
|
+
/** Race the attempt against `connectTimeoutMs`; 0 disables the bound. */
|
|
255
|
+
private raceConnectTimeout;
|
|
222
256
|
/**
|
|
223
257
|
* Handle an unexpected transport close (crash / network drop). Clears the
|
|
224
258
|
* dead client + tools so the next `ensureConnected` re-spawns. No-op if we
|
|
@@ -271,6 +305,8 @@ declare class McpBundler {
|
|
|
271
305
|
private readonly retrySweepIntervalMs;
|
|
272
306
|
private retrySweepTimer;
|
|
273
307
|
private retrySweepInFlight;
|
|
308
|
+
private readonly connectTimeoutMs;
|
|
309
|
+
private readonly retryNeverConnected;
|
|
274
310
|
private readonly deps;
|
|
275
311
|
private readonly onToolError;
|
|
276
312
|
private readonly onServerCrash;
|
|
@@ -320,8 +356,13 @@ declare class McpBundler {
|
|
|
320
356
|
* 500ms → 30s cap). A server that keeps `exit(1)`-ing fast-fails while in
|
|
321
357
|
* backoff, so repeated sweeps are cheap and never become a tight crash-loop
|
|
322
358
|
* — the backoff widens with each failure. Servers that connect on their
|
|
323
|
-
* first warm
|
|
324
|
-
*
|
|
359
|
+
* first warm are left alone, as are cleanly-closed (idle-reaped) ones.
|
|
360
|
+
*
|
|
361
|
+
* Lazily-added servers that were NEVER attempted (no client, no
|
|
362
|
+
* `lastError`) are also left alone by default — but with
|
|
363
|
+
* `retryNeverConnected` (the daemon's eager mode) the sweep picks them up,
|
|
364
|
+
* so a server added after the host's warmup pass self-heals within one
|
|
365
|
+
* sweep instead of stranding its tools until a restart.
|
|
325
366
|
*
|
|
326
367
|
* Returns the statuses of the servers it attempted (empty if none needed a
|
|
327
368
|
* retry). Never throws — per-server failures are reflected in the status.
|
|
@@ -544,8 +585,11 @@ declare class Manager {
|
|
|
544
585
|
/**
|
|
545
586
|
* Register or overwrite a server entry. Mutation lands in the store
|
|
546
587
|
* synchronously; if a bundler has been attached via `loadIntoBundler`,
|
|
547
|
-
* it
|
|
548
|
-
* thrown — the store is the source of truth, the bundler is
|
|
588
|
+
* it is re-reconciled BEFORE `onChange` listeners fire (errors logged,
|
|
589
|
+
* never thrown — the store is the source of truth, the bundler is
|
|
590
|
+
* derived). The ordering is load-bearing: the daemon's `onChange`
|
|
591
|
+
* handler warms the bundler's current connections, so the just-added
|
|
592
|
+
* server must already have its Connection object or it is never warmed.
|
|
549
593
|
*/
|
|
550
594
|
addServer(config: McpServerConfig, opts: AddServerOptions): Promise<void>;
|
|
551
595
|
/**
|
|
@@ -596,7 +640,13 @@ declare class Manager {
|
|
|
596
640
|
* shared instance survives multi-manager environments (rare).
|
|
597
641
|
*/
|
|
598
642
|
dispose(): Promise<void>;
|
|
599
|
-
|
|
643
|
+
/**
|
|
644
|
+
* Awaited by every mutator so `onChange` listeners observe a bundler
|
|
645
|
+
* that already contains the mutation. Reconcile failures are logged,
|
|
646
|
+
* never thrown — a mutation must not fail because the derived bundler
|
|
647
|
+
* hiccuped.
|
|
648
|
+
*/
|
|
649
|
+
private reconcileBundlerLogged;
|
|
600
650
|
private reconcileBundler;
|
|
601
651
|
private fireChange;
|
|
602
652
|
}
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/connection.ts","../src/bundler.ts","../src/tool-naming.ts","../src/store.ts","../src/manager.ts","../src/pattern-a-validator.ts"],"mappings":";;AAIA;;;AAAkD,KAAtC,eAAA,GAAkB,iBAAoB,GAAA,kBAAA;AAAkB,UAEnD,iBAAA,CAFmD;EAEnD,OAAA,EAAA,MAAA;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/connection.ts","../src/bundler.ts","../src/tool-naming.ts","../src/store.ts","../src/manager.ts","../src/pattern-a-validator.ts"],"mappings":";;AAIA;;;AAAkD,KAAtC,eAAA,GAAkB,iBAAoB,GAAA,kBAAA;AAAkB,UAEnD,iBAAA,CAFmD;EAEnD,OAAA,EAAA,MAAA;EASA,IAAA,CAAA,EAAA,MAAA,EAAA;EAOL,GAAA,CAAA,EAbJ,MAaI,CAAA,MAAgB,EAAA,MAAA,CAAA;EAKX,GAAA,CAAA,EAAA,MAAA;EAeA;EAaA,mBAAe,CAAA,EAAA,MAAA;AAahC;AAAuB,UArDN,kBAAA,CAqDM;KACO,EAAA,MAAA;WACD,CAAA,EAAA,KAAA,GAAA,iBAAA;SACA,CAAA,EArDjB,MAqDiB,CAAA,MAAA,EAAA,MAAA,CAAA;qBACC,CAAA,EAAA,MAAA;;AAGb,KArDL,gBAAA,GAqDsB,OACvB,GAAA,KAAM,GAAA,iBAAA;AAKjB;AAkBA;;AACW,UAzEM,iBAAA,CAyEN;;EAoC4B,QAAA,EAAA,MAAA;;;;ECpI1B,QAAA,EAAA,MAAA;EAUG;EAAgB,KAAA,EAAA,MAAA;;aAA2C,EAAA,MAAA;EAAM;EAWhE,UAAA,EDcH,MCdiB,CAAA,MAAA,EAAA,OAAA,CAAA;AAU/B;AAA+B,UDOd,aAAA,CCPc;OAOX,EAAA,MAAA,EAAA;SAAuB,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AAU;;;;;;;;;;;;AAqOT,iBItKE,aAAA,CJsKF,KAAA,EAAA,SIrKI,eJqKJ,EAAA,EAAA,OAAA,EIpKH,eJoKG,CAAA,EInKX,iBJmKW,EAAA;;;;;AAgE2D,iBI/KzD,cAAA,CJ+KyD,KAAA,EAAA,SI9KvD,eJ8KuD,EAAA,EAAA,OAAA,EI7K9D,eJ6K8D,CAAA,EAAA,IAAA;;;;;;AC3TzE;AAIgB,iBG0JA,iBAAA,CH1JuB,UAAA,EG0JO,iBH1JP,CAAA,EG0J2B,eH1J3B;AAcvC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ interface StdioServerConfig {
|
|
|
9
9
|
args?: string[];
|
|
10
10
|
env?: Record<string, string>;
|
|
11
11
|
cwd?: string;
|
|
12
|
+
/** Per-server connect+discovery bound (ms) — overrides `BundlerOptions.connectTimeoutMs`. */
|
|
13
|
+
connectionTimeoutMs?: number;
|
|
12
14
|
}
|
|
13
15
|
interface RemoteServerConfig {
|
|
14
16
|
url: string;
|
|
@@ -101,6 +103,24 @@ interface BundlerOptions {
|
|
|
101
103
|
* outer bound that keeps re-checking.
|
|
102
104
|
*/
|
|
103
105
|
retrySweepIntervalMs?: number;
|
|
106
|
+
/**
|
|
107
|
+
* Upper bound (ms) on one connect + tool-discovery attempt. A hung child —
|
|
108
|
+
* or a cold `npx` download that never completes the MCP handshake — throws
|
|
109
|
+
* past this bound, which records `lastError` and arms reconnect backoff so
|
|
110
|
+
* the retry sweep can re-attempt. Without a bound such a server has no
|
|
111
|
+
* error, no diagnostics, and no self-heal path. Per-server
|
|
112
|
+
* `connectionTimeoutMs` overrides. 0 disables. Default: 120_000 (generous
|
|
113
|
+
* enough for a cold `npx` package download).
|
|
114
|
+
*/
|
|
115
|
+
connectTimeoutMs?: number;
|
|
116
|
+
/**
|
|
117
|
+
* Also have the retry sweep attempt servers that have NEVER had a connect
|
|
118
|
+
* attempt (e.g. added after the host's warmup pass already ran). Off by
|
|
119
|
+
* default to preserve pure-lazy embedding semantics; the daemon — which
|
|
120
|
+
* eagerly warms everything — enables it so a missed warm self-heals within
|
|
121
|
+
* one sweep instead of stranding the server's tools until a restart.
|
|
122
|
+
*/
|
|
123
|
+
retryNeverConnected?: boolean;
|
|
104
124
|
/**
|
|
105
125
|
* Host hook fired when a tool call fails — thrown or `isError` result.
|
|
106
126
|
* Invoked best-effort (exceptions swallowed); must not block.
|
|
@@ -191,6 +211,9 @@ declare class Connection {
|
|
|
191
211
|
private static readonly RECONNECT_BACKOFF_MAX_MS;
|
|
192
212
|
private readonly onUnexpectedClose;
|
|
193
213
|
private readonly onStderrLine;
|
|
214
|
+
private readonly connectTimeoutMs;
|
|
215
|
+
/** Whether any connect has ever been attempted — drives the eager retry sweep. */
|
|
216
|
+
private connectAttempted;
|
|
194
217
|
constructor(params: {
|
|
195
218
|
name: string;
|
|
196
219
|
config: McpServerConfig;
|
|
@@ -200,6 +223,8 @@ declare class Connection {
|
|
|
200
223
|
onUnexpectedClose?: () => void;
|
|
201
224
|
/** Threaded to the connect factory — pipes stdio child stderr when set. */
|
|
202
225
|
onStderrLine?: (line: string) => void;
|
|
226
|
+
/** Bound (ms) on one connect + discovery attempt. 0/undefined disables. */
|
|
227
|
+
connectTimeoutMs?: number;
|
|
203
228
|
});
|
|
204
229
|
/** Returns the most recent known tool list. May be empty if the server hasn't connected yet. */
|
|
205
230
|
snapshotTools(): McpToolDescriptor[];
|
|
@@ -211,6 +236,13 @@ declare class Connection {
|
|
|
211
236
|
failureCount(): number;
|
|
212
237
|
/** Message from the most recent failed connect attempt, if any. */
|
|
213
238
|
lastErrorMessage(): string | undefined;
|
|
239
|
+
/**
|
|
240
|
+
* Whether a connect was ever attempted (success or failure). A reconciled
|
|
241
|
+
* connection that was never warmed has neither a client nor a `lastError` —
|
|
242
|
+
* this flag lets an eager host's retry sweep find it without also
|
|
243
|
+
* resurrecting cleanly-closed (idle-reaped) connections.
|
|
244
|
+
*/
|
|
245
|
+
hasConnectAttempted(): boolean;
|
|
214
246
|
/** Idle timestamp for reaping. */
|
|
215
247
|
idleSinceMs(): number;
|
|
216
248
|
/**
|
|
@@ -219,6 +251,8 @@ declare class Connection {
|
|
|
219
251
|
*/
|
|
220
252
|
ensureConnected(): Promise<void>;
|
|
221
253
|
private connectAndDiscover;
|
|
254
|
+
/** Race the attempt against `connectTimeoutMs`; 0 disables the bound. */
|
|
255
|
+
private raceConnectTimeout;
|
|
222
256
|
/**
|
|
223
257
|
* Handle an unexpected transport close (crash / network drop). Clears the
|
|
224
258
|
* dead client + tools so the next `ensureConnected` re-spawns. No-op if we
|
|
@@ -271,6 +305,8 @@ declare class McpBundler {
|
|
|
271
305
|
private readonly retrySweepIntervalMs;
|
|
272
306
|
private retrySweepTimer;
|
|
273
307
|
private retrySweepInFlight;
|
|
308
|
+
private readonly connectTimeoutMs;
|
|
309
|
+
private readonly retryNeverConnected;
|
|
274
310
|
private readonly deps;
|
|
275
311
|
private readonly onToolError;
|
|
276
312
|
private readonly onServerCrash;
|
|
@@ -320,8 +356,13 @@ declare class McpBundler {
|
|
|
320
356
|
* 500ms → 30s cap). A server that keeps `exit(1)`-ing fast-fails while in
|
|
321
357
|
* backoff, so repeated sweeps are cheap and never become a tight crash-loop
|
|
322
358
|
* — the backoff widens with each failure. Servers that connect on their
|
|
323
|
-
* first warm
|
|
324
|
-
*
|
|
359
|
+
* first warm are left alone, as are cleanly-closed (idle-reaped) ones.
|
|
360
|
+
*
|
|
361
|
+
* Lazily-added servers that were NEVER attempted (no client, no
|
|
362
|
+
* `lastError`) are also left alone by default — but with
|
|
363
|
+
* `retryNeverConnected` (the daemon's eager mode) the sweep picks them up,
|
|
364
|
+
* so a server added after the host's warmup pass self-heals within one
|
|
365
|
+
* sweep instead of stranding its tools until a restart.
|
|
325
366
|
*
|
|
326
367
|
* Returns the statuses of the servers it attempted (empty if none needed a
|
|
327
368
|
* retry). Never throws — per-server failures are reflected in the status.
|
|
@@ -544,8 +585,11 @@ declare class Manager {
|
|
|
544
585
|
/**
|
|
545
586
|
* Register or overwrite a server entry. Mutation lands in the store
|
|
546
587
|
* synchronously; if a bundler has been attached via `loadIntoBundler`,
|
|
547
|
-
* it
|
|
548
|
-
* thrown — the store is the source of truth, the bundler is
|
|
588
|
+
* it is re-reconciled BEFORE `onChange` listeners fire (errors logged,
|
|
589
|
+
* never thrown — the store is the source of truth, the bundler is
|
|
590
|
+
* derived). The ordering is load-bearing: the daemon's `onChange`
|
|
591
|
+
* handler warms the bundler's current connections, so the just-added
|
|
592
|
+
* server must already have its Connection object or it is never warmed.
|
|
549
593
|
*/
|
|
550
594
|
addServer(config: McpServerConfig, opts: AddServerOptions): Promise<void>;
|
|
551
595
|
/**
|
|
@@ -596,7 +640,13 @@ declare class Manager {
|
|
|
596
640
|
* shared instance survives multi-manager environments (rare).
|
|
597
641
|
*/
|
|
598
642
|
dispose(): Promise<void>;
|
|
599
|
-
|
|
643
|
+
/**
|
|
644
|
+
* Awaited by every mutator so `onChange` listeners observe a bundler
|
|
645
|
+
* that already contains the mutation. Reconcile failures are logged,
|
|
646
|
+
* never thrown — a mutation must not fail because the derived bundler
|
|
647
|
+
* hiccuped.
|
|
648
|
+
*/
|
|
649
|
+
private reconcileBundlerLogged;
|
|
600
650
|
private reconcileBundler;
|
|
601
651
|
private fireChange;
|
|
602
652
|
}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/connection.ts","../src/bundler.ts","../src/tool-naming.ts","../src/store.ts","../src/manager.ts","../src/pattern-a-validator.ts"],"mappings":";;AAIA;;;AAAkD,KAAtC,eAAA,GAAkB,iBAAoB,GAAA,kBAAA;AAAkB,UAEnD,iBAAA,CAFmD;EAEnD,OAAA,EAAA,MAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/connection.ts","../src/bundler.ts","../src/tool-naming.ts","../src/store.ts","../src/manager.ts","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