read_smart is an MCP tool that caches file content and returns only what changed — saving 50-99% tokens on re-reads.
The problem
A typical agent session reads the same files multiple times:- Read
src/index.tsto understand the codebase (900 tokens) - Make changes
- Read
src/index.tsagain to verify (900 tokens) - Read it again after another change (900 tokens)
The solution
read_smart maintains a per-file snapshot with content hashes:
AST-aware chunking
Unlike line-based diffing,read_smart splits files into semantic chunks:
TypeScript / JavaScript
Parsed via@babel/parser into top-level declarations:
getConnection and closePool keep their identity (even though their line numbers shifted).
Python
Split by top-leveldef and class blocks using indentation analysis.
Markdown
Split byh2 and h3 headings.
Other files
Fixed 100-line windows.Token estimation
Token count is estimated at 0.3 tokens per character — a blended rate that works for both English and Japanese text.Cache storage
Snapshots are stored in thefile_snapshots table in the same SQLite database as memories. No external services required.