New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

@onigetoc/mdsearch

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onigetoc/mdsearch

Blazing-fast full-text search CLI for Markdown knowledge bases with automatic indexing, fuzzy search, contextual snippets, and LLM-ready output.

latest
Source
npmnpm
Version
0.1.4
Version published
Maintainers
1
Created
Source

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.

For maximum token efficiency and streamlined context retrieval, we recommend using the dedicated mdsearch skill which provides automated, ready-to-use workflows for your LLM agents:

https://github.com/onigetoc/mdsearch-skill

Installation

npm install -g @onigetoc/mdsearch

After global install, use mdsearch directly (no npx):

mdsearch "<query>"              # search current directory
mdsearch "<query>" <folder>     # search a specific folder

Run without installation (npx)

npx @onigetoc/mdsearch "<query>" [<folder>]

Folder defaults to the current directory if omitted. The index is auto-built on first run (cache in .mdsearch/).

Examples

# SIMPLE
mdsearch "karpathy llm wiki"                               # current dir, fuzzy=0.2 (default)
mdsearch "karpathy llm wiki" notes-test                    # specific folder
mdsearch "term" --no-fuzzy                                 # exact only
mdsearch "term" --fuzzy 0.4                                # wider fuzzy

# BOOST
mdsearch "term"                                            # boost: title=3, headings=2, text=1
mdsearch "term" --boost-title 5 --boost-headings 3 --boost-text 1

# CONTEXT / LIMIT
mdsearch "term" --limit 5
mdsearch "term" --context 0                                # no snippet
mdsearch "term" --context 4

# OUTPUT FORMAT
mdsearch "term"                                            # human-readable
mdsearch "term" --json                                     # JSON with normalized scores + line
mdsearch "term" --context 4 --llm-context                  # compact for LLM prompts

# PREFIX, PHRASE & AND
mdsearch "minis" --prefix
mdsearch "karpathy llm" --phrase                           # exact phrase (sequence of terms)
mdsearch "karpathy llm" --and                              # require all terms (default: OR)

# CACHE / INDEX
mdindex ~/my-notes                                         # pre-build index
mdindex ~/my-notes --cache-dir .mycache
mdsearch "term" --reindex                                  # force rebuild
mdsearch "term" ~/my-notes --cache-dir .mycache

# VERSION / HELP / LIST
mdsearch --version
mdsearch --help
mdsearch --list                                            # list indexed files (auto-build if missing)
mdsearch --list --reindex                                  # force re-index before listing

Local dev test only

node src/search-md.mjs "<query>"          # test without installing

Options

FlagTypeDefaultDescription
--no-fuzzybooleanfalseDisable fuzzy matching (exact search only)
--prefixbooleanfalseEnable prefix search (match term prefixes)
--phrasebooleanfalseExact phrase search (sequence of terms in order)
--andbooleanfalseRequire all terms (default is OR — any term matches)
--boost-titlenumber3Weight multiplier for matches in document title
--boost-headingsnumber2Weight multiplier for matches in headings
--boost-textnumber1Weight multiplier for matches in body text
--limitnumber10Maximum number of results to return
--contextnumber2Lines of context before/after match (0 = snippet disabled)
--jsonbooleanfalseOutput results as JSON
--llm-contextbooleanfalseCompact LLM-friendly output format
--reindexbooleanfalseForce rebuild the search index
--cache-dirstring.mdsearchCustom cache directory name
--listbooleanfalseList all indexed files
--versionbooleanfalseShow version number
--helpbooleanfalseShow help message

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).

ModeExample
Terminalline 42: → matching content with highlighted match line
JSON{ "path": "...", "line": 42, "score": 0.92, "snippet": "..." }
LLM contextConfidence: 0.92 for each result, clean body without markers

Keywords

markdown

FAQs

Package last updated on 09 Jul 2026

Related posts