( status: number | undefined, cause: unknown, )
| 170 | * — not a dead transport. 401/403 keep their auth classification; 5xx and |
| 171 | * bodyless 4xx stay opaque, since there is nothing the caller can act on. */ |
| 172 | const httpRefusal = ( |
| 173 | status: number | undefined, |
| 174 | cause: unknown, |
| 175 | ): { readonly httpRefusal: { readonly status: number; readonly message: string } } | {} => { |
| 176 | if (status === undefined || status < 400 || status >= 500 || status === 401 || status === 403) { |
| 177 | return {}; |
| 178 | } |
| 179 | const message = httpRefusalMessageFromCause(cause); |
| 180 | return message === undefined ? {} : { httpRefusal: { status, message } }; |
| 181 | }; |
| 182 | |
| 183 | const asProtocolError = (cause: unknown): ProtocolError | undefined => { |
| 184 | const sdk = mcpClientSdkIfLoaded(); |
no test coverage detected