Skip to content

Commit 931ca42

Browse files
committed
CLI tools: Fix fatal error if command not installed
1 parent 5ac3c28 commit 931ca42

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/MCP/Servers/WP_CLI/Tools/CliCommands.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use McpWp\MCP\Server;
66
use Psr\Log\LoggerInterface;
77
use WP_CLI;
8-
use WP_CLI\Dispatcher\CompositeCommand;
98
use WP_CLI\SynopsisParser;
109

1110
/**
@@ -34,7 +33,14 @@ public function get_tools(): array {
3433
$tools = [];
3534

3635
foreach ( $commands as $command ) {
37-
[$command] = WP_CLI::get_runner()->find_command_to_run( [ $command ] );
36+
$result = WP_CLI::get_runner()->find_command_to_run( [ $command ] );
37+
38+
// Command not found/installed.
39+
if ( is_string( $result ) ) {
40+
continue;
41+
}
42+
43+
[ $command ] = $result;
3844

3945
/**
4046
* Command class.

0 commit comments

Comments
 (0)