Skip to main content

Single-file graph memory for local AI, agents, and Python applications

Project description

liel

License: MIT CI

Single-file graph memory for local AI agents.
Turn LLM interactions into a persistent, traversable knowledge graph - not just text retrieval.

liel is a lightweight local graph memory store for LLM tools, AI agents, and Python applications. It stores facts, decisions, tasks, files, sources, tool results, and their relationships in one portable .liel file. As a product, liel is best understood as a portable external brain for LLM workflows, not as a general-purpose graph database.

Use it standalone from Python, or expose the same .liel file as an MCP-backed memory layer for tools like Claude.

The core package has no runtime dependencies. No external database server, cloud service, or background daemon is required. On supported platforms, pip install liel is enough to get started.

MCP integration is optional. Install liel[mcp] only when you want to expose a .liel memory file to an MCP-capable AI tool.

Under the hood, liel uses a Rust-core property graph storage engine with a Python-first API and optional MCP integration. If SQLite is the one-file relational database, liel aims to be the one-file external brain for relationship-centric AI workflows. It is not positioned as a full graph database server; it is a minimal, persistent graph substrate for building higher-level memory systems.

Etymology: a portmanteau of French lier (to connect) and Latin ligare.

The Zen of Liel

  • One file, any place.
  • No server, no waiting.
  • Minimal dependencies, simple environments.
  • Start small, stay local.

See Design principles.


Table of contents


Quickstart

1. LLM memory in one file

Install the core package:

pip install liel

Instead of losing context between sessions, store decisions and relationships as a graph:

import liel

with liel.open("agent-memory.liel") as db:
    task = db.add_node(["Task"], name="Design AI memory system")
    decision = db.add_node(
        ["Decision"],
        content="Use graph memory instead of text-only retrieval",
    )
    source = db.add_node(["Source"], title="Architecture notes")

    db.add_edge(task, "LED_TO", decision)
    db.add_edge(decision, "SUPPORTED_BY", source)
    db.commit()

    for node in db.neighbors(task, edge_label="LED_TO"):
        print(node["content"])

Now your AI can recall why decisions were made, not just what was said.

2. Python property graph

For a minimal graph API example:

import liel

with liel.open(":memory:") as db:
    alice = db.add_node(["Person"], name="Alice")
    bob = db.add_node(["Person"], name="Bob")
    db.add_edge(alice, "KNOWS", bob, since=2020)
    db.commit()

    print(db.neighbors(alice, edge_label="KNOWS")[0]["name"])  # Bob

For the Python API, transactions, QueryBuilder, traversal, and examples:

3. Claude + MCP project memory

liel[mcp] exposes one official MCP surface for AI memory:

  • liel_overview
  • liel_find
  • liel_explore
  • liel_trace
  • liel_map
  • liel_append
  • liel_merge

Step 1 - Install

pip install "liel[mcp]"

Step 2 - Register the MCP server

Configuration file locations, approval flow, and setup UX differ between MCP clients and change over time. Follow your client's official MCP setup guide, then register liel with a server definition like this:

{
  "mcpServers": {
    "liel": {
      "command": "/path/to/python",
      "args": [
        "-m",
        "liel.mcp",
        "--path",
        "/path/to/your/project.liel"
      ]
    }
  }
}

Replace:

  • command with the Python executable where liel[mcp] is installed
  • --path with the .liel file you want the AI tool to use as durable memory

After registering the server, restart your MCP client and confirm that liel appears as connected in its MCP management UI.

Step 3 - Tell Claude to use it

Add this block to your project's CLAUDE.md:

## Project Memory
- Use `liel[mcp]` as the long-term memory store for this project when the MCP server is available.
- At the start of a task, use `liel_overview`, then `liel_find`, then `liel_explore` to restore context before asking the user to repeat it.
- Save only durable information: confirmed decisions, stable preferences, important facts, open questions, and tasks that should survive the session.
- Do not save temporary reasoning, speculative ideas, or verbose logs.
- Reuse existing nodes and link new ones to related nodes. Avoid duplicates.
- Use `liel_append` when you want guaranteed new records, and `liel_merge` when you want to reuse existing nodes or idempotent edges.
- Write at meaningful checkpoints (task complete, decision confirmed, session end) - not on every turn.

That's it. Claude will now read and write agent-memory.liel autonomously.

For the full setup guide, available tools, and a longer CLAUDE.md example:


Install

Install the dependency-free core package:

pip install liel

Install the optional MCP integration only when you want an MCP-capable AI tool to use a .liel file as external memory:

pip install "liel[mcp]"

Platform support

  • OS: Linux, macOS, Windows
  • Architecture: x86_64 first, arm64 where practical
  • Python: 3.9 or newer

This installs prebuilt wheels for supported platforms. Rust is not required at install time.

If you are contributing or need a source build, see:


What It Is

liel is a single-file external-brain substrate for local memory and relationship-centric AI workflows.

It is built around a few deliberate choices:

  • one portable .liel file instead of a server
  • explicit graph relationships instead of text-only memory
  • local persistence instead of cloud-managed infrastructure
  • a small Rust core with a Python-first interface

Internally this is implemented as a property graph, but the product promise is higher-level: durable, inspectable memory that an LLM or local agent can carry between sessions.

