mcp-server-bm25-code-search
Offers a Function Calling adapter for Hermes Agent to use the BM25 code search engine in non-MCP environments.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-server-bm25-code-searchsearch for getUserProfile implementation"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-server-bm25-code-search
AI コーディングエージェント(Claude Code, Codex CLI, Antigravity, Hermes Agent)におけるファイル検索を高速化・低トークン化するための、SQLite FTS5 ベースのローカル BM25 コード検索エンジン & MCP サーバです。
✨ 特徴
📦 外部依存ゼロ (Python 標準ライブラリのみ)
sqlite3(FTS5) および標準ライブラリのみで構築されており、pip installなどのサードパーティ依存パッケージなしで即座に動作します。🔤 コード識別子 & 日本語ハイブリッド対応
getUserProfile(camelCase) やsession_token(snake_case) のサブワード分割に加え、日本語技術文書の CJK 2-gram(バイグラム)トークナイズを Python 側で事前処理。FTS5 インデックスと検索クエリの両方に自動適用されます。📁 ファイルパスブースト (3.0x)
FTS5 のbm25(code_fts, 3.0, 1.0)列重み付けにより、ファイルパスとの一致を本文の一致より 3.0 倍優遇。探したいファイルへ少ない検索回数で到達できます。⚡ 高速増分更新 & Git Worktree 非干渉
git ls-filesによる.gitignore完全準拠のファイル収集と、git diff/ HEAD ハッシュトラッキングによる高速増分更新(通常編集時 0.1〜0.5秒)。インデックス.bm25_index.dbは Worktree ローカルに配置され.gitignoreで自動除外されます。🔌 マルチエージェント標準対応 (MCP 2026-07-28 & Hermes)
MCP ネイティブ (Claude Code / Codex / Antigravity): 2026-07-28 仕様準拠のステートレス stdio JSON-RPC サーバ。プロンプトキャッシュ効率を高める決定論的ツールソートを実装。
Hermes Agent: MCP 非対応環境向けに薄い Function Calling アダプタ層 (
hermes_adapter.py) を標準同梱。
🛡️ コンテキスト溢れ防止 & フォールバック
出力文字制限 (--max-bytes) は UTF-8 のマルチバイト文字境界を保護して安全に切り詰め。検索結果 0 件時は grep/glob への切り替えを促す構造化フォールバックメッセージを返却します。
Related MCP server: lynx-mcp
📁 モジュール構成
mcp-server-bm25-code-search/
├── bm25_search/
│ ├── db.py # SQLite FTS5 v2 スキーマ (chunks / code_fts / triggers)
│ ├── tokenizer.py # 事前トークナイザ (camelCase / snake_case / CJK 2-gram)
│ ├── indexer.py # インデクサ (git ls-files, 80/20 チャンキング, 増分更新)
│ ├── search.py # 検索エンジン & CLI インターフェース
│ ├── mcp_server.py # MCP 2026-07-28 ステートレス stdio サーバ
│ └── hermes_adapter.py # Hermes Agent 向け Function Calling アダプタ
├── docs/
│ ├── specification.md # 詳細仕様書
│ └── plans/ # 設計ドキュメント
└── tests/ # pytest テストスイート🚀 使い方
1. CLI での検索実行
python bm25_search/search.py "<検索クエリ>" --top-k 5 --format markdown --max-bytes 4000主なオプション:
<query>: 検索クエリ(日本語、camelCase、snake_case 対応)--top-k: 返す検索結果の上限件数(デフォルト:5)--format: 出力形式markdownまたはjson(デフォルト:markdown)--max-bytes: 最大出力バイト数。マルチバイト文字を安全に維持して切詰(デフォルト:4000)--mode: クエリトークンの結合モードORまたはAND(デフォルト:OR)--db: 使用する SQLite インデックス DB パス(デフォルト:.bm25_index.db)
2. MCP サーバとしての起動(uvx / npx 対応)
プロジェクトごとに Stdio + 自動インデックス構築で動かすため、uvx または npx で即座に起動できます。
引数未指定の場合、MCP サーバが起動されたプロジェクト(カレントディレクトリ)のコードベースを自動検出・増分インデックス(.bm25_index.db)の作成・同期を行います。
① uvx (uv / Python) を使う場合
{
"mcpServers": {
"bm25-code-search": {
"command": "uvx",
"args": ["mcp-server-bm25-code-search"],
"alwaysAllow": ["search"]
}
}
}② npx (Node.js / npm) を使う場合
{
"mcpServers": {
"bm25-code-search": {
"command": "npx",
"args": ["-y", "mcp-server-bm25-code-search"],
"alwaysAllow": ["search"]
}
}
}③ ローカル Python での直接指定
{
"mcpServers": {
"bm25-code-search": {
"command": "python",
"args": [
"D:/path/to/mcp-server-bm25-code-search/bm25_search/mcp_server.py",
"--stdio"
],
"alwaysAllow": [
"search"
]
}
}
}💡 AI エージェントに grep 連打を抑止し BM25 検索を優先させる設定 (AGENTS.md / CLAUDE.md)
AI エージェントが grep を何度もリトライしてトークンやコンテキストを無駄に消費するのを防ぐため、利用するプロジェクトの AGENTS.md や CLAUDE.md(またはシステムプロンプト)に以下の指示を追記することを推奨します。
## コード検索の指示方針
- コードベースの機能調査やコード探索を行う際は、最初に MCP ツール `search` (BM25 Code Search) を優先して使用してください。
- `search` で結果が得られない場合、または特定のシンボル名の完全一致を直接検索する場合にのみ `grep_search` や `glob` を使用してください。3. Hermes Agent アダプタの使用
MCP 非対応の Hermes Agent からは、bm25_search.hermes_adapter モジュールを利用します。
from bm25_search.hermes_adapter import hermes_function_schema, run_hermes_tool
# Hermes 用 Tool Schema の取得
schema = hermes_function_schema()
# Hermes からの Function Call 実行
response = run_hermes_tool({
"name": "bm25_search",
"arguments": {
"query": "getUserProfile",
"top_k": 5
}
})🧪 テストの実行
pytest を使ってユニットテストおよび統合テストを実行できます。
pytest tests/📄 ドキュメント
📚 参考文献・関連リンク
論文: Wang et al., "BM25 Wins at Scale: Evaluating Agentic Search over Enterprise Corpora" (2026)
https://arxiv.org/abs/2607.26497解説記事: 須藤英寿(株式会社ナレッジセンス), "BM25を使用してCodexのトークンの消費を30%抑える" (Zenn, 2026)
https://zenn.dev/knowledgesense/articles/9e55a3bb67729c
⚖️ ライセンス
本プロジェクトは MIT License の下で公開されています。
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Tools
Related MCP Servers
- Alicense-qualityDmaintenanceA local, SQLite-backed code index for Claude Code, exposed over MCP, enabling targeted code retrieval without external APIs.1MIT
- AlicenseAqualityAmaintenanceA 100% local MCP server for semantic and lexical search over your code, library docs, and PDFs, featuring hybrid BM25 and dense retrieval, syntax aware chunking, and an optional code knowledge graph. It also ships a Coral integration, so you can expose your code search as SQL and join it with live data, all without anything leaving your machine.68Apache 2.0
- Alicense-qualityBmaintenanceA local hybrid-search MCP server that enables coding agents to query files and folders using natural language, returning relevant code chunks with exact source paths. Everything runs on-device with no API keys or network calls.4MIT
- Alicense-qualityAmaintenanceLocal MCP server to index your codebase once and search it across AI sessions with keyword, semantic, or hybrid search, keeping all data on disk.1314MIT
Related MCP Connectors
User-owned memory for AI agents, Copilot, Claude, IDEs, CLIs, and chat apps over remote MCP.
An MCP server that gives your AI access to the source code and docs of all public github repos
Token-efficient search for coding agents over public and private documentation.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/toaruR/mcp-server-bm25-code-search'
If you have feedback or need assistance with the MCP directory API, please join our Discord server