MarkIndex is a Markdown document retrieval tool for AI agents, with the core idea of "no vectors, structure-first". It does not rely on embedding models or vector databases, nor does it guess at chunking; instead, it parses each Markdown file into a tree made up of its own sections, and stores the tree structure, the raw lines, and a mixed Chinese-English BM25 index together in a single SQLite file. Agents browse the "library → folder → document → section" hierarchy through five read-only tools and read the original text with line numbers, and every piece of evidence can be cited in the form [doc_path, L<start>-<end>].
In terms of main capabilities, MarkIndex's index building is deterministic and requires no LLM: parsing uses mdast rather than regular expressions, and neither tree building nor token cost optimization calls a model, so the same input always produces the same tree. It correctly handles Markdown details such as Setext headings, preamble text before the first heading, documents without headings, front matter, # inside code fences, skipped heading levels, and BOM/CRLF, ensuring that every line of source text belongs to exactly one node, and oversized sections are split into chunk nodes at block boundaries. Keyword fallback supports Chinese, using Intl.Segmenter word segmentation for BM25, supplemented by a trigram substring index as a second pass. Tool responses are budget-limited and never throw exceptions; they return a JSON envelope with next_steps guidance and are kept within 95,000 characters, and outlines and sections are paginated.
In terms of usage, you can build an index with npx markindex index /path/to/docs, then register it as an MCP server with MCP-capable clients (such as Cursor), or let agents drive the tools through the Vercel AI SDK. The project also provides a built-in retrieve() evidence retrieval loop that returns original-text evidence re-read from the index by line range, along with usage and the stop reason. Underneath, it also exports building blocks such as parseMarkdown, buildTree, optimizeTree, openStore, indexLibrary, searchNodes, summarizeDocument, estimateSummaryCost, TOOL_CONTRACT, and createMcpServer. Indexing is incremental, comparing files by content hash and rebuilding only newly added orChange documentation: deleting a file removes it, and summaries are cached by node content hash.
Use cases include agent question answering and citation over long professional documents (such as SEC filings, guidelines, legal texts, and manuals), retrieval over Obsidian note vaults, and document analysis that requires auditable line-number citations. In terms of limitations, search is keyword-based rather than semantic, so the agent must compensate by rewriting queries and browsing folders; only .md and .markdown files are scanned, and .mdx is not processed; the index should be placed on a local disk, because write locks and WAL mode are unreliable on network volumes such as exFAT, SMB/NFS; only one writer is allowed at a time. The optional --rerank jev reranking is off by default; when enabled, it sends the question and candidate section text to a third-party service, so it is not suitable for documents that cannot be shared externally. Summaries and retrieve() send document text to the configured model provider; indexing itself makes no network calls. Documents are treated as untrusted input, and tool output should be handled as data rather than instructions, especially when the vault contains third-party or user-provided files and the agent also has action tools such as send, write, and execute.