(
status: number,
code: number,
message: string,
opts?: {
readonly cors?: boolean;
readonly challenge?: string;
readonly retryAfterSeconds?: number;
},
)
| 128 | * local — the four hand-rolled copies are deleted in favor of this. |
| 129 | */ |
| 130 | export const jsonRpcErrorBody = ( |
| 131 | status: number, |
| 132 | code: number, |
| 133 | message: string, |
| 134 | opts?: { |
| 135 | readonly cors?: boolean; |
| 136 | readonly challenge?: string; |
| 137 | readonly retryAfterSeconds?: number; |
| 138 | }, |
| 139 | ): Response => { |
| 140 | const cors = opts?.cors ?? true; |
| 141 | const challenge = opts?.challenge; |
| 142 | const retryAfterSeconds = opts?.retryAfterSeconds; |
| 143 | return new Response(JSON.stringify({ jsonrpc: "2.0", error: { code, message }, id: null }), { |
| 144 | status, |
| 145 | headers: { |
| 146 | "content-type": "application/json", |
| 147 | ...(cors ? { "access-control-allow-origin": "*" } : {}), |
| 148 | ...(challenge |
| 149 | ? { |
| 150 | "www-authenticate": challenge, |
| 151 | "access-control-expose-headers": "WWW-Authenticate", |
| 152 | } |
| 153 | : {}), |
| 154 | ...(retryAfterSeconds === undefined ? {} : { "retry-after": String(retryAfterSeconds) }), |
| 155 | }, |
| 156 | }); |
| 157 | }; |
| 158 | |
| 159 | /** Graceful rollback response that lets auto-negotiating v2 clients try legacy. */ |
| 160 | export const mcpModernDisabledResponse = (opts?: { readonly cors?: boolean }): Response => |
no outgoing calls
no test coverage detected