At the top of a file, or at the top of an async function body, for example inline in a Server Component
Both places work. A directive at the top of a file marks all its exports as Server Actions, and Client Components can import them. A directive at the top of an async function body defines one inline action inside a Server Component. The tempting "Only inside Client Components" is wrong: Client Components cannot define inline actions at all. They can only import actions from a "use server" file.
Read more