Ai Toolkit
Open-source tools for AI on Memgraph: persistent agent memory, knowledge graphs, GraphRAG, and integrations for LangChain, LightRAG, and MCP.
Python packages for building AI applications with Memgraph: agent memory, knowledge graphs, GraphRAG, and framework integrations.
Use the packages independently, or combine them to bring documents, databases, and agent activity into a graph.
Documentation · Examples · Discord · Issues
Choose your starting point
| I want to… | Start here |
|---|---|
| Give coding agents memory across sessions and tools | Context Graph |
| Extract entities and relationships from documents | unstructured2graph |
| Query Memgraph in natural language or build a LangChain agent | langchain-memgraph |
| Connect an MCP client to Memgraph | mcp-memgraph |
| Use Memgraph as LightRAG storage | lightrag-memgraph |
| Migrate a MySQL or PostgreSQL database into a graph | sql2graph |
| Work directly with Memgraph from Python | memgraph-toolbox |
| Define and validate a graph's entity and relation types | hygm |
Agent memory with Context Graph
Keep what your agents learn in a database you control. Context Graph captures sessions, tool calls, and skill usage, stores explicit memory, and retrieves relevant past conversations for the next session.
It supports Claude Code, Codex, Copilot CLI, Cursor, OpenCode, Antigravity CLI, and Grok Build, plus applications built with the Claude Agent SDK or OpenAI Agents SDK.
curl -fsSL https://raw.githubusercontent.com/memgraph/ai-toolkit/main/context-graph/scripts/install.sh | bash
Setup installs the CLI and connectors, starts its own Memgraph container or connects to one you specify, and wires the agents you select. Docker is needed if setup starts Memgraph for you.
Get started with Context Graph · Components · Recall benchmarks
Knowledge graphs from documents
unstructured2graph parses documents and extracts entities and relationships. Its default backend, GLiNER2, runs locally without an LLM API key; LightRAG is available as an LLM-based alternative.
Start Memgraph:
docker run -p 7687:7687 --name memgraph \
memgraph/memgraph-mage:latest --schema-info-enabled=true
Install the package:
pip install unstructured2graph
Extract a graph from text:
import asyncio
from memgraph_toolbox.api.memgraph import Memgraph
from unstructured2graph import from_texts
from unstructured2graph.gliner2_backend import GLiNER2Backend
async def main():
await from_texts(
texts=["Alice works for Acme in London."],
memgraph=Memgraph(),
extraction_backend=GLiNER2Backend(),
enforce_ontology=True,
)
asyncio.run(main())
The extraction model downloads on first use. See unstructured2graph for files, URLs, document-format extras, and custom ontologies.
Framework integrations
Install only the integration you need:
pip install langchain-memgraph # graph store, QA chain, and agent toolkit
pip install mcp-memgraph # MCP server for database queries and schema tools
pip install lightrag-memgraph # LightRAG storage backends
Each package's README covers its connection settings and examples. LLM-based features need credentials for the model provider you choose; local extraction, capture, and recall do not require an LLM key.
Developing locally
This is a Python 3.10+ uv workspace. From the repository root:
uv sync --all-packages --all-extras
uvx ruff@0.16.0 check .
uvx ruff@0.16.0 format --check .
uvx ty@0.0.75 check .
From the project's README.