| @@ -12,8 +12,9 @@ | ||
| 12 | 12 | exit; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | use ZipAI\MCP\Classes\Core\Helper; |
| 16 | +use ZipAI\MCP\Classes\Core\Response; | |
| 16 | 17 | use ZipAI\MCP\Classes\Core\Utils; |
| 17 | 18 | use ZipAI\MCP\Classes\Security\Protected_Options_Filter; |
| 18 | 19 | |
| 19 | 20 | // Explicit require — composer's classmap autoloader may not pick up |
| @@ -420,8 +421,11 @@ | ||
| 420 | 421 | ); |
| 421 | 422 | } |
| 422 | 423 | |
| 423 | 424 | if ( is_wp_error( $result ) ) { |
| 425 | + // Same envelope as every other refusal — the code rides in `data.code` | |
| 426 | + // (Response::from_wp_error), never top-level, so the brain has ONE | |
| 427 | + // shape to read. | |
| 424 | 428 | return $this->format_mcp_response( |
| 425 | 429 | $id, |
| 426 | 430 | array( |
| 427 | 431 | 'content' => array( |
| @@ -426,15 +430,9 @@ | ||
| 426 | 430 | array( |
| 427 | 431 | 'content' => array( |
| 428 | 432 | array( |
| 429 | 433 | 'type' => 'text', |
| 430 | - 'text' => wp_json_encode( | |
| 431 | - array( | |
| 432 | - 'success' => false, | |
| 433 | - 'error' => $result->get_error_message(), | |
| 434 | - 'code' => $result->get_error_code(), | |
| 435 | - ) | |
| 436 | - ), | |
| 434 | + 'text' => wp_json_encode( Response::from_wp_error( $result ) ), | |
| 437 | 435 | ), |
| 438 | 436 | ), |
| 439 | 437 | 'isError' => true, |
| 440 | 438 | ) |