MCPcopy Index your code
hub / github.com/codeaashu/claude-code / isMcpSessionExpiredError

Function isMcpSessionExpiredError

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

Source from the content-addressed store, hash-verified

191 * We check both signals to avoid false positives from generic 404s (wrong URL, server gone, etc.).
192 */
193export function isMcpSessionExpiredError(error: Error): boolean {
194 const httpStatus =
195 'code' in error ? (error as Error & { code?: number }).code : undefined
196 if (httpStatus !== 404) {
197 return false
198 }
199 // The SDK embeds the response body text in the error message.
200 // MCP servers return: {"error":{"code":-32001,"message":"Session not found"},...}
201 // Check for the JSON-RPC error code to distinguish from generic web server 404s.
202 return (
203 error.message.includes('"code":-32001') ||
204 error.message.includes('"code": -32001')
205 )
206}
207
208/**
209 * 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