semantic-search-mcp
Enables AI coding agents to perform semantic code search locally, finding code by meaning rather than exact keywords.
README
semantic-search-mcp
Semantic code search for AI coding agents. Local embeddings. No API keys. No data leaves your machine.
Your AI agent (opencode, Claude) can grep for exact words - but semantic-search-mcp lets it find code by meaning. Ask "where do we handle authentication?" and it returns auth.controller.ts, login.component.jsx, auth.config.php - even if the word "handle" doesn't appear in any of them.
80MB model. Runs 100% locally. Powered by bge-small-en-v1.5.
Grep vs. Semantic Search
On a 6,900-file codebase:
| Query | Grep | semantic-search-mcp |
|---|---|---|
| "where users upload avatars" | 30+ results, unsorted, mixed noise | 5 ranked, best match first (0.835) |
| "how error logs are sent" | 0 results (no file contains "sent" + "logs") | 5 results across handlers, mailers, config |
| "scheduled task for cleanup" | 2 results (only exact matches) | 5 results - cron jobs, queues, commands |
| Time | ~30s searching + scanning | 2 seconds from cache |
Quick Start (3 steps)
1. Install
npm install -g semantic-search-mcp
2. Index your project
cd /path/to/your-project
semantic-search-mcp index
The folder you run this from gets indexed. Shows live progress:
████████████████░░░░░░ 70% (5200/7368) - ~120s remaining
██████████████████████ Done! 7368 chunks in 726s.
First run downloads the model (~80MB, one-time) + indexes your code (5-15 min depending on project size). After that, the cache is saved and restarts are instant.
Multiple projects? Run cd /project-a && semantic-search-mcp index, then cd /project-b && semantic-search-mcp index. Each project gets its own cache automatically.
3. Connect your AI agent
Add this to your opencode.json (or opencode.jsonc) in the project root:
{
"mcp": {
"semantic-search": {
"type": "local",
"command": ["npx", "-y", "semantic-search-mcp"],
"enabled": true
}
}
}
Claude Desktop - add to claude_desktop_config.json:
{
"mcpServers": {
"semantic-search": {
"command": "npx",
"args": ["-y", "semantic-search-mcp"]
}
}
}
Claude Code (CLI) - add .mcp.json to your project root:
{
"mcpServers": {
"semantic-search": {
"command": "npx",
"args": ["-y", "semantic-search-mcp"]
}
}
}
Restart your AI agent. Done. Searches are instant - cache was already built.
FAQ
Which folder gets indexed?
The folder you cd into before running semantic-search-mcp index. It's your current working directory. When opencode or Claude starts the MCP server, that same folder gets used automatically.
I have 3 projects. Do I index each one?
Yes. Each project has its own cache:
project-a/.opencode/mcp-cache/semantic-search/index.json
project-b/.opencode/mcp-cache/semantic-search/index.json
project-c/.opencode/mcp-cache/semantic-search/index.json
Where is the cache stored?
{your-project}/.opencode/mcp-cache/semantic-search/index.json
About 50-100MB per project. Survives PC restarts, Git pulls, everything. It's just files on disk. Only cleared if you run semantic-search-mcp clean.
How do I remove the cache?
semantic-search-mcp clean
Do I need to re-index after code changes?
No. But if you add many new files or want fresh results: semantic-search-mcp clean && semantic-search-mcp index.
What model does it use?
Xenova/bge-small-en-v1.5 by default (80MB, 384-dim, retrieval-optimized). You can switch models via semantic-search-mcp config.
Is my code sent anywhere?
No. Everything runs on your machine - model, embeddings, search. Zero network calls after model download.
CLI Commands
semantic-search-mcp index # Index current folder (live progress bar)
semantic-search-mcp config # Interactive TUI to pick extensions, model, thresholds
semantic-search-mcp clean # Remove index cache
semantic-search-mcp init # Print opencode/Claude config snippet
semantic-search-mcp # Start the MCP server (used by AI agents)
semantic-search-mcp --help # All commands
Configuration
Run semantic-search-mcp config for interactive setup (checkboxes for extensions, searchable model picker, number inputs).
Or create .semantic-search.json in your project root:
{
"extensions": [".php", ".js", ".jsx", ".ts", ".tsx"],
"skipDirs": ["node_modules", "vendor", ".git", "dist"],
"model": "Xenova/bge-small-en-v1.5",
"chunkThreshold": 300,
"maxChunksPerFile": 4
}
Or env vars: SEMANTIC_SEARCH_EXTENSIONS=.php,.js, SEMANTIC_SEARCH_MODEL=Xenova/bge-small-en-v1.5
All options
| Key | Default | |
|---|---|---|
extensions |
20+ code extensions | File types to index |
skipDirs |
node_modules, vendor, .git, ... | Directories to skip |
model |
Xenova/bge-small-en-v1.5 | HuggingFace embedding model |
cacheDir |
.opencode/mcp-cache/semantic-search | Where cache is stored (per project) |
chunkThreshold |
300 | Lines before splitting file |
maxChunksPerFile |
4 | Max chunks per large file |
maxResults |
50 | Max search results |
defaultLimit |
10 | Default results per query |
How It Works
- Scan - walk your project, find code files
- Extract - split at function/class boundaries (PHP, JS, TS, Python, Go, Rust, Java)
- Embed - run each chunk through a local ONNX model (384-dim vectors)
- Cache - save everything to disk
- Search - embed your query, find closest matches via cosine similarity
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。