Skip to content
Conduit

mcp server

DotCode

sư dụng trên nền tảng aider phát triển và tối ưu

kavsir/DotCodecommunitylistedunreviewed

Set up

Runs on your computer. Pick your agent and operating system.

Before you start

  • uv (`curl -LsSf https://astral.sh/uv/install.sh | sh`)
~/Library/Application Support/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "dotcode": {
      "command": "uvx",
      "args": [
        "aider-chat"
      ]
    }
  }
}

same format Cursor, GitHub Copilot CLI, Junie, JetBrains AI Assistant, Augment (Auggie CLI), Factory Droid, Kiro, Devin CLI +12

Values in angle brackets are placeholders. Restart Claude Desktop after editing its config.Claude Desktop docs

README

synced Oct 25, 2026

DotCode - AI-Powered Software Engineering Team


Architecture Overview

User Input
    │
    ├──► DialogueStateTracker (dst.py)     ← Multi-turn context, TTL, pending questions
    │
    ├──► IntentAgent (agents/)             ← LLM classify + rule-based fallback (VI/EN)
    │         question / search / command / architecture (ambiguous -> LLM fallback)
    │
    ├──► SafeModelRouter (model_router.py)
    │         SIMPLE → flash | MODERATE → chat | COMPLEX → pro
    │
    ├──► CodeGraph (graph/)                ← Structural analysis hub
    │         ├── Indexer (Tree-sitter, 20+ languages)
    │         ├── SQLite / Neo4j backend (auto-select by symbol count)
    │         ├── PageRank (networkx, alpha=0.85)
    │         ├── MultiHopEngine           ← k-hop, shortest path, community bridges
    │         └── GraphRAGEngine           ← Leiden communities, BAAI/bge-m3, ChromaDB
    │
    ├──► CodeRAG (code_rag.py)             ← LangChain ReAct agent
    │         code_graph_tool + graphrag_tool
    │
    ├──► ContextPruner (context_pruner.py) ← Token reduction before LLM call
    │
    ├──► HITLManager (hitl.py)             ← Risk classification for code changes
    │
    ├──► SAGEEngine (sage.py)              ← Long-term memory (SQLite events)
    │
    └──► MCP Server (mcp_server.py)        ← 10 tools via FastMCP

DotCode's core innovation is the deep integration between two knowledge engines:

EngineRoleTechnology
Code GraphStructural understanding (call graph, inheritance, imports)Tree-sitter, SQLite, PageRank
GraphRAGSemantic understanding (communities, summaries, embeddings)ChromaDB, Leiden algorithm, BAAI/bge-m3

Together, they enable DotCode to:

  • Answer architectural questions ("What are the main modules?")
  • Find all callers/callees of any function
  • Detect dead code
  • Perform impact analysis (blast radius)
  • Cross-community bridge analysis

Key Features

Deep Code Understanding

  • Multi-language support: Python, JavaScript, TypeScript, Rust, Go, Java, Kotlin, and more via Tree-sitter
  • Cross-file analysis: Tracks function calls across the entire codebase
  • Community detection: Automatically groups related code into semantic modules using the Leiden algorithm
  • LLM-powered summaries: Each module gets a natural language description (DeepSeek, fallback to rule-based)

Intelligent Agent & Multi-Provider Gateway

  • Centralized LLM Gateway (DotCodeLLM): Powered by litellm. Supports DeepSeek, OpenAI, Anthropic (Claude), Google Gemini, Groq, OpenRouter, and local Ollama out of the box.
  • Model Control Commands:
    • /dotcode-model: Switch between auto model routing and manual model override (e.g. /dotcode-model gpt-4o).
    • /dotcode-providers: List all available local & cloud LLM providers.
  • Multi-intent classifier: Distinguishes question, search, command, and architecture. Ambiguous inputs ask clarification questions (Product Manager mode) or fallback seamlessly — supports Vietnamese & English.
  • Semantic Context Pruner: Uses Vector Search (Cosine Similarity) and exact token counting (litellm.token_counter) to trim history intelligently while preserving crucial context.
  • Hybrid Embedder (HybridEmbedder): Offloads embedding generation to cloud APIs (OpenAI text-embedding-3-small, Gemini text-embedding-004) to save 100% local CPU/RAM, with seamless local SentenceTransformer fallback.
  • Tree-sitter Extensibility (.scm queries): Dynamic language loading and custom AST query support for multi-language symbol extraction.
  • Dialogue State Tracker: Manages multi-turn conversation context with TTL and pending questions.
  • CodeRAG: LangChain ReAct agent combining structural (Code Graph) and semantic (GraphRAG) search.
  • Model Router: Automatically selects the cheapest capable LLM based on task complexity.

MCP Server (Model Context Protocol)

Expose 10 tools for any AI agent via FastMCP:

ToolDescription
get_calleesFunctions called by a symbol
get_callersFunctions that call a symbol
search_codeSearch symbols by name/signature
global_searchFind relevant communities by query
local_searchSymbol details + neighbors (BFS)
get_blast_radiusImpact analysis (direct/indirect callers)
get_unused_symbolsDead code detection
get_file_contextContext summary for one or more files
get_community_contextCommunity details by ID or symbol name
multi_hop_queryk-hop / shortest path / community bridges

/codebase Report Command

Generate an interactive HTML report of the entire codebase:

  • Interactive graph powered by vis.js (nodes sized by PageRank, colored by kind)
  • AI summary generated by LLM (DeepSeek), with rule-based fallback
  • Statistics: files, symbols, classes, functions, methods, relationships, languages, modules
  • Community cards with summaries and key symbols
  • Toggle visibility of node types (class/function/method/file/module) and edge types

Safety & Optimization

  • HITL Manager: Classifies code changes as LOW (auto-apply) / MEDIUM (confirm) / HIGH (review)
  • Incremental Update: Automatically syncs Code Graph + GraphRAG after every commit/edit
  • Automatic backend selection: SQLite for small projects (<5000 symbols), Neo4j for large ones
  • SAGE Memory: Learns from user feedback — boosts (×1.5) or decays (×0.5) symbol relevance

Installation

Prerequisites

  • Python 3.10+
  • Git

Install from source

git clone https://github.com/kavsir/DotCode.git
cd DotCode
python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate
pip install -e .

Set up API keys

DotCode auto-detects active providers from your environment variables:

# DeepSeek (Recommended default)
export DEEPSEEK_API_KEY=sk-your-key-here

# OpenAI
export OPENAI_API_KEY=sk-your-key-here

# Anthropic (Claude)
export ANTHROPIC_API_KEY=sk-ant-your-key-here

# Google Gemini
export GEMINI_API_KEY=your-gemini-api-key

# Groq / OpenRouter / Ollama
export GROQ_API_KEY=gsk-your-key-here
export OPENROUTER_API_KEY=sk-or-your-key-here

# HuggingFace (Optional for local BAAI/bge-m3 embeddings)
export HF_TOKEN=hf-your-token-here

Quick Start

# Navigate to your project
cd /path/to/your/project

# Start DotCode
python -m aider.main

In the DotCode shell:

# Ask a question
> hàm lend_book làm gì?

# Search for code
> tìm tất cả class

# Edit code
> thêm docstring cho class Book

# Architecture questions
> có những module chính nào trong dự án?

# Impact analysis
> Book có liên quan đến LibraryService không?

# Generate interactive codebase report (HTML)
> /codebase

Project Structure

DotCode/
├── aider/                      # Aider core (forked & enhanced)
│   └── commands.py             # Slash commands (includes /codebase)
├── dotcode/
│   ├── agents/
│   │   └── intent_agent.py     # LLM + rule-based intent classifier (VI/EN)
│   ├── graph/
│   │   ├── __init__.py         # CodeGraph: main integration class
│   │   ├── database.py         # SQLite schema (symbols, edges, events)
│   │   ├── indexer.py          # Multi-language Tree-sitter parser
│   │   ├── interface.py        # GraphDBInterface (abstract base)
│   │   ├── sqlite_adapter.py   # SQLite backend
│   │   ├── neo4j_adapter.py    # Neo4j backend (large projects)
│   │   ├── multi_hop.py        # k-hop, shortest path, community bridges
│   │   └── queries/            # Tree-sitter .scm query files
│   ├── graphrag.py             # GraphRAG Engine (Leiden, BAAI/bge-m3, ChromaDB)
│   ├── code_rag.py             # LangChain ReAct agent
│   ├── mcp_server.py           # FastMCP server (10 tools)
│   ├── model_router.py         # ModelRouter + SafeModelRouter
│   ├── hitl.py                 # Human-in-the-Loop risk classifier
│   ├── sage.py                 # Long-term memory (event store)
│   ├── dst.py                  # Dialogue State Tracker (multi-turn)
│   ├── context_pruner.py       # Token-efficient context management
│   ├── intent.py               # Lightweight rule-based intent (ask/edit)
│   └── models.py               # Pydantic: Symbol, Edge, BlastRadiusResult
├── tests/
│   └── test_dotcode_graph.py   # Test suite
├── requirements/               # Dependencies
└── README.md

