* Return true when an MCP tool-call result carries an application-level error * payload, regardless of whether the transport-level `isError` flag was set. * * Safe-output handlers encode errors as `{"result":"error", ...}` inside the * first content text item. This helper provides a defense-in-
(result)
| 499 | * @returns {boolean} |
| 500 | */ |
| 501 | function sampleResultIsError(result) { |
| 502 | if (!result) return false; |
| 503 | if (result.isError) return true; |
| 504 | const text = result.content && result.content[0] && result.content[0].text; |
| 505 | if (!text) return false; |
| 506 | try { |
| 507 | const parsed = JSON.parse(text); |
| 508 | return !!(parsed && parsed.result === "error"); |
| 509 | } catch { |
| 510 | return false; |
| 511 | } |
| 512 | } |
| 513 | |
| 514 | /** |
| 515 | * Append a synthetic terminal_reason: completed marker to the engine stdio log |
no test coverage detected