Airsc miễn phí cho tất cả. Nếu nó giúp bạn, hãy ủng hộ $2–$20.

Ủng hộ
SkillCẩn thậnQuy trình & bộ nhớ agentNâng cao

CodeGraphContext

CodeGraphContext · CodeGraphContext/CodeGraphContext

Lập chỉ mục mã nguồn cục bộ vào đồ thị có thể truy vấn để cung cấp cho AI agent ngữ cảnh cấu trúc sâu về mã nguồn.

An MCP server plus a CLI tool that indexes local code into a graph database to provide context to AI assistants.

4.3k sao833Giấy phép: MITCập nhật 9 ngày trước0 lượt mở

Xem trước

▍

Bạn có thể làm gì với nó

  • Giúp agent điều hướng các phụ thuộc phức tạp giữa các tệp và hàm
  • Tạo bản đồ trực quan hoặc giải thích các luồng logic của ứng dụng
  • Cải thiện chất lượng đánh giá mã bằng cách cung cấp cho agent ngữ cảnh dự án rộng hơn

Kiểm tra an toàn

Cẩn thận

Dùng được, nhưng nên đọc ghi chú trước.

  • ●Trình cài đặt tải script từ xa và chạy thẳng bằng shell.README.md

Quét tự động các file trong repo. Luôn xem lại code trước khi chạy.

Trích từ README

🏗️ CodeGraphContext (CGC)

Turn code repositories into a queryable graph for AI agents.

🌐 Languages:

🌍 Help translate CodeGraphContext to your language by raising an issue & PR on GitHub Issues!

Bridge the gap between deep code graphs and AI context.

A powerful MCP server and CLI toolkit that indexes local code into a graph database to provide context to AI assistants and developers. Use it as a standalone CLI for comprehensive code analysis or connect it to your favorite AI IDE via MCP for AI-powered code understanding.


📍 Quick Navigation


✨ Experience CGC

👨🏻‍💻 Installation and CLI

Install in seconds with pip and unlock a powerful CLI for code graph analysis.

🛠️ Indexing in Seconds

The CLI intelligently parses your tree-sitter nodes to build the graph.

🤖 Powering your AI Assistant

Use natural language to query complex call-chains via MCP.


Why CodeGraphContext?

CodeGraphContext is built for the moment when plain text search stops being enough. It turns a repository into a graph of files, symbols, calls, inheritance, imports, and relationships so you can move from "where is this defined?" to "how does this actually connect?" without jumping between tools.

flowchart LR
  A[Source code] --> B[Tree-sitter and SCIP indexers]
  B --> C[Graph database]
  C --> D[CLI queries]
  C --> E[MCP server]
  D --> F[Direct analysis]
  E --> G[AI assistants with repo context]

Comparison at a glance

ApproachBest forTradeoff
grep / file searchExact string lookupMisses relationships and code structure
RAG over code chunksNatural-language retrievalCan lose symbol-level precision
CodeGraphContextRepository-wide reasoningRequires an indexing step

Common use cases

  • Trace call chains across files and packages.
  • Understand class hierarchies, imports, and module boundaries.
  • Find dead code, hotspots, and unexpected dependencies.
  • Give an AI assistant the same structural context a maintainer would use.

FAQ

  • Do I need a remote service? No. CGC works locally with embedded backends or with external graph databases when you want them.
  • Is it only for one language? No. It supports a broad mix of mainstream languages and keeps expanding.
  • Can I use it with an AI assistant? Yes. That is one of the main reasons the MCP server exists.

Project Details


👨‍💻 Maintainer

CodeGraphContext is created and actively maintained by:

Shashank Shekhar Singh

Contributions and feedback are always welcome! Feel free to reach out for questions, suggestions, or collaboration opportunities.


Star History

Star History Chart ↗


Features

  • Code Indexing: Analyzes code and builds a knowledge graph of its components.
  • Relationship Analysis: Query for callers, callees, class hierarchies, call chains and more.
  • Pre-indexed Bundles: Load famous repositories instantly with .cgc bundles - no indexing required! (Learn more)
  • Live File Watching: Watch directories for changes and automatically update the graph in real-time (cgc watch).
  • Interactive Setup: A user-friendly command-line wizard for easy setup.
  • Dual Mode: Works as a standalone CLI toolkit for developers and as an MCP server for AI agents.
  • Multi-Language Support: Full support for 23 programming languages.
  • Flexible Database Backend: FalkorDB Lite (Default), KuzuDB, LadybugDB, FalkorDB Remote, Nornic DB, or Neo4j (all platforms via Docker/native).

🏗️ Architecture & Workflow

CodeGraphContext parses your source code and builds a comprehensive knowledge graph. This graph can be queried directly via the CLI toolkit or exposed to AI assistants through the MCP server.

flowchart TD
    A[Code Repository] -->|Parsed by| B[Tree-sitter / SCIP Indexing]
    B -->|Generates| C[Knowledge Graph]
    C -->|Stored in| D[(Graph Database)]
    D -->|Queried via| E[CLI Toolkit]
    D -->|Served by| F[MCP Server]
    F -->|Provides context to| G[🤖 AI Assistant]

    classDef default fill:#1f2937,stroke:#8b5cf6,stroke-width:2px,color:#fff;
    classDef db fill:#0f172a,stroke:#3b82f6,stroke-width:2px,color:#fff;
    classDef ai fill:#312e81,st
Xem mã nguồn trên GitHub