SpaceX has quite optimized its operations since the early days where they used commercially available cranes and SPMTs. You can watch it happen live on NSF's Space Coast Live 24/7 live stream. When a booster returns to port, they usually switch to "fleet cam" which is on the deck of Rusty's Seafood and Oyster right across the water from SpaceX's facilities.
In fact, NSF have compiled a video showing the whole booster processing in the port from start to finish:
First things first, there seem to be two misconceptions in your question: SpaceX's facilities for booster lifting are at Port Canaveral, not somewhere inside KSC or CCSFS. And the boosters are not going to LC-39A or SLC-40, they are going to Roberts Road. (They used to go to HangarX which is part of LC-39A, but they never went to SLC-40. That makes no sense: why would SpaceX refurbish their boosters inside of a military base, where it is much harder to get people, equipment, and supplies in?)
First, a jig, nicknamed the "lifting cap" by the community, gets attached to lifting points on the interstage. The lifting cap also contains a mechanism to fold the landing legs back up, basically 4 winches with cables that come down from the cap to the legs and get attached there. Once the lifting cap is attached, the crane releases the cap and moves out of the way.
This is done without any humans needing to be near the booster. In contrast, in the past, they had to use a crane to lift a cherry picker onto the drone ship, then send people up in the cherry picker to attach the crane.
After attaching the lifting cap and the leg folding cables, and releasing the cap, the legs are folded up, by pulling them up using the winches in the lifting cap. In the past, the legs were lifted up from the ground.
With the legs folded up, the crane moves back over and re-attaches to the lifting cap. Once the crane has picked up the load, the hold down clamps on Octagrabber are released. With the booster now free, it is lifted up by the crane and swung over to the pier.
On the pier, a second, smaller crane is attached to the bottom of the booster. Using this second anchoring point, the booster is laid on its side.
SpaceX bought one of the old Orbiter Transporters from NASA's Space Shuttle program and converted it to … ahem … shuttle boosters between Port Canaveral and HangarX, or nowadays Roberts Road: