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:

Every node carries a confidence score and full provenance — the exact file path and line numbers where it was extracted from.

Extractors

ExtractorFile typesWhat it extracts
CodeExtractor.kt, .java, .py, .js, .ts…Classes, functions, methods, imports
MarkdownExtractor.mdHeadings, sections, links
SqlExtractor.sqlTables, columns, foreign keys
PdfExtractor.pdfSections, text content
ConfigExtractor.yaml, .yml, .json, .tomlKeys, values, structure
SemanticExtractorany (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.

Note
Semantic extraction via LiteLLM is disabled by default. All other extractors work fully offline.