sage-mcp
Hybrid semantic search (dense vector + BM25) over local knowledge bases and codebases, exposed as MCP tools for AI agents to search and list knowledge bases.
README
sage-mcp
Hybrid semantic search (dense vector + BM25) over local knowledge bases and codebases.
Stack: LlamaIndex · Qdrant (local embedded) · OpenAI embeddings · FastMCP
Setup
uv venv # creates .venv with Python 3.11 per .python-version
source .venv/bin/activate
uv pip install -e ".[mcp]"
cp config-example.yaml config.yaml
# edit config.yaml — add your KB paths
echo "OPENAI_API_KEY=sk-..." > .env
uv will download Python 3.11 automatically if it's not already installed.
Index
# Index all configured KBs
sage index
# Index one KB only
sage index --kb homelab
# Force full re-index (ignore cache)
sage index --force
Status
# Diff KB files vs cache without embedding
sage status
# Single KB
sage status --kb homelab
Search
# Hybrid search across all KBs
sage search "pihole DNS configuration"
# Limit to one KB
sage search "pihole" --kb homelab
# Filter by frontmatter fields
sage search "storage" --filter type=lxc --filter status=running
# More results
sage search "networking" --top-k 20
# Dense-only (no BM25)
sage search "pihole" --no-hybrid
# JSON output (for scripting / agent use)
sage search "pihole" --json
# Markdown output with full file paths (default template: blockquote)
sage search "pihole" --markdown
# Markdown table layout
sage search "pihole" --markdown --template table
# Custom Jinja2 template
sage search "pihole" --markdown --template ~/my-template.md.j2
Markdown templates
The --markdown flag renders results via a Jinja2 template.
Two built-in templates are included:
| Name | Description |
|---|---|
blockquote |
Each chunk indented as a blockquote under a ### heading with full file path (default) |
table |
Compact markdown table with score, KB, full file path, and truncated excerpt |
To write a custom template, copy a built-in from sage_mcp/templates/ and pass the file path via --template. The following variables are available:
| Variable | Type | Description |
|---|---|---|
query |
str |
The search query |
results |
list[dict] |
Each entry has score, file_path, kb, text, text_safe, metadata |
duplicates_removed |
int |
Number of duplicate chunks filtered out |
Each result's text_safe is the chunk text with newlines collapsed to spaces and pipe characters escaped — safe for use inside a Markdown table cell. Use text for blockquote or fenced-code rendering where the original formatting should be preserved.
List KBs
sage list-kbs
MCP (AI agent access)
Add to your MCP client config (use absolute paths):
{
"mcpServers": {
"sage-mcp": {
"command": "/path/to/sage-mcp/.venv/bin/sage-mcp",
"args": ["--config", "/path/to/sage-mcp/config.yaml"]
}
}
}
The --config flag is optional; without it the server looks for config.yaml in its working directory.
Tools exposed:
search_kb(query, kb?, top_k?, filter_type?, filter_status?)— returns{results: [...], duplicates_removed: N}list_knowledge_bases()— list configured KBs
Config
Edit config.yaml to add KBs or switch the embedding backend. Use config-example.yaml as a template.
Switching to Ollama (once nomic-embed-text is running with GPU acceleration):
embedding:
provider: ollama
model: nomic-embed-text
base_url: http://<ollama-ip>:11434
Then sage index --force to re-embed everything.
Incremental updates
The indexer tracks a content hash per file in pipeline_cache/<kb-name>/hashes.json.
Re-running sage index only re-embeds files that have changed. Safe to run on a cron or inotify watch.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
E2B
Using MCP to run code via e2b.