3.7 KiB
Model Context Protocol (MCP)
The MCP server exposes haiku.rag as MCP tools for compatible MCP clients like Claude Desktop.
Starting MCP Server
The MCP server supports Streamable HTTP and stdio transports:
# Default streamable HTTP transport on port 8001
haiku-rag mcp
# Custom port
haiku-rag mcp --port 9000
# stdio transport (for Claude Desktop)
haiku-rag mcp --stdio
# Read-only mode (excludes write tools)
haiku-rag --read-only mcp --stdio
Read-only mode: When --read-only is specified, write tools (add_document_from_file, add_document_from_url, add_document_from_text, delete_document) are not registered. Only search and query tools remain available.
Claude Desktop Integration
Add to your Claude Desktop configuration (claude_desktop_config.json):
{
"mcpServers": {
"haiku-rag": {
"command": "haiku-rag",
"args": ["mcp", "--stdio"]
}
}
}
With a custom database path:
{
"mcpServers": {
"haiku-rag": {
"command": "haiku-rag",
"args": ["mcp", "--stdio", "--db", "/path/to/database.lancedb"]
}
}
}
After restarting Claude Desktop, you can ask Claude to search your documents, add new content, or answer questions using your knowledge base.
Available Tools
Document Management
-
add_document_from_file- Add documents from local file pathsfile_path(required): Path to the filemetadata(optional): Key-value metadatatitle(optional): Human-readable title
-
add_document_from_url- Add documents from URLsurl(required): URL to fetchmetadata(optional): Key-value metadatatitle(optional): Human-readable title
-
add_document_from_text- Add documents from raw text contentcontent(required): Text contenturi(optional): URI identifiermetadata(optional): Key-value metadatatitle(optional): Human-readable title
-
get_document- Retrieve a document by IDdocument_id(required): The document ID
-
list_documents- List documents with pagination and filteringlimit(optional): Maximum number to returnoffset(optional): Number to skipfilter(optional): SQL WHERE clause for filtering
-
delete_document- Delete a document by IDdocument_id(required): The document ID
Search
-
search_documents- Search using hybrid search (vector + full-text)query(required): Search querylimit(optional): Maximum results (uses config default if not specified)include_images(optional, defaulttrue): Attach base64-encoded picture bytes to picture-labeled results
-
search_documents_by_image- Search using an image as the query (registered only when the configured embedder supports images)image_base64(required): Base64-encoded image (PNG/JPEG bytes)limit(optional): Maximum resultsinclude_images(optional, defaulttrue)
Question Answering
-
ask_question- Ask questions about your documentsquestion(required): The question to askcite(optional): Include source citations (default: false)deep(optional): Use multi-agent deep QA for complex questions (default: false)
-
analyze- Answer complex analytical questions via code executionquestion(required): The question to answerfilter(optional): SQL WHERE clause to restrict document accessdocument(optional): Document title/ID to pre-load (can repeat)- Best for aggregation, computation, and multi-document analysis
Continuous ingestion
For continuous document ingestion (filesystem watch, S3 polling, HTTP
sources, a job queue with retries), run haiku-ingester
as a separate process against the same LanceDB.