Skip to content

Latest commit

 

History

History
265 lines (185 loc) · 7.74 KB

File metadata and controls

265 lines (185 loc) · 7.74 KB

code-context-mcp-hologres

Model Context Protocol (MCP) integration for Code Context - A powerful MCP server that enables AI assistants and agents to index and search codebases using semantic search.

npm version npm downloads

Check out the main project README for an overview and setup instructions.

🚀 Use Code Context as MCP in Claude Code and others

Model Context Protocol (MCP) allows you to integrate Code Context with your favorite AI coding assistants, e.g. Claude Code.

Quick Start

Prerequisites

Before using the MCP server, make sure you have:

  • API key for your chosen embedding provider (OpenAI, VoyageAI, Gemini, Ollama, or DashScope setup)
  • Hologres vector database instance

💡 Setup Help: See the main project setup guide for detailed installation instructions.

Prepare Environment Variables

Embedding Provider Configuration

Code Context MCP supports multiple embedding providers. Choose the one that best fits your needs:

📋 Quick Reference: For a complete list of environment variables and their descriptions, see the Environment Variables Guide.

# Supported providers: OpenAI, VoyageAI, Gemini, Ollama, DashScope
EMBEDDING_PROVIDER=OpenAI
1. OpenAI Configuration (Default)
OPENAI_API_KEY=sk-your-openai-api-key
EMBEDDING_MODEL=text-embedding-3-small
OPENAI_BASE_URL=https://api.openai.com/v1

Available Models: See getSupportedModels in openai-embedding.ts for the full list.

2. VoyageAI Configuration
VOYAGEAI_API_KEY=pa-your-voyageai-api-key
EMBEDDING_MODEL=voyage-code-3
3. Gemini Configuration
GEMINI_API_KEY=your-gemini-api-key
EMBEDDING_MODEL=gemini-embedding-001
4. Ollama Configuration (Local/Self-hosted)
EMBEDDING_MODEL=nomic-embed-text
OLLAMA_HOST=http://127.0.0.1:11434
5. DashScope Configuration (阿里云百炼)
DASHSCOPE_API_KEY=sk-your-dashscope-api-key
EMBEDDING_MODEL=text-embedding-v4

Available Models: See getSupportedModels in dashscope-embedding.ts for the full list.

Hologres Vector Database Configuration

Configure your Hologres connection:

HOLOGRES_HOST=your-hologres-instance.hologres.aliyuncs.com
HOLOGRES_PORT=80
HOLOGRES_DATABASE=your-database-name
HOLOGRES_USER=your-access-id
HOLOGRES_PASSWORD=your-access-secret

Embedding Batch Size

EMBEDDING_BATCH_SIZE=512

Custom File Processing (Optional)

CUSTOM_EXTENSIONS=.vue,.svelte,.astro,.twig
CUSTOM_IGNORE_PATTERNS=temp/**,*.backup,private/**,uploads/**

Usage with MCP Clients

Claude Code
claude mcp add code-context-hologres -e OPENAI_API_KEY=your-openai-api-key -e HOLOGRES_HOST=your-hologres-host -e HOLOGRES_PORT=80 -e HOLOGRES_DATABASE=your-database-name -e HOLOGRES_USER=your-access-id -e HOLOGRES_PASSWORD=your-hologres-password -- npx code-context-mcp-hologres@latest
Cursor / Windsurf / VS Code / Claude Desktop / Gemini CLI / Qwen Code / Void / Cline / Roo Code / Cherry Studio
{
  "mcpServers": {
    "code-context-hologres": {
      "command": "npx",
      "args": ["-y", "code-context-mcp-hologres@latest"],
      "env": {
        "OPENAI_API_KEY": "your-openai-api-key",
        "HOLOGRES_HOST": "your-hologres-host",
        "HOLOGRES_PORT": "80",
        "HOLOGRES_DATABASE": "your-database-name",
        "HOLOGRES_USER": "your-access-id",
        "HOLOGRES_PASSWORD": "your-hologres-password"
      }
    }
  }
}
OpenAI Codex CLI
[mcp_servers.code-context-hologres]
command = "npx"
args = ["code-context-mcp-hologres@latest"]
env = { "OPENAI_API_KEY" = "your-openai-api-key", "HOLOGRES_HOST" = "your-hologres-host", "HOLOGRES_PORT" = "80", "HOLOGRES_DATABASE" = "your-database-name", "HOLOGRES_USER" = "your-access-id", "HOLOGRES_PASSWORD" = "your-hologres-password" }
startup_timeout_ms = 20000
Augment
"augment.advanced": { 
  "mcpServers": [ 
    { 
      "name": "code-context-hologres", 
      "command": "npx", 
      "args": ["-y", "code-context-mcp-hologres@latest"] 
    } 
  ] 
}
LangChain/LangGraph

For LangChain/LangGraph integration examples, see this example.

Other MCP Clients
npx code-context-mcp-hologres@latest

Features

  • 🔌 MCP Protocol Compliance: Full compatibility with MCP-enabled AI assistants and agents
  • 🔍 Hybrid Code Search: Natural language queries using advanced hybrid search (BM25 + dense vector)
  • 📁 Codebase Indexing: Index entire codebases for fast hybrid search
  • 🔄 Incremental Indexing: Efficiently re-index only changed files using Merkle trees
  • 🧩 Intelligent Code Chunking: AST-based code analysis for syntax-aware chunking
  • 🗄️ Scalable: Integrates with Hologres for scalable vector search
  • 🛠️ Customizable: Configure file extensions, ignore patterns, and embedding models
  • Real-time: Interactive indexing and searching with progress feedback

Available Tools

1. index_codebase

Index a codebase directory for hybrid search (BM25 + dense vector).

Parameters:

  • path (required): Absolute path to the codebase directory to index
  • force (optional): Force re-indexing (default: false)
  • splitter (optional): Code splitter - 'ast' or 'langchain' (default: "ast")
  • customExtensions (optional): Additional file extensions (default: [])
  • ignorePatterns (optional): Additional ignore patterns (default: [])

2. search_code

Search the indexed codebase using natural language queries.

Parameters:

  • path (required): Absolute path to the codebase directory
  • query (required): Natural language query
  • limit (optional): Maximum results (default: 10, max: 50)
  • extensionFilter (optional): File extension filter (default: [])

3. clear_index

Clear the search index for a specific codebase.

Parameters:

  • path (required): Absolute path to the codebase directory

4. get_indexing_status

Get the current indexing status of a codebase.

Parameters:

  • path (required): Absolute path to the codebase directory

Contributing

This package is part of the Code Context monorepo. Please see:

Related Projects

License

MIT - See LICENSE for details