'object', 'properties' => $props ?: new \stdClass()]; if ($required) $schema['required'] = $required; return ['name' => $name, 'description' => $desc, 'scope' => $scope, 'handler' => 'AskTamMCP\\Extensions\\Batch39::' . $method, 'inputSchema' => $schema]; }; $registry->register($def('mc4wp_detect', 'Report whether Mailchimp for WordPress is active and its version.', [], [], 'read', 'detect')); $registry->register($def('mc4wp_list_forms', 'List Mailchimp for WP forms (id, title).', ['per_page' => ['type' => 'integer', 'default' => 50]], [], 'read', 'listForms')); $registry->register($def('mc4wp_get_form', 'Get one mc4wp form: title plus its raw form markup.', ['form_id' => ['type' => 'integer']], ['form_id'], 'read', 'getForm')); } public static function detect(array $args): array { return ['active' => defined('MC4WP_VERSION'), 'version' => defined('MC4WP_VERSION') ? MC4WP_VERSION : null]; } public static function listForms(array $args): array { $posts = get_posts(['post_type' => 'mc4wp-form', 'post_status' => ['publish', 'draft'], 'numberposts' => (int) ($args['per_page'] ?? 50), 'orderby' => 'title', 'order' => 'ASC']); $out = []; foreach ($posts as $p) $out[] = ['id' => $p->ID, 'title' => $p->post_title]; return ['count' => count($out), 'forms' => $out]; } public static function getForm(array $args): array { $id = (int) ($args['form_id'] ?? 0); $p = get_post($id); if (!$p || $p->post_type !== 'mc4wp-form') throw new \RuntimeException("mc4wp form not found: {$id}"); return ['id' => $id, 'title' => $p->post_title, 'markup' => (string) $p->post_content]; } }