Skip to content

About

A minimalist setup for indexing items like codebase etc. which can be hooked up with cli based tools like claude code to harness the power of context and get improved performance from code edits.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

10 Commits

Folders and files

Repository files navigation

Vector MCP - Code Context Server

A Model Context Protocol (MCP) server for Claude Code that provides semantic search across codebases using MongoDB and Ollama embeddings.

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Claude Code   β”‚    β”‚   Web Browser   β”‚    β”‚   File System   β”‚
β”‚                 β”‚    β”‚                 β”‚    β”‚                 β”‚
β”‚  - Context AI   β”‚    β”‚  - Project Mgmt β”‚    β”‚  - Source Code  β”‚
β”‚  - Code Search  β”‚    β”‚  - Live Logs    β”‚    β”‚  - Delta Check  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚                      β”‚                      β”‚
          β”‚ stdio/MCP            β”‚ HTTP API             β”‚ fs.watch
          β”‚                      β”‚                      β”‚
          β–Ό                      β–Ό                      β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Vector MCP Server                         β”‚
β”‚                                                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”‚
β”‚  β”‚ MCP Handler β”‚  β”‚ Web Server  β”‚  β”‚ Job Manager β”‚           β”‚
β”‚  β”‚             β”‚  β”‚             β”‚  β”‚             β”‚           β”‚
β”‚  β”‚ - Tools     β”‚  β”‚ - REST API  β”‚  β”‚ - Async Ops β”‚           β”‚
β”‚  β”‚ - Resources β”‚  β”‚ - Static UI β”‚  β”‚ - Progress  β”‚           β”‚
β”‚  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜           β”‚
β”‚        β”‚                β”‚                β”‚                   β”‚
β”‚        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                   β”‚
β”‚                         β”‚                                    β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚              File Indexer                               β”‚ β”‚
β”‚  β”‚                                                         β”‚ β”‚
β”‚  β”‚  - Code Chunking    - File Hashing    - Delta Logic     β”‚ β”‚
β”‚  β”‚  - Content Filter   - Pattern Match   - Change Track    β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                        β”‚                                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚               β”‚               β”‚
         β–Ό               β–Ό               β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Ollama    β”‚  β”‚  MongoDB    β”‚  β”‚   Logger    β”‚
β”‚             β”‚  β”‚             β”‚  β”‚             β”‚
β”‚ - llama2    β”‚  β”‚ - Vectors   β”‚  β”‚ - Live Feed β”‚
β”‚ - Embedding β”‚  β”‚ - Metadata  β”‚  β”‚ - Job Logs  β”‚
β”‚ - Local AI  β”‚  β”‚ - Projects  β”‚  β”‚ - File Log  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

✨ Features

  • πŸ” Semantic Code Search - Search your codebase using natural language queries
  • πŸ“ Project Management - Index multiple projects with isolated namespaces
  • πŸ”„ Delta Indexing - Only re-index files that have changed, saving time and resources
  • 🎨 Web UI - Easy-to-use interface for managing indexes and testing searches
  • πŸ”§ MCP Integration - Works seamlessly with Claude Code/OpenCode
  • 🐳 Docker Ready - Simple setup with Docker Compose for mongodb (vector store)
  • πŸ¦™ Ollama Support - Local embeddings using Ollama with llama2 model
  • ⚑ Async Job System - Background processing with real-time progress tracking

πŸš€ Quick Start

πŸ“‹ Prerequisites

πŸ’Ώ Installation

  1. Clone the repository:

    git clone <repository-url>
    cd vector-mcp
  2. Start MongoDB:

    yarn run setup
    # or manually: docker-compose up -d
  3. Install and configure Ollama:

    # Install Ollama (macOS)
    brew install ollama
    
    # Start Ollama service
    ollama serve
    
    # Pull the llama2 model
    ollama pull llama2
  4. Install dependencies:

    yarn install
  5. Start the web UI server:

    yarn start

    Visit http://localhost:3000 to access the web interface.

  6. For Claude Code integration, start the MCP server:

    yarn run mcp

πŸ“– Usage

