MarkIndex MCP Server
Vectorless, structure-first search over large Markdown libraries: section trees + zh/en BM25
MarkIndex scores 67 (Good), licensed MIT and written in TypeScript. It installs as a local process. It declares 5 tools. Filed under Databases, AI and memory. GitHub shows 1 stars. Package registries report about 305 downloads a week. Install configs are generated for 10 clients. Being listed in the registry is not the same as being vendor-official.
Good trust
67 of 100 from six public signals. Nobody can buy a point.
- Listed in the official MCP registry.
- OSI-style license: mit.
License, quality and maintenance
Where the 67 comes from
22 + 20 + 1 + 10 + 4 + 10 = 67. Each factor is capped, so no single signal can carry a listing.
Active in the official MCP registry, plus a known vendor namespace.
Registry: 22 of 30 points.How recently the repository saw a commit or release.
Maintenance: 20 of 20 points.GitHub stars and weekly downloads, on a log scale.
Popularity: 1 of 20 points.A clear, OSI-style open-source license.
License: 10 of 10 points.Not archived, a secure install path, a pinned version.
Security: 4 of 10 points.A real summary, a README with depth, listed tools.
Docs: 10 of 10 points.Install
Pick your client, copy the config, paste it in.
Needs Cursor or VS Code installed on this device. The button opens the app and asks you to confirm before it adds the server.
{ "mcpServers": { "jackjin1997-markindex": { "command": "npx", "args": [ "-y", "markindex@0.2.0" ] } }}
Environment variables
This server does not declare environment variables.
Tools5Tool docs quality grade B
All capabilitiesbrowse_documentstoolList a folder: sub-folders and documents (path, title, description, tokens), paginated. The default discovery tool.
get_documenttoolOne document's metadata, front matter, size and readstructurefirst (true above 15 000 tokens).
The section outline (node ids, titles, line ranges, tokens, summaries — no body), depth levels (default 2), optionally only one node's subtree; paginated with part.
get_node_contenttoolOriginal Markdown of 1-20 nodes with line numbers (123│ …), paginated for long nodes.
search_documentstoolBM25 keyword search over titles, merged sub-headings, summaries and text, with trigram fallback; scope by folder or docpath. The escalation path when browsing stalls.
About
MarkIndex
Vectorless, structure-first retrieval over large libraries of long Markdown documents — for agents.
MarkIndex parses every Markdown file into a tree of its own sections, stores the trees, the original lines and a
mixed Chinese/English BM25 index in one SQLite file, and gives an agent five read-only tools to walk
"library → folder → document → section" and read the original text with line numbers. No embeddings, no vector
database, no chunking guesswork: the document's own structure is the index, and every piece of evidence can be
cited back as [doc_path, L<start>-<end>].

