( transport: string, message: string, cause: unknown, )
| 179 | }); |
| 180 | |
| 181 | const connectionFailure = ( |
| 182 | transport: string, |
| 183 | message: string, |
| 184 | cause: unknown, |
| 185 | ): McpConnectionError | McpOAuthReauthorizationRequired => { |
| 186 | if (Predicate.isTagged(cause, "McpOAuthReauthorizationRequired")) { |
| 187 | return new McpOAuthReauthorizationRequired({ message: "MCP OAuth re-authorization required" }); |
| 188 | } |
| 189 | // Carry the handshake HTTP status structurally (and in the message for |
| 190 | // humans) so the liveness health check can classify a rejected credential |
| 191 | // as expired rather than a generic connection failure. |
| 192 | const status = httpStatusFromCause(cause); |
| 193 | return new McpConnectionError({ |
| 194 | transport, |
| 195 | message: status === undefined ? message : `${message} (HTTP ${status})`, |
| 196 | ...(status === undefined ? {} : { httpStatus: status }), |
| 197 | }); |
| 198 | }; |
| 199 | |
| 200 | const connectClient = (input: { |
| 201 | transport: string; |
no test coverage detected