ameliabooking
/
vendor
/
wordpress
/
mcp-adapter
/
includes
/
Transport
/
Infrastructure
/
HttpRequestContext.php
ameliabooking
/
vendor
/
wordpress
/
mcp-adapter
/
includes
/
Transport
/
Infrastructure
Last commit date
HttpRequestContext.php
1 month ago
HttpRequestHandler.php
1 month ago
HttpSessionValidator.php
1 month ago
JsonRpcResponseBuilder.php
1 month ago
McpTransportContext.php
1 month ago
McpTransportHelperTrait.php
1 month ago
RequestRouter.php
1 month ago
SessionManager.php
1 month ago
HttpRequestContext.php
76 lines
| 1 | <?php |
| 2 | /** |
| 3 | * MCP HTTP Transport for WordPress - MCP 2025-11-25 Compliant |
| 4 | * |
| 5 | * @package McpAdapter |
| 6 | */ |
| 7 | declare( strict_types=1 ); |
| 8 | |
| 9 | namespace WP\MCP\Transport\Infrastructure; |
| 10 | |
| 11 | /** |
| 12 | * A simple data carrier for HTTP request context. |
| 13 | * Properties are public for easy access but should be treated as read-only after construction. |
| 14 | */ |
| 15 | class HttpRequestContext { |
| 16 | |
| 17 | /** |
| 18 | * The original WordPress REST request object. |
| 19 | * |
| 20 | * @var \WP_REST_Request<array<string, mixed>> |
| 21 | */ |
| 22 | public \WP_REST_Request $request; |
| 23 | |
| 24 | /** |
| 25 | * The HTTP method of the request. |
| 26 | * |
| 27 | * @var string |
| 28 | */ |
| 29 | public string $method; |
| 30 | |
| 31 | |
| 32 | /** |
| 33 | * The Mcp-Session-Id header from the request. |
| 34 | * |
| 35 | * @var string|null |
| 36 | */ |
| 37 | public ?string $session_id; |
| 38 | |
| 39 | /** |
| 40 | * The JSON-decoded body of the request. |
| 41 | * |
| 42 | * @var array|null |
| 43 | */ |
| 44 | public ?array $body; |
| 45 | |
| 46 | /** |
| 47 | * The MCP-Protocol-Version header from the request. |
| 48 | * |
| 49 | * @since 0.5.0 |
| 50 | * |
| 51 | * @var string|null |
| 52 | */ |
| 53 | public ?string $protocol_version; |
| 54 | |
| 55 | /** |
| 56 | * The Accept header from the request. |
| 57 | * |
| 58 | * @var string|null |
| 59 | */ |
| 60 | public ?string $accept_header; |
| 61 | |
| 62 | /** |
| 63 | * Constructor. |
| 64 | * |
| 65 | * @param \WP_REST_Request<array<string, mixed>> $request The original request object. |
| 66 | */ |
| 67 | public function __construct( \WP_REST_Request $request ) { |
| 68 | $this->request = $request; |
| 69 | $this->method = $request->get_method(); |
| 70 | $this->session_id = $request->get_header( 'Mcp-Session-Id' ); |
| 71 | $this->protocol_version = $request->get_header( 'Mcp-Protocol-Version' ); |
| 72 | $this->accept_header = $request->get_header( 'accept' ); |
| 73 | $this->body = 'POST' === $this->method ? $request->get_json_params() : null; |
| 74 | } |
| 75 | } |
| 76 |