'object', 'properties' => $props ?: new \stdClass()]; if ($required) $schema['required'] = $required; return ['name' => $name, 'description' => $desc, 'scope' => $scope, 'handler' => 'AskTamMCP\\Extensions\\Batch54::' . $method, 'inputSchema' => $schema]; }; $registry->register($def('generateblocks_detect', 'Report whether GenerateBlocks is active and its version.', [], [], 'read', 'detect')); $registry->register($def('generateblocks_list_posts', 'List recent posts that use GenerateBlocks blocks (id, title, type).', ['per_page' => ['type' => 'integer', 'default' => 50]], [], 'read', 'listPosts')); } public static function detect(array $args): array { return ['active' => defined('GENERATEBLOCKS_VERSION'), 'version' => defined('GENERATEBLOCKS_VERSION') ? GENERATEBLOCKS_VERSION : null]; } public static function listPosts(array $args): array { global $wpdb; $per = max(1, (int) ($args['per_page'] ?? 50)); $like = '%' . $wpdb->esc_like('wp:generateblocks') . '%'; $rows = $wpdb->get_results($wpdb->prepare( "SELECT ID, post_title, post_type FROM {$wpdb->posts} WHERE post_status = 'publish' AND post_content LIKE %s ORDER BY ID DESC LIMIT %d", $like, $per), ARRAY_A); $out = []; foreach ((array) $rows as $r) $out[] = ['id' => (int) $r['ID'], 'title' => $r['post_title'], 'type' => $r['post_type']]; return ['count' => count($out), 'posts' => $out]; } }