# SDL-MCP: An Intelligent Indexing System for AI Programming Agents to Obtain Precise Code Context

> SDL-MCP helps AI programming agents obtain precise code context with extremely low token consumption by building a symbolic graph of the codebase and adopting a hierarchical progressive context retrieval strategy, saving up to 20 times the token usage.

- 板块: [Openclaw Llm](https://www.zingnex.cn/en/forum/board/openclaw-llm)
- 发布时间: 2026-04-14T22:15:20.000Z
- 最近活动: 2026-04-14T22:18:40.589Z
- 热度: 154.9
- 关键词: AI编程, 代码索引, MCP协议, Token优化, 代码图谱, 智能检索, 开发工具, 代码审查, 上下文管理, 编程效率
- 页面链接: https://www.zingnex.cn/en/forum/thread/sdl-mcp-ai
- Canonical: https://www.zingnex.cn/forum/thread/sdl-mcp-ai
- Markdown 来源: floors_fallback

---

## [Introduction] SDL-MCP: A Precise Context Indexing System for AI Programming Agents

SDL-MCP is an intelligent indexing system designed for AI programming agents. Its core goal is to solve the token waste problem in context acquisition for AI programming. By building a symbolic graph of the codebase and adopting a hierarchical progressive context retrieval strategy, it helps AI agents accurately obtain the required code information, saving up to 20 times the token usage while improving the output quality of the agents.

## Background: Context Dilemma in AI Programming

When AI programming agents answer code questions, traditional methods often require reading entire files (e.g., a 500-line code file where only the function signature is needed but the whole file is read), leading to severe token waste. In a debugging session involving 20 files, context collection may consume over 40,000 tokens. SDL-MCP was created to address this pain point of粗放式 (extensive/unrefined) context acquisition.

## Core Methods: Symbolic Graph Construction and Hierarchical Context Acquisition

### Core Architecture
The SDL-MCP workflow consists of three phases:
1. **Indexing Phase**: Parse code symbols (functions, classes, etc.) to generate symbol cards, supporting 12 languages (Rust native parsing or Tree-sitter fallback);
2. **Storage Phase**: Store symbol cards in the LadybugDB graph database, maintain dependency relationships to form a code knowledge graph;
3. **Service Phase**: Provide 38 query tools (symbol search, dependency slicing, etc.) via the MCP protocol.

### Iris Gate Ladder Hierarchical Mechanism
Divide context acquisition into four levels:
- Symbol Card (~100 Token): Contains core information such as name, signature, summary, etc.;
- Skeleton IR (~300 Token): Function signature + control flow structure;
- Hot Fragment (~600 Token): Code lines related to specific identifiers;
- Raw Code Window (~2000 Token): Requires policy-gated access.
This design ensures that full code is read only when necessary, reducing token waste.

## Key Components: Symbol Cards and Intelligent Graph Slicing

### Symbol Cards
Each symbol is encoded into a ~100-token card, including: basic information, signature, LLM-generated summary, invariants, side effects, dependencies, code metrics, context, etc. It can replace 2000 tokens of full code information.

### Graph Slicing Function
Traverse along the dependency graph, starting from task-related symbols, calculate relevance scores based on weighted edges (call:1.0, config:0.8, import:0.6), and return important symbols within the token budget. Supports natural language task descriptions, incremental updates, overflow pagination, ETag caching, and other features.

## Additional Features: Change Impact Analysis and Real-Time Indexing Experience

### Delta and Impact Radius Analysis
When code changes, generate semantic differences (signatureDiff, etc.), calculate the impact radius to identify affected symbols, mark test files that need re-running, and assist in code review and refactoring.

### Real-Time Indexing
Real-time update of in-memory storage when editing in the editor; background AST parsing and merging into the database, so functions like symbol search reflect unsaved states. Also provides development memory (cross-session notes), SCIP integration (improves dependency accuracy), and sandbox runtime (supports 16 runtimes).

### Governance Policies
Raw code access requires gating (reason, expected identifiers, line count estimate), and decision records are stored in audit logs; runtime execution has control measures such as whitelisting, isolation, and timeouts.

## Application Effects: Token Saving Comparison and Scenario Validation

Token saving effects of SDL-MCP in various scenarios:
| Scenario | Traditional Method | SDL-MCP | Token Saving |
|-----|---------|---------|----------|
| Understanding parseConfig parameters | ~2000 Token | ~100 Token | 20x |
| Viewing AuthService structure | ~4000 Token | ~300 Token |13x |
| Locating this.cache setting | ~2000 Token | ~500 Token |4x |
For large codebases, cumulative savings significantly reduce API costs and improve agent response speed.

## Summary and Recommendations: A New Paradigm for Intelligent Code Interaction

SDL-MCP fundamentally improves the context management capability of AI programming agents through symbolic graphs and hierarchical retrieval, allowing agents to 'understand' code rather than just 'read' it. It significantly reduces token consumption while improving output quality, providing a more intelligent and cost-effective code interaction method for users of AI programming tools like Claude Code and Cursor. It is recommended that developers combine SDL-MCP with AI programming tools to optimize their experience.
