Skip to main content

Durable, searchable memory of your engineering docs for AI coding assistants.

Project description

Codicil

Tests PyPI License: MIT

Durable, searchable documentation for MCP-compatible coding assistants.

Codicil indexes the documentation already in a repository and exposes two MCP tools: query_docs for retrieval and reindex_docs for refreshes. It uses an Ollama-compatible embedding endpoint when one is available. If the endpoint is unavailable, search continues with a keyword fallback that reads the current files from disk.

Status: early, single-user software. The core index and fallback paths are tested, but the command-line interface and storage format may change before a stable release.

What It Does

  • Indexes .md, .mdx, .rst, .txt, .yaml, .yml, and .toml files.
  • Splits Markdown at H1 and H2 headings; other files use overlapping character chunks.
  • Stores a local Chroma index in .codicil/ by default.
  • Returns semantic matches when embeddings are available, or keyword matches when they are not.
  • Reindexes incrementally using file modification times.

Directories such as .git, .venv, node_modules, dist, build, and .codicil are excluded. Files with no indexable content are recorded as empty and remove any older chunks.

Quick Start

Requirements: Python 3.11+ and a Unix-like host. Codicil uses an advisory file lock to protect its local store.

python3.11 -m venv .venv
./.venv/bin/pip install -e ".[dev]"

# Optional: works without an embedding server, using keyword fallback.
./.venv/bin/codicil index .
./.venv/bin/codicil serve .

serve starts the stdio MCP server. If its selected index is empty, it attempts an initial index automatically. With no reachable embedding endpoint, that initial index skips semantic embeddings and query_docs still searches the files directly.

Run the offline test suite with:

./.venv/bin/python -m pytest -q

Connect an MCP Client

The repository includes this local Claude Code configuration:

{
  "mcpServers": {
    "codicil": {
      "command": ".venv/bin/codicil",
      "args": ["serve", "."]
    }
  }
}

Place equivalent configuration in the repository you want to search, adjusting command to the absolute path of the installed codicil executable when necessary. The path passed to serve is the repository Codicil indexes.

Your client can then call:

query_docs(query="How is the reverse proxy configured?", n_results=5)
reindex_docs(force=false)

Illustrative — the Claude Code chat UI isn't something a terminal recording can reproduce.

Codicil answering a real query in a terminal, via keyword fallback

The GIF above is real, unedited output — the same query_docs function called directly in a terminal instead of over MCP. No local embedding host was running when this was recorded, so it's answering via keyword fallback, not semantic search — a live demonstration of the degrade-don't-fail behavior this project is actually about.

n_results should be between 1 and 10. reindex_docs() is the supported way to refresh an index while the MCP server owns the store.

Embeddings and Fallback

By default Codicil calls http://localhost:11434/api/embeddings with the nomic-embed-text model. Start a compatible local service to enable semantic search, then index the repository:

export CODICIL_EMBED_URL=http://localhost:11434
export CODICIL_EMBED_MODEL=nomic-embed-text
./.venv/bin/codicil index .

For nomic models, Codicil automatically uses the recommended document and query task prefixes. Other model names are sent without prefixes.

If the embedding host cannot be reached, or the selected index has no chunks, query_docs uses keyword search over the repository. Keyword results rank files by matching query terms and include nearby lines; they are useful but do not understand synonyms or semantic similarity.

Using a remote embedding endpoint sends indexed text and search queries to that endpoint. Keep the default localhost URL or use an endpoint you trust. Do not commit private hostnames or credentials in .mcp.json.

Configuration

Configuration is read when the server module starts, so set environment variables before running codicil or launching your MCP client.

Variable Default Meaning
CODICIL_REPO . Repository to index. The CLI sets this from its path argument.
CODICIL_STORE <repo>/.codicil Local Chroma data, index state, and lock file.
CODICIL_EMBED_URL http://localhost:11434 Base URL of the Ollama-compatible embedding host.
CODICIL_EMBED_MODEL nomic-embed-text Embedding model requested from the host.
CODICIL_EMBED_WORKERS 3 Concurrent embedding requests during indexing.
CODICIL_MIN_SCORE 0.5 Minimum semantic similarity score returned by query_docs.

Changing CODICIL_EMBED_MODEL selects a separate collection and state file, avoiding incompatible vector dimensions. Run codicil index after changing models; existing collections remain in the store until you deliberately remove the store while no Codicil process is running.

Operations and Limitations

codicil index [path] indexes a repository and exits. Add --force to ignore recorded mtimes and re-embed every indexable file. codicil serve [path] runs the MCP server.

Only one Codicil process may use a store at a time. Starting codicil index while codicil serve owns the same store fails intentionally. Use reindex_docs from the running MCP server, or stop the server before running the CLI indexer.

Codicil is currently designed for one local repository and one user. It does not provide file watching, git hooks, multi-user access, or cross-repository retrieval.

Troubleshooting

  • “store is already in use”: another Codicil process owns CODICIL_STORE. Stop it, or call reindex_docs through that running MCP server.
  • Keyword results instead of scores: the embedding endpoint is unavailable or the selected model has not been indexed yet. Check CODICIL_EMBED_URL, then run codicil index.
  • No matching files: confirm the file extension is supported and it is not in an excluded directory. Queries with only words of two characters or fewer have no fallback search terms.
  • Need a clean rebuild: stop every Codicil process, then remove the local store and run codicil index. This permanently removes all local collections for that store.

For development details and reliability invariants, see CLAUDE.md. For a more detailed installation guide, see docs/SETUP.md.

License

Released under the MIT License.

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

codicil-0.2.0.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

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

codicil-0.2.0-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file codicil-0.2.0.tar.gz.

File metadata

  • Download URL: codicil-0.2.0.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for codicil-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9b843698f6fa8f156e34baf8a705bb6933ad7119fb7e05d7e0c7ca23313fcece
MD5 3c4e61467cec553cc255b54aff505ae1
BLAKE2b-256 16fbfce40120d2eb5362efdd5a9f37e95afdaee217d33c93b86b929da2890064

See more details on using hashes here.

File details

Details for the file codicil-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: codicil-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for codicil-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0a794c87e768b32db636b77fe9b77dfc2975007e4aa42a73e53c56de8ee36de2
MD5 19081f17e930a44b9dc2dd062188340c
BLAKE2b-256 1a89d50b6fde838d814bf344db039963074ed71920653184427a5b54ab6141f0

See more details on using hashes here.

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