'object', 'properties' => $props ?: new \stdClass()]; if ($required) $schema['required'] = $required; return ['name' => $name, 'description' => $desc, 'scope' => $scope, 'handler' => 'AskTamMCP\\Extensions\\Batch35::' . $method, 'inputSchema' => $schema]; }; $registry->register($def('amelia_detect', 'Report whether Amelia is active and its version.', [], [], 'read', 'detect')); $registry->register($def('amelia_list_services', 'List Amelia services (id, name, price, duration).', ['per_page' => ['type' => 'integer', 'default' => 100]], [], 'read', 'listServices')); $registry->register($def('amelia_list_appointments', 'List Amelia appointments (newest first): id, status, booking start.', ['per_page' => ['type' => 'integer', 'default' => 30]], [], 'read', 'listAppointments')); $registry->register($def('amelia_list_employees', 'List Amelia employees/providers (id, name, email).', [], [], 'read', 'listEmployees')); } public static function detect(array $args): array { return ['active' => defined('AMELIA_VERSION'), 'version' => defined('AMELIA_VERSION') ? AMELIA_VERSION : null]; } private static function tableExists(string $t): bool { global $wpdb; return $wpdb->get_var($wpdb->prepare('SHOW TABLES LIKE %s', $t)) === $t; } public static function listServices(array $args): array { global $wpdb; $t = $wpdb->prefix . 'amelia_services'; if (!self::tableExists($t)) return ['supported' => false, 'note' => 'amelia_services table not found.', 'services' => []]; $per = max(1, (int) ($args['per_page'] ?? 100)); $rows = $wpdb->get_results($wpdb->prepare("SELECT id, name, price, duration, status FROM {$t} ORDER BY id DESC LIMIT %d", $per), ARRAY_A); $out = []; foreach ((array) $rows as $r) $out[] = ['id' => (int) $r['id'], 'name' => $r['name'], 'price' => $r['price'], 'duration' => (int) $r['duration'], 'status' => $r['status']]; return ['supported' => true, 'count' => count($out), 'services' => $out]; } public static function listAppointments(array $args): array { global $wpdb; $t = $wpdb->prefix . 'amelia_appointments'; if (!self::tableExists($t)) return ['supported' => false, 'note' => 'amelia_appointments table not found.', 'appointments' => []]; $per = max(1, (int) ($args['per_page'] ?? 30)); $rows = $wpdb->get_results($wpdb->prepare("SELECT id, status, bookingStart FROM {$t} ORDER BY id DESC LIMIT %d", $per), ARRAY_A); $out = []; foreach ((array) $rows as $r) $out[] = ['id' => (int) $r['id'], 'status' => $r['status'], 'start' => $r['bookingStart']]; return ['supported' => true, 'count' => count($out), 'appointments' => $out]; } public static function listEmployees(array $args): array { global $wpdb; $t = $wpdb->prefix . 'amelia_users'; if (!self::tableExists($t)) return ['supported' => false, 'note' => 'amelia_users table not found.', 'employees' => []]; $rows = $wpdb->get_results("SELECT id, firstName, lastName, email FROM {$t} WHERE type = 'provider' ORDER BY id ASC LIMIT 200", ARRAY_A); $out = []; foreach ((array) $rows as $r) $out[] = ['id' => (int) $r['id'], 'name' => trim(($r['firstName'] ?? '') . ' ' . ($r['lastName'] ?? '')), 'email' => $r['email'] ?? '']; return ['supported' => true, 'count' => count($out), 'employees' => $out]; } }