Skip to main content

Lybrary — local codebase memory for coding agents

Lybrary indexes a repository by code structure and gives Codex, Claude Code, and other MCP clients a searchable map of its functions, classes, and files. It runs locally, watches for changes, and lets an agent find relevant source lines before opening whole files.

PyPI · Documentation · Source · Issues

Start in any repository

Install once, then run lybrary start in each folder you want indexed:

pip install lybrary
cd /path/to/your/repo
lybrary start
lybrary status

start creates .lybrary/ if needed, builds the index, and runs a file-watching daemon in the background. It keeps running after the terminal closes. Run lybrary stop in that repository to stop it. The first indexing run may download the local embedding model; later runs use the cache.

Each repository has its own index and .lybrary/config.toml. The index stays on your machine; no API key or hosted database is required.

Connect an agent

Register the MCP server once on your machine. Start your agent in an indexed repository, then ask it to call memory_status to confirm the root and chunk count.

Codex

codex mcp add lybrary -- lybrary mcp
codex mcp list

Add this to that repository's AGENTS.md if you want Codex to use the memory consistently:

When .lybrary/index.db exists, use Lybrary memory_query before broad code searches or reading multiple files. Inspect the returned source paths and lines before editing. If the index is absent or the tool fails, use normal search.

Claude Code

claude mcp add --scope user --transport stdio lybrary -- lybrary mcp
claude mcp list

In Claude Code, /mcp shows connection status. Put the same instruction in the repository's CLAUDE.md. Registration makes the tool available; the instruction helps the agent choose it when useful.

For another stdio MCP client, configure command lybrary with argument mcp. See the setup guides.

What the agent gets

memory_query blends exact symbol, SQLite text, and vector search. Its default response gives ranked paths, symbols, line ranges, and compact numbered excerpts. The agent can then inspect the relevant source lines. Set include_content=true when a full chunk is needed.

memory_status reports the active repository and index health. memory_update triggers incremental, full, or path-scoped re-indexing.

This can avoid repeated broad searches and large file reads, especially when the agent needs to locate a feature across sessions. Actual token use depends on the task, the agent's tool choices, and how much source it still needs to inspect. The benchmark guide explains how to compare complete runs rather than infer savings from the size of one response.

Make it fit your repo

Edit .lybrary/config.toml to choose the embedding model and device, chunk sizes, indexed languages, excluded paths, and file-watcher debounce. Add Git-style ignore patterns to .lybrary/ignore. Re-run lybrary index --full after changing settings that affect stored chunks or embeddings.

Supported parsers: Python, JavaScript, TypeScript, TSX, Go, Rust, Java, C, and C++. The indexer uses tree-sitter boundaries and refreshes changed files while the daemon is running.

CLI

Command Purpose
lybrary start Initialize, index, and watch the current repository
lybrary stop Stop its background daemon
lybrary status Show daemon and index status
lybrary query "authentication flow" Search from the terminal
lybrary index --full Rebuild the index
lybrary logs Show daemon logs
lybrary mcp Run the stdio MCP server

If an agent starts above the indexed repository, pass that repository's absolute path as repo_root to the MCP tool, or start the agent inside it.

Measure the effect

From a source checkout, compare the same read-only question with and without Lybrary:

python benchmark.py /path/to/indexed/repo "Trace how interview invitations are sent"

The script records both answers, tool calls, and total, cached, and uncached input tokens under .lybrary/benchmarks/. Check answer correctness first; one question does not establish typical savings.

Contribute

Issues and pull requests are welcome. For a local checkout:

pip install -e ".[dev]"
pytest

Lybrary is MIT licensed. See the changelog for releases.

Metadata

Release files for lybrary 0.3.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 lybrary 0.3.0
File Size Uploaded Provenance Actions
lybrary-0.3.0.tar.gz 42.6 kB With provenance Details for lybrary-0.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 73.1 kB

Release files / lybrary-0.3.0.tar.gz

Download URL lybrary-0.3.0.tar.gz
Size 42.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f8b60bdc215fb68df2253d06e06d257c6e8876d1fe2ca96e806c5ff0504896a4
BLAKE2b-256 checksum
How to use checksums
a28bfb690fd014db0868188779d34598113d6c9149146ea1db836e0a8732ef98
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

Release files / lybrary-0.3.0-py3-none-any.whl

Download URL lybrary-0.3.0-py3-none-any.whl
Size 30.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
624bdfca426fc6067d48f21b651313095da3c602f40c90ca73d50093ea6d69e7
BLAKE2b-256 checksum
How to use checksums
e41b50c5a8973302a1b0234fe3891505dde33a09973628942ee7cbb41276671a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

Security for lybrary 0.3.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for lybrary-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

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.

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