Skip to main content

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.

Metadata

Release files for codicil 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for codicil 0.2.0
File Size Uploaded Provenance
codicil-0.2.0.tar.gz 16.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for codicil 0.2.0
File Interpreter ABI Platform
codicil-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 29.8 kB

Release files / codicil-0.2.0.tar.gz

Download URL codicil-0.2.0.tar.gz
Size 16.3 kB
Tags Source
SHA-256 checksum
How to use checksums
9b843698f6fa8f156e34baf8a705bb6933ad7119fb7e05d7e0c7ca23313fcece
BLAKE2b-256 checksum
How to use checksums
16fbfce40120d2eb5362efdd5a9f37e95afdaee217d33c93b86b929da2890064
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / codicil-0.2.0-py3-none-any.whl

Download URL codicil-0.2.0-py3-none-any.whl
Size 13.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0a794c87e768b32db636b77fe9b77dfc2975007e4aa42a73e53c56de8ee36de2
BLAKE2b-256 checksum
How to use checksums
1a89d50b6fde838d814bf344db039963074ed71920653184427a5b54ab6141f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Security for codicil 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page