The quote appears at the beginning of Chapter VI of James's Principles of Psychology, and is preceded by a sentence that gives important context:
"The reader who found himself swamped with too much metaphysics in the last chapter will have a still worse time of it in this one, which is exclusively metaphysical. Metaphysics means nothing but an unusually obstinate effort to think clearly. The fundamental conceptions of psychology are practically very clear to us, but theoretically they are very confused..."
It is clear from the text that the metaphysics in question is the metaphysics underlying "fundamental conceptions of psychology", and that it is James's own "unusually obstinate effort" to clarify them that the chapter represents. It is titled The Mind Stuff Theory (the previous one is The Automaton Theory) and is dedicated to metaphysics of the mind, still a very confused subject with obscurest assumptions even today. The phrasing is reminiscent of Peirce's manifesto How to Make Our Ideas Clear (Peirce was James's friend and fellow pragmatist), which seeks to clarify "metaphysically" some fundamental conceptions of physics and logic.
The sentences after the OP quote are relevant as well:
"When these assumptions have once established themselves (as they have a way of doing in our very descriptions of the phenomenal facts) it is almost impossible to get rid of them afterwards or to make anyone see that they are not essential features of the subject. The only way to prevent this disaster is to scrutinize them beforehand and make them give an articulate account of themselves before letting them pass."
What follows is a discussion of assumptions about mental states (that they are compound), consciousness (that it has an evolutionary role), etc. In other words, James has in mind a very modern conception of metaphysics as conceptual ontology underlying scientific findings, psychological in this case, and engages in conceptual analysis to sort out their presuppositions and clear out the ground for laying down the ontological essentials.
But, in a sense, James is not that far even from the original wellspring of metaphysics as a direct engagement of the intellect with the being in a search for clarity missing from the senses. Chessick in Metaphysics or Autistic Reverie? relates his quote to Plato's Theaetetus, where Socrates opines:"We no longer seek for knowledge in perception
at all, but in that other process, however called, in which the mind is alone and engaged with being."
As Vidarte pointed out in Psychologism and the Self, James's approach, ironically, is also very much in spirit of late Wittgenstein's, which dissolves many foundational problems of metaphysics as due to "conceptual confusion" cured by his therapy. James would, perhaps, see it as complementary to Plato's view: in the light of clarity the clutter is dissolved and only "essential features" remain. Of course, Wittgenstein himself likely would not be sympathetic to such a positive spin on metaphysics, but he was an avid reader of James, and echoed his obstinate effort to think clearly in psychology in Philosophical Investigations:
"The confusion and barrenness of psychology is not to be explained by its being a “young science”; its state is not comparable with that of physics, for instance, in its beginnings. (Rather, with that of certain branches of mathematics. Set theory.) For in psychology, there are experimental methods and conceptual confusion. (As in the other case, conceptual confusion and methods of proof.) The existence of the experimental method makes us think that we have the means of getting rid of the problems which trouble us; but problem and method pass one another by."