teapot-coding-agent 0.37.51 → 0.37.53

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.
@@ -176,8 +176,31 @@ export class McpRegistry {
176
176
  st.status = "disabled";
177
177
  return st;
178
178
  }
179
- if (st.status === "connected" && st.connection)
180
- return st;
179
+ if (st.status === "connected" && st.connection) {
180
+ /**
181
+ * A cached connection is not proof the server is still there.
182
+ *
183
+ * This used to return immediately, so a server that restarted kept `status: "connected"` with
184
+ * its OLD tool list while the transport underneath was dead. The UI's `test` button opened a
185
+ * FRESH connection (`testConfig`), so it reported success and the tools appeared — and the
186
+ * agent, going through this cached path, could not call any of them. Reported as "test をすると
187
+ * 接続に成功するのに、エージェントからは呼べない".
188
+ *
189
+ * A cheap liveness probe settles it: a server that answers is reused, one that does not is
190
+ * dropped so the reconnect below builds a new transport. `tools()` is the cheapest call that
191
+ * exercises the transport for real (unlike reading the cached list).
192
+ */
193
+ try {
194
+ st.tools = await st.connection.tools();
195
+ st.lastChecked = Date.now();
196
+ return st;
197
+ }
198
+ catch {
199
+ st.connection = undefined;
200
+ st.tools = [];
201
+ st.status = "disconnected";
202
+ }
203
+ }
181
204
  st.status = "connecting";
182
205
  st.lastError = undefined;
183
206
  const auth = await this.authFor(name);
@@ -254,6 +277,22 @@ export class McpRegistry {
254
277
  return { ok: r.ok, text: r.text };
255
278
  }
256
279
  catch (err) {
280
+ /**
281
+ * A failed call means the transport is suspect, not just this one call.
282
+ *
283
+ * Leaving `status: "connected"` made the next attempt reuse the same dead connection, so one
284
+ * server restart broke every subsequent call until the process restarted. Dropping the
285
+ * connection here lets `connect()` rebuild it on the next attempt — and the tools list is
286
+ * cleared with it, because a stale list is what let the UI show tools that could not be called.
287
+ */
288
+ const st = this.servers.get(parts.server);
289
+ if (st) {
290
+ st.connection = undefined;
291
+ st.tools = [];
292
+ st.status = "disconnected";
293
+ st.lastError = err.message;
294
+ st.lastChecked = Date.now();
295
+ }
257
296
  return { ok: false, text: `MCP call failed: ${err.message}` };
258
297
  }
259
298
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teapot-coding-agent",
3
- "version": "0.37.51",
3
+ "version": "0.37.53",
4
4
  "description": "A lightweight, always-on multi-agent harness for AI coding agents",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-or-later",