@@ -26,6 +26,8 @@ class AiCommand extends WP_CLI_Command {
2626
2727 public function __construct (
2828 private CollectionToolRepository $ tools ,
29+ private WP_CLI \AiCommand \MCP \Server $ server ,
30+ private WP_CLI \AiCommand \MCP \Client $ client
2931 ) {
3032 parent ::__construct ();
3133 }
@@ -54,20 +56,16 @@ public function __construct(
5456 * @param array $assoc_args Associative array of associative arguments.
5557 */
5658 public function __invoke ( $ args , $ assoc_args ) {
57- $ server = new MCP \ Server ( );
58- $ client = new MCP \ Client ( $ server );
59+ $ this -> register_tools ( $ this -> server );
60+ $ this -> register_resources ( $ this -> server );
5961
60- $ this ->register_tools ($ server , $ client );
61-
62- $ this ->register_resources ($ server );
63-
64- $ result = $ client ->call_ai_service_with_prompt ( $ args [0 ] );
62+ $ result = $ this ->client ->call_ai_service_with_prompt ( $ args [0 ] );
6563
6664 WP_CLI ::success ( $ result );
6765 }
6866
6967 // Register tools for AI processing
70- private function register_tools ($ server, $ client ) : void {
68+ private function register_tools ($ server ) : void {
7169 $ filters = apply_filters ( 'wp_cli/ai_command/command/filters ' , [] );
7270
7371 foreach ( $ this ->tools ->find_all ( $ filters ) as $ tool ) {
0 commit comments