{
  "id": "ku_876f08e4d7da2e881577fb00be994241",
  "version": 1,
  "domains": [
    "mcp",
    "streamable-http",
    "client",
    "sessions"
  ],
  "insight": {
    "summary": "Every call fails with HTTP 404 and JSON-RPC error -32001 \"Session not found\" after the server restarted, scaled, or expired your session.",
    "detail": "MCP transport spec (2025-11-25): the server MAY terminate a session at any time and MUST then answer requests carrying that MCP-Session-Id with 404. A client that receives 404 for a request with a session id MUST start a new session with a fresh initialize and no session id. Clients that retry with the same id loop on the 404.",
    "action": "On a 404 for a request that carried MCP-Session-Id, drop the id, initialize again, then repeat the request once. Do not repeat a mutating call whose outcome you did not see."
  },
  "context": {
    "languages": [
      "typescript"
    ],
    "frameworks": [
      "@modelcontextprotocol/sdk"
    ],
    "pattern": "session-recovery"
  },
  "evidence": {
    "confidence": 0.85,
    "confirmations": 1,
    "first_observed": "2026-12-02T00:00:00Z",
    "last_confirmed": "2026-12-02T00:00:00Z"
  },
  "tier": "public",
  "created_by": "neomorphic:house",
  "flags": [],
  "extensions": {
    "neomorphic:title": "MCP \"Session not found\" (404, -32001): the client keeps sending a dead session id",
    "neomorphic:signature": {
      "surface": "mcp",
      "provider": "mcp",
      "code": "streamable-http-session-not-found",
      "http": 404,
      "versions": "@modelcontextprotocol/sdk 1.31.0 reproduced",
      "environment": "Streamable HTTP with sessions",
      "key": "mcp/mcp/streamable-http-session-not-found"
    },
    "neomorphic:status": "fixed",
    "neomorphic:fix": {
      "summary": "On a 404 for a request that carried MCP-Session-Id, drop the id, initialize again, then repeat the request once. Do not repeat a mutating call whose outcome you did not see.",
      "snippet": {
        "lang": "ts",
        "text": "async function call(body: object): Promise<Response> {\n  let r = await post(body, sessionId);\n  if (r.status === 404 && sessionId) {\n    sessionId = undefined;\n    const init = await post(initializeRequest, undefined);\n    sessionId = init.headers.get('mcp-session-id') ?? undefined;\n    await post({ jsonrpc: '2.0', method: 'notifications/initialized' }, sessionId);\n    r = await post(body, sessionId); // safe for reads; for writes, check first\n  }\n  return r;\n}"
      }
    },
    "neomorphic:sources": [
      {
        "kind": "doc",
        "url": "https://modelcontextprotocol.io/specification/2025-11-25/basic/transports",
        "observed_at": "2026-12-02",
        "note": "When a client receives HTTP 404 in response to a request containing an MCP-Session-Id, it MUST start a new session by sending a new InitializeRequest without a session ID attached."
      },
      {
        "kind": "observation",
        "observed_at": "2026-12-02",
        "note": "Reproduced on @modelcontextprotocol/sdk 1.31.0: a request with an unknown MCP-Session-Id returned 404 with code -32001 \"Session not found\"."
      }
    ],
    "neomorphic:author": {
      "kind": "house",
      "name": "Neomorphic"
    },
    "neomorphic:escalation": "mcp-a2a",
    "neomorphic:observed_at": "2026-12-02",
    "neomorphic:updated_at": "2026-12-02",
    "neomorphic:stale_after": "2027-06-01"
  }
}
