@ateam-ai/mcp 0.3.17 → 0.3.19

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/http.js +12 -40
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ateam-ai/mcp",
3
- "version": "0.3.17",
3
+ "version": "0.3.19",
4
4
  "mcpName": "io.github.ariekogan/ateam-mcp",
5
5
  "description": "A-Team MCP Server — build, validate, and deploy multi-agent solutions from any AI environment",
6
6
  "type": "module",
package/src/http.js CHANGED
@@ -242,48 +242,20 @@ export function startHttpServer(port = 3100) {
242
242
  await server.connect(transport);
243
243
 
244
244
  if (isStaleRecovery) {
245
- // Synthesize an initialize handshake so the SDK transport is in "ready" state
246
- // before we dispatch the real request. We call handleRequest twice: once with a
247
- // fake initialize (response is discarded), then with the real payload.
248
- const fakeInit = {
249
- jsonrpc: "2.0",
250
- id: `__auto_init_${newSessionId}`,
251
- method: "initialize",
252
- params: {
253
- protocolVersion: "2025-03-26",
254
- capabilities: {},
255
- clientInfo: { name: "auto-reinit", version: "1.0" },
256
- },
257
- };
258
- // Mock response object that swallows the init response
259
- const mockRes = {
260
- _h: {},
261
- statusCode: 200,
262
- headersSent: false,
263
- setHeader(k, v) { this._h[k.toLowerCase()] = v; },
264
- getHeader(k) { return this._h[k.toLowerCase()]; },
265
- removeHeader(k) { delete this._h[k.toLowerCase()]; },
266
- writeHead() { return this; },
267
- write() { return true; },
268
- end() { this.headersSent = true; return this; },
269
- json() { return this; },
270
- status() { return this; },
271
- on() {},
272
- once() {},
273
- emit() {},
274
- };
275
- // Strip the stale session-id header so the SDK treats this as a new init
276
- const initReq = { ...req, headers: { ...req.headers } };
277
- delete initReq.headers["mcp-session-id"];
278
- try {
279
- await transport.handleRequest(initReq, mockRes, fakeInit);
280
- } catch (e) {
281
- console.error("[HTTP] Auto-reinit synthetic initialize failed:", e.message);
245
+ // Force the underlying web-standard transport into "initialized" state without
246
+ // requiring a real initialize handshake. This bypasses the SDK's built-in check
247
+ // (`Bad Request: Server not initialized`) so the non-initialize request dispatches.
248
+ const inner = transport._webStandardTransport;
249
+ console.log(`[HTTP] auto-reinit debug: inner=${!!inner} initBefore=${inner?._initialized} sidBefore=${inner?.sessionId}`);
250
+ if (inner) {
251
+ inner.sessionId = newSessionId;
252
+ inner._initialized = true;
253
+ console.log(`[HTTP] auto-reinit debug: initAfter=${inner._initialized} sidAfter=${inner.sessionId}`);
254
+ } else {
255
+ console.log(`[HTTP] auto-reinit debug: transport keys = ${Object.keys(transport)}`);
282
256
  }
283
- // Ensure the transport is registered under the new id and update the real request
284
257
  transports[newSessionId] = transport;
285
- // Overwrite the client-supplied (stale) session-id with the new one so the SDK
286
- // routes the real request to the freshly-initialized transport.
258
+ // Rewrite the request's session-id header so SDK session validation passes.
287
259
  req.headers["mcp-session-id"] = newSessionId;
288
260
  // Tell the client about the new session id so future requests use it.
289
261
  res.setHeader("mcp-session-id", newSessionId);