Install
$ agentstack add mcp-etherled-local-mcp-search ✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ● Environment & secrets Used
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
About
local-mcp-search
Chinese README: [README.zh-CN.md](/D:/traeprj/mcpsd/README.zh-CN.md)
local-mcp-search is a Windows-first local STDIO MCP Server for Codex, Claude Code, and similar MCP-capable coding agents. The core idea is simple: use a small amount of local CPU/GPU for retrieval, reranking, and context compression, so the remote model spends less budget on blind scanning and more budget on reasoning and editing.
Why It Matters
Without a local retrieval layer, coding agents often:
- search too broadly
- read too many files
- waste expensive context on low-value text
- take extra turns to recover the right implementation context
local-search pushes that work down to local infrastructure:
- exact search with local
ripgrep - semantic retrieval with local embeddings
- local reranking
- compact span selection and context packing
- MCP tools and resources that agents can call directly
The goal is not "more tools". The goal is better agent economics:
- preserve task success
- reduce wasted token budget
- reduce unnecessary turns
- improve time-to-context
Measured Impact
Current benchmark evidence already shows practical value, but the gain pattern is agent-specific.
| Agent | Sample | Success Rate | Main Measured Gain | | --- | --- | --- | --- | | Claude | 4 tasks, baseline vs local-search | 4/4 -> 4/4 | cost -31.92%, turns -33.33%, latency -15.59% | | Codex | 4 tasks, baseline vs local-search | 4/4 -> 4/4 | token -21.94%, latency -3.76% |
Interpretation:
- for
Claude, the strongest current value signal issuccess rate + cost + latency + turn count - for
Codex, the strongest current value signal issuccess rate + latency + token - the exact gain depends on the agent and provider route; do not force one metric across every client
So the public claim should be:
local-searchalready shows practical, measurable efficiency wins in controlled agent benchmarks- a typical gain range today is on the order of
15%~30%, but the metric that moves most depends on the agent
How It Works
The design is intentionally simple:
- use small local resources to build and query a local index
- retrieve and rerank candidate files or spans before the agent reads them
- send the remote model only the most relevant context
That shifts cost away from repeated remote context waste and toward a lightweight local retrieval layer.
Current Positioning
alpha / 0.1.xWindows-first- built for
Codex,Claude Code, and MCP-oriented coding workflows - optimized for local
llama-serverdeployment
What You Get
- local exact search that is fast enough to replace broad blind file scanning
- semantic retrieval and reranking before the agent spends remote context
- compact file/span packaging so the model reads less but sees better context
- a single
cpxentrypoint for startup, reindex, MCP registration, and session resume - stable MCP resources and tools that fit real coding-agent workflows
Included MCP Tools
code_exact_searchsymbol_searchcode_semantic_searchcode_context_packkb_searchdoc_answer_contextfile_outlinesymbol_contextchange_contextdependency_overviewrepo_overviewopen_spansindex_statusreindex
Current Status
As of 2026-05-09:
- embedding and reranking are served locally through
llama-server cpxdefaults toCodexand resumes the latest session for the current workspacecpx -Clauderesumes the latest Claude session for the current workspacedoctorverifies model health and MCP registrationrepo://overview,repo://dependency-summary, andrepo://changesare available as stable MCP resources- the repo includes an automated benchmark harness for
baseline x local-search x Codex x Claude
The current strongest controlled benchmark evidence comes from Claude + Xiaomi Mimo 2.5 Pro, plus an earlier verified compatible Codex route.
Good Fit
- medium or large repositories
- workflows that frequently resume prior context
- projects that need both code and knowledge retrieval
- daily
Codex/Claude Codeusage
Not A Good Fit
- very small repositories
- workflows with little need for semantic retrieval
- users unwilling to maintain local models
- users expecting cross-platform zero-config setup
Quick Start
python -m venv .venv
.venv\Scripts\Activate.ps1
pip install -e .
Set model paths:
$env:LOCAL_SEARCH_LLAMA_SERVER="D:\path\to\llama-server.exe"
$env:LOCAL_SEARCH_EMBED_GGUF="D:\models\bge-base-zh.f16.gguf"
$env:LOCAL_SEARCH_RERANK_GGUF="D:\models\bge-reranker-v2-m3-Q8_0.gguf"
Then run a minimal smoke test:
python -m local_mcp_search.cli reindex --mode auto
python -m local_mcp_search.cli status
python -m local_mcp_search.cli doctor
codex mcp get local-search --json
claude mcp get local-search
Unified launcher entrypoint:
cpx
cpx -Claude
Local Models
The default setup expects local llama-server and launches two services through the Python launcher:
- embedding:
bge-base-zh - reranker:
bge-reranker-v2-m3
The launcher reads model paths from environment variables first. If they are not configured, it uses:
llama-serveras the executable name- empty GGUF paths, which causes startup to fail explicitly instead of silently falling back to a machine-specific path
Private local fallback config is supported and should not be committed:
- workspace-level:
/.local-search.env - user-level:
%USERPROFILE%/.local-mcp-search.env
Resolution order:
- CLI arguments
- environment variables
- workspace private config
- user private config
- safe defaults
Recommended environment setup:
$env:LOCAL_SEARCH_LLAMA_SERVER="D:\path\to\llama-server.exe"
$env:LOCAL_SEARCH_EMBED_GGUF="D:\models\bge-base-zh.f16.gguf"
$env:LOCAL_SEARCH_RERANK_GGUF="D:\models\bge-reranker-v2-m3-Q8_0.gguf"
Or put the same values in a private dotenv file:
LOCAL_SEARCH_LLAMA_SERVER=D:\path\to\llama-server.exe
LOCAL_SEARCH_EMBED_GGUF=D:\models\bge-base-zh.f16.gguf
LOCAL_SEARCH_RERANK_GGUF=D:\models\bge-reranker-v2-m3-Q8_0.gguf
Default ports:
embedding port: 8887
reranker port: 8888
The launcher probes ports first:
- if a healthy service is already running, it is reused
- if the port is occupied but the endpoint is unhealthy, startup fails loudly
- if no service is running, local
llama-serveris started automatically
Logs are written to:
%TEMP%\llama-logs\
Environment Variables
In most cases you do not need to export embedding or reranker variables manually; the launcher injects them.
Project-specific search and indexing config can live at the workspace root as .local-search.json. See [.local-search.example.json](/D:/traeprj/mcpsd/.local-search.example.json:1).
If you want to run python -m local_mcp_search directly, you need at least:
$env:MCP_SEARCH_WORKSPACE_ROOT="D:\your_repo"
$env:EMBEDDING_BASE_URL="http://127.0.0.1:8887/v1"
$env:EMBEDDING_MODEL="bge-base-zh"
$env:EMBEDDING_API_KEY=""
$env:MCP_SEARCH_RERANKER_ENABLED="true"
$env:RERANKER_BASE_URL="http://127.0.0.1:8888"
$env:RERANKER_MODEL="bge-reranker-v2-m3"
$env:RERANKER_API_KEY=""
Common optional variables:
$env:MCP_SEARCH_INDEX_DIR="D:\your_repo\.mcp-index"
$env:MCP_SEARCH_MAX_FILE_BYTES="300000"
$env:MCP_SEARCH_AUTO_REINDEX="false"
$env:MCP_SEARCH_AUTO_REINDEX_INTERVAL_SECONDS="5"
$env:MCP_SEARCH_RERANKER_CANDIDATE_MULTIPLIER="6"
$env:MCP_SEARCH_RERANKER_MAX_CANDIDATES="80"
$env:MCP_SEARCH_RERANKER_CACHE_ENABLED="true"
$env:MCP_SEARCH_RERANKER_CACHE_MAX_ENTRIES="5000"
$env:MCP_SEARCH_CONTEXT_PACK_MAX_CHARS="20000"
$env:MCP_SEARCH_QUERY_DEBUG="false"
$env:EMBEDDING_TIMEOUT_SECONDS="10"
$env:RERANKER_TIMEOUT_SECONDS="30"
$env:MCP_SEARCH_CODE_CHUNK_LINES="120"
$env:MCP_SEARCH_KB_CHUNK_CHARS="1600"
Notes:
- the default workspace root is the current directory; if the current directory is inside a git repository, it is promoted to the git root
- the default index directory is
\.mcp-index - project-level
.local-search.jsoncan override part of the indexing and retrieval behavior reindexuses batch embedding requests to avoid oversized single requests- if you switch embedding models or dimensions, run
reindex full - with
MCP_SEARCH_QUERY_DEBUG=true,code_exact_search,code_semantic_search,kb_search, andcode_context_packinclude an extradebugfield in their JSON payload - if model paths are missing, launcher startup fails explicitly instead of falling back to the author's machine-specific paths
Currently supported .local-search.json keys:
ignore_dirsdoc_dirsmax_file_byteslanguages
Example:
{
"ignore_dirs": [".openhands", "vendor", "tmp"],
"doc_dirs": ["docs", "notes", "runbooks"],
"max_file_bytes": 200000,
"languages": ["python", "typescript", "javascript"]
}
CLI
Reindex:
python -m local_mcp_search.cli reindex --mode auto
Force a full rebuild:
python -m local_mcp_search.cli reindex --mode full
Incremental only:
python -m local_mcp_search.cli reindex --mode incremental
Status:
python -m local_mcp_search.cli status
Build a compact context pack:
python -m local_mcp_search.cli context-pack "authentication-related implementation" --max-results 6 --max-chars 12000
Enable query debug output:
$env:MCP_SEARCH_QUERY_DEBUG="true"
python -m local_mcp_search.cli context-pack "authentication-related implementation" --max-results 6 --max-chars 12000
Start The MCP Server Directly
If you already prepared the required environment variables:
python -m local_mcp_search
The more common entrypoint is the launcher:
python -m local_mcp_search.launcher
It will:
- ensure local embedding and reranker services are available
- inject workspace-specific environment variables
- run
reindex - refresh the
local-searchMCP registration - launch
Codexby default and resume the latest session
cpx Unified Entry Point
[cpx.ps1](/D:/traeprj/mcpsd/cpx.ps1:1) is the PowerShell wrapper. By default it is equivalent to:
python -m local_mcp_search.launcher --client codex
Running:
cpx
automatically:
- resolves the target workspace
- starts or reuses local llama services
- refreshes the index
- registers
local-search - launches
Codex - resumes the latest workspace session, or starts a new one if none exists
If you want cpx available globally in PowerShell, add a thin wrapper to your profile:
function cpx {
param(
[Parameter(ValueFromRemainingArguments = $true)]
[string[]]$Args
)
& "D:\trae_prj\mcp_sd\cpx.ps1" @Args
}
Common cpx Examples
Start in the current directory and resume the latest Codex session:
cpx
Explicitly start Codex:
cpx -Codex
Explicitly start Claude Code:
cpx -Claude
Specify a project root:
cpx -ProjectRoot D:\trae_prj\myagent -Codex
Resume the latest Claude session:
cpx -ProjectRoot D:\trae_prj\myagent -Claude
Ignore history and force a fresh session:
cpx -Codex -Fresh
cpx -Claude -Fresh
Interactively pick a session:
cpx -Codex -Pick
cpx -Claude -Pick
Fork the latest session:
cpx -Codex -Fork
cpx -Claude -Fork
Force full reindex:
cpx -Codex -ReindexMode full
Update MCP only and do not launch a client:
python -m local_mcp_search.launcher --client none
Disable reranking:
cpx -ProjectRoot D:\trae_prj\myagent -Claude -DisableReranker
Register Claude MCP at the same time:
cpx -ProjectRoot D:\trae_prj\myagent -Codex -RegisterClaude
Write project-level Claude .mcp.json:
cpx -ProjectRoot D:\trae_prj\myagent -WriteClaudeProjectConfig
MCP Registration
The launcher refreshes MCP configuration automatically.
Current Codex registration is equivalent to:
codex mcp add local-search -- C:\Program Files\Python311\python.exe D:\your_repo\.mcp-index\_mcp_server_wrapper.py
Current Claude Code registration is equivalent to:
claude mcp add local-search C:\Program Files\Python311\python.exe D:\your_repo\.mcp-index\_mcp_server_wrapper.py
The wrapper is written to:
\.mcp-index\_mcp_server_wrapper.py
It prepares:
PYTHONPATH/srcMCP_SEARCH_WORKSPACE_ROOT- embedding and reranker endpoints
Verify MCP
Codex:
codex mcp list
codex mcp get local-search --json
Claude:
claude mcp list
claude mcp get local-search
You can also run a health check directly:
python -m local_mcp_search.cli status
Under normal conditions, index_status should show:
reranker_enabled: true
reranker_model: bge-reranker-v2-m3
embedding_model: bge-base-zh
health.status: healthy
If Codex or Claude Code still reports MCP startup failures, or tools such as change_context / repo://changes misbehave:
- first confirm that
codex mcp get local-search --json/claude mcp get local-searchpoints to the current workspace.mcp-index/_mcp_server_wrapper.py - if the path is already correct but the session still uses an old connection, restart the client session
- then run
python -m local_mcp_search.cli doctorand inspectcodex_mcp_matches_workspace, embedding, and reranker status
How To Use It Inside Codex / Claude
Examples of direct prompts:
Use local-search to inspect the project structure first.
Call index_status and confirm reranker_enabled and reranker_model.
Use code_exact_search to find a concrete function name, then open the key spans.
Use code_context_pack to inspect authentication-related implementation, then continue from the returned spans.
Use kb_search to find deployment notes, then open the most relevant spans.
If the client prefers MCP resources, these stable resources are also available:
repo://overviewrepo://dependency-summaryrepo://changes
Recommended Tool Order
- use
repo_overviewfirst for repository structure - use
symbol_searchfirst for concrete symbols - use
code_exact_searchfirst for concrete strings - use
code_semantic_searchfor similar logic or implementation patterns - prefer
code_context_packfor implementation or debugging work - use
file_outlinebefore reading a file - use
open_spansfor precise spans - use
symbol_contextbefore editing a function or class - use
change_contextfor current worktree changes - use
dependency_overviewfor dependency and build configuration - use
index_statusfor index and backend health
change_context currently provides:
- change types such as added / modified / deleted / renamed / untracked
- grouping into
docs/code/config/tests/high_attention - risk levels based on file type and change scale
- git
numstatsummary
Benchmark
The repository includes an automated harness to compare baseline vs local-search on both Claude and Codex.
Current controlled results already show practical value:
| Agent | Sample | Success | Main Result | | --- | --- | --- | --- | | Claude | 4 tasks | 4/4 -> 4/4 | cost -31.92%, turns -33.33%, latency -15.59% | | Codex | 4 tasks | 4/4 -> 4/4 | token -21.94%, latency -3.76% |
That is the main benchmark takeaway:
- for
Claude, the value is preserving success while reducing cost, time, and turn count - for
Codex, the clearest signal is token reduction with a modest latency win - benchmark interpretation should stay agent-specific, rather than forcing one m
…
Source & license
This open-source MCP server is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: etherled
- Source: etherled/local-mcp-search
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet — be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.