Automattic\WooCommerce\Internal\Abilities
AbilitiesTracking::is_json_rpc_tool_call
Whether the outermost REST request is a JSON-RPC tools/call, as every MCP tool call over HTTP is, including from
2025-03-26 clients that send no MCP headers. Batches (2025-03-26) are checked message by message.
Method of the class: AbilitiesTracking{}
No Hooks.
Returns
bool.
Usage
// private - for code of main (parent) class only $result = $this->is_json_rpc_tool_call(): bool;
AbilitiesTracking::is_json_rpc_tool_call() AbilitiesTracking::is json rpc tool call code WC 11.3.0
private function is_json_rpc_tool_call(): bool {
$request = $this->rest_requests[0] ?? null;
$body = $request ? $request->get_json_params() : null;
if ( ! is_array( $body ) ) {
return false;
}
foreach ( isset( $body['jsonrpc'] ) ? array( $body ) : $body as $message ) {
if ( is_array( $message ) && '2.0' === ( $message['jsonrpc'] ?? null ) && 'tools/call' === ( $message['method'] ?? null ) ) {
return true;
}
}
return false;
}