Testing

# Run the test suite
python -m pytest tests/test_dotcode_graph.py -v

# Test MCP tools
python -m dotcode.mcp_server

Configuration

Environment VariableDescriptionDefault
DEEPSEEK_API_KEYDeepSeek API key—
OPENAI_API_KEYOpenAI API key—
HF_TOKENHuggingFace token (for BAAI/bge-m3)—
DOTCODE_BACKENDDatabase backend (auto, sqlite, neo4j)auto
NEO4J_URINeo4j connection URIbolt://localhost:7687
NEO4J_USERNAMENeo4j usernameneo4j
NEO4J_PASSWORDNeo4j passwordpassword
DOTCODE_MODEL_SIMPLEModel for simple tasks (comments, docstrings)openai/deepseek-v4-flash
DOTCODE_MODEL_MODERATEModel for moderate tasks (add function, small refactor)openai/deepseek-v4-flash
DOTCODE_MODEL_COMPLEXModel for complex tasks (multi-file, architect)openai/deepseek-v4-pro

Backend Auto-selection Logic

DOTCODE_BACKEND=auto (default):
  - If existing DB has > 5000 symbols AND NEO4J_URI is set -> Neo4j
  - Otherwise -> SQLite (stored at .dotcode/<project-name>.db)

System Benchmark & Accuracy Evaluation

DotCode includes an automated benchmark suite (tests/run_benchmark.py) modeled after international academic and industry standards including SWE-bench, Microsoft GraphRAG, RAGAS Framework, and IEEE/ACM Software Engineering Metrics.

Benchmark Standards Compliance

Benchmark DimensionStandard / Academic FrameworkEvaluation Focus
AST Symbol & Edge PrecisionSWE-bench (Princeton / OpenAI)Code context retrieval & exact AST symbol/call-edge ground truth precision
Graph Traversal & CentralityMicrosoft GraphRAG MethodologyPageRank centrality calculation & k-hop shortest path graph search latency
Context Pruning & EfficiencyRAGAS / RAG Triad FrameworkContext recall preservation (100%) and token reduction ratio (>83.6%)
Parsing & Embedding ThroughputIEEE / ACM Software EngineeringMulti-language Tree-sitter AST throughput (files/sec) & embedding speed

Benchmark Results Overview

Metric / Evaluation ComponentResult / PerformanceAcademic / Industry Standard
Tree-sitter AST Indexing Speed214.53 files/sec (786.62 symbols/sec)IEEE/ACM Throughput Metric
PageRank Computation361.27 msMicrosoft GraphRAG Centrality
Blast Radius Impact Analysis0.798 ms/queryGraph Traversal Latency
Multi-Hop Neighbors Traversal0.505 ms/queryGraph Traversal Latency
Context Pruner Token Savings83.6% savedRAGAS Compression Ratio
AST Symbol Extraction Accuracy100.0% (5/5 ground truth)SWE-bench Ground Truth
Call Edge Relationship Extraction100.0% (4/4 relationships)SWE-bench Ground Truth
Context Pruner Recall Accuracy100.0% preservationRAGAS Context Recall
Intent Classification Accuracy~95-98% (Online LLM mode)Intent Classification Precision

Run the Benchmark Suite

python tests/run_benchmark.py

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

DotCode is licensed under the Apache License 2.0, the same license as the original Aider project.

This project is a fork of Aider, created by Aider AI. All original copyright notices are preserved.


Acknowledgments


↑↓ navigate openesc close