'object', 'properties' => $props ?: new \stdClass()]; if ($required) $schema['required'] = $required; return ['name' => $name, 'description' => $desc, 'scope' => $scope, 'handler' => 'AskTamMCP\\Extensions\\Batch53::' . $method, 'inputSchema' => $schema]; }; $registry->register($def('vcv_detect', 'Report whether Visual Composer Website Builder is active and its version.', [], [], 'read', 'detect')); $registry->register($def('vcv_list_templates', 'List Visual Composer templates (id, title).', ['per_page' => ['type' => 'integer', 'default' => 100]], [], 'read', 'listTemplates')); $registry->register($def('vcv_is_built', 'Report whether Visual Composer content is stored on a post.', ['post_id' => ['type' => 'integer']], ['post_id'], 'read', 'isBuilt')); } public static function detect(array $args): array { return ['active' => defined('VCV_VERSION'), 'version' => defined('VCV_VERSION') ? VCV_VERSION : null]; } public static function listTemplates(array $args): array { $out = []; foreach (['vcv_templates', 'vcv_tpl'] as $pt) { if (!post_type_exists($pt)) continue; $posts = get_posts(['post_type' => $pt, 'post_status' => ['publish', 'draft'], 'numberposts' => (int) ($args['per_page'] ?? 100), 'orderby' => 'title', 'order' => 'ASC']); foreach ($posts as $p) $out[] = ['id' => $p->ID, 'title' => $p->post_title, 'type' => $pt]; } return ['count' => count($out), 'templates' => $out]; } public static function isBuilt(array $args): array { $id = (int) ($args['post_id'] ?? 0); if (!get_post($id)) throw new \RuntimeException("Post not found: {$id}"); return ['post_id' => $id, 'vcv_built' => (bool) get_post_meta($id, 'vcv-pageContent', true)]; } }