Heuristic MCP Server
An enhanced MCP server for your codebase. It provides intelligent semantic search, find-similar-code, recency-aware ranking, call-graph proximity boosts, and smart chunking. Optimized for Antigravity, Cursor, Claude Desktop, and VS Code.
Key Features
- Zero-touch setup: postinstall auto-registers the MCP server with supported IDEs when possible.
- Smart indexing: detects project type and applies smart ignore patterns on top of your excludes.
- Semantic search: find code by meaning, not just keywords.
- Find similar code: locate near-duplicate or related patterns from a snippet.
- Recency ranking and call-graph boosting: surfaces fresh and related code.
- Optional ANN index: faster candidate retrieval for large codebases.
- Optional binary vector store: mmap-friendly cache format for large repos.
Installation
Install globally (recommended):
npm install -g @softerist/heuristic-mcp
What happens during install:
- Registration runs automatically (
scripts/postinstall.js). - Model pre-download is attempted (
scripts/download-model.js). If offline, it will be skipped and downloaded on first run.
If auto-registration did not update your IDE config, run:
heuristic-mcp --register
CLI Commands
The heuristic-mcp binary manages the server lifecycle.
Status
heuristic-mcp --status
Shows server PID(s) and cache stats.
Logs
heuristic-mcp --logs
Tails the server log for the current workspace (defaults to last 200 lines and follows).
Optional flags:
heuristic-mcp --logs --tail 100
heuristic-mcp --logs --no-follow
Version
heuristic-mcp --version
Register (manual)
heuristic-mcp --register
heuristic-mcp --register antigravity
heuristic-mcp --register cursor
heuristic-mcp --register "Claude Desktop"
Start/Stop
heuristic-mcp --start
heuristic-mcp --stop
--stop also disables the MCP server entry in supported IDE configs so the IDE won't immediately respawn it. --start re-enables it (restart/reload the IDE to launch).
Clear Cache
heuristic-mcp --clear-cache
Clears the cache for the current working directory (or --workspace if provided) and removes stale cache directories without metadata.
Configuration (config.json)
Configuration is loaded from your workspace root when the server runs with --workspace (this is how IDEs launch it). In server mode, it falls back to the package config.json and then your current working directory.
Example config.json:
{
"excludePatterns": ["**/legacy-code/**", "**/*.test.ts"],
"fileNames": ["Dockerfile", ".env.example", "Makefile"],
"smartIndexing": true,
"embeddingModel": "jinaai/jina-embeddings-v2-base-code",
"workerThreads": 0,
"recencyBoost": 0.1,
"recencyDecayDays": 30,
"callGraphEnabled": true,
"callGraphBoost": 0.15,
"annEnabled": true,
"vectorStoreFormat": "binary",
"vectorStoreContentMode": "external",
"vectorStoreLoadMode": "disk",
"contentCacheEntries": 256,
"vectorCacheEntries": 64,
"clearCacheAfterIndex": true
}
Cache location:
- By default, the cache is stored in a global OS cache directory under
heuristic-mcp/<hash>. - You can override with
cacheDirectoryinconfig.json.
Environment Variables
Selected overrides (prefix SMART_CODING_):
SMART_CODING_VERBOSE=true|falseSMART_CODING_WORKER_THREADS=auto|0|NSMART_CODING_BATCH_SIZE=100SMART_CODING_CHUNK_SIZE=25SMART_CODING_MAX_RESULTS=5SMART_CODING_RECENCY_BOOST=0.1SMART_CODING_RECENCY_DECAY_DAYS=30SMART_CODING_ANN_ENABLED=true|falseSMART_CODING_ANN_EF_SEARCH=64SMART_CODING_VECTOR_STORE_FORMAT=json|binarySMART_CODING_VECTOR_STORE_CONTENT_MODE=external|inlineSMART_CODING_VECTOR_STORE_LOAD_MODE=memory|diskSMART_CODING_CONTENT_CACHE_ENTRIES=256SMART_CODING_VECTOR_CACHE_ENTRIES=64SMART_CODING_CLEAR_CACHE_AFTER_INDEX=true|false
See lib/config.js for the full list.
Binary Vector Store
Set vectorStoreFormat to binary to use the on-disk binary cache. This keeps vectors and content out of JS heap
and reads on demand. Recommended for large repos.
vectorStoreContentMode=externalkeeps content in the binary file and only loads for top-N results.contentCacheEntriescontrols the small in-memory LRU for decoded content strings.vectorStoreLoadMode=diskstreams vectors from disk to reduce memory usage.vectorCacheEntriescontrols the small in-memory LRU for vectors when using disk mode.clearCacheAfterIndex=truedrops in-memory vectors after indexing and reloads lazily on next query.- Note:
annEnabled=truewithvectorStoreLoadMode=diskcan increase disk reads during ANN rebuilds on large indexes.
Benchmarking Search
Use the built-in script to compare memory vs latency tradeoffs:
node tools/scripts/benchmark-search.js --query "database connection" --runs 10
Compare modes quickly:
SMART_CODING_VECTOR_STORE_LOAD_MODE=memory node tools/scripts/benchmark-search.js --runs 10
SMART_CODING_VECTOR_STORE_LOAD_MODE=disk node tools/scripts/benchmark-search.js --runs 10
SMART_CODING_VECTOR_STORE_FORMAT=binary SMART_CODING_VECTOR_STORE_LOAD_MODE=disk node tools/scripts/benchmark-search.js --runs 10
Note: On small repos, disk mode may be slightly slower and show noisy RSS deltas; benefits are clearer on large indexes with a small vectorCacheEntries.
Troubleshooting
Server isn't starting
- Run
heuristic-mcp --statusto check config and cache status. - Run
heuristic-mcp --logsto see startup errors.
Search returns no results
- Check
heuristic-mcp --statusfor indexing progress. - If indexing shows zero files, review
excludePatternsandfileExtensions.
Model download fails
- The install step tries to pre-download the model, but it can be skipped offline.
- The server will download on first run; ensure network access at least once.
Clear cache
- Use the MCP tool
c_clear_cache, runheuristic-mcp --clear-cache, or delete the cache directory. For local dev, runnpm run clean.
Inspect cache
node tools/scripts/cache-stats.js --workspace <path>
Stop doesn't stick
- The IDE will auto-restart the server if it's still enabled in its config.
--stopnow disables the server entry for Antigravity, Cursor, Claude Desktop, and VS Code (when using common MCP settings keys). Restart the IDE after--startto re-enable.
Contributing
See CONTRIBUTING.md for guidelines.
License: MIT