I am looking to get to Costa Rica or a country close by such as Nicaragua or Guatemala, but I need a direct flight because I cannot enter the US.
I think this sort of question may have been asked previously, but I can't find it just now.
A good way to solve this problem is to use a search engine like Kayak which lets you filter by layover airport. If you search for a flight from Montreal (YUL) to San José (SJO, not SJC), there is a "layover airport" dropdown on the left panel, where you can uncheck layover airports that you want to avoid. Unchecking all US airports leaves, among other options, flying Copa with a connection in Panama City, or Aeroméxico with a connection in Mexico City. There are further options available with an extra connection in Toronto.
As Nate explained (+1), many search engines do let you filter flights by layover and exclude specific airports based on your needs.
Another way to find flights that do not go through the US is to look up Wikipedia articles or official websites from the main airports in Costa Rica and start from there. Thus, you can see that Air Canada Rouge or Air Transat have direct flights from Canada to Juan Santamaría International Airport. There are also various flights to destinations in Latin America like Mexico that could be used as a layover.