This guide covers common issues and their solutions when using semantic-code-mcp.
Symptoms: Search returns "Index is empty. Run indexing first."
Causes:
- No supported files in the directory
- All files are in ignored patterns
- Index directory is different from expected
Solutions:
- Check for supported files:
# List TypeScript files
find . -name "*.ts" | head -20
# Check if files are being ignored
ls -la .semantic-code/- Verify environment variables:
echo $SEMANTIC_CODE_ROOT
echo $SEMANTIC_CODE_INDEX- Force re-index by removing the index:
rm -rf .semantic-code/index/Symptoms:
- Search crashes with database errors
- Inconsistent results
- LanceDB errors in logs
Solution:
# Remove and rebuild the index
rm -rf .semantic-code/index/
# Restart the server - index rebuilds automaticallyThe index can be safely cleared at any time. It will automatically rebuild on the next search.
When to clear:
- Index seems bloated or stale
- After major refactoring (file renames/moves outside editor)
- Switching between branches with very different file structures
- Any unexplained search issues
How to clear:
rm -rf .semantic-code/index/
# Index rebuilds automatically on next searchWhat happens:
- All indexed data is removed
- Next search triggers a full re-index
- No configuration is lost (only the vector data)
Note: You don't need to clear regularly. The index automatically:
- Skips unchanged files (via content hashing)
- Updates modified files (delete + re-insert)
- Removes deleted files (via file watcher)
Clearing is only needed for edge cases like files renamed outside the editor while the server wasn't running.
Symptoms: Changes to code aren't reflected in search results
Causes:
- File watcher not running
- File is in an ignored pattern
- Content hash hasn't changed
Solutions:
- Check if file is being tracked:
# File should be in a supported extension
file your-file.ts
# Check if it matches ignore patterns
# Default ignores: node_modules, dist, build, .git, etc.- Force re-index the specific file by modifying it slightly
Symptoms:
- "Failed to load embedding model" error
- Network timeout errors
- Stuck on "Loading embedding model..."
Solutions:
- Check network connectivity:
curl -I https://huggingface.co- Clear the model cache:
rm -rf ~/.cache/semantic-code-mcp/transformers/- Check disk space (models are ~500MB):
df -h ~/.cache/- Set a custom cache directory:
export HF_HOME=/path/with/more/space/.cache/huggingfaceSymptoms:
- "JavaScript heap out of memory" error
- Process killed during model loading
Solutions:
- Increase Node.js memory limit:
NODE_OPTIONS="--max-old-space-size=8192" npx semantic-code-mcp- Use quantized model (default is q8, which is already efficient)
Symptoms: Search returns empty results for queries that should match
Causes:
- Index is empty
- Filter is too restrictive
- Query doesn't match indexed content semantically
Solutions:
- Check index status:
// The response includes indexStats
{
"indexStats": {
"totalChunks": 0, // Should be > 0
"indexed": true
}
}- Try without filters first:
semantic_search({ query: "function" }) // Basic test- Check if content was indexed:
# Look for chunker logs
LOG_LEVEL=debug npx semantic-code-mcpSymptoms: Results don't seem relevant to the query
Solutions:
- Use more specific queries:
// Instead of:
semantic_search({ query: "auth" })
// Try:
semantic_search({ query: "user authentication with JWT tokens" })- Use filters to narrow scope:
semantic_search({
query: "authentication",
path: "src/auth/",
file_pattern: "*.ts"
})- Increase result limit and review:
semantic_search({ query: "authentication", limit: 20 })Symptoms: Search takes too long or times out
Solutions:
- Use filters to reduce search space
- Reduce candidate multiplier:
// In code, when using hybridSearch directly
hybridSearch(query, store, { candidateMultiplier: 3 }) // Default is 5- Disable reranking for faster results:
hybridSearch(query, store, { useReranking: false })Symptoms: Initial indexing takes very long
Solutions:
- Add more files to ignore patterns:
const ignorePatterns = [
'**/node_modules/**',
'**/dist/**',
'**/*.min.js',
'**/coverage/**',
'**/__snapshots__/**',
];- Reduce batch size for more consistent progress:
indexDirectory({ batchSize: 5 }) // Default is 10- Monitor progress:
LOG_LEVEL=info npx semantic-code-mcp
# Watch for "Processing batch X/Y" messagesSymptoms: Process uses excessive memory
Solutions:
- Reduce chunks in memory:
indexDirectory({ maxChunksInMemory: 200 }) // Default is 500- Process smaller file batches:
indexDirectory({ batchSize: 5 })- Monitor memory:
# Watch Node.js memory usage
node --expose-gc -e "setInterval(() => console.log(process.memoryUsage()), 5000)"Symptoms: Claude Code can't connect to the server
Solutions:
- Check if server starts correctly:
# Run directly to see errors
npx semantic-code-mcp /path/to/project- Verify configuration in
claude_desktop_config.json:
{
"mcpServers": {
"semantic-code": {
"command": "npx",
"args": ["semantic-code-mcp"]
}
}
}- Use absolute paths when specifying a directory argument
Symptoms: Server indexes the wrong directory or can't find your code
Root directory priority:
- CLI argument:
npx semantic-code-mcp /path/to/project - Environment variable:
SEMANTIC_CODE_ROOT - Current working directory:
process.cwd()
Solutions:
- Check what directory is being used:
# Look for "Root directory:" in server output
npx semantic-code-mcp 2>&1 | head -5- For global MCP configs, always specify the directory:
{
"mcpServers": {
"semantic-code": {
"command": "npx",
"args": ["semantic-code-mcp", "/absolute/path/to/project"]
}
}
}- If using Claude Code directly, run from your project directory:
cd /path/to/project
claude
# The MCP server will use /path/to/project as rootSymptoms: "Invalid JSON" or protocol-related errors
Causes: Something is writing to stdout (MCP uses stdout for communication)
Solutions:
- Ensure all logging goes to stderr
- Remove any
console.logstatements - Check for third-party libraries writing to stdout
Symptoms: Can't read files or write index
Solutions:
- Check file permissions:
ls -la /path/to/project/
ls -la /path/to/project/.semantic-code/-
Run with appropriate permissions
-
Use a different index location:
SEMANTIC_CODE_INDEX=/tmp/semantic-code-index npx semantic-code-mcpSymptoms: Symlinked files not indexed or cause errors
Solutions:
- Symlinks are followed by default
- Circular symlinks may cause issues - add them to ignore patterns
- Consider using absolute paths
npx semantic-code-mcp --versionLOG_LEVEL=debug npx semantic-code-mcpnode -e "console.log({node: process.version, platform: process.platform, arch: process.arch})"# This will test if the model can be loaded
node -e "
const { pipeline } = require('@huggingface/transformers');
pipeline('feature-extraction', 'nomic-ai/nomic-embed-text-v1.5').then(() => console.log('OK')).catch(console.error);
"If you're still having issues:
- Check the GitHub Issues for known problems
- Enable debug logging and capture the output
- Report issues with:
- Node.js version
- Operating system
- Error messages
- Steps to reproduce