rag-code-mcp

VS Code + GitHub Copilot Integration Guide

This guide explains how to integrate RagCode MCP with Visual Studio Code and GitHub Copilot to enable semantic code search capabilities in Copilot’s agent mode.


Overview

RagCode integrates with GitHub Copilot through the Model Context Protocol (MCP), which is a standardized way for AI models to interact with external tools and services. When configured, Copilot can automatically use RagCode’s semantic search tools as part of its autonomous coding workflow.

Key Benefits


Prerequisites

Before setting up RagCode with VS Code + Copilot, ensure you have:

  1. VS Code version 1.95 or higher
    • Check version: Help → About
    • Update if needed: Help → Check for Updates
  2. GitHub Copilot Subscription
    • Individual, Business, or Enterprise plan
    • Copilot extension installed and activated
  3. RagCode Installed
    • Run ragcode-installer from the latest GitHub release (recommended)
    • Or build from source with go run ./cmd/install
  4. Required Services Running
    • Docker (for Qdrant vector database)
    • Ollama (for AI models)

Installation

ragcode-installer automatically configures VS Code and creates the MCP entry:

# Linux (amd64) - ONE COMMAND
curl -fsSL https://github.com/doITmagic/rag-code-mcp/releases/latest/download/rag-code-mcp_linux_amd64.tar.gz | tar xz && ./ragcode-installer -ollama=docker -qdrant=docker

This creates the MCP configuration file at:

~/.config/Code/User/globalStorage/mcp-servers.json

Manual Setup

If you need to configure manually or customize the setup:

  1. Create the MCP configuration directory:
    mkdir -p ~/.config/Code/User/globalStorage
    
  2. Create or edit mcp-servers.json:
    nano ~/.config/Code/User/globalStorage/mcp-servers.json
    
  3. Add the RagCode configuration:
    {
      "mcpServers": {
        "ragcode": {
          "command": "/home/YOUR_USERNAME/.local/share/ragcode/bin/rag-code-mcp",
          "args": [],
          "env": {
            "OLLAMA_BASE_URL": "http://localhost:11434",
            "OLLAMA_MODEL": "phi3:medium",
            "OLLAMA_EMBED": "mxbai-embed-large",
            "QDRANT_URL": "http://localhost:6333"
          }
        }
      }
    }
    

    Important: Replace YOUR_USERNAME with your actual Linux username.

  4. Restart VS Code to load the new configuration.

Windows Setup

On Windows, the MCP configuration file is located at:

%APPDATA%\Code\User\mcp.json

Example configuration:

{
  "servers": {
    "ragcode": {
      "command": "C:\\Users\\YOUR_USERNAME\\.local\\share\\ragcode\\bin\\rag-code-mcp.exe",
      "args": [],
      "env": {
        "OLLAMA_BASE_URL": "http://localhost:11434",
        "OLLAMA_MODEL": "phi3:medium",
        "OLLAMA_EMBED": "mxbai-embed-large",
        "QDRANT_URL": "http://localhost:6333"
      }
    }
  }
}

Windows with WSL Setup

If you installed RagCode in WSL but use VS Code on Windows:

{
  "servers": {
    "ragcode": {
      "command": "wsl.exe",
      "args": ["-e", "/home/YOUR_USERNAME/.local/share/ragcode/bin/rag-code-mcp"],
      "env": {
        "OLLAMA_BASE_URL": "http://localhost:11434",
        "OLLAMA_MODEL": "phi3:medium",
        "OLLAMA_EMBED": "mxbai-embed-large",
        "QDRANT_URL": "http://localhost:6333"
      }
    }
  }
}

💡 The localhost URLs work because WSL2 shares network ports with Windows.


Verification

Check MCP Server Status

  1. Open Command Palette (Ctrl+Shift+P / Cmd+Shift+P)
  2. Type: MCP: Show MCP Servers
  3. Verify that ragcode appears in the list
  4. Status should show “Connected”

