Environment Variables Configuration

April 2, 2026 Β· View on GitHub

🎯 Global Configuration

Code Context supports a global configuration file at ~/.context/.env to simplify MCP setup across different MCP clients.

Benefits:

  • Configure once, use everywhere
  • No need to specify environment variables in each MCP client
  • Cleaner MCP configurations

πŸ“‹ Environment Variable Priority

  1. Process Environment Variables (highest)
  2. Global Configuration File (~/.context/.env)
  3. Default Values (lowest)

πŸ”§ Required Environment Variables

Embedding Provider

VariableDescriptionDefault
EMBEDDING_PROVIDERProvider: OpenAI, VoyageAI, Gemini, Ollama, DashScopeOpenAI
EMBEDDING_MODELEmbedding model name (works for all providers)Provider-specific default
OPENAI_API_KEYOpenAI API keyRequired for OpenAI
OPENAI_BASE_URLOpenAI API base URL (optional, for custom endpoints)https://api.openai.com/v1
VOYAGEAI_API_KEYVoyageAI API keyRequired for VoyageAI
GEMINI_API_KEYGemini API keyRequired for Gemini
GEMINI_BASE_URLGemini API base URL (optional, for custom endpoints)https://generativelanguage.googleapis.com/v1beta
DASHSCOPE_API_KEYDashScope (ι˜Ώι‡ŒδΊ‘η™Ύη‚Ό) API keyRequired for DashScope
DASHSCOPE_BASE_URLDashScope API base URL (optional)https://dashscope.aliyuncs.com/compatible-mode/v1

πŸ’‘ Note: EMBEDDING_MODEL is a universal environment variable that works with all embedding providers. Simply set it to the model name you want to use (e.g., text-embedding-3-large for OpenAI, voyage-code-3 for VoyageAI, etc.).

Supported Model Names:

  • OpenAI Models: See getSupportedModels in openai-embedding.ts for the full list of supported models.

  • VoyageAI Models: See getSupportedModels in voyageai-embedding.ts for the full list of supported models.

  • Gemini Models: See getSupportedModels in gemini-embedding.ts for the full list of supported models.

  • Ollama Models: Depends on the model you install locally.

  • DashScope Models: See getSupportedModels in dashscope-embedding.ts for the full list of supported models.

πŸ“– For detailed provider-specific configuration examples and setup instructions, see the MCP Configuration Guide.

Vector Database (Hologres)

VariableDescriptionDefault
HOLOGRES_HOSTHologres instance host addressRequired
HOLOGRES_PORTHologres port80
HOLOGRES_DATABASEHologres database nameRequired
HOLOGRES_USERHologres access IDRequired
HOLOGRES_PASSWORDHologres access secretRequired

Ollama (Optional)

VariableDescriptionDefault
OLLAMA_HOSTOllama server URLhttp://127.0.0.1:11434
OLLAMA_MODEL(alternative to EMBEDDING_MODEL)Model name

Advanced Configuration

VariableDescriptionDefault
HYBRID_MODEEnable hybrid search (BM25 + dense vector). Set to false for dense-only searchtrue
EMBEDDING_BATCH_SIZEBatch size for processing. Larger batch size means less indexing time100
SPLITTER_TYPECode splitter type: ast, langchainast
CUSTOM_EXTENSIONSAdditional file extensions to include (comma-separated, e.g., .vue,.svelte,.astro)None
CUSTOM_IGNORE_PATTERNSAdditional ignore patterns (comma-separated, e.g., temp/**,*.backup,private/**)None

πŸš€ Quick Setup

1. Create Global Config

mkdir -p ~/.context
cat > ~/.context/.env << 'EOF'
EMBEDDING_PROVIDER=OpenAI
OPENAI_API_KEY=sk-your-openai-api-key
EMBEDDING_MODEL=text-embedding-3-small
HOLOGRES_HOST=your-hologres-host
HOLOGRES_PORT=80
HOLOGRES_DATABASE=your-database
HOLOGRES_USER=your-access-id
HOLOGRES_PASSWORD=your-access-secret
EOF

See the Example File for more details.

2. Simplified MCP Configuration

Claude Code:

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

Cursor/Windsurf/Others:

{
  "mcpServers": {
    "code-context-hologres": {
      "command": "npx",
      "args": ["-y", "code-context-mcp-hologres@latest"]
    }
  }
}

πŸ“š Additional Information

For detailed information about file processing rules and how custom patterns work, see: