@@ -162,16 +162,18 @@ protected function get_tools( array $sessions ): array {
162162 * @return ClientSession[]
163163 */
164164 public function get_sessions ( bool $ with_wp_server , bool $ with_cli_server ): array {
165+ $ logger = new CliLogger ();
166+
165167 $ sessions = [];
166168
167169 if ( $ with_cli_server ) {
168- $ sessions ['current_site ' ] = ( new Client ( new CliLogger () ) )->connect (
170+ $ sessions ['current_site ' ] = ( new Client ( $ logger ) )->connect (
169171 MCP \Servers \WP_CLI \WP_CLI ::class
170172 );
171173 }
172174
173175 if ( $ with_wp_server ) {
174- $ sessions ['wp_cli ' ] = ( new Client ( new CliLogger () ) )->connect (
176+ $ sessions ['wp_cli ' ] = ( new Client ( $ logger ) )->connect (
175177 WordPress::class
176178 );
177179 }
@@ -186,7 +188,7 @@ public function get_sessions( bool $with_wp_server, bool $with_cli_server ): arr
186188 $ server = $ args ['server ' ];
187189
188190 if ( str_starts_with ( $ server , 'http:// ' ) || str_starts_with ( $ server , 'https:// ' ) ) {
189- $ sessions [] = ( new Client ( new CliLogger () ) )->connect (
191+ $ sessions [] = ( new Client ( $ logger ) )->connect (
190192 $ server
191193 );
192194 continue ;
@@ -195,7 +197,7 @@ public function get_sessions( bool $with_wp_server, bool $with_cli_server ): arr
195197 $ server = explode ( ' ' , $ server );
196198 $ cmd_or_url = array_shift ( $ server );
197199
198- $ sessions [ $ args ['name ' ] ] = ( new Client ( new CliLogger () ) )->connect (
200+ $ sessions [ $ args ['name ' ] ] = ( new Client ( $ logger ) )->connect (
199201 $ cmd_or_url ,
200202 $ server ,
201203 );
0 commit comments