(error: Error)
| 202 | * We check both signals to avoid false positives from generic 404s (wrong URL, server gone, etc.). |
| 203 | */ |
| 204 | export function isMcpSessionExpiredError(error: Error): boolean { |
| 205 | const httpStatus = |
| 206 | 'code' in error ? (error as Error & { code?: number }).code : undefined |
| 207 | if (httpStatus !== 404) { |
| 208 | return false |
| 209 | } |
| 210 | // The SDK embeds the response body text in the error message. |
| 211 | // MCP servers return: {"error":{"code":-32001,"message":"Session not found"},...} |
| 212 | // Check for the JSON-RPC error code to distinguish from generic web server 404s. |
| 213 | return ( |
| 214 | error.message.includes('"code":-32001') || |
| 215 | error.message.includes('"code": -32001') |
| 216 | ) |
| 217 | } |
| 218 | |
| 219 | /** |
| 220 | * Default timeout for MCP tool calls (effectively infinite - ~27.8 hours). |
no outgoing calls
no test coverage detected