Check Available Tools

In the MCP Servers view, expand the ragcode server to see available tools:


Usage

Enabling Agent Mode

RagCode tools work with GitHub Copilot’s Agent Mode:

  1. Open Copilot Chat (Ctrl+Shift+I / Cmd+Shift+I)
  2. Click the “Agent” button in the chat interface
    • Or type /agent in the chat
  3. Agent mode is now active (indicated by an icon/badge)

Asking Questions

Once in agent mode, Copilot will automatically use RagCode tools when appropriate:

Example Prompts:

Find all authentication middleware functions in this codebase
Show me the User model definition and all its methods
Search for functions that handle database connections
What are all the API endpoints related to user management?
Find where the ProcessPayment function is called

Explicit Tool Invocation

You can explicitly reference RagCode tools using the # symbol:

#ragcode search for payment processing functions
#ragcode find the UserController type definition
#ragcode list all exports from the auth package

Example Workflow

  1. Open your project in VS Code
    cd ~/projects/my-app
    code .
    
  2. Index the workspace (first time only)
    • Open Copilot Chat
    • Ask: “Please index this workspace using RagCode”
    • Wait for confirmation (1-5 minutes depending on project size)
  3. Start asking questions
    • “Find all HTTP handlers in this project”
    • “Show me the database schema models”
    • “Where is the authentication logic implemented?”

Configuration Options

Custom Ollama Models

Edit the MCP configuration to use different models:

{
  "mcpServers": {
    "ragcode": {
      "command": "/home/YOUR_USERNAME/.local/share/ragcode/bin/rag-code-mcp",
      "args": [],
      "env": {
        "OLLAMA_BASE_URL": "http://localhost:11434",
        "OLLAMA_MODEL": "phi3:medium",          //  Changed
        "OLLAMA_EMBED": "all-minilm",           //  Changed
        "QDRANT_URL": "http://localhost:6333"
      }
    }
  }
}

Recommended Models:

Remote Ollama/Qdrant

If running Ollama or Qdrant on a different machine:

{
  "mcpServers": {
    "ragcode": {
      "command": "/home/YOUR_USERNAME/.local/share/ragcode/bin/rag-code-mcp",
      "args": [],
      "env": {
        "OLLAMA_BASE_URL": "http://192.168.1.100:11434",  //  Remote Ollama
        "OLLAMA_MODEL": "phi3:medium",
        "OLLAMA_EMBED": "mxbai-embed-large",
        "QDRANT_URL": "http://192.168.1.101:6333"         //  Remote Qdrant
      }
    }
  }
}

Logging and Debugging

Enable detailed logging for troubleshooting:

{
  "mcpServers": {
    "ragcode": {
      "command": "/home/YOUR_USERNAME/.local/share/ragcode/bin/rag-code-mcp",
      "args": [],
      "env": {
        "OLLAMA_BASE_URL": "http://localhost:11434",
        "OLLAMA_MODEL": "phi3:medium",
        "OLLAMA_EMBED": "mxbai-embed-large",
        "QDRANT_URL": "http://localhost:6333",
        "MCP_LOG_LEVEL": "debug",                         //  Enable debug logs
        "MCP_LOG_FILE": "/tmp/ragcode-mcp.log"           //  Log file path
      }
    }
  }
}

View logs:

tail -f /tmp/ragcode-mcp.log

Troubleshooting

MCP Server Not Showing

Problem: RagCode doesn’t appear in the MCP Servers list.

Solutions:

  1. Verify config file exists:
    cat ~/.config/Code/User/globalStorage/mcp-servers.json
    
  2. Check VS Code version (must be 1.95+):
    • Help → About
  3. Restart VS Code completely:
    • Close all windows
    • Reopen VS Code
  4. Check for JSON syntax errors in config file

Connection Failed

Problem: MCP server shows “Disconnected” or “Error” status.

