mdsearch - Fast full-text search for Markdown knowledge bases
Local full-text search CLI for Markdown knowledge bases, Obsidian vaults, and note collections. Powered by MiniSearch, with automatic indexing, fuzzy search, contextual snippets with line numbers, and LLM-ready output.
LLM-ready workflows
mdsearch helps AI tools and LLM workflows retrieve relevant context from Markdown knowledge bases.
Search results are available in structured formats designed for AI agents, automation, and context retrieval.
Learn more about the mdsearch skill:
https://github.com/onigetoc/mdsearch-skill
Version, Help & Listing
mdsearch --version
mdsearch --help
mdsearch --list
mdsearch --list --reindex
Installation
npm install
Or from npm:
npm install -g mdsearch-tool
Usage
npx mdsearch "<query>" [<folder>] [options]
node src/search-md.mjs "<query>" [<folder>] [options]
Folder defaults to the current directory if omitted. The index is auto-built on first run (cache in .mdsearch/).
All commands - copy/paste
mdsearch "minisearrch" notes-test
mdsearch "minisearrch" notes-test --no-fuzzy
mdsearch "minisearch" notes-test --fuzzy 0.4
mdsearch "term" notes-test
mdsearch "term" notes-test --boost-title 5 --boost-headings 3 --boost-text 1
mdsearch "term" notes-test --boost-title 1 --boost-headings 1 --boost-text 1
mdsearch "term" notes-test --limit 5
mdsearch "term" notes-test --context 0
mdsearch "term" notes-test --context 4
mdsearch "term" notes-test
mdsearch "term" notes-test --json
mdsearch "term" notes-test --context 4 --llm-context
mdsearch "minis" notes-test --prefix
mdindex ~/my-notes
mdindex ~/my-notes --cache-dir .mycache
mdsearch "minisearch" ~/my-notes
mdsearch "term" ~/my-notes --reindex
mdsearch "term" ~/my-notes --cache-dir .mycache
mdsearch "PI agent shell injection" ~/my-notes --context 4 --limit 3 --llm-context
Local development (without global install)
node src/search-md.mjs "minisearrch" notes-test
node src/search-md.mjs "minisearrch" notes-test --no-fuzzy
node src/search-md.mjs "minisearch" notes-test --fuzzy 0.4
node src/search-md.mjs "term" notes-test
node src/search-md.mjs "term" notes-test --boost-title 5 --boost-headings 3 --boost-text 1
node src/search-md.mjs "term" notes-test --boost-title 1 --boost-headings 1 --boost-text 1
node src/search-md.mjs "term" notes-test --limit 5
node src/search-md.mjs "term" notes-test --context 0
node src/search-md.mjs "term" notes-test --context 4
node src/search-md.mjs "term" notes-test
node src/search-md.mjs "term" notes-test --json
node src/search-md.mjs "term" notes-test --context 4 --llm-context
node src/search-md.mjs "minis" notes-test --prefix
node src/index-md.mjs ~/my-notes
node src/index-md.mjs ~/my-notes --cache-dir .mycache
node src/search-md.mjs "minisearch" ~/my-notes
node src/search-md.mjs "term" ~/my-notes --reindex
node src/search-md.mjs "term" ~/my-notes --cache-dir .mycache
node src/search-md.mjs "PI agent shell injection" ~/my-notes --context 4 --limit 3 --llm-context
Cache structure
.mdsearch/ contains:
index.json - serialized MiniSearch index
meta.json - folder signature (file count + max mtime), id → absolute path mapping
If the signature changes (file added/removed/modified), search-md.mjs detects it and re-indexes automatically.
Output formats
All formats include line numbers and normalized scores (0.00 - 1.00).
| Terminal | line 42: → matching content with highlighted match line |
| JSON | { "path": "...", "line": 42, "score": 0.92, "snippet": "..." } |
| LLM context | Confidence: 0.92 for each result, clean body without markers |
Skills
mdsearch supports reusable skills to extend and automate search workflows.
A skill defines a custom workflow for processing search results, generating summaries, extracting insights, or preparing content for AI-powered workflows.
Available skills
- Summarize - Generate concise summaries from indexed Markdown content.
- More skills coming soon.
Learn more about skills:
https://github.com/onigetoc/mdsearch-skills
Dependencies
Possible improvements
- Tag filtering -
mdsearch "claude" --tag "video" to filter by front-matter tags
- Multi-term -
mdsearch "claude archon" --and (results containing all terms)
- Stats mode -
mdsearch --stats : file count, estimated tokens, cache size
- Markdown export -
--export generates a .md file with formatted results
- Shell completions - tab completion for zsh/bash/powershell
- Watch mode -
--watch monitors files and re-indexes on change