- rag_example: rewrite for current haiku.rag. The MCP server is `haiku-rag mcp` and opens the database read-only, so documents are added with the CLI; the page described `serve`, SQLite storage and add/delete tools that no longer exist. - mcp: stdio servers accept cwd and inherit HOME, LOGNAME, PATH, SHELL, TERM and USER. - app_config: each openaiCompatible endpoint is its own provider; XDG_DATA_HOME applies everywhere but Windows; list OTERM_OLLAMA_IMAGE_MODEL and everything under OTERM_DATA_DIR. - commands: add Copy message, an Images section and the command-line options; clicking a code block copies the whole message. - installation: document the speak extra and nix updates; drop the 0.13.1 tap note. - development: uv-based setup; docs are built with Zensical. - One H1 per page; no em dashes. - README points at the CHANGELOG; drop the stale announcement banner.
2.9 KiB
RAG with haiku.rag
haiku.rag, also by oterm's author, is a RAG library. It stores documents in LanceDB, searches them with hybrid (vector and full-text) search, and serves that search over MCP. Its default configuration runs the embedding model through Ollama.
Build a database
The MCP server opens the database read-only, so documents go in through the haiku-rag command line:
uvx haiku-rag init --db /path/to/rag.lancedb
uvx haiku-rag add-src /path/to/report.pdf --db /path/to/rag.lancedb
uvx haiku-rag add-src https://example.com/article.html --db /path/to/rag.lancedb
uvx haiku-rag add-src /path/to/notes/ --db /path/to/rag.lancedb
A directory is added recursively. See the haiku.rag command line reference for everything else, including listing and deleting documents.
Connect oterm
Add the server to config.json (run oterm --data-dir to find it):
{
"mcpServers": {
"haiku-rag": {
"command": "uvx",
"args": ["haiku-rag", "mcp", "--stdio", "--db", "/path/to/rag.lancedb"]
}
}
}
Restart oterm, then select the haiku-rag tools when creating or editing a chat.
Tools
| Tool | What it does |
|---|---|
search_documents |
Hybrid search over the database. |
search_documents_by_image |
Search by image. Only offered with a multimodal embedder. |
list_documents |
Titles, URIs and metadata of the stored documents. |
get_document |
A whole document, in reading order. |
get_document_outline |
A document's heading tree, with page numbers. |
get_document_section |
The text of one section of a document. |
execute_code |
Runs a Python program in a sandbox over the selected documents. |
The model sees them as haiku-rag_search_documents and so on. The haiku.rag MCP reference documents their arguments.
Then ask questions such as:
What does the report say about revenue in the third quarter?
Which of my notes mention the migration, and what did we decide?
Configuration
haiku.rag reads haiku.rag.yaml from the path in HAIKU_RAG_CONFIG_PATH, then the current directory, then its own data directory. The MCP server runs in the directory oterm was started from, so either set cwd on the server or point it at the file:
{
"mcpServers": {
"haiku-rag": {
"command": "uvx",
"args": ["haiku-rag", "mcp", "--stdio", "--db", "/path/to/rag.lancedb"],
"env": {
"HAIKU_RAG_CONFIG_PATH": "/path/to/haiku.rag.yaml"
}
}
}
}
The embedding model in that configuration must match the one the database was built with. See the haiku.rag configuration guide for providers, models and reranking.