MicroSearch MCP Server
by kineticdirt
README.md
# microsearch-mcp
**MicroSearch** as a small, generic **MCP server** (Model Context Protocol): ingest context and training-style JSONL, keep **multiple named iterations** on disk, then run the **four-tool** retrieval ladder (preview → retrieve → MCP handoff) over a **BDH-style** lexical chunk graph (`next` / `prev` link expansion).
No vector DB required. Optional HTTP transport uses FastAPI.
## Four tools
| Tool | Purpose |
|------|---------|
| `microsearch_ingest` | Ingest `documents[]` (chunked into the graph), append `training_records[]` as JSON Lines, **list** iterations, **activate** an iteration, or **create** a new iteration. |
| `microsearch_preview` | Pass 1 — corpus index + cheap lexical hits (no link expansion). |
| `microsearch_retrieve` | Passes 2–3 — linked expansion, `max_chars`, optional `refine_query`, `tier` (`ground` / `deep`). |
| `microsearch_prepare_mcp_handoff` | Pass 4 — suggested downstream MCP tools + argument hints (does **not** call foreign MCPs). |
## Data layout
Set **`MICROSEARCH_DATA_ROOT`** (default: `./data` under the process working directory):
```text
{MICROSEARCH_DATA_ROOT}/
registry.json # active_iteration_id + iteration metadata
iterations/
{iteration_id}/
bdh_graph.json # chunk graph
training/
examples.jsonl # one JSON object per line (your schema)
```
Iterations are plain string ids (slugged on create). **`microsearch_preview`** responses include `iterations` and `active_iteration_id` so hosts can orient without an extra tool.
## Environment
| Variable | Meaning |
|----------|---------|
| `MICROSEARCH_DATA_ROOT` | Root directory for registry + `iterations/` |
| `MICROSEARCH_MCP_HANDOFF_CATALOG` | Optional JSON file for pass-4 rules (`tools` array); see `examples/handoff_catalog.example.json` |
## Install
```bash
cd microsearch-mcp
pip install .
# HTTP transport:
pip install '.[http]'
```
Editable install:
```bash
pip install -e .
```
## Run (stdio MCP)
```bash
export MICROSEARCH_DATA_ROOT="$PWD/data"
python -m microsearch_mcp serve stdio
```
**Cursor / Claude Desktop** (conceptually):
```json
{
"mcpServers": {
"microsearch": {
"command": "python3",
"args": ["-m", "microsearch_mcp", "serve", "stdio"],
"cwd": "/path/to/project",
"env": { "MICROSEARCH_DATA_ROOT": "/path/to/project/data" }
}
}
}
```
## Run (HTTP)
```bash
pip install '.[http]'
export MICROSEARCH_DATA_ROOT="$PWD/data"
python -m microsearch_mcp serve http --host 127.0.0.1 --port 8777
```
`POST /mcp` — JSON-RPC: `initialize`, `tools/list`, `tools/call` (same pattern as many sample MCP HTTP servers).
## Repository
**https://github.com/kineticdirt/microsearch-mcp**
## Batch file ingest (CLI)
```bash
export MICROSEARCH_DATA_ROOT="$PWD/data"
microsearch-mcp ingest-files --text ./notes.txt --manifest ./paths.list --iteration-id default
```
## Ingest via MCP (tool)
Call `microsearch_ingest` with:
- `documents`: `[{ "doc_id": "runbook-auth", "text": "...", "metadata": { "source": "notion" }, "replace": true }]`
- `training_records`: arbitrary objects appended to `training/examples.jsonl` (for fine-tuning datasets, intent logs, etc.)
- `create_iteration_id` + `make_created_iteration_active` to start a new snapshot
- `list_iterations: true` or `activate_iteration_id: "v2"` for housekeeping
Same `doc_id` re-ingested with `replace: true` (default) replaces that document’s chunks.
## License
MIT — see `LICENSE`.
## Upstream
Extracted from the Cequence BlackWall workspace; this repo is the **portable** MCP + BDH package. Monorepo copies under `retrieval-eval/experiments/microsearch_mcp_*.py` may lag — treat **this repository** as canonical for installs.
Maintenance
ActivityInactive
ResponsivenessNo recent community issues