Local-first knowledge graph memory for LLMs and AI agents: MCP server, RAG context, provenance
pip install knowledge-worker==0.8.4 Copy PIP instructions
A personal knowledge graph that survives between AI conversations. User-centered (not conversation-centered). Provenance-or-bust. Built on boring infrastructure.
Your AI is only as smart as what it remembers about you.
knowledge-worker is a local-first personal knowledge graph for carrying context across AI sessions. It turns notes into reviewable concepts, decisions, goals, and relationships, keeps source excerpts attached, and exports compact context you can paste into Claude, GPT, Ollama, or any other LLM workflow.
Your private graph stays on your machine, enabling you to preserve the thread of your own reasoning across AI sessions.
AI conversations usually start from zero. You clarify a decision, name a constraint, sketch a goal, and then the next session forgets it. RAG can be heavy, full-note prompts are noisy, and most note apps do not plug cleanly into chat workflows.
Stop dumping context. Build memory. knowledge-worker turns chats, notes, decisions, and sources into a local provenance-backed knowledge graph, then uses graph analytics to show what matters, what connects, what is weak, and what context an AI should see.
knowledge-worker keeps the useful parts: cited claims, explicit relationships, human review, and a small context snapshot when you need continuity.
Requirements: Python 3.10+ on macOS, Linux, or Windows.
The core CLI has no runtime dependencies beyond the standard library. Optional extras pull in LLM backends and RDF export only when you need them:
pip install knowledge-worker # core CLI, stdlib only (mykg / mygraph) pip install "knowledge-worker[rdf]" # + Turtle/RDF export (rdflib) pip install "knowledge-worker[anthropic]" # + Claude-backed ingest pip install "knowledge-worker[openai]" # + OpenAI-backed ingest pip install "knowledge-worker[ollama]" # + local Ollama ingest pip install "knowledge-worker[all]" # all ingest backends + RDF exports Verify the install (no clone needed — seed generates its own demo graph):
mykg --help MYGRAPH_PATH=/tmp/knowledge-worker-demo.jsonld mykg seed MYGRAPH_PATH=/tmp/knowledge-worker-demo.jsonld mykg summary Using a virtual environment avoids Homebrew/system Python's externally-managed install errors:
python3 -m venv .venv source .venv/bin/activate pip install knowledge-worker export MYGRAPH_PATH=/tmp/knowledge-worker-demo.jsonld mykg summary What It Does
Graph memory is promoted through a review lifecycle:
source note -> candidates.json -> validate -> review -> merge accepted items into MYGRAPH_PATH Candidates are proposals, not memory. Validation checks schema, IDs, provenance excerpts, and edge endpoints. Review is the promotion gate. The active graph changes only after accepted candidates are merged.
High-confidence nodes and edges require a source excerpt that matches after whitespace and case normalization. Missing or unmatched excerpts demote the candidate to low confidence. --auto-accept-high (also the default for --non-interactive) excludes these edges even when their endpoints already exist in the graph. --auto-accept-all explicitly accepts lower-confidence candidates as well; validation reports and eval logs retain edge demotion reasons.
The model proposes. Artifacts expose reasoning. Provenance verifies. Human review promotes.
If you are already working with Claude, Codex, or ChatGPT in an app session, you do not need an API key. Ask the assistant to produce a *.candidates.json file that follows the schema in mygraph/extractor.py, then let the local CLI validate, review, and merge it. In Claude Code, the bundled /ingest-notes skill runs this flow for you:
Provenance first. Every durable claim points back to a source document and literal excerpt.
Local first. The graph is a file on your machine. No cloud sync, accounts, or telemetry.
Review before merge. The LLM proposes. You decide. Deterministic validation runs before anything enters the graph.
Boring persistence. Compact JSON-LD until it becomes the limiting factor. The schema stays stable across storage backends.
Open-web storage. Local JSON-LD is the source of truth; JSONL records capture history, and Turtle/RDF exports let the graph participate in linked-data workflows without moving private memory into a hosted system. Additionally, JSON-LD, which has clear semantic markup gives AI engines like Google Gemini or Microsoft Copilot higher attribution confidence when extracting facts
For the shorter mykg command from a clone, install it editable inside a virtual environment:
py -3 -m venv .venv .\.venv\Scripts\Activate.ps1 python -m pip install knowledge-worker $env:MYGRAPH_PATH = "$env:TEMP\knowledge-worker-demo.jsonld" mykg seed mykg summary From a clone, install editable instead:
python -m pip install -e . $env:MYGRAPH_PATH = "examples\demo_graph.jsonld" mykg query provenance mykg audit --out "$env:TEMP\analytics.json" --html "$env:TEMP\memory_audit.html" If PowerShell blocks activation scripts, run this for the current terminal session and activate again:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass Commands Command What it does seed Populate a fictional demo graph summary Show node and edge counts by type query Search nodes, neighbors, and provenance list List nodes of a given type path Find the shortest path between two nodes ingest Extract, validate, review, merge, and eval candidates deep-dive Generate a pre-ingest workspace with artifacts and candidates check --provenance Flag nodes with missing source citations export / export --jsonld Emit canonical JSON-LD export --ttl Emit Turtle/RDF context Print a compact LLM-ready context snapshot viz Generate an offline single-file HTML viewer audit Emit graph analytics, directed idea-flow queues, and optional Memory Audit HTML discover Propose derived edges and second-order insights (read-only, promotion queue) state " " Append a mood/state sidecar entry dump Print the raw graph JSON reset Delete the active graph file Use Your Own Notes You can ingest your notes with or without an API key.
Use deep-dive when a source needs synthesis, challenge, or a reasoning workspace before it becomes graph memory:
mykg deep-dive notes.md --out-dir ~/private/deepdives/notes mykg deep-dive inspect ~/private/deepdives/notes mykg deep-dive add-to-graph ~/private/deepdives/notes Generation creates a workspace with manifest.json, artifact-plan.json, Markdown artifacts, validation reports, an artifact-local graph summary, and canonical candidates. It does not mutate MYGRAPH_PATH.
add-to-graph reads the workspace manifest and delegates to the existing ingest validation/review/merge path. Keep using ingest directly when you already have a focused source note or hand-curated candidates file.
See Deep-Dive Interaction Model for the generate, inspect, challenge, approve, and add-to-graph semantics.
If you want the CLI to call an LLM directly, use a provider API key or local Ollama.
MYGRAPH_PATH=~/my-private-graph/mygraph.jsonld mykg summary MYGRAPH_PATH=~/my-private-graph/mygraph.jsonld mykg query "architecture" MYGRAPH_PATH=~/my-private-graph/mygraph.jsonld mykg context Your private mygraph.jsonld and/or legacy mygraph.json, generated private viewers, TTL/JSON-LD exports, eval logs, state logs, and local env files are ignored by default.
In v0.8.0, knowledge-worker resolves the storage question this way: JSON-LD is the canonical local graph; JSONL is the append-only history layer for reviews, evals, analyzer runs, and future replay; Turtle/RDF export is the semantic-web bridge. Kuzu is a future optional local query backend, and graphify.net is a future publishing or interchange target.
See Storage Decision for the full decision record.
mykg audit is a read-only layer over the graph. It ranks important concepts with PageRank, bridge ideas with betweenness, structural strength with k-core, communities with deterministic graph splitting, and weak claims from confidence and provenance gaps. It also includes directed idea-flow queues: idea_attractors for concepts that many edges point into, idea_generators for ideas that branch outward, and a weak_claim_queue that asks for human review actions instead of auto-promoting conclusions.
MYGRAPH_PATH=examples/demo_graph.jsonld mykg audit \ --out /tmp/analytics.json \ --html /tmp/memory_audit.html The generated HTML puts ranked panels and legwork queues first, with the graph canvas second. This keeps the feature focused on memory governance instead of making the raw graph view the product.
Where audit ranks what the graph already says, mykg discover infers what it implies but does not yet say — and turns every inference into a reviewable proposal:
See CONTRIBUTING.md. The core graph model is intentionally minimal; contributions that preserve that shape are preferred.
All 2 files in this release have provenance metadata.
knowledge-graph ai-memory llm-memory agent-memory memory context-management context-engineering local-first provenance personal-knowledge-management note-taking obsidian markdown rag graphrag retrieval-augmented-generation mcp mcp-server model-context-protocol llm llm-tools ai agents claude anthropic openai ollama json-ld rdf sparql
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
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 verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
All 2 files in this release have been uploaded with provenance metadata.
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.




