@@ -19,6 +19,9 @@ class McpServerCommand extends WP_CLI_Command {
1919 *
2020 * ## OPTIONS
2121 *
22+ * [--<field>=<value>]
23+ * : Filter results by key=value pairs.
24+ *
2225 * [--format=<format>]
2326 * : Render output in a particular format.
2427 * ---
@@ -42,6 +45,8 @@ class McpServerCommand extends WP_CLI_Command {
4245 *
4346 * @subcommand list
4447 *
48+ * @when before_wp_load
49+ *
4550 * @param array $args Indexed array of positional arguments.
4651 * @param array $assoc_args Associative array of associative arguments.
4752 */
@@ -51,6 +56,13 @@ public function list_( $args, $assoc_args ): void {
5156 $ servers = [];
5257
5358 foreach ( $ config as $ name => $ server ) {
59+ // Support features like --status=active.
60+ foreach ( array_keys ( $ server ) as $ field ) {
61+ if ( isset ( $ assoc_args [ $ field ] ) && ! in_array ( $ server [ $ field ], array_map ( 'trim ' , explode ( ', ' , $ assoc_args [ $ field ] ) ), true ) ) {
62+ continue 2 ;
63+ }
64+ }
65+
5466 $ servers [] = [
5567 'name ' => $ name ,
5668 'server ' => $ server ['server ' ],
@@ -83,6 +95,8 @@ public function list_( $args, $assoc_args ): void {
8395 * $ wp mcp server add "server-filesystem" "npx -y @modelcontextprotocol/server-filesystem /my/allowed/folder/"
8496 * Success: Server added.
8597 *
98+ * @when before_wp_load
99+ *
86100 * @param array $args Indexed array of positional arguments.
87101 */
88102 public function add ( $ args ): void {
@@ -93,7 +107,7 @@ public function add( $args ): void {
93107 } else {
94108 $ config [ $ args [0 ] ] = [
95109 'server ' => $ args [1 ],
96- 'status ' => 'enabled ' ,
110+ 'status ' => 'active ' ,
97111 ];
98112
99113 $ result = $ this ->get_config ()->update_config ( $ config );
@@ -123,6 +137,8 @@ public function add( $args ): void {
123137 * $ wp mcp server remove "server-filesystem"
124138 * Success: Server removed.
125139 *
140+ * @when before_wp_load
141+ *
126142 * @param array $args Indexed array of positional arguments.
127143 */
128144 public function remove ( $ args , $ assoc_args ): void {
@@ -172,9 +188,11 @@ public function remove( $args, $assoc_args ): void {
172188 * ## EXAMPLES
173189 *
174190 * # Remove server.
175- * $ wp mcp server update "server-filesystem" --status=disabled
191+ * $ wp mcp server update "server-filesystem" --status=inactive
176192 * Success: Server updated.
177193 *
194+ * @when before_wp_load
195+ *
178196 * @param array $args Indexed array of positional arguments.
179197 */
180198 public function update ( $ args , $ assoc_args ): void {
@@ -187,7 +205,7 @@ public function update( $args, $assoc_args ): void {
187205 foreach ( $ config [ $ args [0 ] ] as $ key => $ value ) {
188206 if ( isset ( $ assoc_args [ $ key ] ) ) {
189207 if ( 'status ' === $ key ) {
190- $ value = 'disabled ' === $ value ? 'enabled ' : 'disabled ' ;
208+ $ value = 'inactive ' === $ value ? 'active ' : 'inactive ' ;
191209 }
192210 $ config [ $ args [0 ] ][ $ key ] = $ value ;
193211 }
0 commit comments