| 159 | /** The class name and stable code of an SDK rejection, for the defect log. |
| 160 | * Structural only: the message is deliberately not read here. */ |
| 161 | const summarizeSdkFailure = (cause: unknown): { name: string; code?: string | number } => { |
| 162 | // oxlint-disable-next-line executor/no-instanceof-error -- boundary: the MCP SDK rejects with Error subclasses whose constructor name is the only class discriminator for non-branded errors |
| 163 | const name = cause instanceof Error ? cause.constructor.name : typeof cause; |
| 164 | const code = Predicate.hasProperty(cause, "code") ? cause.code : undefined; |
| 165 | return typeof code === "string" || typeof code === "number" ? { name, code } : { name }; |
| 166 | }; |
| 167 | |
| 168 | /** A 4xx other than the auth walls, with a JSON body that names the problem, |
| 169 | * is the server refusing THIS call (a validation failure at the HTTP layer) |