I'm a math professor. I get asked to write a number of recommendation letters to graduate schools where my honest view of the candidate is "this student would fall somewhere in the bottom 25-50% of their student body. I expect there will be dozens of applicants of similar quality and I have no reason to favor this one except that I have a good personal relationship with him or her."
Logically, this candidate deserves to go as much as any of the dozen similar people in the pool, but I feel that a letter which said the above would be a real disservice to them. Should I refuse to write them? Describe their accomplishments and pointedly ignore that (if my estimates are right) they don't particularly make them stand out?
I've only been a student, so take this with a grain of salt.
Be honest to them about their abilities and your perception of them before you write a letter for them. Grad school is not a small commitment. See my answer here also, for an answer to a related question. An excerpt which I feel is very relevant:
Be very honest. You have information that they don't have that will
be useful for them. I would rather you tell them what you know and have
them make the decision for themselves, rather than let them keep doing
what they're doing and seeing them fail.
You may respond as follows to these flocks of mediocre students:
I wouldn't be the best person to write a recommendation letter for you, because (a) my standards are so absurdly high that I can only write a strong recommendation letter for about x% of the students in our department, and (b) I believe that our department doesn't give a solid preparation for grad school to many of our students.
Please don't let this discourage you from approaching other members of the department. I am an anomaly.
Similarly, please don't let this response discourage you from going to grad school.
I wish you all the best with your future endeavors, and best of luck with your grad applications.