All Products
Search
Document Center

Hologres:Code Context Hologres user guide

Last Updated:Jun 02, 2026

Code Context Hologres is an MCP plugin that gives AI coding assistants semantic code search across your entire codebase. It vectorizes code with DashScope embedding models, stores vectors in Hologres, and retrieves results through BM25 + dense vector hybrid search with reciprocal rank fusion re-ranking.

With Code Context Hologres, you can:

  • Search for relevant code snippets using natural language.

  • Let your AI assistant retrieve relevant code context automatically, without manual file browsing.

  • Scale to codebases with millions of lines and reduce costs by adding only relevant chunks to the AI context.

  • Detect file changes automatically with Merkle-tree-based incremental indexing.

Learn more at the Model Context Protocol specification site.

Overview

Core capabilities:

Capability

Description

Semantic search

Query code using natural language, such as "Find the function that handles user authentication."

Hybrid search

Combines BM25 sparse vectors and dense vectors, then re-ranks results with Reciprocal Rank Fusion to improve accuracy.

Incremental indexing

Detects file changes based on Merkle trees and only re-indexes the modified parts.

AST-aware chunking

Chunks code based on its abstract syntax tree (AST) to preserve its semantic structure.

Scalable storage

Supports codebases with millions of lines of code, powered by the Hologres vector database.

Background indexing

Asynchronous indexing does not interfere with code search operations.

Supported AI coding assistants: Qwen Code, Claude Code, and other MCP-compatible clients such as Cursor, VS Code, and Windsurf.

Supported programming languages: TypeScript, JavaScript, Python, Java, C++, C#, Go, Rust, PHP, Ruby, Swift, Kotlin, Scala, and Markdown.

Supported embedding model providers: DashScope (Alibaba Cloud Model Studio), OpenAI, VoyageAI, Google Gemini, and Ollama (local). All examples in this guide use DashScope models.

Prerequisites

Environment requirements

Item

Requirement

Node.js

20.x or 22.x

Package manager

npm (recommended) or pnpm

Operating system

macOS, Linux, or Windows

Note

Only Node.js 20.x and 22.x are supported. Other versions (21.x, 23.x, 24.x) are not compatible.

DashScope and Bailian configuration

You need a DashScope API Key to use the embedding models.

  1. Sign up for an Alibaba Cloud account.

  2. Activate the Model Studio (Bailian) service.

  3. Create an API Key in the Model Studio (Bailian) console. The key starts with sk-.

Available DashScope embedding models:

Model name

Vector dimension

Description

Batch size limit

text-embedding-v4

1024

Latest recommended model

10

text-embedding-v3

1024

Supports multiple dimensions (1024, 768, or 512)

25

text-embedding-v2

1536

Legacy model

25

text-embedding-v1

1536

Legacy model

25

Note

Use text-embedding-v4 for best results. EMBEDDING_BATCH_SIZE for this model must not exceed 10.

Hologres instance configuration

Prepare the following Hologres connection details:

Item

Description

Example

Endpoint

The connection endpoint for your Hologres instance.

hgpostcn-cn-xxx.hologres.aliyuncs.com

Port

The connection port.

80 (default)

Database name

The name of the database you created.

mydb

AccessKey ID

Your Alibaba Cloud AccessKey ID.

Obtain it from AccessKey Management.

AccessKey Secret

Your Alibaba Cloud AccessKey Secret.

Same as above.

Note

Your Hologres instance must be V4.0 or later.

AI coding assistant installation

Install the AI coding assistant you plan to use:

Installation

No manual installation is required. The latest version downloads automatically through npx.

On first run, npx code-context-mcp-hologres@latest downloads and executes the package from npm.

Verify the tool is available:

npx code-context-mcp-hologres@latest --help

This displays all supported environment variables and configuration options.

Credential configuration

Claude Code configuration

CLI method

Run the following command to register Code Context Hologres as an MCP server:

