'object', 'properties' => $props ?: new \stdClass()]; if ($required) $schema['required'] = $required; return ['name' => $name, 'description' => $desc, 'scope' => $scope, 'handler' => 'AskTamMCP\\Extensions\\Batch52::' . $method, 'inputSchema' => $schema]; }; $registry->register($def('thrive_detect', 'Report whether Thrive Architect is active and its version.', [], [], 'read', 'detect')); $registry->register($def('thrive_is_built', 'Report whether Thrive Architect content is stored on a post.', ['post_id' => ['type' => 'integer']], ['post_id'], 'read', 'isBuilt')); $registry->register($def('thrive_list_built', 'List recent posts that have Thrive Architect content (id, title).', ['post_type' => ['type' => 'string', 'default' => 'page'], 'per_page' => ['type' => 'integer', 'default' => 50]], [], 'read', 'listBuilt')); } public static function detect(array $args): array { return ['active' => defined('TVE_VERSION'), 'version' => defined('TVE_VERSION') ? TVE_VERSION : null]; } public static function isBuilt(array $args): array { $id = (int) ($args['post_id'] ?? 0); if (!get_post($id)) throw new \RuntimeException("Post not found: {$id}"); $built = get_post_meta($id, 'tcb2_ready', true) || get_post_meta($id, 'tve_updated_post', true); return ['post_id' => $id, 'thrive_built' => (bool) $built]; } public static function listBuilt(array $args): array { $pt = (string) ($args['post_type'] ?? 'page'); $posts = get_posts(['post_type' => $pt, 'post_status' => 'publish', 'numberposts' => (int) ($args['per_page'] ?? 50), 'meta_query' => [['key' => 'tve_updated_post', 'compare' => 'EXISTS']]]); $out = []; foreach ($posts as $p) $out[] = ['id' => $p->ID, 'title' => $p->post_title]; return ['count' => count($out), 'posts' => $out]; } }