register( 'agentdesk_discover', array( 'description' => 'Search and browse available WordPress MCP tools by keyword or domain.', 'domain' => 'gateway', 'capability' => 'read', 'inputSchema' => array( 'type' => 'object', 'properties' => array( 'query' => array( 'type' => 'string', 'description' => 'Keyword search' ), 'domain' => array( 'type' => 'string', 'description' => 'Filter by domain: core, content, media, plugins, themes, woocommerce, elementor, integrations' ), 'limit' => array( 'type' => 'integer', 'description' => 'Max results (1-100)' ), ), ), ), function ( $args ) use ( $registry ) { return $registry->discover( $args ); } ); $registry->register( 'agentdesk_info', array( 'description' => 'Get full schema and metadata for a specific MCP tool.', 'domain' => 'gateway', 'capability' => 'read', 'inputSchema' => array( 'type' => 'object', 'properties' => array( 'name' => array( 'type' => 'string', 'description' => 'Tool name' ), ), 'required' => array( 'name' ), ), ), function ( $args ) use ( $registry ) { if ( empty( $args['name'] ) ) { return new WP_Error( 'agentdesk_missing_arg', 'name is required' ); } return $registry->info( $args['name'] ); } ); $registry->register( 'agentdesk_run', array( 'description' => 'Execute any registered MCP tool by name.', 'domain' => 'gateway', 'capability' => 'read', 'inputSchema' => array( 'type' => 'object', 'properties' => array( 'name' => array( 'type' => 'string' ), 'arguments' => array( 'type' => 'object' ), 'dry_run' => array( 'type' => 'boolean' ), ), 'required' => array( 'name' ), ), ), function ( $args ) use ( $registry ) { if ( empty( $args['name'] ) ) { return new WP_Error( 'agentdesk_missing_arg', 'name is required' ); } $tool_args = isset( $args['arguments'] ) && is_array( $args['arguments'] ) ? $args['arguments'] : array(); $dry_run = ! empty( $args['dry_run'] ); return $registry->run( $args['name'], $tool_args, $dry_run ); } ); $registry->register( 'agentdesk_batch', array( 'description' => 'Run multiple MCP tools in sequence. Stops on first error by default.', 'domain' => 'gateway', 'capability' => 'read', 'inputSchema' => array( 'type' => 'object', 'properties' => array( 'steps' => array( 'type' => 'array', 'items' => array( 'type' => 'object', 'properties' => array( 'name' => array( 'type' => 'string' ), 'arguments' => array( 'type' => 'object' ), 'dry_run' => array( 'type' => 'boolean' ), ), ), ), 'stop_on_error' => array( 'type' => 'boolean' ), ), 'required' => array( 'steps' ), ), ), function ( $args ) use ( $registry ) { $steps = isset( $args['steps'] ) && is_array( $args['steps'] ) ? $args['steps'] : array(); $stop = ! isset( $args['stop_on_error'] ) || ! empty( $args['stop_on_error'] ); return $registry->batch( $steps, $stop ); } ); } );