Hmmm ya, back in the day, pirates relied on loud noises and aggressive body language, to intimidate the crew into submission.
I think we should take a hint from the crew that successfully fended of the pirates with yelling.
Probably some loud sirens and flashing lights
would foil most contemporary boarding attempts,
anyone that has resorted to piracy, due to a life of crime, is probably terrified of police like sirens and lights
In terms of poison, I don't think so, that's more for assassinations, on select people, with lots of exposure time. If you start spiking things with poison, more likely to hurt yourself, a kid, or inspection officer than anyone else.
The siren system however, is security that can even work if you aren't on the boat, for instance could be triggered like any security system, if someone tries to force a door open, without deactivating it. Though if you don't have a security system, can always yell, especially if you're below deck and hear someone unexpected on board.
If you do choose to use a weapon, would be best if you knew how to do so, and were ready to do so,
also if it's limited range like a knife, in these modern times of guns, would have to have some place where can operate it from before they notice you -- btw, it's more effective if you take a hostage in a submission hold (twisted arm, finger, or likewise), then they can help motivate the rest of the crew to leave, especially if they don't speak your language (besides you don't want any blood on your hands, it can be traumatic, and would require a lot of explaining).
Hiding places for valuables is also a good idea of course. As does looking run down and impoverished in piracy zones - wear your worst and likely most comfortable clothing, while letting the exterior get a dull grimy color - shiny and new is apealing even to crows. As the common saying goes, an ounce of prevention, is worth a pound of cure.For the government even better than law enforcement, (which in this case, I doubt would lead to anything) would be to have good social safety nets, so people don't have to resort to crime to meet their basic needs.