( error: unknown, request?: NextRequest )
| 87 | } |
| 88 | |
| 89 | export function mcpBodyReadErrorResponse( |
| 90 | error: unknown, |
| 91 | request?: NextRequest |
| 92 | ): NextResponse | null { |
| 93 | if (!(error instanceof McpBodyReadError)) { |
| 94 | return null |
| 95 | } |
| 96 | if (error.kind === 'aborted' || request?.signal.aborted) { |
| 97 | return createMcpErrorResponse(error.cause, 'Client cancelled request', 499) |
| 98 | } |
| 99 | if (error.kind === 'payload_too_large') { |
| 100 | return createMcpErrorResponse( |
| 101 | error.cause, |
| 102 | 'MCP management request body exceeds maximum size', |
| 103 | 413 |
| 104 | ) |
| 105 | } |
| 106 | return createMcpErrorResponse(error.cause, 'Invalid request body', 400) |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * Validates MCP authentication and authorization |
no test coverage detected