Skip to main content

RAG knowledge base server with ChromaDB and MCP interface

Project description

Candlekeep

Candlekeep

The great library fortress on the Sword Coast, where all knowledge is preserved.

A RAG knowledge base server that gives AI agents the power to search, retrieve, and manage technical documentation through the Model Context Protocol. Ask a question, and the library answers — with the right scroll, expanded to full context, in milliseconds.

The Arcane Arts

  • Bardic Knowledge — Documents are enriched with title and description at ingestion, woven into every embedding
  • Bardic Inspiration — Result-time metadata boosting that ensures specific technical guides outrank generic content
  • Arcane Recall — Intelligent expansion using Scholar's Discernment and Arcane Coalescence to return full sections without token waste
  • Wild Magic — Hybrid retrieval merging Vector and BM25 (lexical) search, fixing "keyword blindness" for exact identifiers
  • The Rosetta Seal — Corpus-derived BM25 token normalisation map that bridges surface-form variants (crossencodercross-encoder), rebuilt automatically in the background after each ingest
  • Divine Insight — Cross-encoder reranking for when precision matters more than speed
  • The Relevance Ward — Results below a configured threshold are filtered, so the library says "I don't know" instead of guessing
  • True Sight — Images in PDFs and markdown are captioned at ingestion via VLM, making diagram details searchable

Features

  • Adaptive Search Routing: Three paths — hybrid (BM25+Vector), precise (Reranked), and explore (Divination — entity expansion)
  • True Sight: Opt-in vision captioning for PDFs and markdown images — deployment topologies, benchmark charts, and architecture diagrams become searchable
  • Statistical Rigor: Validated against The Centurion Set (100+ multi-category queries)
  • Quality Gate: Documents must have frontmatter and structure to enter the library
  • Embedding Protection: Auto-detects model mismatch on remote databases
  • 14 MCP Tools: Search, ingest, critique, generate docs, agent memory, and more
  • LLM & True Sight Providers: Pluggable anthropic, openai, bedrock, and openai_compat (Ollama/LM Studio/vLLM) — text and True Sight independently configurable
  • Token Auth: Bearer token authentication for remote ChromaDB

Quick Start

PyPI (Recommended)

The easiest way to get the library up and running for use with any MCP client:

pip install candlekeep

# Run in stdio mode (standard)
candlekeep

# Run in HTTP mode (recommended for better performance)
CANDLEKEEP_TRANSPORT=http CANDLEKEEP_HTTP_PORT=8111 candlekeep

Docker (Isolated)

Run the server in a container. Note that if your ChromaDB is running on localhost, you'll need to use your host's internal IP (e.g., host.docker.internal on Docker Desktop):

docker run -p 8111:8111 \
  -e CHROMA_URL=http://host.docker.internal:8000 \
  ghcr.io/bansheeemperor/candlekeep:latest

Local Development

If you wish to contribute or modify the library's arcane secrets:

git clone https://github.com/raalgaw/candlekeep.git
cd candlekeep
pip install -e .
./scripts/setup.sh        # Download the tomes (embedding models)
./scripts/configure.sh    # Set your wards (configuration)
./scripts/start_chroma.sh  # Awaken the vault (ChromaDB)
candlekeep                # Enter the library

MCP Client Integration

HTTP mode (recommended) — one server, multiple agents. Models loaded once, shared memory, no cold-start per agent (~230ms first query vs ~6s in stdio mode):

# Start the server once
CANDLEKEEP_TRANSPORT=http CANDLEKEEP_HTTP_PORT=8111 candlekeep
{
  "mcpServers": {
    "candlekeep": {
      "url": "http://localhost:8111/mcp"
    }
  }
}

stdio mode — each agent spawns its own server process. Simpler setup, but each agent pays ~6s cold-start and loads its own copy of the models:

{
  "mcpServers": {
    "candlekeep": {
      "command": "/path/to/.venv/bin/candlekeep",
      "args": [],
      "env": {
        "CANDLEKEEP_SPICE": "true"
      }
    }
  }
}

See Setup Guide for auth configuration and production deployment.

The Tomes (Documentation)

MCP Tools

  • search — Semantic search with adaptive routing (simple 22–36ms, precise ~1550ms)
  • list_documents — List all indexed tomes
  • get_stats — Library statistics
  • critique_document — Check document quality before ingestion
  • explore_entity — Explore an entity's co-occurring entities and source chunks via the graph
  • generate_documentation — Scan a project and create structured docs
  • memory_recall — Recall recorded memories semantically similar to a query
  • memory_list — List recorded memories, newest first
  • ingest — Add documents with automatic quality validation
  • delete_document — Remove a tome from the index
  • repopulate_database — Clear and rebuild the library
  • rebuild_normalisation_map — Regenerate The Rosetta Seal from the current corpus after a full repopulate + ingest cycle
  • memory_store — Record a short-form memory (lesson, failure pattern, debug tip) in the Chronicle
  • memory_delete — Delete a memory from the Chronicle by ID

The Chronicle is a separate store of agent-recorded memories, isolated from the document corpus and preserved across repopulate_database.

Access to write tools is managed by your database permissions (configured via CHROMA_AUTH_TOKEN).

Testing

# Unit tests — no database required (~1.4s)
pytest tests/test_router.py tests/test_quality_gate.py tests/test_arcane_recall_unit.py \
       tests/test_protection.py tests/test_processor.py tests/test_search.py \
       tests/test_providers.py

# Benchmarks — requires local ChromaDB on localhost:8000
./scripts/start_chroma.sh
pytest tests/test_router_benchmark.py -v -s

59 unit tests covering router, quality gate, chunk expansion, embedding protection, document processing, and LLM/True Sight providers. Benchmark tests include regression assertions that fail if precision or content match drops below 80%.

Requirements

  • Python 3.10+
  • ChromaDB server (local or remote)

Candlekeep is a trademark of Wizards of the Coast. This project is unofficial fan content and is not endorsed by or affiliated with Wizards of the Coast.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

candlekeep-2.1.0.tar.gz (8.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

candlekeep-2.1.0-py3-none-any.whl (89.7 kB view details)

Uploaded Python 3

File details

Details for the file candlekeep-2.1.0.tar.gz.

File metadata

  • Download URL: candlekeep-2.1.0.tar.gz
  • Upload date:
  • Size: 8.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for candlekeep-2.1.0.tar.gz
Algorithm Hash digest
SHA256 e5ee12658a41b94bab6edcee19a243333b91af74ebf5a5f0dedcebf9a203b6f8
MD5 6e5845b2b86e6cdf01d669dd0a1737f3
BLAKE2b-256 0bbab06ec820dc07c664a0babcd61d4430dd676900a9ca06f138fa25a56c4f98

See more details on using hashes here.

Provenance

The following attestation bundles were made for candlekeep-2.1.0.tar.gz:

Publisher: release.yml on BansheeEmperor/candlekeep

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file candlekeep-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: candlekeep-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 89.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for candlekeep-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 15d8c4864affdf66c27f6aae5d8cb4ce6ff6ddcab9e9e5dfc9f8b2af2ffa693c
MD5 ee9ee616f0d94b65eacae13d9b0ec17a
BLAKE2b-256 05186a0caec76ff9b31dad03fcbf9042d344f57382b25200df6dac9458a4daf2

See more details on using hashes here.

Provenance

The following attestation bundles were made for candlekeep-2.1.0-py3-none-any.whl:

Publisher: release.yml on BansheeEmperor/candlekeep

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page