claude mcp add code-context-hologres \
    -e EMBEDDING_PROVIDER=DashScope \
    -e DASHSCOPE_API_KEY=sk-your-dashscope-api-key \
    -e EMBEDDING_MODEL=text-embedding-v4 \
    -e EMBEDDING_BATCH_SIZE=10 \
    -e HOLOGRES_HOST=your-hologres-instance.hologres.aliyuncs.com \
    -e HOLOGRES_PORT=80 \
    -e HOLOGRES_DATABASE=your-database-name \
    -e HOLOGRES_USER=your-access-id \
    -e HOLOGRES_PASSWORD=your-access-secret \
  -- npx code-context-mcp-hologres@latest

Replace the following placeholders with your actual values:

Placeholder

Replace with

sk-your-dashscope-api-key

Your DashScope API key from Model Studio (Bailian).

your-hologres-instance.hologres.aliyuncs.com

Your Hologres instance endpoint.

your-database-name

Your Hologres database name.

your-access-id

Your AccessKey ID.

your-access-secret

Your AccessKey Secret.

JSON file configuration

You can also configure the MCP server by editing the Claude Code configuration file directly.

Create or edit the ~/.claude.json file and add the following content:

{
  "mcpServers": {
    "code-context-hologres": {
      "command": "npx",
      "args": ["-y", "code-context-mcp-hologres@latest"],
      "env": {
        "EMBEDDING_PROVIDER": "DashScope",
        "DASHSCOPE_API_KEY": "sk-your-dashscope-api-key",
        "EMBEDDING_MODEL": "text-embedding-v4",
        "EMBEDDING_BATCH_SIZE": "10",
        "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"
      }
    }
  }
}

Verification

Confirm the MCP server is registered:

claude mcp list

The output should list code-context-hologres.

Qwen Code configuration

CLI method

Run the following command:

qwen mcp add \
    -t stdio \
    -e EMBEDDING_PROVIDER=DashScope \
    -e DASHSCOPE_API_KEY=sk-your-dashscope-api-key \
    -e EMBEDDING_MODEL=text-embedding-v4 \
    -e EMBEDDING_BATCH_SIZE=10 \
    -e HOLOGRES_HOST=your-hologres-instance.hologres.aliyuncs.com \
    -e HOLOGRES_PORT=80 \
    -e HOLOGRES_DATABASE=your-database-name \
    -e HOLOGRES_USER=your-access-id \
    -e HOLOGRES_PASSWORD=your-access-secret \
    code-context-hologres \
    npx -y code-context-mcp-hologres@latest

JSON file configuration

Create or edit the ~/.qwen/settings.json file and add the following content:

{
  "mcpServers": {
    "code-context-hologres": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "code-context-mcp-hologres@latest"],
      "env": {
        "EMBEDDING_PROVIDER": "DashScope",
        "DASHSCOPE_API_KEY": "sk-your-dashscope-api-key",
        "EMBEDDING_MODEL": "text-embedding-v4",
        "EMBEDDING_BATCH_SIZE": "10",
        "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"
      }
    }
  }
}

Verification

Confirm that code-context-hologres appears in your Qwen Code MCP server list.

Global configuration file

To share credentials across multiple MCP clients, store them in a single global configuration file instead of setting environment variables per client.

Create a ~/.context/.env file with the following content:

# DashScope embedding model configuration
EMBEDDING_PROVIDER=DashScope
DASHSCOPE_API_KEY=sk-your-dashscope-api-key
EMBEDDING_MODEL=text-embedding-v4
EMBEDDING_BATCH_SIZE=10

# Hologres database configuration
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

With the global configuration in place, the MCP registration command simplifies to:

Claude Code:

claude mcp add code-context-hologres -- npx code-context-mcp-hologres@latest

Qwen Code:

qwen mcp add \
    -t stdio \
    code-context-hologres \
    npx -y code-context-mcp-hologres@latest
Note

Environment variable priority: 1. Process environment variables (set with -e). 2. ~/.context/.env file. 3. Default values.

Environment variables

DashScope embedding model configuration

Variable

Required

Default

Description

EMBEDDING_PROVIDER

No

OpenAI

The embedding model provider. Set this to DashScope.

DASHSCOPE_API_KEY

Yes (if using DashScope)

None

Your DashScope API key from Model Studio (Bailian).

EMBEDDING_MODEL

No

text-embedding-v4

The name of the embedding model.

