Menu

1 / 2

How I stopped Claude Code from hallucinating function names on a 4,000-file repo (with a local MCP server)

DEV Community·Nikita Groshin·6 months ago
#fGhHrZST
#claude#ai#agent#grep#sverklo
Reading 0:00
15s threshold

TL;DR: My Claude Code agent kept inventing function names that looked plausible but didn't exist ( getUserByEmail , parseConfigFile , validateInput — all fake in my codebase). Adding a local MCP server that gives the agent a real symbol graph and ranked code search cut hallucinations to roughly zero on the same repo. Below: the bug, the cause, the fix, the bench numbers, and the cases where it still doesn't help.

The bug

I was refactoring a logging middleware in a 4,000-file TypeScript monorepo. The agent's task: rename logRequest to logHttpRequest everywhere it's called, including transitive callers.

What Claude Code generated, paraphrased:

// src/middleware/auth.ts import { logRequest } from " ../logging/logger "

export function withAuth ( handler : Handler ) { return async ( req , res ) => { logRequest ( req ) // ← real if ( ! req . session ) { return res . status ( 401 ).…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.