'wp', 'args' => array( 'mcp-adapter', 'serve', '--server=' . $server_slug, '--user=admin', '--path=' . $wp_root, ), ); $stdio_json = (string) wp_json_encode( $stdio_config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); echo '
'; printf( '

%s

', esc_html__( 'WP-CLI (STDIO Transport)', 'acrossai-mcp-manager' ) ); printf( '

%s

', esc_html__( 'MCP clients can connect by launching WP-CLI as a subprocess instead of calling the HTTP endpoint. This is ideal for local WordPress installs — no credentials are transmitted over the network.', 'acrossai-mcp-manager' ) ); printf( '

%s

', esc_html__( 'STDIO Transport (Local / Subprocess Mode)', 'acrossai-mcp-manager' ) ); printf( '

%s

', esc_html__( 'MCP clients can also connect by launching WP-CLI as a subprocess instead of calling the HTTP endpoint. This is ideal for local WordPress installs — no credentials are transmitted over the network.', 'acrossai-mcp-manager' ) ); $this->render_command_block( 'wpcli_list_' . $server_id, __( 'List all registered MCP servers', 'acrossai-mcp-manager' ), '', $cmd_list, 1 ); $this->render_command_block( 'wpcli_serve_' . $server_id, __( 'Start this server via STDIO', 'acrossai-mcp-manager' ), __( 'Blocks until the MCP client disconnects. Replace "admin" with any WordPress user login or ID.', 'acrossai-mcp-manager' ), $cmd_serve, 1 ); $this->render_command_block( 'wpcli_stdio_config_' . $server_id, __( 'STDIO config block (paste into your MCP client)', 'acrossai-mcp-manager' ), sprintf( /* translators: %s: server key */ __( 'Add this under the key "%s" in your MCP client\'s config file. WP-CLI must be in your PATH, or replace "wp" with the full path to the binary.', 'acrossai-mcp-manager' ), $server_key ), $stdio_json, 8 ); $this->render_transport_notice(); echo '
'; } /** * Renders a single label + textarea + copy-button block. * * @since 0.0.6 * @param string $field_id DOM id — used by the copy handler's data-field. * @param string $label Label text (i18n'd, plain string). * @param string $description Optional description shown under the label. * @param string $body Textarea content. * @param int $rows Row count (1 for single-line command; 8 for JSON). * @return void */ private function render_command_block( string $field_id, string $label, string $description, string $body, int $rows ): void { echo '
'; printf( '', esc_attr( $field_id ), esc_html( $label ) ); if ( '' !== $description ) { printf( '

%s

', esc_html( $description ) ); } $css_class = 1 === $rows ? 'widefat code mcp-cmd' : 'widefat code'; printf( '', esc_attr( $field_id ), esc_attr( $css_class ), (int) $rows, esc_textarea( $body ) ); printf( '', esc_attr( $field_id ), esc_html__( 'Copy', 'acrossai-mcp-manager' ) ); echo '
'; } /** * Renders the STDIO-vs-HTTP explanation notice. * * @since 0.0.6 * @return void */ private function render_transport_notice(): void { echo '
'; printf( '

%s

', esc_html__( 'STDIO vs HTTP transport', 'acrossai-mcp-manager' ) ); echo ''; printf( '

%s

', esc_html__( 'The --path flag in the STDIO config is the absolute path to this WordPress installation on disk. Adjust it if the wp binary cannot find WordPress automatically.', 'acrossai-mcp-manager' ) ); echo '
'; } }