EMBEDDING_BATCH_SIZE

No

10

The embedding batch size. For text-embedding-v4, we recommend setting this to 10.

DASHSCOPE_BASE_URL

No

https://dashscope.aliyuncs.com/compatible-mode/v1

The DashScope API endpoint. You usually do not need to change this.

Hologres database configuration

Variable

Required

Default

Description

HOLOGRES_HOST

Yes

None

The Hologres instance endpoint.

HOLOGRES_PORT

No

80

The connection port.

HOLOGRES_DATABASE

Yes

None

The database name.

HOLOGRES_USER

Yes

None

Your AccessKey ID.

HOLOGRES_PASSWORD

Yes

None

Your AccessKey Secret.

Advanced configuration

Variable

Required

Default

Description

HYBRID_MODE

No

true

Enables hybrid search (BM25 + dense vector).

CUSTOM_EXTENSIONS

No

None

Additional file extensions, separated by commas. For example, .vue,.svelte.

CUSTOM_IGNORE_PATTERNS

No

None

Additional ignore patterns, separated by commas. For example, *.test.ts,__mocks__.

Usage

Basic workflow

  1. Open your AI coding assistant (Qwen Code or Claude Code) in your project's directory.

  2. Ask the AI to index your codebase.

  3. Check the indexing status and wait for it to complete.

  4. Search your code using natural language.

Codebase indexing

Indexing splits project files into chunks, generates vector embeddings, and stores them in Hologres. The process runs asynchronously in the background.

Ask the AI in natural language:

> Index this codebase

The AI calls the index_codebase tool with the following parameters:

Parameter

Required

Default

Description

path

Yes

None

Absolute path to the codebase. The AI uses the current working directory by default.

force

No

false

Whether to force re-indexing.

splitter

No

ast

The code splitter: ast (AST-aware) or langchain (character-based).

customExtensions

No

None

A list of additional file extensions, such as [".vue", ".svelte"].

ignorePatterns

No

None

A list of additional ignore patterns.

Example: Include additional file types during indexing.

> Index this codebase, and include .vue and .svelte files

Example: Force re-indexing.

> Force re-indexing of the current codebase

Indexing status

Check indexing progress at any time. The AI calls the get_indexing_status tool.

> Check indexing status

Possible statuses:

Status

Description

indexed

Indexing complete. Shows the number of indexed files and chunks.

indexing

Indexing in progress. Shows percentage complete.

indexfailed

Indexing failed. Shows an error message. Re-run the indexing command to retry.

not_found

Not indexed yet. Run the index command first.

Clear the index

To clear the index data for a codebase (for example, after switching embedding models):

> Clear the index for the current codebase

The AI calls clear_index to delete the index data from Hologres.

Example (Claude Code)

$ cd /path/to/your-project
$ claude

> Index this codebase
code-context-hologres: Started background indexing for codebase '/path/to/your-project'
using AST splitter. Indexing is running in the background.

> Check indexing status
code-context-hologres: Codebase '/path/to/your-project' is currently being indexed.
Progress: 45.2% (Processing files and generating embeddings...)

> Check indexing status
code-context-hologres: Codebase '/path/to/your-project' is fully indexed and ready
for search. Statistics: 128 files, 1,536 chunks.

> Find the function that handles user login authentication
code-context-hologres: Found 5 results for query "user login authentication":
1. Code snippet (TypeScript) [your-project]
   Location: src/auth/login.ts:15-42
   ...

Example (Qwen Code)

$ cd /path/to/your-project
$ qwen

> Index this codebase
code-context-hologres: Started background indexing for codebase '/path/to/your-project'
using AST splitter. Indexing is running in the background.

> Check indexing status
code-context-hologres: Codebase '/path/to/your-project' is fully indexed and ready
for search. Statistics: 128 files, 1,536 chunks.

> Find the function that handles user login authentication
code-context-hologres: Found 5 results for query "user login authentication":
1. Code snippet (TypeScript) [your-project]
   Location: src/auth/login.ts:15-42
   ...

Advanced configuration

Switching models

Switch embedding models by changing the EMBEDDING_MODEL environment variable.

