diff --git a/ivette/src/frama-c/api/generated/kernel/ast/index.ts b/ivette/src/frama-c/api/generated/kernel/ast/index.ts
index 03afaed2e4db3b3f14b83ae484aea67859036425..f72426c5a3222d23e3d51df6f2ef0807fd723987 100644
--- a/ivette/src/frama-c/api/generated/kernel/ast/index.ts
+++ b/ivette/src/frama-c/api/generated/kernel/ast/index.ts
@@ -284,6 +284,15 @@ export const byLocation: Compare.Order<location> =
     marker: byMarker,
   });
 
+const getMainFunction_internal: Server.GetRequest<null,Json.key<'#fct'>> = {
+  kind: Server.RqKind.GET,
+  name:   'kernel.ast.getMainFunction',
+  input:  Json.jNull,
+  output: Json.jKey<'#fct'>('#fct'),
+};
+/** Get the current 'main' function. */
+export const getMainFunction: Server.GetRequest<null,Json.key<'#fct'>>= getMainFunction_internal;
+
 const getFunctions_internal: Server.GetRequest<null,Json.key<'#fct'>[]> = {
   kind: Server.RqKind.GET,
   name:   'kernel.ast.getFunctions',
diff --git a/ivette/src/frama-c/menu.ts b/ivette/src/frama-c/menu.ts
index ea9e37c0a0137140f10c9755175da356e7508c72..0fa355294406c4d3ae5a615dc883c9f37653dcfd 100644
--- a/ivette/src/frama-c/menu.ts
+++ b/ivette/src/frama-c/menu.ts
@@ -46,7 +46,8 @@ async function setFiles(): Promise<void> {
   });
   await Server.send(Ast.setFiles, files);
   await Server.send(Ast.compute, { });
-  States.setSelection({fct: undefined});
+  const main = await Server.send(Ast.getMainFunction, { });
+  States.setSelection({ fct: main });
   return;
 }
 
diff --git a/src/plugins/server/kernel_ast.ml b/src/plugins/server/kernel_ast.ml
index 5f98ce741468bce978c4196c2685ba0bb9d812af..10c62c2128a474836bcf83a0c95d42cdf6754fb5 100644
--- a/src/plugins/server/kernel_ast.ml
+++ b/src/plugins/server/kernel_ast.ml
@@ -353,6 +353,12 @@ end
 (* --- Functions                                                          --- *)
 (* -------------------------------------------------------------------------- *)
 
+let () = Request.register ~package
+    ~kind:`GET ~name:"getMainFunction"
+    ~descr:(Md.plain "Get the current 'main' function.")
+    ~input:(module Junit) ~output:(module Kf)
+    (fun () -> fst (Globals.entry_point ()))
+
 let () = Request.register ~package
     ~kind:`GET ~name:"getFunctions"
     ~descr:(Md.plain "Collect all functions in the AST")