# Code Graph MCP Server

A code indexing system that creates searchable code graphs accessible via MCP (Model Context Protocol) for LLM consumption.

## Features

- 🔍 **Semantic Code Search** - Search across multiple repositories with context
- 📊 **Code Graph Analysis** - Understand relationships between functions, classes, and modules
- 🚀 **Fast Indexing** - Targeted repository indexing for relevant codebases only
- 🔌 **MCP Integration** - Direct LLM access via Model Context Protocol
- 🛠️ **Multi-Language Support** - TypeScript, JavaScript, Python, Go, Rust, Java via Tree-sitter
- 📱 **Cross-Platform** - Works on Windows, macOS, and Linux

## Quick Start

### Installation

```bash
npx code-graph-mcp
```

### Setup

1. **Configure Repositories**: Edit `config/repos.json` to specify which repositories to index:

```json
{
  "repositories": [
    {
      "url": "https://github.com/your-org/your-repo",
      "name": "your-repo",
      "priority": "high"
    }
  ]
}
```

2. **Index Repositories** (automatically syncs and indexes):

```bash
npx code-graph-mcp index
```

3. **Start MCP Server**:

```bash
npx code-graph-mcp start
```

## Architecture

### Core Components

- **Repository Manager** - Clone and manage repositories from config list
- **Code Parser** - Extract symbols, AST, relationships using tree-sitter
- **Graph Database** - Store code relationships in SQLite
- **Search Engine** - Semantic and structural code search
- **MCP Server** - Protocol interface for LLM access
- **CLI Interface** - Management and configuration tools

### MCP Tools Available

- `search_code` - Semantic code search across repositories
- `find_references` - Find symbol usage and references
- `get_call_graph` - Trace function calls and dependencies
- `analyze_dependencies` - File/module dependency analysis
- `get_symbol_info` - Symbol definitions and documentation
- `explore_codebase` - High-level structure analysis

## Configuration

### Repository Configuration

The `config/repos.json` file defines which repositories to index:

```json
{
  "repositories": [
    {
      "url": "https://github.com/microsoft/vscode",
      "name": "vscode",
      "priority": "high",
      "branch": "main",
      "include": ["src/**/*.ts"],
      "exclude": ["node_modules/**", "**/*.test.*"]
    }
  ],
  "settings": {
    "maxFileSize": "1MB",
    "indexBinaryFiles": false,
    "languages": ["typescript", "javascript", "python"],
    "updateInterval": "1h"
  }
}
```

## Development

### Build

```bash
npm run build
```

### Development Mode

```bash
npm run dev
```

### Testing

```bash
npm test
```

## Maintenance

Maintained by **[Kynlo Akari](https://github.com/Kynlos)**.

## License

MIT