For example, to use the text-embedding-v3 model:

# Modify in the MCP registration command
-e EMBEDDING_MODEL=text-embedding-v3

Or modify it in ~/.context/.env:

EMBEDDING_MODEL=text-embedding-v3
Important

Models have different vector dimensions (text-embedding-v4: 1024, text-embedding-v2: 1536). After switching models, clear the index and re-index.

Custom file extensions

By default, common programming language files are indexed. To include additional file types (.vue, .svelte, .astro):

Method 1: Set the CUSTOM_EXTENSIONS environment variable.

CUSTOM_EXTENSIONS=.vue,.svelte,.astro

Method 2: Specify during indexing in natural language.

> Index this codebase and include .vue and .svelte files

Custom ignore patterns

Code Context Hologres reads .gitignore, .contextignore (project-level), and ~/.context/.contextignore (global). Add extra ignore rules as follows:

Method 1: Use the CUSTOM_IGNORE_PATTERNS environment variable.

CUSTOM_IGNORE_PATTERNS=*.test.ts,__mocks__,*.generated.ts

Method 2: Specify during indexing in natural language.

> Index this codebase, ignoring the .test.ts and __mocks__ directories

Code splitters

Two code splitters are available:

Splitter

Description

Use case

ast (default)

Semantic chunking based on the AST, which preserves code structure.

Recommended. Produces higher-quality chunks.

langchain

Chunking based on character count.

A fallback option if the AST splitter is not available.

The system uses ast by default and falls back automatically if needed. Manual selection is rarely necessary.

FAQ

Q1: Indexing fails with "DASHSCOPE_API_KEY is not configured"

Check:

  1. -e DASHSCOPE_API_KEY=sk-xxx is set in the MCP registration command.

  2. ~/.context/.env exists and contains DASHSCOPE_API_KEY.

  3. The key starts with sk-.

Q2: How do I troubleshoot a failed indexing job?

  1. Use "Check indexing status" to view the error message.

  2. Common causes: Hologres connection failure (verify HOLOGRES_HOST, HOLOGRES_USER, HOLOGRES_PASSWORD), invalid DashScope API key, or insufficient balance.

  3. Re-run the indexing command to retry without manual cleanup.

Q3: Does it support multiple projects or codebases?

Yes. The system detects the current working directory automatically and maintains a separate index per codebase. A background sync runs every five minutes to detect changes and perform incremental updates.

Q4: How do I force re-indexing?

Tell the AI "force re-indexing of the current codebase," or pass force=true when indexing.

Q5: What should I do if I encounter the DashScope API rate limit?

text-embedding-v4 has a batch size limit of 10. If rate-limited on large codebases, reduce EMBEDDING_BATCH_SIZE.

Q6: How do I reconnect to the MCP server in Claude Code?

If the MCP server disconnects or its configuration changes, reconnect:

/mcp reconnect code-context-hologres

Q7: How do I switch to a different embedding model provider?

Modify EMBEDDING_PROVIDER. Example for Ollama (local):

EMBEDDING_PROVIDER=Ollama
OLLAMA_HOST=http://127.0.0.1:11434
OLLAMA_MODEL=nomic-embed-text

After switching providers, clear the index and re-index.

Q8: What is the maximum number of chunks that can be indexed?

450,000 chunks per codebase. Indexing stops automatically at this limit and a notification is shown.

Important notes

  1. Node.js version: Only 20.x and 22.x are supported. Versions 21.x, 23.x, and 24.x are not compatible.

  2. API key security: Never hard-code API keys in your codebase. Use ~/.context/.env or your MCP client's environment variable mechanism.

  3. Data security: Vectors are stored in your own Hologres instance under your Alibaba Cloud account. Code Context Hologres does not store or transmit your code content.

  4. Model switching: Clear the index and re-index after changing embedding models, as vector dimensions may differ.

  5. Version updates: After updating the MCP server, reconnect. In Claude Code, run /mcp reconnect code-context-hologres; in Qwen Code, restart the server.

  6. Initial indexing time: First-time indexing of large codebases may take significant time depending on codebase size and API response speed. Indexing runs in the background, and you can search during this time (results may be incomplete).

Related resources