CodeKG: Structural Knowledge Graph Construction from Python Codebases
Abstract
CodeKG builds a deterministic, source-grounded knowledge graph from Python codebases using static AST analysis. It captures structural relationships — definitions, calls, imports, inheritance, and data flow — in SQLite with full file/line provenance, augments retrieval with vector embeddings in LanceDB, and executes queries in two phases: semantic seeding followed by bounded graph traversal. Results are packed into source-grounded snippets for LLM ingestion. The system ships with a Python library, CLI tools, a Streamlit graph explorer, and an MCP server for AI agent integration. Its central thesis is that code structure, not embeddings, should be the authoritative foundation for code understanding — making it a practical alternative to embedding-only and probabilistic graph RAG approaches.
Fields of Study & Subjects
Software Engineering Research
Semantic Web and Ontologies
Model-Driven Software Engineering Techniques
Publication details
- Journal / source
- OSF Preprints (OSF Preprints)
- Publication date
- 25 February 2026
- Language
- EN
- Document type
- Preprint