Inspired by VectifyAI/PageIndex, MarkIndex is an independent, unofficial TypeScript implementation focused on Markdown. It is not affiliated with or endorsed by VectifyAI.
中文说明:README.zh-CN.md
Results
FinanceBench, 150 questions about SEC filings, all 367 filings in one library, the same judge for every row (method, tables and paired tests):
| Setup | Accuracy | Cost of the whole run |
|---|---|---|
| Dense retrieval, top-20 pages, one model call (Sonnet 5.5) | 67.3% | $21.35 |
| Agent with MarkIndex (Sonnet 5.5) | 88.0% | $8.45 |
| Agent with MarkIndex (Haiku 5.5) | 90.7% | $1.69 |
| Agent over flat page chunks with BM25 (Sonnet 5.5) | 89.3% | $7.07 |
- An agent over a keyword index beats dense retrieval by 20.7 points at 40% of the cost, and a small model does it for about one cent per question.
- The section tree is not what wins. An agent over flat chunks scores the same, so the gain comes from letting the model search, read and search again. We report that instead of hiding it; on QASPER, where one retrieval already finds the evidence, the three setups do not differ at all.
- The index costs nothing to build: a few minutes on a laptop CPU for these 367 filings (1.8 million lines), with no model call and no embedding step.
Why
- Reads documents the way their authors organized them. Long professional documents (filings, guidelines, laws, manuals) already have an outline. Sections, not arbitrary chunks, are the unit an agent browses and cites. On our benchmarks this does not raise accuracy over flat chunks (see Results); it gives the agent an outline to read and every answer a line range to point at.
- Deterministic and LLM-free indexing. Parsing (mdast, not regex), tree building and the token-cost tree
optimization never call a model; the same input always produces the same tree. LLMs are optional and only used
for node summaries, document descriptions and the built-in
retrieve()loop. - Markdown done properly. Setext headings, preface text before the first heading, documents without any
heading, front matter,
#inside code fences, skipped heading levels, BOM / CRLF — every source line belongs to exactly one node, and oversized sections are split at block boundaries intochunknodes. - Keyword fallback that works for Chinese. BM25 over
Intl.Segmenterword segmentation (Chinese, English and mixed text, identifiers likeC++,ISO-27001,v2.1), plus a trigram substring index as a second pass. - Budgeted tool responses. Tools never throw; they return JSON envelopes with
next_stepsguidance and stay under a 95 000-character budget, paginating large outlines and sections.
Install
npm install markindex # library + CLI (Node.js >= 22.12)
npx markindex --help
From source:
git clone https://github.com/jackjin1997/markindex.git && cd markindex
npm install && npm run build
node dist/cli.js --help # or `npm link` to get a `markindex` command
Optional, only for LLM features (summaries, retrieve(), agent-mode evaluation): install the
AI SDK provider you want, e.g. npm install @ai-sdk/anthropic, and set its API key
(ANTHROPIC_API_KEY, …). With npx and no local install, put the provider in the same temporary environment:
npx -p markindex -p @ai-sdk/anthropic markindex index ./docs --summary-model anthropic:claude-sonnet-5-5
CLI
# Build or incrementally update the index (stored in <root>/.markindex/index.db)
markindex index ./docs
markindex index ./docs --summary-model anthropic:claude-sonnet-5-5 --estimate # cost estimate, no LLM calls
markindex index ./docs --summary-model anthropic:claude-sonnet-5-5 # with node summaries
markindex index ./docs --summary-model anthropic:claude-sonnet-5-5 --summary-rpm 50 --summary-tpm 40000 # rate-limited
markindex index ./docs --json # machine-readable report
markindex index ./docs --no-setext # converter output with `---` page breaks
markindex index ./docs --ignore 'drafts/' --ignore '*.tmp.md' # extra ignore patterns (repeatable)
# Inspect one document's section tree
markindex tree ./docs guides/setup.md --depth 3
# Keyword search (BM25 + trigram fallback)
markindex search ./docs "离职 补偿"
markindex search ./docs "ISO-27001 audit" --folder policies --limit 5 --json
# Serve the library to agents over MCP (stdio, read-only)
markindex mcp ./docs
markindex mcp ./docs --reindex-on-start
# Measure retrieval quality on your own documents (see "Evaluation")
markindex eval ./docs --questions questions.jsonl --mode bm25 --out report.json
markindex eval ./docs --questions questions.jsonl --mode agent --model anthropic:claude-sonnet-5-5 --out report.json
markindex eval ./docs --questions questions.jsonl --mode agent --model anthropic:claude-sonnet-5-5 --rpm 50 --tpm 40000
Rate limits. Calls are always bounded by concurrency (--concurrency for eval; 8 for summaries) and the AI SDK's
retries, which already honor retry-after / retry-after-ms on 429 / 5xx responses (up to 60 s). To stay under a
provider quota, add a client-side limit: --summary-rpm / --summary-tpm on index, --rpm / --tpm on eval
(agent mode). rpm caps requests and tpm caps estimated input tokens in any sliding 60 s window; both are
shared by all documents (index) or all questions (eval) of the run, and waiting callers are served in order. Input
tokens are estimated from the prompt text (about 1 token per CJK character, otherwise 4 characters), so leave
headroom below the real quota; output tokens and tool definitions are not counted. A single request larger than the
tpm still goes through, alone. In the library, pass rateLimit: { requestsPerMinute, inputTokensPerMinute } to
summarizeDocument / indexLibrary({ summary }) or retrieve(); reuse the same object to share one budget.
--summary-model / --model take <provider>:<model>; MarkIndex imports @ai-sdk/<provider> dynamically, so
only the provider you use needs to be installed. Every command accepts --db <file> to use a different index file.
Put the index on a local disk: the writer lock uses hard links and SQLite runs in WAL mode, neither of which works
reliably on exFAT, SMB / NFS shares or other network volumes. If the documents live there, keep them in place and
point --db at a local path (e.g. --db ~/.cache/markindex/docs.db).
Indexing is incremental: files are compared by content hash, only new or changed documents are rebuilt (one
transaction per document), deleted files are removed, and summaries are cached by node content hash. Scanned files
are .md and .markdown (not .mdx). Ignored are: paths matched by the library's own .gitignore files (at any
level under the root; global git excludes and .git/info/exclude are not read), by an optional .markindexignore
file at the root (same syntax, for rules you don't want in .gitignore) and by --ignore <pattern> options
(gitignore syntax, relative to the root, repeatable; ignore: string[] in the library API; also accepted by
mcp --reindex-on-start; a leading ./ is dropped, a leading / anchors at the root as in gitignore, and
absolute filesystem paths or ../ are rejected). The sources only add exclusions: a ! rule in .markindexignore
or --ignore cannot re-include a path that a .gitignore excludes. A document that becomes ignored is removed
from the index on the next run.
Dot-directories such as .git and .markindex are skipped and symlinks are not followed. One writer at a time (a
second index fails fast); readers such as the MCP server are never blocked. When the index was built by an older MarkIndex version or with different
tree parameters, the next index run rebuilds every document (full rebuild: … in the output, rebuilt in the
report); cached summaries are reused.
Page breaks from PDF / HTML converters. Converters often emit a bare --- line right after a page's last
paragraph. CommonMark reads that as a setext heading, so the whole paragraph becomes a level-2 heading. index
warns when it sees setext h2 headings whose text spans several lines or exceeds 120 characters (warning <path>: …
on stdout, warnings in the JSON report). For such libraries pass --no-setext (also on
mcp --reindex-on-start; setext: false in the library API): --- then is a thematic break and === plain text.
The setting is stored in the index: later runs without the flag (index, mcp --reindex-on-start,
Library.index()) keep it; pass --setext (setext: true) to turn it back on. Changing it rebuilds the index.
Library usage
import { openLibrary } from 'markindex'
// Index (or update) a folder, then open it read-only for agents.
const writer = openLibrary({ root: './docs', readonly: false })
await writer.index() // { added, updated, removed, unchanged, skipped, summaryErrors, warnings }
writer.close()
const lib = openLibrary({ root: './docs' })
const envelope = await lib.callTool('search_documents', { query: 'termination notice period' })
console.log(JSON.parse(envelope)) // { success: true, data: { results: [...] }, next_steps: {...} }
With the Vercel AI SDK (your agent drives the tools)
import { generateText, stepCountIs } from 'ai'
import { anthropic } from '@ai-sdk/anthropic'
import { AGENT_INSTRUCTIONS, createAiSdkTools, openLibrary } from 'markindex'
const lib = openLibrary({ root: './docs' })
const { text } = await generateText({
model: anthropic('claude-sonnet-5-5'),
system: AGENT_INSTRUCTIONS, // browse first, read structure, cite [doc_path, L<start>-<end>]
tools: createAiSdkTools(lib),
stopWhen: stepCountIs(15),
prompt: 'What notice period applies when an employee resigns?',
})
Built-in evidence retrieval
retrieve() runs the same tools in a model loop and returns evidence only (original text re-read from the
index by line range — never model-written text), plus usage and why it stopped:
import { anthropic } from '@ai-sdk/anthropic'
import { openLibrary, retrieve } from 'markindex'
const lib = openLibrary({ root: './docs' })
const { evidence, usage, stopReason } = await retrieve(lib, 'What notice period applies when an employee resigns?', {
model: anthropic('claude-sonnet-5-5'),
maxSteps: 12,
maxInputTokens: 200_000,
rateLimit: { requestsPerMinute: 50, inputTokensPerMinute: 40_000 }, // optional, client-side
})
for (const e of evidence) console.log(`${e.docPath} L${e.startLine}-${e.endLine}`, e.titlePath.join(' > '))
Lower-level building blocks are exported too: parseMarkdown, buildTree, optimizeTree, openStore,
indexLibrary, searchNodes, summarizeDocument, estimateSummaryCost, TOOL_CONTRACT, createMcpServer.
MCP setup
Build the index first (npx markindex index /path/to/docs), then register the server. MarkIndex is also listed in the
official MCP Registry as io.github.jackjin1997/markindex, so registry-aware
clients can install it from there (they start it as npx markindex mcp <docs_dir> --reindex-on-start).
Claude Code
claude mcp add markindex -- npx markindex mcp /path/to/docs
Cursor (~/.cursor/mcp.json or .cursor/mcp.json in a project)
{
"mcpServers": {
"markindex": {
"command": "npx",
"args": ["markindex", "mcp", "/path/to/docs"]
}
}
}
The server sends AGENT_INSTRUCTIONS as its MCP instructions and marks all tools read-only.
On an Obsidian vault
A vault is a folder of Markdown, so it works as a library as it is:
npx markindex index ~/vault
claude mcp add vault -- npx markindex mcp ~/vault --reindex-on-start
--reindex-on-start picks up the notes changed since the last session and skips the rest. On the official
Obsidian Help vault (181 English notes, 18,000 lines) the first index
takes about 3 seconds on a laptop, and a start with nothing changed takes under 1 second.
MarkIndex never writes to your notes. The only file it creates is the index, <vault>/.markindex/index.db by
default; pass --db <file> to both commands to keep it outside the vault, or add .markindex/ to .gitignore if
the vault is a git repository. To keep a folder away from the agent (a journal, say), list it in a
.markindexignore file at the vault root, in gitignore syntax.
What happens to Obsidian's own syntax:
| In the vault | In MarkIndex |
|---|---|
| Headings | The section tree the agent browses and cites by line range. |
[[Wikilinks]], ![[embeds]], callouts, #tags in the text | Kept as text and searchable. Links are not followed, embeds are not expanded, and there is no backlink graph. |
| Properties (YAML front matter) | Returned with the note's metadata by get_document. Not searched. |
.canvas, .base, PDFs, images | Not indexed. Markdown only. |
| Dataview and other plugin queries | Left as code blocks. Nothing is evaluated. |
Search is by keyword, not by meaning: it finds notes that share words with the query, in Chinese, English or a mix. An agent makes up for that by rewording its query and by browsing folders, so clear folder and note names help.
Optional: rerank search results (experimental)
Off by default. search_documents is a keyword search: it finds sections that share words with the query, in BM25
order. With --rerank jev the server takes the 50 best keyword hits, asks Jev
(a hosted decision model by TypeSafe that answers yes/no questions with a probability and generates no text)
whether each one helps answer the question, and returns the best. The tool then also takes an optional intent:
the agent says in a full sentence what it is looking for, and the hits are judged against that instead of the
keywords. Each hit carries a relevance between 0 and 1, and the result says how many hits were scored.
TYPESAFE_API_KEY=... npx markindex mcp /path/to/docs --rerank jev
- It sends text to a third party. Every search sends its question and up to 8,000 characters of each
candidate section to the model's endpoint (
TYPESAFE_API_KEY: api.typesafe.ai;OPENROUTER_API_KEY: OpenRouter;JEV_BASE_URL+JEV_API_KEY: an endpoint of your choice). Leave it off for documents that must not leave the machine. The server prints the endpoint on start. - Cost and time. One request per candidate: about 1.5 seconds and a quarter of a US cent per search in our runs. If the model fails or takes more than 8 seconds, the keyword order is returned.
- What is known about the benefit. On 50 BrowseComp-Plus questions (100,195 web documents) a Haiku agent
with this option answered 88% against 82% without it, a difference that size cannot confirm (4 questions
against 1, p = 0.375). It needed fewer searches, 11.3 per question instead of 16.0, and passed
intentin three searches out of four. On FinanceBench, where the agent already finds the pages by browsing, better retrieval did not raise accuracy. Seeeval/bcp/README.md.
From code, pass any object with a score() method, or the built-in one:
import { jevReranker, openLibrary } from 'markindex'
const lib = openLibrary({ root: './docs', rerank: { reranker: jevReranker() } }) // key from the environment
await lib.callTool('search_documents', { query: 'notice period', intent: 'How much notice must an employee give?' })
// createMcpServer(lib) and createAiSdkTools(lib) serve the tools with `intent`: they read `lib.contract`.
Tools
| Tool | What it does |
|---|---|
browse_documents | List a folder: sub-folders and documents (path, title, description, tokens), paginated. The default discovery tool. |
get_document | One document's metadata, front matter, size and read_structure_first (true above 15 000 tokens). |
get_document_structure | The section outline (node ids, titles, line ranges, tokens, summaries — no body), depth levels (default 2), optionally only one node's subtree; paginated with part. |
get_node_content | Original Markdown of 1-20 nodes with line numbers (123│ …), paginated for long nodes. |
search_documents | BM25 keyword search over titles, merged sub-headings, summaries and text, with trigram fallback; scope by folder or doc_path. The escalation path when browsing stalls. |
All tools return { success: true, data, next_steps } or { success: false, error, code, details, next_steps } as a JSON string
and never throw — unknown document paths come back with similar-name suggestions, stale node ids with a
"re-fetch the structure" hint. Arguments that do not match the schema (wrong type, unknown field, a string over
1 024 characters) get an INVALID_INPUT envelope from lib.callTool; over MCP and the AI SDK, however, the
transport validates arguments against the same schema before the tool runs, so there such errors come back as the
transport's own error (an MCP tool error / an AI SDK invalid-tool-input error), not as the JSON envelope.
Security and trust
- Read-only, library-scoped. The tools only read the index of the library you pointed them at; they never read files outside it, never write, and never fetch URLs. Paths and node ids are looked up in the index, not on disk.
- Documents are untrusted input. Tool output is raw document text, and LLM summaries / descriptions are generated from it. A document can contain text written to steer an agent (prompt injection). Treat everything the tools return as data, not instructions — especially when the library holds third-party or user-supplied files, and when the agent also has tools that act (send, write, execute).
- Summaries and
retrieve()send document text to the model provider you configure; indexing alone makes no network calls. Search makes none either unless you turn on--rerank, which sends the text of candidate sections to the reranking service.
Design notes
- Tree. Top-level mdast headings define sections; text before the first heading is a
prefacenode; a document without headings is one root node. Node ids are short hashes of the ancestor title chain plus the sibling ordinal, so they stay stable while the outline does. - Tree optimization. The merge / expand pass is a port of PageIndex's
tree_optimize.pycost model with pages replaced by tokens: a subtree is merged into its parent when reading it whole is no more expensive than routing through it (S(v) <= tree_cost(v), routing costR = 150tokens), merged-away headings are kept askeyItems, and a node whose own text exceedsMAX_NODE_TOKENS(8 000) is split deterministically at Markdown block boundaries intochunkchildren. Credit for the cost model goes to PageIndex. - Search. Only a node's own text is indexed (not its subtree), so parents and children don't double-count. Titles weigh 10×, merged headings 5×, summaries 2×, body 1×.
- Tool contract. One zod contract (names, descriptions, schemas) feeds the AI SDK adapter, the MCP server and
retrieve(); descriptions and agent instructions are adapted from PageIndex'sagent_tools.py(pages → line ranges) and pinned by snapshot tests. - Tokens. Counts are approximate (CJK character = 1 token, other characters / 4); a real tokenizer can be
injected. Defaults live in
src/config.ts.
Evaluation
markindex eval measures whether retrieval lands on the right section: give it a library folder and a JSONL
question file with gold locations (document path + line range, or a title path), and it reports hit rate, token
cost, steps and evidence size / precision overall and per language, for the BM25 baseline and for the LLM agent
(--max-evidence-lines <n> additionally requires hits to be at most n lines long). The question-file format,
the hit rule, the development corpus (329 public documents, ~38 M tokens, English filings and guidelines plus
Chinese laws and encyclopedia articles), baseline results and scale benchmarks are in
eval/README.md.
Headline (n = 30, Claude Code sonnet restricted to the five MarkIndex MCP tools): the gold passage was found for 30/30 questions (93.3% at rank 1), citing 15 lines on average with 88.6% of cited lines inside the gold range — vs 73.3% hit and 209 lines (12.8% precision) for BM25 top-5 on the same questions, at ~3 agent turns per question (details and caveats).
FinanceBench (public benchmark): on its 150 open-source questions about SEC filings, with all 367 filings of the benchmark in one library and the same agent setup, 92.0% of the answers were correct after adjudication (88.7% by a three-judge majority). For reference, the FinanceBench paper reports 19% for GPT-4-Turbo with one shared vector store, and Mafin2.5 (PageIndex) reports 98.7%. The comparison is not controlled for the model or the grading (method, judges and caveats).
Controlled baselines (same model, same judge): on the same questions the MarkIndex agent scores 88.0% with one judge, against 67.3% for the same model reading the top-20 pages of a dense retriever in one prompt, at 40% of the cost. The gain comes from the agent loop over a cheap keyword index, not from the tree: an agent over flat BM25 chunks scores 89.3%, and MarkIndex without its navigation tools scores the same 88.0%. On QASPER, where single-shot retrieval already finds the evidence, all setups perform alike (89-93%). Tables and tests.
Development
npm install
npm test # vitest
npm run typecheck
npm run build
npx tsx eval/fetch-corpus.ts # download the evaluation corpus (eval/corpus, not committed)
npx tsx eval/bench.ts # scale benchmark
npx tsx eval/claude-code-eval.ts --root eval/corpus --questions eval/questions.jsonl --per-lang 10 --out cc.json
# agent eval with Claude Code over MCP (spends Claude usage; eval/README.md §7)
Releasing
Releases are published to npm by .github/workflows/publish.yml through npm
Trusted Publishing (OIDC, no npm token; provenance attached). Bump version in package.json, move the
[Unreleased] notes in CHANGELOG.md under the new version, push, then create a GitHub Release with tag
v<version>; the workflow checks the tag against package.json, runs typecheck and tests, builds and publishes.
License
MIT. PageIndex is also MIT-licensed; MarkIndex contains no PageIndex code, but ports its tree cost model and adapts its agent-tool descriptions, instructions and prompts, with thanks — see THIRD_PARTY_NOTICES.md for its copyright and license notice.
Frequently asked questions
What is MarkIndex MCP Server?
Vectorless, structure-first search over large Markdown libraries: section trees + zh/en BM25
How do I install MarkIndex MCP Server in Claude Desktop, Cursor, or VS Code?
Pick your client in the Install section on this page and copy the generated config into the client's config file. Step-by-step guides: Claude Desktop, Cursor, and VS Code. MarkIndex MCP Server runs locally from the npm package markindex with the command npx -y markindex@0.2.0.
Is MarkIndex MCP Server free and open source?
Yes. MarkIndex MCP Server is released under the MIT license, an OSI-approved open-source license, so you can use, modify, and self-host it under those terms.
Does MarkIndex MCP Server support remote (HTTP) connections?
No remote endpoint is listed for MarkIndex MCP Server. It runs locally on your machine over stdio, started by your MCP client.
What tools does MarkIndex MCP Server provide?
MarkIndex MCP Server provides 5 tools, including browse_documents, get_document, get_document_structure, and get_node_content. See the full tool list for descriptions and parameters.
How is MarkIndex MCP Server's trust score calculated?
MarkIndex MCP Server scores 67 out of 100 (Good). The score adds six capped public signals: registry status, maintenance, popularity, license, documentation, and security. Nobody can pay for points. Read the methodology for the full formula.
Reviews
No reviews yet—Be the first to review
No published reviews yet. Used it? Tell the next person how it went.
Sign inA verified email is required to review this server.
Add badge to your README
Paste either snippet into the repository README. The image links to this listing.