Skip to main content

grag

Local graph memory for AI agents. Keep code structure, documents and decisions in a project knowledge graph that your agent can query and update across sessions.

Documentation · Getting started · PyPI · DeepWiki

grag combines an embedded LadybugDB database with MCP tools, full-text search and optional vector retrieval. It returns source citations and connected context under a configurable budget. The package is gragdb; the command and Python import are grag.

Start with your project

Python 3.10–3.14. Use a stable CLI installation so the launcher survives changes to your project's virtual environment:

pipx install 'gragdb[code]'
cd your-project
grag init

uv tool install 'gragdb[code]' or pip install 'gragdb[code]' also works. The code extra enables non-Python parsers; plain gragdb can index Python.

Restart your MCP client, then ask:

Index this project's source directory with grag. Show me where the authentication functions are defined, with file and line citations.

Remember why we chose this authentication approach, with its source, and link the decision to the relevant code.

init supports Claude Code, Cursor, Windsurf and Zed. Use --client claude or --client cursor to select explicitly. It saves the checkout's database and port, installs agent guidance, and configures a shared server that starts on first use. grag status shows its address and log; grag stop shuts it down cleanly.

grag init --ingest also indexes immediately. Scanning honors .gitignore and .gragignore, and skips nested repositories/worktrees and symlinks. Choose the intended roots; see scope and language coverage.

Windows: grag 0.9.0+ Windows x64 wheels include the required OpenSSL DLLs. Some agent harnesses require starting the shared server in a separate terminal. The Windows installation notes cover that case, source builds and offline readiness checks.

What it helps with

  • Find code structure: definitions, signatures and line ranges, with supported import/call relationships. Source bodies stay in your files.
  • Keep project memory: agents save decisions, tasks and evidence, and can preserve correction history when updating them.
  • Connect documents and code: index Markdown sections and link mentioned symbols.
  • Retrieve focused context: BM25 search, optional embeddings, graph expansion, citations and explicit truncation. Budgets use a byte-based token estimate.
  • Share across harnesses: Claude Code and Cursor can use one database through one owning server. New worktrees get separate databases by default.
  • Preserve continuity: consistent backups retain authored history and retry receipts, with verified restore into a separate database.

Code coverage varies. Python, JS/TS and Go support conservative static relationships; framework scripts and Java/C# overload identities also have explicit coverage. See language coverage. An absent edge does not prove no relationship exists. grag complements source search; useful answers and token savings depend on the question, graph and harness.

Local by default

The default install uses BM25 without an embedding service. Graph storage and retrieval run locally. Native extensions and optional grammars/models can require first-use downloads; prepare those assets before offline use. Your agent harness may send retrieved context to its model provider.

Local embeddings are optional through gragdb[embed-local] and ONNX Runtime. Installing that extra makes a later init configure them automatically; model preparation costs time, disk and memory. The optional remote provider sends embedding input to its configured endpoint.

Go deeper

Task Guide
Understand the components and data flow Architecture
Install and verify a first session Getting started
Index code or documents Code · Documents
Save, revise and retrieve evidence Memory · Retrieval
Set up FastEmbed and understand hybrid search Embeddings and semantic search
Connect multiple clients or move a checkout Servers · Projects
Diagnose startup, locks or recovery Troubleshooting · Recovery
Configure tools and resource limits MCP · Configuration · Limits
Develop and measure grag Development · Contributing

The maintained documentation lives in docs/ and publishes to GitHub Pages, including the maintained architecture guide. DeepWiki is a supplementary, generated architecture guide; check its displayed source commit and indexing date before relying on it.

MIT license.

Release files for gragdb 0.12.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 gragdb 0.12.0
File Size Uploaded
gragdb-0.12.0.tar.gz 623.9 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for gragdb 0.12.0
File Interpreter ABI Platform
gragdb-0.12.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
gragdb-0.12.0-py3-none-any.whl Python 3 none any Details

Total release size: 4.3 MB

Release files / gragdb-0.12.0.tar.gz

Download URL gragdb-0.12.0.tar.gz
Size 623.9 kB
Tags Source
SHA-256 checksum
How to use checksums
278b0c8727e2f2dfd57cc26135367ccad23adc519dd8588f592d4f445e4d8bb0
BLAKE2b-256 checksum
How to use checksums
9ab3421aa67cd0128bffabdada66ece23440e431a529e58f903779b6a8aaf67f
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 Sep 23, 2026.

Transparency log

Release files / gragdb-0.12.0-py3-none-win_amd64.whl

Download URL gragdb-0.12.0-py3-none-win_amd64.whl
Size 3.0 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
81cc20f99fa2170e6f0d9523a80ec9eb483ac1f0f2f2de1d9aceec8d2d98898b
BLAKE2b-256 checksum
How to use checksums
85b72c580e6749575f86f0e7d3f70950831928e267f33cc8db9f20dab9c8ae1d
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 Sep 23, 2026.

Transparency log

Release files / gragdb-0.12.0-py3-none-any.whl

Download URL gragdb-0.12.0-py3-none-any.whl
Size 601.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
df5a731b5133af4eb3ec46e3a2fd7895a5d0c4e5928c647ef2f903330d661c96
BLAKE2b-256 checksum
How to use checksums
2fd78bd5aa975263e75ffe49e94f21dcb5014db52ec4d6487d05635dec614dc6
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 Sep 23, 2026.

Transparency log

Release history Release notifications | RSS feed

0.13.0

3 release files

This release

0.12.0 This release

3 release files

0.11.0

3 release files

0.10.1

3 release files

0.10.0

3 release files

0.9.0

3 release files

0.8.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.7

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

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