Skip to main content
Glama
README.md
# GOGO - Code Intelligence MCP Server

**GOGO** is a local-first Model Context Protocol (MCP) server that gives AI agents a searchable vector db of your codebase without requiring heavy hardware.

## Features

- **Ultra-low memory footprint**: 96-99% compression using Matryoshka Representation Learning and Binary Quantization
- **Hybrid search**: Combines vector similarity, BM25 keyword search, and symbol lookups
- **Smart chunking**: Tree-sitter powered extraction of functions, classes, and methods
- **Code intelligence**: Symbol definitions, call graphs, reference finding, and more
- **Git-aware sync**: Only re-indexes changed files (incremental updates)
- **Local-first**: All processing happens on your machine via Ollama
- **File watching**: Auto-sync when files change

## Requirements

- Python 3.11+
- [Ollama](https://ollama.ai/) with `nomic-embed-text` model
- 4GB+ RAM

## Installation

Install Ollama and pull the embedding model:
```bash
ollama pull nomic-embed-text
```

Then from source:
```bash
git clone https://github.com/eccreativ/gogo-mcp.git
cd gogo-mcp
uv sync
```

## Configuration

Add to your Claude Desktop config (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):

```json
{
  "mcpServers": {
    "gogo": {
      "command": "uv",
      "args": ["run", "gogo-server"],
      "cwd": "/path/to/gogo-mcp"
    }
  }
}
```

## MCP Tools

### Indexing

| Tool | Description |
|------|-------------|
| `index_directory` | Full index of a codebase with parallel tree-sitter parsing |
| `sync_index` | Git-aware incremental sync (only changed files) |
| `clear_index` | Remove index for a codebase |
| `watch_directory` | Auto-sync on file changes |
| `unwatch_directory` | Stop watching a directory |

### Search

| Tool | Description |
|------|-------------|
| `super_grep` | **Powerful unified search** - combines vector similarity, BM25, symbol lookup, and reference search in one call |
| `code_research` | Semantic search with query intent classification |
| `find_references` | Find all usages of a symbol (calls, imports, inheritance) |

### Code Intelligence

| Tool | Description |
|------|-------------|
| `get_symbol_definition` | O(1) lookup of where a function/class is defined |
| `get_codebase_overview` | High-level architecture: entry points, key classes, file structure |
| `get_call_graph` | What calls this function? What does it call? |
| `get_related_symbols` | Find symbols often used together (co-occurrence analysis) |

## Usage Examples

### Index a codebase
```
index_directory("/path/to/your/project")
```

### Search with super_grep
```
super_grep("authentication", "/path/to/project")
```
Returns:
- Symbol definitions matching "authentication"
- All references/usages
- Semantically similar code
- Related symbols

### Get codebase overview
```
get_codebase_overview("/path/to/project")
```
Returns:
- File count, symbol count, reference count
- Symbol types breakdown (functions, classes, etc.)
- Entry points (main functions, handlers)
- Key classes with method counts

### Explore a function
```
get_call_graph("handleLogin", "/path/to/project", direction="both")
```
Returns:
- Where the function is defined
- All callers (who calls this)
- All callees (what this calls)

## Architecture

### Chunking Pipeline

1. Parse code with **tree-sitter** (supports 30+ languages)
2. Extract functions, classes, methods as separate chunks
3. Augment with metadata (imports, signatures, docstrings)
4. Embed each chunk with Ollama

### Vector Compression

Two-stage retrieval for speed + accuracy:

1. **Stage 1: Hamming Distance Filter**
   - Binary quantized vectors (256 bits)
   - Fast XOR + popcount
   - Returns top 100 candidates

2. **Stage 2: Cosine Similarity Reranking**
   - MRL-truncated float vectors (256 dimensions)
   - Precise ranking
   - RRF fusion with BM25 scores

### Indexes

| Index | Purpose |
|-------|---------|
| Vector (binary) | Fast similarity search |
| Vector (MRL float) | Precise reranking |
| BM25 (FTS) | Keyword search |
| Symbols | O(1) definition lookup |
| References | Call graph, usages |

## Supported Languages

Python, JavaScript, TypeScript, Go, Rust, Java, C, C++, C#, Ruby, PHP, Swift, Kotlin, Scala, Lua, R, Julia, Elixir, Erlang, Haskell, OCaml, Clojure, Perl, Dart, and more via tree-sitter.

## Performance

- **Memory**: ~16 bytes per code chunk (vs 3KB for standard RAG)
- **Indexing**: Parallel tree-sitter parsing + parallel embedding
- **Search**: <100ms on 100K+ chunks
- **Compression**: 96-99% vs full float32 vectors

## Development

```bash
# Install dependencies
uv sync

# Run tests
uv run pytest

# Run server directly
uv run gogo-server
```

## License

MIT License - see [LICENSE](LICENSE) file.

## Credits

Built with:
- [MCP SDK](https://github.com/modelcontextprotocol/python-sdk)
- [DuckDB](https://duckdb.org/)
- [Ollama](https://ollama.ai/)
- [tree-sitter](https://tree-sitter.github.io/tree-sitter/)
- [nomic-embed-text](https://huggingface.co/nomic-ai/nomic-embed-text-v1.5)