🌐 Web Interface

  1. Open http://localhost:3000
  2. Create a new index by providing:
    • Project ID (unique identifier)
    • Directory path to index
    • Optional exclude patterns
  3. Use the search interface to test queries
  4. Manage existing projects (view stats, delete)

πŸ€– Claude Code Integration

The project includes a pre-configured MCP setup in the dist/ folder.

Option 1: Use the provided configuration (Recommended)

  1. Copy dist/.mcp.json to your Claude Code config directory
  2. Edit dist/mcp.sh to update the absolute path:
    #!/bin/bash
    # Update this path to your actual project location
    cd /path/to/your/vector-mcp
    node mcp-server.js
  3. Make the script executable: chmod +x dist/mcp.sh

Option 2: Manual configuration Add this to your Claude Code configuration:

{
  "mcpServers": {
    "vector-mcp": {
      "command": "node",
      "args": ["mcp-server.js"],
      "cwd": "/path/to/vector-mcp",
      "env": {
        "MONGODB_URI": "mongodb://root:examplepassword@localhost:27017",
        "OLLAMA_HOST": "http://localhost:11434",
        "OLLAMA_MODEL": "llama2"
      }
    }
  }
}

πŸ› οΈ Available MCP Tools

  • search_code - Search through indexed code using semantic similarity
  • index_codebase - Index a new project directory
  • update_project - Update an existing project with delta changes only
  • list_projects - List all indexed projects
  • delete_project - Delete a project and its data
  • get_project_stats - Get detailed project statistics

πŸ”„ Delta Indexing

The project supports intelligent delta indexing that only processes files that have changed since the last index update. This provides significant performance benefits for large codebases.

βš™οΈ How Delta Indexing Works

  1. File Tracking - Each indexed file stores metadata including:

    • File size, modification time, and content hash
    • File path and chunk information
  2. Change Detection - During delta updates:

    • Compares current file hash with stored hash
    • Checks file modification time and size
    • Only processes files that have actually changed
  3. Efficient Updates - Delta indexing will:

    • βœ… Skip unchanged files (fastest)
    • πŸ”„ Update modified files by removing old chunks and adding new ones
    • βž• Add newly created files
    • πŸ—‘οΈ Remove chunks for deleted files

🎯 Using Delta Indexing

Web UI: Click the orange "Update" button next to any project to run a delta update.

MCP Tool: Use the update_project tool with your project ID and directory path.

API: POST to /api/projects/{projectId}/update with directory path and exclude patterns.

πŸ“Š Performance Benefits

  • Large codebases: Instead of re-indexing 1000+ files, typically only 1-10 files change
  • Development workflow: Quick updates during active development
  • CI/CD integration: Efficient incremental indexing in automated pipelines

Example delta update results:

Delta stats: 847 skipped, 3 updated, 1 added, 0 deleted
Files processed: 4/851 files
Time saved: ~95% compared to full re-index

⚑ Asynchronous Job System

All indexing operations now run asynchronously with real-time progress monitoring:

✨ Features

  • Immediate Response: APIs return immediately with a job ID
  • Progress Monitoring: Real-time status updates every 3-5 seconds
  • Job History: View recent and active jobs in the web UI
  • Non-blocking: Browser doesn't freeze during long indexing operations
  • Detailed Logs: Per-job logging and statistics

πŸ”„ API Changes

Before (blocking):

POST /api/projects -> waits for completion, returns final result

After (async):

POST /api/projects -> returns immediately with jobId
GET /api/jobs/{jobId} -> poll for status and progress
GET /api/jobs -> list all jobs

πŸ“Š Job Statuses

  • pending - Job created, waiting to start
  • running - Currently processing files with real-time progress tracking
  • completed - Successfully finished
  • failed - Error occurred during processing

πŸ“ˆ Progress Tracking

Jobs now show data-driven progress percentages:

  • 5-15%: Directory scanning and metadata loading
  • 15-85%: File processing (incremental based on files processed)
  • 85-95%: Database operations and cleanup
  • 95-100%: Final metadata saving and completion

Progress Display:

  • Visual progress bars in job cards
  • Percentage indicators for running jobs
  • File counters: "45/192 files processed"
  • Fallback to status-only if progress unavailable

