If boarding somewhat early then just ask the FA. Or on deplaning. Before flight is preferred cause often I have to bail especially at a hub. I dont think ive ever denied anyone and love having pax up to say hey.
Even adults are welcome. Most of us are aviation geeks and enjoy the work, title, responsibility, and like to share that. Even if its not a good time and we have mx and delayed or whatever we wont be annoyed or offended might just say hey come up after the flight.
No need to ask gate agent, just the boarding door flight attendant they'll stick their head up in the cockpit and ask/tell us "you guys have a visitor".