For the feature surface and file format:

How this differs from RAG

RAG retrieves similar text chunks. liel stores and traverses relationships between entities, decisions, tasks, sources, files, and tool results.

Use RAG when your main problem is finding relevant passages. Use liel when your AI tool needs durable memory that can answer relationship-centric questions like:

  • Which decision led to this task?
  • What source supported that claim?
  • Which files, tool calls, and follow-up tasks are connected?

liel is not a retrieval system. It is a persistent memory substrate for local AI workflows.


When liel fits

Use liel when:

  • you want local AI memory as a file, not a service
  • relationships between entities matter
  • you want decisions, facts, sources, tasks, and tool outputs to survive across sessions
  • you want graph traversal without deploying a separate database server
  • you want something easy to copy, back up, inspect, and archive

Common good fits:

  • project memory for coding assistants
  • local agent memory
  • personal or team knowledge graphs
  • MCP-backed memory for AI tools
  • lightweight provenance-aware tool result stores

Examples and usage patterns:


When liel does not fit

liel is not the right tool when your primary need is:

  • semantic similarity search over text
  • full-text search or document retrieval as the main access pattern
  • very large graph workloads with heavy concurrent writes
  • server-style multi-user mutation
  • SQL-centric graph querying over an existing relational system

In those cases, a vector database, search engine, PostgreSQL recursive queries, DuckDB graph extensions, or a server-backed graph database may fit better.

More detailed comparisons and non-goals:


Design trade-offs

liel is intentionally narrow. The main trade-offs are:

  • single-writer design rather than concurrent peer-to-peer mutation
  • page-level WAL for durability, not ultra-high-frequency tiny commits
  • no full-text engine, query language, or property index in the current product shape
  • Python API and MCP integration first, with the Rust core kept small

That narrowness comes from the product framing: liel is trying to be a portable external brain for local AI systems, not a general-purpose graph database platform.

This is what keeps the system simple and portable, but it also defines where it is and is not comfortable to use.

Read these before using liel as durable application state:


Documentation

The PyPI source distribution is intentionally small and does not include the full documentation tree or example scripts. Use the GitHub repository for:


Contributing

Pull requests and issues are welcome. Start here:

Local checks:

cargo fmt
cargo clippy --all-targets --all-features -- -D warnings
cargo test
pytest tests/python/

License

MIT

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

liel-0.2.6.tar.gz (135.4 kB view details)

Uploaded Source

Built Distributions

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

liel-0.2.6-cp39-abi3-win_amd64.whl (352.6 kB view details)

Uploaded CPython 3.9+Windows x86-64

liel-0.2.6-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (495.3 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

liel-0.2.6-cp39-abi3-macosx_11_0_arm64.whl (446.5 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

File details

Details for the file liel-0.2.6.tar.gz.

File metadata

  • Download URL: liel-0.2.6.tar.gz
  • Upload date:
  • Size: 135.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for liel-0.2.6.tar.gz
Algorithm Hash digest
SHA256 192d722aee023c805a3fedf2832ade33eb80ec12b66055b43a72cb990b0dba31
MD5 0a730ad37543022d888893c44ed41984
BLAKE2b-256 c8308f34f121b56aa163f9542408e5d4551db96b6563711ab3a655cb12bbcfd5

See more details on using hashes here.

Provenance

The following attestation bundles were made for liel-0.2.6.tar.gz:

Publisher: release-pypi.yml on hy-token/liel

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

File details

Details for the file liel-0.2.6-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: liel-0.2.6-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 352.6 kB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for liel-0.2.6-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 30c946f80a3205ed387058c356f54cf599c84e1e0c8f24bec60c17f50aef9c1b
MD5 53e222b63d96809712e25f3638b93cc9
BLAKE2b-256 aac8c84a75eef829dafec34ae761c332dd3750fc4cd8f368d10d0e38498df44e

See more details on using hashes here.

Provenance

The following attestation bundles were made for liel-0.2.6-cp39-abi3-win_amd64.whl:

Publisher: release-pypi.yml on hy-token/liel

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

File details

Details for the file liel-0.2.6-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for liel-0.2.6-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b48b3c69fb82362c67a453450d6b425e290946748ac9d5b13d3a3147196d7d3b
MD5 52dfa2bd26a4192634aba5b6eb9ad499
BLAKE2b-256 7dfb922b81d1f36906abc075063350e5f19ed1f6831e28b9bf04ba35d10262c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for liel-0.2.6-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release-pypi.yml on hy-token/liel

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

File details

Details for the file liel-0.2.6-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: liel-0.2.6-cp39-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 446.5 kB
  • Tags: CPython 3.9+, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for liel-0.2.6-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d9d99a1ffe2f75dd377cf6ac72d2b16c5a211b6cad2cddfaa724ff2665d3fec6
MD5 a5669ae419b3ea5d77282c4269cdd810
BLAKE2b-256 9324b3c4a3857384c7be7f1e11e609cba0b6ab0661238293e3cf27664c726c04

See more details on using hashes here.

Provenance

The following attestation bundles were made for liel-0.2.6-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: release-pypi.yml on hy-token/liel

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