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 |
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.
-
Sign up for an Alibaba Cloud account.
-
Activate the Model Studio (Bailian) service.
-
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 |
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. |
|
|
Port |
The connection port. |
|
|
Database name |
The name of the database you created. |
|
|
AccessKey ID |
Your Alibaba Cloud AccessKey ID. |
Obtain it from AccessKey Management. |
|
AccessKey Secret |
Your Alibaba Cloud AccessKey Secret. |
Same as above. |
Your Hologres instance must be V4.0 or later.
AI coding assistant installation
Install the AI coding assistant you plan to use:
-
Qwen Code: Install from the official Qwen Code documentation.
-
Claude Code: Install from the Claude Code documentation.
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 |
|
|
Your DashScope API key from Model Studio (Bailian). |
|
|
Your Hologres instance endpoint. |
|
|
Your Hologres database name. |
|
|
Your AccessKey ID. |
|
|
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
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 |
|
|
No |
|
The embedding model provider. Set this to |
|
|
Yes (if using DashScope) |
None |
Your DashScope API key from Model Studio (Bailian). |
|
|
No |
|
The name of the embedding model. |
|
|
No |
|
The embedding batch size. For |
|
|
No |
|
The DashScope API endpoint. You usually do not need to change this. |
Hologres database configuration
|
Variable |
Required |
Default |
Description |
|
|
Yes |
None |
The Hologres instance endpoint. |
|
|
No |
|
The connection port. |
|
|
Yes |
None |
The database name. |
|
|
Yes |
None |
Your AccessKey ID. |
|
|
Yes |
None |
Your AccessKey Secret. |
Advanced configuration
|
Variable |
Required |
Default |
Description |
|
|
No |
|
Enables hybrid search (BM25 + dense vector). |
|
|
No |
None |
Additional file extensions, separated by commas. For example, |
|
|
No |
None |
Additional ignore patterns, separated by commas. For example, |
Usage
Basic workflow
-
Open your AI coding assistant (Qwen Code or Claude Code) in your project's directory.
-
Ask the AI to index your codebase.
-
Check the indexing status and wait for it to complete.
-
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 |
|
|
Yes |
None |
Absolute path to the codebase. The AI uses the current working directory by default. |
|
|
No |
|
Whether to force re-indexing. |
|
|
No |
|
The code splitter: |
|
|
No |
None |
A list of additional file extensions, such as |
|
|
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 |
|
|
Indexing complete. Shows the number of indexed files and chunks. |
|
|
Indexing in progress. Shows percentage complete. |
|
|
Indexing failed. Shows an error message. Re-run the indexing command to retry. |
|
|
Not indexed yet. Run the index command first. |
Code search
Search your indexed codebase with natural language. The AI calls the search_code tool.
> Find the function that handles user authentication
search_code parameters:
|
Parameter |
Required |
Default |
Description |
|
|
Yes |
None |
Absolute path to the codebase. Auto-detected by the AI. |
|
|
Yes |
None |
The natural language query. |
|
|
No |
|
The number of results to return (maximum 50). |
|
|
No |
None |
Filter by file extension, such as |
More search examples:
> Find all code related to database connections> Search for error handling logic, but only in .py files> Find code snippets related to the payment process> Search for the implementation code of Hologres vector retrieval
You can search during indexing, but results may be incomplete until indexing finishes.
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
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 |
|
|
Semantic chunking based on the AST, which preserves code structure. |
Recommended. Produces higher-quality chunks. |
|
|
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.
Hybrid search configuration
Hybrid search (BM25 + dense vector) is enabled by default. To disable it and use only dense vectors:
HYBRID_MODE=false
Keep hybrid search enabled (default) for best results.
FAQ
Q1: Indexing fails with "DASHSCOPE_API_KEY is not configured"
Check:
-
-e DASHSCOPE_API_KEY=sk-xxxis set in the MCP registration command. -
~/.context/.envexists and containsDASHSCOPE_API_KEY. -
The key starts with
sk-.
Q2: How do I troubleshoot a failed indexing job?
-
Use "Check indexing status" to view the error message.
-
Common causes: Hologres connection failure (verify
HOLOGRES_HOST,HOLOGRES_USER,HOLOGRES_PASSWORD), invalid DashScope API key, or insufficient balance. -
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
-
Node.js version: Only 20.x and 22.x are supported. Versions 21.x, 23.x, and 24.x are not compatible.
-
API key security: Never hard-code API keys in your codebase. Use
~/.context/.envor your MCP client's environment variable mechanism. -
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.
-
Model switching: Clear the index and re-index after changing embedding models, as vector dimensions may differ.
-
Version updates: After updating the MCP server, reconnect. In Claude Code, run
/mcp reconnect code-context-hologres; in Qwen Code, restart the server. -
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).