MCPcopy Create free account
hub / github.com/Noumena-Network/code / isMcpSessionExpiredError

Function isMcpSessionExpiredError

src/services/mcp/client.ts:204–217  ·  view source on GitHub ↗
(error: Error)

Source from the content-addressed store, hash-verified

202 * We check both signals to avoid false positives from generic 404s (wrong URL, server gone, etc.).
203 */
204export 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).

Callers 2

client.tsFile · 0.85
callMCPToolFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected