@putao520/gcode
v0.13.0
Published
Advanced code search and project understanding tool with four-layer indexing - MCP Server for Code Intelligence
Maintainers
Readme
GCode - MCP Server for Zero-Error AI Code Development
🚨 BREAKTHROUGH: First MCP server that enables 100% error-free AI code development through intelligent constraints and architectural guidance.
🎯 Core Mission
GCode prevents AI assistants from making architectural and implementation errors before they happen.
Unlike traditional code analysis tools, GCode operates as a development plan constraint generator that provides AI assistants with the context they need before coding begins.
✅ What GCode Guarantees
Through MCP protocol enforcement, GCode ensures 100% elimination of:
- 🚫 Architectural Errors - Wrong patterns, broken layering, incompatible tech stack choices
- 🚫 Implementation Errors - Duplicate code, inconsistent patterns, ignored existing components
- 🚫 Breaking Changes - Modified public APIs, broken dependencies, compatibility issues
- 🚫 Redundant Development - Reimplementing existing functionality, wasted effort
🏗️ Architecture Overview
UPSG 7-Layer Intelligence Model
┌─────────────────────────────────────────────────────┐
│ MCP Protocol Layer │
│ AI-Friendly Tool Descriptions │
├─────────────────────────────────────────────────────┤
│ Tool Implementation (2 tools) │
│ • pre_plan • project_overview │
├─────────────────────────────────────────────────────┤
│ Query Engine │
│ • BM25 Search • Vector Search • UPSG │
├─────────────────────────────────────────────────────┤
│ Storage Layer │
│ • SurrealDB (Embedded) • UPSG Data Model │
├─────────────────────────────────────────────────────┤
│ Analysis Pipeline │
│ • Tree-sitter Parsers • 5-Perspective Extractors │
│ • 18 Framework Adapters │
└─────────────────────────────────────────────────────┘Zero-Abstraction Data Model
| Layer | Data Type | Purpose | |-------|-----------|---------| | L1 | Module | Crates, packages, logical groups | | L2 | File | Source code files | | L3 | Symbol | Functions, classes, types | | L4 | Statement | Code statements | | L5 | Reference | Symbol references and relationships | | L6 | Quality | Code quality metrics and analysis | | L7 | Analysis | Import cycles, test mappings, coupling |
🛠️ MCP Tools: Simplicity + Power
GCode provides exactly two tools to maintain simplicity while delivering comprehensive intelligence:
Tool 1: project_overview - Complete Project Understanding
🎯 Purpose: Understand the project's architecture, patterns, and conventions before coding.
🚨 AI TRIGGER WORDS:
- "implement", "add", "create", "build", "develop"
- "review", "analyze", "understand", "explain"
- "fix", "debug", "optimize", "refactor"
Returns:
- 📊 Architecture patterns (MVC, Clean Architecture, etc.)
- 🏗️ Framework usage (React, Vue, Angular, etc.)
- 📈 Code quality metrics and technical debt
- 🧪 Test coverage analysis
- ♻️ Reusable components and utilities
- 🔗 Module dependencies and coupling analysis
Tool 2: pre_plan - Task-Specific Development Constraints
🎯 Purpose: Get detailed context for specific development tasks to prevent errors.
🚨 AI TRIGGER WORDS:
- Any task-specific keywords ("user", "auth", "payment", "dashboard")
- "how to", "where is", "best way to", "should I use"
- "modify", "update", "extend", "enhance"
Parameters:
keywords: Task-specific keywords for exact matchingdescription: Natural language task descriptionmax_depth: Relationship traversal depth (default: 2)
Returns:
- 🎯 Task-specific context and constraints
- ♻️ Reusable components and existing implementations
- ⚠️ Risk assessments and potential breaking changes
- 🧪 Test requirements and coverage gaps
- 📋 Implementation recommendations following project patterns
🌐 Comprehensive Framework Support
Frontend Framework Ecosystem (18 Frameworks)
JavaScript/TypeScript Frameworks:
- ✅ React - Components, Hooks, Server Actions, JSX/TSX
- ✅ Vue.js - Vue 2/3, Options API, Composition API, script setup
- ✅ Angular - @Component/@Injectable, DI, RxJS
- ✅ Svelte - .svelte compiler, Reactivity system, Store patterns
- ✅ Next.js - App/Pages Router, SSR/SSG, Server/Client Components
- ✅ Nuxt.js - Vue-based SSR, Auto-imports, Middleware, Nitro
- ✅ Remix - Full-stack React, Loader actions, Route conventions
- ✅ Solid.js - Fine-grained reactivity, JSX, CreateSignal
- ✅ Astro - Content-focused, Island architecture, Multi-UI
- ✅ Qwik - Resumable, Lazy loading, No hydration
- ✅ Preact - Lightweight React alternative, 10kb bundle
- ✅ Alpine.js - Minimalist, Reactive declarative syntax
- ✅ Lit - Web components, Declarative templates, Scoped styles
Cross-Platform Frameworks:
- ✅ Flutter - Widget tree, State management, Material/Cupertino
- ✅ Qt - QObject hierarchy, Signals/slots, Meta-object system
- ✅ React Native - Native components, Bridge, Platform-specific
- ✅ Electron - Main/Renderer process, IPC, Native APIs
- ✅ Tauri - Rust backend, WebView IPC, Small bundles
Programming Language Support
13 production languages with tree-sitter AST parsing:
- ✅ Rust, TypeScript, JavaScript, Python
- ✅ Go, Java, C/C++, C#, Ruby
- ✅ Dart, Zig, and more...
🚀 Quick Start
Prerequisites
- Rust 1.70+ (for building from source)
- Claude Code or any MCP-compatible AI assistant
Installation
# Option 1: Install from crates.io
cargo install gcode
# Option 2: Build from source
git clone https://github.com/gcode/gcode.git
cd gcode
cargo build --releaseMCP Configuration
Add to your Claude Code configuration (~/.claude/claude_desktop_config.json):
{
"mcpServers": {
"gcode": {
"command": "gcode",
"args": []
}
}
}💪 Usage Examples
Example 1: Adding User Authentication
# AI Assistant Workflow:
User: "Implement user authentication with JWT"
# Step 1: AI calls project_overview automatically
# -> Discovers project uses React + TypeScript + Material-UI
# -> Finds existing AuthContext in src/auth/
# -> Identifies JWT utils already implemented
# Step 2: AI calls pre_plan with keywords
# -> Gets reusable LoginButton component
# -> Understands existing API integration patterns
# -> Knows test requirements (80% coverage policy)
# Step 3: AI implements following constraints
# -> Uses existing patterns, avoids duplication
# -> Maintains architectural consistency
# -> Adds appropriate testsExample 2: Vue.js Feature Enhancement
# AI Assistant Workflow:
User: "Add shopping cart functionality to our Vue app"
# Step 1: project_overview
# -> Detects Vue 3 + Composition API + Pinia
# -> Finds existing ProductCard component
# -> Identifies Vue Router setup
# Step 2: pre_plan(["cart", "shopping", "Pinia"])
# -> Discovers existing CartStore in stores/
# -> Finds reusable useCart composable
# -> Understands component testing patterns
# Result: 100% error-free implementation following Vue best practices📊 Performance Specifications
Response Times
- ⚡ Tool queries: < 200ms (95th percentile)
- 🔄 Index updates: < 5s per 1000 files
- 📁 Full reindex: < 60s for projects < 100k files
Resource Usage
- 💾 Memory: ~100MB base + ~10MB per 10k files
- 🗄️ Storage: Embedded SurrealDB, ~50MB per project
- ⚙️ CPU: Minimal impact, background processing
🏢 Platform Support
- ✅ Linux - Full support with pre-built binaries
- ✅ macOS - Full support with universal binaries
- ✅ Windows - Full support (Windows 10+)
🔧 Development
Building
# Debug build
cargo build
# Release build (optimized)
cargo build --release
# Run tests
cargo test
# Run with logging
RUST_LOG=debug cargo run -- --helpProject Commands
# Reset all indexed data
gcode reset
# Show version
gcode --version📁 Project Structure
gcode/
├── src/
│ ├── mcp/ # MCP server implementation
│ │ ├── server.rs # Main MCP server with enhanced tool descriptions
│ │ └── tools/ # pre_plan and project_overview implementations
│ ├── storage/ # SurrealDB storage layer
│ ├── upsg/ # Universal Program Structure Graph (7-layer)
│ ├── pipeline/ # Unified analysis pipeline
│ ├── extractors/ # Data extractors (5 perspectives)
│ └── library/ # Framework adapters (18 frameworks)
├── SPEC/ # Complete architecture specifications
├── tests/ # Comprehensive test suites
└── Cargo.toml # Project configuration📚 Documentation
- Architecture Specification - Complete system architecture
- MCP Tools Specification - Detailed tool documentation
- Data Model Specification - UPSG 7-layer model
- AI Usage Guide - How AI assistants should use GCode
- Testing Strategy - Test coverage and E2E testing
🤝 Contributing
We welcome contributions! Please see our Development Guidelines for details.
Code Style
- Follow Rust standard conventions
- Use
cargo fmtfor formatting - Use
cargo clippyfor linting - Write tests for new features
📄 License
MIT License - see LICENSE file for details.
🔗 Related Projects
- rmcp - Rust MCP SDK
- SurrealDB - Modern embedded database
- tree-sitter - Incremental parsing library
🎯 Why GCode is Different
Traditional tools: Help you fix errors after they happen GCode: Prevents errors from happening in the first place
By providing AI assistants with comprehensive project context and development constraints before coding begins, GCode enables a new paradigm of zero-error AI code development.
GCode - The intelligent constraint system that makes AI code development error-proof.
