well unfortunately I dont know how to mod, and I am just too lazy to learn by myself, but perhaps the good modders this community has can do something about it
External docking? I've seen this in another game. The ship docks externally, and the station protects the ship with its capital ships grade shields. A casual pirate attack is not possible against ships that are docked.
Still, being able to attack docked ships is an interesting idea, so let's not make docked ships invincible. That's what the local law enforcement is for.