Introduction
Overview
ContextGraph is a local-first knowledge graph engine that turns your project's files — source code, Markdown documentation, PDFs, SQL schemas, YAML/JSON configs — into a connected, queryable graph stored in SQLite.
Once indexed, you can search the graph from the CLI, explore relationships between concepts, and expose the entire knowledge base to AI agents through a Model Context Protocol (MCP) server.
Why it exists
Large codebases and documentation collections are hard to navigate — for humans and AI agents alike. Reading every file to answer "what does this module do?" or "what depends on this function?" is slow and expensive. ContextGraph solves this by building a persistent, structured graph of your project's knowledge so that questions can be answered in milliseconds instead of minutes.
AI agents using ContextGraph can answer questions with far fewer token-consuming file reads, because they can navigate the graph directly.
What's in the graph
Every indexed file produces nodes and edges:
- Artifact nodes — the file itself (
CodeFile,MarkdownFile,PDF,DatabaseSchema,ConfigFile…) - Entity nodes — symbols extracted from the file (
Class,Function,Method,DatabaseTable,Concept,Claim…) - Edges — relationships between nodes (
DEFINES,CALLS,DEPENDS_ON,REFERENCES,CONTAINS…)
Every node carries a confidence score and full provenance — the exact file path and line numbers where it was extracted from.
Extractors
| Extractor | File types | What it extracts |
|---|---|---|
CodeExtractor | .kt, .java, .py, .js, .ts… | Classes, functions, methods, imports |
MarkdownExtractor | .md | Headings, sections, links |
SqlExtractor | .sql | Tables, columns, foreign keys |
PdfExtractor | Sections, text content | |
ConfigExtractor | .yaml, .yml, .json, .toml | Keys, values, structure |
SemanticExtractor | any (via LiteLLM) | Concepts, claims, decisions, relationships |
100% local
ContextGraph runs entirely on your machine. The graph is stored in a single SQLite file at .contextgraph/graph.db in your project directory. No data is sent to any cloud service unless you explicitly enable the optional semantic extractor and point it at your own LiteLLM endpoint.