🎨 Web UI Improvements

  • Real-time Progress: See live updates as files are processed
  • Job Dashboard: Monitor active and recent jobs
  • Auto-refresh: Jobs list updates every 10 seconds
  • Progress Indicators: Visual feedback during operations
  • Live Log Streaming: Real-time logs via Server-Sent Events
  • Modal Forms: Professional UI instead of browser alerts
  • Project Memory: Stores directory paths and settings for easy updates

⏱️ Real-time Features

πŸ“‘ Live Log Streaming

  • File-based Logging: All logs written to server.log file
  • Server-Sent Events: Real-time streaming from actual log file
  • Historical Logs: Shows recent log entries on connection
  • Automatic Connection: Starts streaming immediately on page load
  • Auto-reconnection: Handles connection drops gracefully
  • Persistent Storage: Logs survive server restarts

πŸ’Ύ Project Metadata Storage

  • Path Memory: Directory paths stored in database after first index
  • Settings Persistence: Exclude patterns remembered per project
  • Smart Defaults: Update forms pre-filled with previous settings
  • Backward Compatible: Works with existing projects

πŸ“ Enhanced Forms

  • Modal Interface: Clean, professional forms instead of browser prompts
  • Pre-filled Data: Forms populate with existing project settings
  • Validation: Client-side validation before submission
  • Contextual Help: Helpful placeholders and tips

πŸ”Œ API Enhancements

πŸ†• New Endpoints

  • GET /api/logs/stream - Server-Sent Events for real-time logs
  • GET /api/projects/{id}/metadata - Get stored project settings
  • GET /api/jobs/active - Get only currently running jobs

πŸ—„οΈ Database Schema

Projects now store metadata in project_metadata collection:

{
  "projectId": "my-project",
  "directoryPath": "/path/to/project", 
  "excludePatterns": ["*.log", "node_modules/**"],
  "createdAt": "2025-01-06T...",
  "lastIndexed": "2025-01-06T...",
  "updatedAt": "2025-01-06T..."
}

βš™οΈ Configuration

🌍 Environment Variables

MONGODB_URI=mongodb://root:examplepassword@localhost:27017
OLLAMA_HOST=http://localhost:11434
OLLAMA_MODEL=llama2
PORT=3000

πŸ“ Project Structure

vector-mcp/
β”œβ”€β”€ index.js                    # Express web server + REST API
β”œβ”€β”€ mcp-server.js              # MCP protocol server for Claude
β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ vector-store/
β”‚   β”‚   β”œβ”€β”€ mongovs.js         # MongoDB vector storage
β”‚   β”‚   └── embeddings.js      # Ollama embedding provider
β”‚   β”œβ”€β”€ indexer/
β”‚   β”‚   └── xr.js             # File indexing and chunking
β”‚   β”œβ”€β”€ jobs/
β”‚   β”‚   └── manager.js        # Async job management
β”‚   β”œβ”€β”€ logger/
β”‚   β”‚   └── logger.js         # Structured logging with emojis
β”‚   └── sh/
β”‚       └── setup.sh          # Environment setup script
β”œβ”€β”€ public/
β”‚   └── index.html            # Web UI interface
β”œβ”€β”€ dist/                     # MCP server distribution
└── docker-compose.yml       # MongoDB container setup

🐳 Docker Commands

πŸŽ›οΈ Service Management

# Start all services
docker-compose up -d

# Stop all services  
docker-compose down

# View all service logs
docker-compose logs -f

πŸ” Service Health Checks

# Check service status
docker-compose ps

# Check individual service health
curl http://localhost:3000/health      # Vector MCP
curl http://localhost:11434/api/tags   # Ollama

πŸ’Ύ Data Management

# Backup MongoDB data
docker-compose exec mongodb mongodump --uri="mongodb://root:examplepassword@localhost:27017"

# Clear all data (destructive!)
docker-compose down -v

πŸ“„ License

MIT

About

A minimalist setup for indexing items like codebase etc. which can be hooked up with cli based tools like claude code to harness the power of context and get improved performance from code edits.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages