An MCP (Model Context Protocol) server for local knowledge base operations. LocalKB allows agents to create, manage, and search personal knowledge bases using semantic search and document chunking.
Before using LocalKB, download the required models to avoid startup delays:
pip install huggingface-hub
huggingface-cli download Qwen/Qwen3-Embedding-0.6B
huggingface-cli download Qwen/Qwen3-Reranker-0.6B
Expected timings, based on my M1 Max MacBook Pro:
- The first use of
add_text_to_kb
orsearch_kb
in a session will load the models into memory, taking roughly 10 extra seconds. - Searches take roughly 10 seconds (results are retrieved in about 0.5 seconds, then the reranker model spends about 1.5-2 seconds to score each result.)
list_kbs
- List all available knowledge bases
- No arguments
create_kb
- Create a new knowledge base
kb_name
(string): Name for the knowledge basedescription
(string): Description of the knowledge base
add_text_to_kb
- Add text content directly to a knowledge base
kb_name
(string): Name of the knowledge base to add content tosource
(string): Unique identifier for the text content (e.g., filename, document title)text
(string): The text content to add to the knowledge basemetadata
(object, optional): Optional metadata dict to attach to all content
search_kb
- Search for relevant content using semantic search
kb_name
(string): Name of the knowledge base to searchquery
(string): Search query stringfilters
(object, optional): Optional ChromaDB metadata filters to narrow search
Add to your Claude Code MCP configuration:
claude mcp add-json -s user LocalKB '{"command": "uvx", "args": ["--from", "git+https://github.com/RoryMB/LocalKB@main", "localkb"]}'
Add to your Claude Desktop MCP configuration:
{
"mcpServers": {
"LocalKB": {
"command": "uvx",
"args": ["--from", "git+https://github.com/RoryMB/LocalKB@main", "localkb"]
}
}
}
Run this command to open an interactive menu with options to use the various tools:
uvx --from git+https://github.com/RoryMB/LocalKB@main localkb --cli
Run Python files with this command if you do not want to clone the repo:
uv run --with git+https://github.com/RoryMB/LocalKB@main file.py
Example Python file:
from localkb.tools import (
create_kb,
add_text_to_kb,
search_kb,
list_kbs
)
def main():
# Create a knowledge base
result = create_kb("my-docs", "Project documentation")
print(result)
# Add content
result = add_text_to_kb(
"my-docs",
"installation-guide",
"To install this project, run: pip install -e ."
)
print(result)
# Search for content
results = search_kb("my-docs", "how to install")
for result in results:
print(f"Content: {result['content']}")
print(f"Source: {result['metadata']['source']}")
# Run the function
main()