Solutions:

  1. Verify binary exists and is executable:
    ls -la ~/.local/share/ragcode/bin/rag-code-mcp
    chmod +x ~/.local/share/ragcode/bin/rag-code-mcp
    
  2. Check Qdrant is running:
    docker ps | grep ragcode-qdrant || docker start ragcode-qdrant
    
  3. Check Ollama is running:
    ollama list
    

    If not running:

    ollama serve
    
  4. Test RagCode manually:
    ~/.local/share/ragcode/bin/rag-code-mcp --version
    

Tools Not Working

Problem: Copilot doesn’t use RagCode tools or tools fail.

Solutions:

  1. Ensure you’re in Agent Mode:
    • Look for the “Agent” indicator in Copilot Chat
    • Click “Agent” button or type /agent
  2. Index your workspace first:
    • Ask Copilot: “Please index this workspace using RagCode”
    • Wait for confirmation
  3. Check MCP logs:
    # Add logging to config (see Configuration Options above)
    tail -f /tmp/ragcode-mcp.log
    
  4. Verify services are running:
    docker ps | grep qdrant
    ollama list
    
  5. Try explicit tool invocation:
    #ragcode search for authentication functions
    

Workspace Not Indexed

Problem: Error message “Workspace ‘/path’ is not indexed yet”

Solutions:

  1. Index the workspace:
    • In Copilot Chat: “Please index this workspace using RagCode”
    • Or manually: Ask Copilot to call index_workspace with a file path from your project
  2. Verify file_path is correct:
    • Tools require a file_path parameter from your project
    • Copilot should automatically provide this
  3. Check indexing status:
    • Indexing runs in background
    • Wait 1-5 minutes for large projects
    • You can start searching immediately (results improve as indexing progresses)

Slow Performance

Problem: RagCode tools are slow to respond.

Solutions:

  1. Use a smaller/faster model:
    "OLLAMA_MODEL": "phi3:mini"  // Instead of phi3:medium
    
  2. Exclude large directories: Edit ~/.local/share/ragcode/config.yaml:
    workspace:
      exclude_patterns:
        - "node_modules"
        - "vendor"
        - "dist"
        - "build"
        - ".git"
    
  3. Check system resources:
    • Ollama requires significant RAM (8GB+ recommended)
    • Consider using GPU acceleration if available

Advanced Features

Multi-Workspace Support

RagCode automatically handles multiple projects:

  1. Each project gets its own Qdrant collection
  2. Collections are named: ragcode-{workspace-id}-{language}
  3. RagCode auto-detects workspace from file paths
  4. No manual switching needed

Example:

# Project 1
cd ~/projects/backend-api
code .
# Ask Copilot to index → creates ragcode-abc123-go

# Project 2
cd ~/projects/frontend-app
code .
# Ask Copilot to index → creates ragcode-def456-javascript

Language-Specific Collections

RagCode creates separate collections per language:

This improves search accuracy and performance.

Custom Instructions

You can create .github/copilot-instructions.md in your project to guide Copilot’s use of RagCode:

# Copilot Instructions

When searching for code:
- Always use RagCode semantic search first
- Prefer `hybrid_search` for finding specific function names
- Use `get_function_details` to understand implementation details
- Index the workspace on first use

Comparison with Other IDEs

Feature VS Code + Copilot Windsurf/Cursor Antigravity
MCP Support ✅ Agent Mode ✅ Native ✅ Native
Auto Tool Selection
Explicit Tool Invocation ✅ (#ragcode)
Configuration JSON file JSON file JSON file
Setup Complexity Medium Easy Easy

VS Code Advantages:

Considerations:


Resources


Support

If you encounter issues:

  1. Check the troubleshooting section above
  2. Review MCP logs (enable debug logging)
  3. Open an issue: https://github.com/doITmagic/rag-code-mcp/issues
  4. Include:
    • VS Code version
    • RagCode version
    • Error messages
    • MCP configuration
    • Log excerpts

Happy coding with RagCode + VS Code + Copilot! 🚀