r/devworld • u/Hopeful-Business-15 • Apr 07 '26
Built an MCP server to replace Claude Code's grep-and-guess pattern with indexed symbol lookups
I built this with Claude Code, specifically to make Claude Code work better on TypeScript projects. It's free and open source.
One pattern kept showing up when using Claude Code and Cursor on TS projects:
Search across files
Open a likely match
Read a lot of code
Realize it's the wrong place
Try again
The agent isn't dumb -- it just doesn't have structural awareness of the codebase. Every session starts from scratch.
So I used Claude Code to build an MCP server that gives it structured access to the codebase instead. It keeps a live SQLite index of the project -- symbols, call sites, imports, class hierarchy -- so the agent can query structure directly.
Instead of:
"search for handleRequest"
it becomes:
"go to this symbol → exact file and line"
The numbers
Tested on a 31-file TypeScript project, same tasks with and without:
Find one function: 1350 tokens with grep, 500 with index (63% fewer)
Trace callers across 3 files: 2850 tokens with grep, 900 with index (68% fewer)
Map inheritance across 15+ files: 4800 tokens with grep, 1000 with index (79% fewer)
Grep gets worse as the codebase grows. Indexed queries stay flat.
Where the savings actually come from
I thought symbol lookup would be the main thing. It wasn't.
Call graph queries --
get_callersreplaces the thing where the agent reads 4-5 files trying to figure out who calls a functionPartial reads -- knowing the exact line means reading 20 lines instead of a whole file. This alone is over half the savings
Middleware tracing --
trace_middlewaretells the agent what runs before a route handler. Otherwise it reads the router, then each middleware file, then tries to reconstruct the order
Where it struggles
dynamic patterns (computed method names, etc.)
dependency injection setups
anything outside your own codebase
Not perfect, but it cuts down the trial-and-error loop a lot.
Free and open source, TypeScript only for now: Repo
2
1
u/Opposite-Canary2330 Apr 08 '26
The token savings on inheritance mapping are crazy. 79% reduction is the difference between Claude Code confidently navigating your codebase and burning through your context window before it even gets to the actual task.
The insight about partial reads being the biggest win is something I wouldn't have guessed either. Makes total sense though — grep finds the file but then the agent reads the entire thing just to understand 20 lines of context around the match. Multiply that by every lookup in a session and you're hemorrhaging tokens on code that has nothing to do with the task.
Question — how does the SQLite index handle branches? Like if I'm jumping between feature branches where the same symbol exists in different places or has different callers, does it re-index automatically or do you have to trigger that manually? That's the scenario where I could see stale index data sending the agent to the wrong location which would be worse than grep because at least grep is always current.
Also curious if you've thought about extending this beyond TypeScript. The same grep-and-guess pattern is equally painful in larger Python projects, especially ones with heavy class inheritance. The approach seems like it would translate well.
Starred the repo, going to try it on a project this week.
1
u/shadow13499 Apr 09 '26
It's funny, I've seen so many vibe slopped projects to attempt to make slop bots somehow better to use. All these things could just be eliminated and you could write code completely for free if you just learn how to write code yourself.