But McCoy is not in the line of command
He explicitly says this in more than one episode. His specific wording at one point is "if I were an officer of the line, I would..."
a medical officer a warrant, NCO or a commissioned officer of some sort
Based on numerous data points from another thread from sometime back, it can be suggested that the blueshirt corresponds to a staff officer, especially one in the sciences, who would not take command, with a few exceptions (Spock, Krasnovsky, Will Decker, and Admiral Kirk). Spock being a special case is the very topic of this thread. Admiral Kirk being an exception can be justified by the plot points in TMP which suggest he could command, but may not be recently doing so. Decker, who has a yellow uniform in some promotional shots, may still be wearing a blue uniform from his time as a commander, and never gets to change because he is moved to science officer when Kirk takes over command. That just leaves Krasnovsky as unexplained, but perhaps that can be explained by the fact that some have suggested he is a science ship captain, and therefore wears blue while in command. It would also explain the USS Kelvin officers, if you wanted to count that movie as being included, not sure I want to
Since Anne Mulhal and a few others are science officers who wear red, and we have Kelowitz as a tactical officer in blue, it seems possible that in-universe there some rules that determine shirt color in more detail than just command/science/engineering within certain parameters. My theory on this is that many officers are double-trained, and they, or the captain, have some choice in what qualifications they display, based on the job they are doing.
Maybe Spock developed some revolutionary duty assignment approach that affected the assignment of shirt color (that is the way officers are identified while on duty), and that is partly why he is considered "the best first officer in the fleet"?
I believe his exact words are "Mr. Chekhov, take over" as he (Kirk) heads for the turbolift clutching his side.
I'm pretty sure Uhura takes command in TOS at least once, but I'll have to think about which episode.
Uhura is never explicitly shown in command, but I think it can be said to have been "strongly implied" in at least three episodes I can recall.
"In Balance of Terror," when all of the "regular cast" officers are at the wedding, she is the one calling from the bridge. So there either has to be an offscreen person with a higher position than her on duty (there could be some candidates, but not in the episode itself), or she is in command.
In "The Alternative Factor," she is shown standing next to the empty command chair, as Kirk enters and goes to Spock station. If Spock got there a few moments before Kirk and was not there long, she could have been in command, since this is an episode without Sulu or Scotty, who may have been "off-duty," or even at a base for briefing on some kind of new dilithium systems which are first mentioned in this episode.
In "The Trouble with Tribbles," Kirk is handing Uhura tribbles while giving her instructions on what to do, then leaves the Bridge. Scotty is not present, Sulu is not in the episode, and Chekov is only an ensign. So it seems that Uhura would be in command at least until Scotty can arrive.
In my view, Kirk giving Chekov orders to take over just before Kirk starts to bleed internally, especially knowing that it has been expressly stated in the episode by McCoy that Scotty could take over, indicates that whoever Kirk left in charge would only be filling that role until Scotty could get there. It does not, on its own, suggest to me that Chekov is somehow in line for command ahead of Uhura. That being said, some episodes of TNG and Voyager occasionally have the captain leave someone in charge who ordinarily would not be, so that person can gain experience. One example would be Geordi being left in charge of higher-ranks officers on one half of Enterprise after it had been separated. So just because Chekov may take command ahead of Uhura in one case does not mean he always does.