md-chunk-lite

v1.1.3
io.github.tidybytetools/md-chunk-lite Checked 1 day ago Published 17 hours ago

Split Markdown into chunks by heading.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

chunk_markdown Split Markdown into chunks

Split a Markdown file or Markdown text into chunks by heading, for search, embeddings or RAG. Use this when you need a long Markdown document (docs, notes, a README) broken into pieces that each know where they came from. A chunk never mixes two sections. Each chunk has heading_path (like ["Guide", "Install"]), anchor (the GitHub-style #link), start_line and end_line (1-based, in the file), part and parts (when a big section had to be split), chars and text. Code blocks and tables are kept whole when they fit; when they don't, each piece gets the fence or table hea…

ParameterTypeDescription
limitintegerMost chunks to return in one call. Default 100.
max_charsintegerBiggest chunk size in characters (not tokens). Default 1500.
overlap_charsintegerCharacters repeated from the end of one part at the start of the next, only when a section is split. Must be at most half of max_chars. Default 0.
pathstringFull path to a local Markdown or text file (UTF-8, up to 10 MB). Leave empty if you pass text.
prefix_pathbooleanIf true, each chunk text starts with its heading path, like "Guide > Install".
startintegerFirst chunk number to return (1 = the first). Use next_start from the last call to get more.
textstringMarkdown text to use instead of a file. Leave empty if you pass path.

outline_markdown List Markdown headings

List every heading in a Markdown file or text, with its level, path, anchor, line number and size. Use this when you want a quick map of a long document before you read or chunk it, or to find the exact heading or anchor to pass to get_section. Headings inside code blocks and YAML front matter are ignored. Both "# Title" and underlined (=== / ---) headings are found. Do not use it to get the text itself (use get_section or chunk_markdown). Returns {"source", "count", "headings": [{"level", "title", "path", "anchor", "line", "end_line", "chars"}]}. chars is the si…

ParameterTypeDescription
pathstringFull path to a local Markdown or text file (UTF-8, up to 10 MB). Leave empty if you pass text.
textstringMarkdown text to use instead of a file. Leave empty if you pass path.

get_section Get one Markdown section

Return the text of one section of a Markdown file or text, found by heading title or anchor. Use this when you only need one part of a long document, like the "Install" section of a README, so you don't have to read the whole file. If two headings have the same title, the first one is returned and "matches" tells you how many there are; use the anchor (from outline_markdown) to pick another. Do not use it to split the whole document (use chunk_markdown). Returns {"title", "heading_path", "level", "anchor", "start_line", "end_line", "chars", "matches", "text"}. If…

ParameterTypeDescription
anchorstringAnchor to find, like "install" or "install-1" for the second "Install". Wins over heading.
headingstringHeading title to find, like "Install". Not case sensitive. Leave empty if you pass anchor.
include_subsectionsbooleanIf true (default), include the smaller headings under it.
pathstringFull path to a local Markdown or text file (UTF-8, up to 10 MB). Leave empty if you pass text.
textstringMarkdown text to use instead of a file. Leave empty if you pass path.

save_chunks_jsonl Save chunks to a JSONL file

Split a Markdown file into chunks and save them as a JSONL file (one chunk per line). Use this when the chunks are going into a search index, vector database or another program, and you want a file instead of a long chat reply. The chunks are the same as chunk_markdown gives. It writes only the one .jsonl file and replaces it if it is already there. It never changes the Markdown file. Do not use it to look at chunks in the chat (use chunk_markdown). Returns {"output_path", "chunks", "bytes", "biggest_chunk_chars"}.

ParameterTypeDescription
path *stringFull path to the local Markdown file to split (UTF-8, up to 10 MB).
max_charsintegerBiggest chunk size in characters (not tokens). Default 1500.
output_pathstringWhere to save. Must end in .jsonl. Default: next to the input, as NAME.chunks.jsonl.
overlap_charsintegerCharacters repeated from the end of one part at the start of the next, only when a section is split. Must be at most half of max_chars. Default 0.
prefix_pathbooleanIf true, each chunk text starts with its heading path, like "Guide > Install".