Add custom gemini baseurl support (#183)

* Add Gemini API basic URL configuration, optimize CI workflow to support multiple operating systems, update dependencies and fix cleanup scripts

* Optimize build performance, add Windows specific settings and troubleshooting documentation, update configurations to support incremental builds and caching

* Optimize CI workflow to support cross platform build output validation, update documentation to include validation commands for Windows and Unix
This commit is contained in:
Max Qian
2025-08-30 21:52:52 +08:00
committed by GitHub
parent 5df059a8c1
commit 54cc336378
25 changed files with 430 additions and 61 deletions

View File

@@ -44,6 +44,9 @@ OPENAI_API_KEY=your-openai-api-key-here
# Google Gemini API key
# GEMINI_API_KEY=your-gemini-api-key-here
# Gemini API base URL (optional, for custom endpoints)
# GEMINI_BASE_URL=https://generativelanguage.googleapis.com/v1beta
# =============================================================================
# Ollama Configuration
# =============================================================================

View File

@@ -2,39 +2,61 @@ name: CI
on:
push:
branches: [ master, main, claude_context ]
branches: [master, main, claude_context]
pull_request:
branches: [ master, main, claude_context ]
branches: [master, main, claude_context]
jobs:
lint_and_build:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
node-version: [20.x, 22.x]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
# - name: Lint code
# run: pnpm lint
- name: Build packages
run: pnpm build
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
- name: Configure Windows line endings
if: matrix.os == 'windows-latest'
run: git config --global core.autocrlf false
- name: Install dependencies
run: pnpm install --frozen-lockfile
# - name: Lint code
# run: pnpm lint
- name: Build packages
run: pnpm build
- name: Test clean command (Windows validation)
if: matrix.os == 'windows-latest'
run: |
pnpm clean
echo "Clean command executed successfully on Windows"
- name: Verify build outputs (Unix)
if: matrix.os != 'windows-latest'
run: |
ls -la packages/core/dist || echo "packages/core/dist not found"
ls -la packages/mcp/dist || echo "packages/mcp/dist not found"
- name: Verify build outputs (Windows)
if: matrix.os == 'windows-latest'
run: |
Get-ChildItem packages/core/dist -ErrorAction SilentlyContinue | Format-Table -AutoSize || Write-Host "packages/core/dist not found"
Get-ChildItem packages/mcp/dist -ErrorAction SilentlyContinue | Format-Table -AutoSize || Write-Host "packages/mcp/dist not found"

17
.npmrc Normal file
View File

@@ -0,0 +1,17 @@
# Enable shell emulator for cross-platform script execution
shell-emulator=true
# Ignore workspace root check warning (already configured in package.json)
ignore-workspace-root-check=true
# Build performance optimizations
prefer-frozen-lockfile=true
auto-install-peers=true
dedupe-peer-dependents=true
# Enhanced caching
store-dir=~/.pnpm-store
cache-dir=~/.pnpm-cache
# Parallel execution optimization
child-concurrency=4

View File

@@ -13,22 +13,44 @@ Thank you for your interest in contributing to Claude Context! This guide will h
### Development Setup
1. **Fork and Clone**
```bash
git clone https://github.com/your-username/claude-context.git
cd claude-context
```
2. **Install Dependencies**
2. **Platform-Specific Setup**
**Windows Users:**
```powershell
# Configure git line endings (recommended)
git config core.autocrlf false
# Ensure pnpm is installed
npm install -g pnpm
```
**Linux/macOS Users:**
```bash
# Standard setup - no additional configuration needed
```
3. **Install Dependencies**
```bash
pnpm install
```
3. **Build All Packages**
4. **Build All Packages**
```bash
pnpm build
```
4. **Start Development Mode**
5. **Start Development Mode**
```bash
pnpm dev
```
@@ -71,6 +93,7 @@ pnpm dev
### Package-Specific Development
For detailed development instructions for each package, see:
- [Core Package Development](packages/core/CONTRIBUTING.md)
- [VSCode Extension Development](packages/vscode-extension/CONTRIBUTING.md)
- [MCP Server Development](packages/mcp/CONTRIBUTING.md)
@@ -97,6 +120,7 @@ refactor(mcp): improve error handling
### Pull Request Process
1. **Create Feature Branch**
```bash
git checkout -b feature/your-feature-name
```
@@ -106,17 +130,20 @@ refactor(mcp): improve error handling
- Update documentation if needed
3. **Build and Verify**
```bash
pnpm build
```
4. **Commit Your Changes**
```bash
git add .
git commit -m "feat(core): add your feature description"
```
5. **Push and Create PR**
```bash
git push origin feature/your-feature-name
```

View File

@@ -1,4 +1,5 @@
![](assets/claude-context.png)
### Your entire codebase as Claude's context
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
@@ -27,6 +28,7 @@
Model Context Protocol (MCP) allows you to integrate Claude Context with your favorite AI coding assistants, e.g. Claude Code.
## Quick Start
### Prerequisites
<details>
@@ -52,7 +54,9 @@ Copy your key and use it in the configuration examples below as `your-openai-api
### Configure MCP for Claude Code
**System Requirements:**
- Node.js >= 20.0.0 and < 24.0.0
> Claude Context is not compatible with Node.js 24.0.0, you need downgrade it first if your node version is greater or equal to 24.
#### Configuration
@@ -66,10 +70,8 @@ claude mcp add claude-context \
-- npx @zilliz/claude-context-mcp@latest
```
See the [Claude Code MCP documentation](https://docs.anthropic.com/en/docs/claude-code/mcp) for more details about MCP server management.
### Other MCP Client Configurations
<details>
@@ -94,6 +96,7 @@ Gemini CLI requires manual configuration through a JSON file:
}
}
```
3. Save the file and restart Gemini CLI to apply the changes.
</details>
@@ -121,7 +124,6 @@ Create or edit the `~/.qwen/settings.json` file and add the following configurat
</details>
<details>
<summary><strong>Cursor</strong></summary>
@@ -409,7 +411,6 @@ For LangChain/LangGraph integration examples, see [this example](https://github.
</details>
<details>
<summary><strong>Other MCP Clients</strong></summary>
@@ -422,22 +423,30 @@ npx @zilliz/claude-context-mcp@latest
</details>
---
### Usage in Your Codebase
1. **Open Claude Code**
```
cd your-project-directory
claude
```
2. **Index your codebase**:
```
Index this codebase
```
3. **Check indexing status**:
```
Check the indexing status
```
4. **Start searching**:
```
Find functions that handle user authentication
```
@@ -461,22 +470,26 @@ For detailed explanation of file inclusion and exclusion rules, and how to custo
### Available Tools
#### 1. `index_codebase`
Index a codebase directory for hybrid search (BM25 + dense vector).
#### 2. `search_code`
Search the indexed codebase using natural language queries with hybrid search (BM25 + dense vector).
#### 3. `clear_index`
Clear the search index for a specific codebase.
#### 4. `get_indexing_status`
Get the current indexing status of a codebase. Shows progress percentage for actively indexing codebases and completion status for indexed codebases.
---
## 🏗️ Architecture
![](assets/Architecture.png)
![](assets/Architecture.png)
### 🔧 Implementation Details
@@ -488,6 +501,7 @@ Get the current indexing status of a codebase. Shows progress percentage for act
- 🛠️ **Customizable**: Configure file extensions, ignore patterns, and embedding models.
### Core Components
Claude Context is a monorepo containing three main packages:
- **`@zilliz/claude-context-core`**: Core indexing engine with embedding and vector database integration
@@ -495,6 +509,7 @@ Claude Context is a monorepo containing three main packages:
- **`@zilliz/claude-context-mcp`**: Model Context Protocol server for AI agent integration
### Supported Technologies
- **Embedding Providers**: [OpenAI](https://openai.com), [VoyageAI](https://voyageai.com), [Ollama](https://ollama.ai), [Gemini](https://gemini.google.com)
- **Vector Databases**: [Milvus](https://milvus.io) or [Zilliz Cloud](https://zilliz.com/cloud)(fully managed vector database as a service)
- **Code Splitters**: AST-based splitter (with automatic fallback), LangChain character-based splitter
@@ -564,6 +579,13 @@ Integrates Claude Context directly into your IDE. Provides an intuitive interfac
### Setup Development Environment
#### Prerequisites
- Node.js 20.x or 22.x
- pnpm (recommended package manager)
#### Cross-Platform Setup
```bash
# Clone repository
git clone https://github.com/zilliztech/claude-context.git
@@ -579,18 +601,53 @@ pnpm build
pnpm dev
```
#### Windows-Specific Setup
On Windows, ensure you have:
- **Git for Windows** with proper line ending configuration
- **Node.js** installed via the official installer or package manager
- **pnpm** installed globally: `npm install -g pnpm`
```powershell
# Windows PowerShell/Command Prompt
git clone https://github.com/zilliztech/claude-context.git
cd claude-context
# Configure git line endings (recommended)
git config core.autocrlf false
# Install dependencies
pnpm install
# Build all packages (uses cross-platform scripts)
pnpm build
# Start development mode
pnpm dev
```
### Building
```bash
# Build all packages
# Build all packages (cross-platform)
pnpm build
# Build specific package
pnpm build:core
pnpm build:vscode
pnpm build:mcp
# Performance benchmarking
pnpm benchmark
```
#### Windows Build Notes
- All build scripts are cross-platform compatible using rimraf
- Build caching is enabled for faster subsequent builds
- Use PowerShell or Command Prompt - both work equally well
### Running Examples
```bash
@@ -641,6 +698,7 @@ For detailed evaluation methodology and results, see the [evaluation directory](
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details on how to get started.
**Package-specific contributing guides:**
- [Core Package Contributing](packages/core/CONTRIBUTING.md)
- [MCP Server Contributing](packages/mcp/CONTRIBUTING.md)
- [VSCode Extension Contributing](packages/vscode-extension/CONTRIBUTING.md)

39
build-benchmark.json Normal file
View File

@@ -0,0 +1,39 @@
[
{
"timestamp": "2025-08-25T19:04:13.664Z",
"platform": "win32",
"nodeVersion": "v22.15.1",
"results": [
{
"success": true,
"duration": 1849,
"command": "pnpm clean",
"description": "Clean all packages"
},
{
"success": true,
"duration": 6754,
"command": "pnpm build:core",
"description": "Build core package"
},
{
"success": true,
"duration": 9782,
"command": "pnpm build:mcp",
"description": "Build MCP package"
},
{
"success": true,
"duration": 6821,
"command": "pnpm build:vscode",
"description": "Build VSCode extension"
},
{
"success": true,
"duration": 14526,
"command": "pnpm -r --filter=\"./packages/chrome-extension\" build",
"description": "Build Chrome extension"
}
]
}
]

View File

@@ -23,8 +23,10 @@ Claude Context supports a global configuration file at `~/.context/.env` to simp
| `EMBEDDING_PROVIDER` | Provider: `OpenAI`, `VoyageAI`, `Gemini`, `Ollama` | `OpenAI` |
| `EMBEDDING_MODEL` | Embedding model name (works for all providers) | Provider-specific default |
| `OPENAI_API_KEY` | OpenAI API key | Required for OpenAI |
| `OPENAI_BASE_URL` | OpenAI API base URL (optional, for custom endpoints) | `https://api.openai.com/v1` |
| `VOYAGEAI_API_KEY` | VoyageAI API key | Required for VoyageAI |
| `GEMINI_API_KEY` | Gemini API key | Required for Gemini |
| `GEMINI_BASE_URL` | Gemini API base URL (optional, for custom endpoints) | `https://generativelanguage.googleapis.com/v1beta` |
> **💡 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.).

View File

@@ -19,7 +19,8 @@
"release:core": "pnpm --filter @zilliz/claude-context-core... run build && pnpm --filter @zilliz/claude-context-core publish --access public --no-git-checks",
"release:mcp": "pnpm --filter @zilliz/claude-context-mcp... run build && pnpm --filter @zilliz/claude-context-mcp publish --access public --no-git-checks",
"release:vscode": "pnpm --filter @zilliz/claude-context-core build && pnpm --filter semanticcodesearch run webpack && pnpm --filter semanticcodesearch release",
"example:basic": "pnpm --filter claude-context-basic-example start"
"example:basic": "pnpm --filter claude-context-basic-example start",
"benchmark": "node scripts/build-benchmark.js"
},
"devDependencies": {
"@types/node": "^20.0.0",
@@ -30,6 +31,7 @@
"eslint": "^9.25.1",
"https-browserify": "^1.0.0",
"os-browserify": "^0.3.0",
"rimraf": "^6.0.1",
"stream-http": "^3.2.0",
"tree-sitter-cli": "^0.25.6",
"typescript": "^5.8.3",

View File

@@ -9,6 +9,7 @@ Thanks for your interest in contributing to the Claude Context Chrome extension!
This guide covers development specific to the Chrome extension.
### Quick Commands
```bash
# Build Chrome extension
pnpm build:chrome
@@ -32,12 +33,14 @@ pnpm prebuild
### Development Setup
1. **Install Dependencies**:
```bash
cd packages/chrome-extension
pnpm install
```
2. **Build Extension**:
```bash
pnpm build
```
@@ -48,6 +51,7 @@ pnpm prebuild
- Click "Load unpacked" and select the `dist` folder
4. **Development Mode**:
```bash
pnpm dev # Watch mode for automatic rebuilds
```
@@ -82,21 +86,25 @@ src/
## Development Workflow
### 1. Content Script Development
- Modify `src/content.ts` for GitHub UI integration
- Test on various GitHub repository pages
- Ensure UI doesn't conflict with GitHub's interface
### 2. Background Service Worker
- Edit `src/background.ts` for extension lifecycle management
- Handle cross-tab communication and data persistence
- Test extension startup and shutdown scenarios
### 3. Options Page
- Update `src/options.ts` and `src/options.html` for settings
- Test configuration persistence and validation
- Ensure user-friendly error messages
### 4. Testing Workflow
1. Make changes to source files
2. Run `pnpm build` or use `pnpm dev` for watch mode
3. Go to `chrome://extensions/` and click "Reload" on the extension
@@ -106,10 +114,12 @@ src/
## Browser Compatibility
### WebPack Configuration
- `webpack.config.js` handles Node.js polyfills for browser environment
- Modules like `crypto`, `fs`, `path` are replaced with browser-compatible versions
### Key Polyfills
- `crypto-browserify` - Cryptographic functions
- `buffer` - Node.js Buffer API
- `process` - Process environment variables
@@ -117,6 +127,7 @@ src/
- `vm-browserify` - Virtual machine context
### Testing Browser Compatibility
```bash
# Build and test in different browsers
pnpm build
@@ -126,22 +137,26 @@ pnpm build
## Extension-Specific Guidelines
### Manifest V3 Compliance
- Use service workers instead of background pages
- Follow content security policy restrictions
- Handle permissions properly
### Performance Considerations
- Minimize content script impact on GitHub page load
- Use efficient DOM manipulation
- Lazy load heavy components
### Security Best Practices
- Validate all user inputs
- Sanitize HTML content
- Use secure communication between scripts
- Handle API keys securely
### UI/UX Guidelines
- Match GitHub's design language
- Provide loading states for async operations
- Show clear error messages
@@ -150,12 +165,14 @@ pnpm build
## Chrome Extension Features
### Core Functionality
- **Repository Indexing**: Parse GitHub repositories and create vector embeddings
- **Semantic Search**: Natural language code search within repositories
- **UI Integration**: Seamless GitHub interface enhancement
- **Configuration Management**: User settings and API key management
### Advanced Features
- **Cross-Repository Search**: Search across multiple indexed repositories
- **Context-Aware Search**: Search similar code from selected snippets
- **Progress Tracking**: Real-time indexing progress indicators
@@ -164,6 +181,7 @@ pnpm build
## Testing Checklist
### Manual Testing
- [ ] Extension loads without errors
- [ ] UI appears correctly on GitHub repository pages
- [ ] Indexing works for public repositories
@@ -173,12 +191,14 @@ pnpm build
- [ ] No conflicts with GitHub's native functionality
### Cross-Browser Testing
- [ ] Chrome (latest)
- [ ] Edge (Chromium-based)
- [ ] Brave Browser
- [ ] Other Chromium-based browsers
### GitHub Integration Testing
- [ ] Repository home pages
- [ ] File browser pages
- [ ] Code view pages
@@ -189,31 +209,41 @@ pnpm build
## Debugging
### Chrome DevTools
1. Right-click extension icon → "Inspect popup"
2. Go to GitHub page → F12 → check console for content script errors
3. `chrome://extensions/` → click "service worker" link for background script debugging
### Common Issues
- **Permission errors**: Check manifest.json permissions
- **CSP violations**: Verify content security policy compliance
- **Module not found**: Check webpack polyfill configuration
- **API errors**: Validate API keys and network connectivity
### Debug Commands
```bash
# Check build output
# Check build output (Unix/macOS)
ls -la dist/
# Validate manifest
# Check build output (Windows PowerShell)
Get-ChildItem dist/ | Format-Table -AutoSize
# Validate manifest (Unix/macOS)
cat dist/manifest.json | jq
# Check for TypeScript errors
# Validate manifest (Windows PowerShell)
Get-Content dist/manifest.json | ConvertFrom-Json | ConvertTo-Json -Depth 10
# Check for TypeScript errors (cross-platform)
pnpm typecheck
```
## Publishing Preparation
### Pre-Publishing Checklist
- [ ] All tests pass
- [ ] No console errors
- [ ] Icons generated correctly
@@ -222,13 +252,17 @@ pnpm typecheck
- [ ] Screenshots prepared for store listing
### Build for Production
```bash
# Clean build
pnpm clean
pnpm build
# Verify bundle size
# Verify bundle size (Unix/macOS)
ls -lh dist/
# Verify bundle size (Windows PowerShell)
Get-ChildItem dist/ | Select-Object Name, @{Name="Size";Expression={[math]::Round($_.Length/1KB,2)}} | Format-Table -AutoSize
```
> **Note**: Only maintainers can publish to Chrome Web Store

View File

@@ -6,11 +6,11 @@
"scripts": {
"build": "webpack --mode=production",
"dev": "webpack --mode=development --watch",
"clean": "rm -rf dist",
"clean": "rimraf dist",
"lint": "eslint src --ext .ts,.tsx",
"lint:fix": "eslint src --ext .ts,.tsx --fix",
"typecheck": "tsc --noEmit",
"build:milvus": "./build.sh"
"build:milvus": "echo 'build:milvus script not implemented'"
},
"dependencies": {
"@zilliz/claude-context-core": "workspace:*"

View File

@@ -14,6 +14,12 @@ module.exports = {
filename: '[name].js',
clean: true
},
cache: {
type: 'filesystem',
buildDependencies: {
config: [__filename]
}
},
devtool: false,
experiments: {
outputModule: false

View File

@@ -7,7 +7,7 @@
"scripts": {
"build": "pnpm clean && tsc --build --force",
"dev": "tsc --watch",
"clean": "rm -rf dist",
"clean": "rimraf dist",
"lint": "eslint src --ext .ts",
"lint:fix": "eslint src --ext .ts --fix",
"typecheck": "tsc --noEmit"

View File

@@ -4,6 +4,7 @@ import { Embedding, EmbeddingVector } from './base-embedding';
export interface GeminiEmbeddingConfig {
model: string;
apiKey: string;
baseURL?: string; // Optional custom API endpoint URL
outputDimensionality?: number; // Optional dimension override
}
@@ -18,6 +19,11 @@ export class GeminiEmbedding extends Embedding {
this.config = config;
this.client = new GoogleGenAI({
apiKey: config.apiKey,
...(config.baseURL && {
httpOptions: {
baseUrl: config.baseURL
}
}),
});
// Set dimension based on model and configuration

View File

@@ -17,7 +17,9 @@
"moduleResolution": "node",
"composite": true,
"allowSyntheticDefaultImports": true,
"downlevelIteration": true
"downlevelIteration": true,
"incremental": true,
"tsBuildInfoFile": "./dist/.tsbuildinfo"
},
"include": [
"src/**/*"

View File

@@ -1,4 +1,5 @@
# @zilliz/claude-context-mcp
![](../../assets/claude-context.png)
Model Context Protocol (MCP) integration for Claude Context - A powerful MCP server that enables AI assistants and agents to index and search codebases using semantic search.
@@ -7,19 +8,18 @@ Model Context Protocol (MCP) integration for Claude Context - A powerful MCP ser
> 📖 **New to Claude Context?** Check out the [main project README](../../README.md) for an overview and setup instructions.
## 🚀 Use Claude Context as MCP in Claude Code and others
![img](https://lh7-rt.googleusercontent.com/docsz/AD_4nXf2uIf2c5zowp-iOMOqsefHbY_EwNGiutkxtNXcZVJ8RI6SN9DsCcsc3amXIhOZx9VcKFJQLSAqM-2pjU9zoGs1r8GCTUL3JIsLpLUGAm1VQd5F2o5vpEajx2qrc77iXhBu1zWj?key=qYdFquJrLcfXCUndY-YRBQ)
Model Context Protocol (MCP) allows you to integrate Claude 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, or Ollama setup)
- Milvus vector database (local or cloud)
@@ -58,6 +58,7 @@ OPENAI_BASE_URL=https://api.openai.com/v1
See `getSupportedModels` in [`openai-embedding.ts`](https://github.com/zilliztech/claude-context/blob/master/packages/core/src/embedding/openai-embedding.ts) for the full list of supported models.
**Getting API Key:**
1. Visit [OpenAI Platform](https://platform.openai.com/api-keys)
2. Sign in or create an account
3. Generate a new API key
@@ -82,6 +83,7 @@ EMBEDDING_MODEL=voyage-code-3
See `getSupportedModels` in [`voyageai-embedding.ts`](https://github.com/zilliztech/claude-context/blob/master/packages/core/src/embedding/voyageai-embedding.ts) for the full list of supported models.
**Getting API Key:**
1. Visit [VoyageAI Console](https://dash.voyageai.com/)
2. Sign up for an account
3. Navigate to API Keys section
@@ -100,12 +102,16 @@ GEMINI_API_KEY=your-gemini-api-key
# Optional: Specify embedding model (default: gemini-embedding-001)
EMBEDDING_MODEL=gemini-embedding-001
# Optional: Custom API base URL (for custom endpoints)
GEMINI_BASE_URL=https://generativelanguage.googleapis.com/v1beta
```
**Available Models:**
See `getSupportedModels` in [`gemini-embedding.ts`](https://github.com/zilliztech/claude-context/blob/master/packages/core/src/embedding/gemini-embedding.ts) for the full list of supported models.
**Getting API Key:**
1. Visit [Google AI Studio](https://aistudio.google.com/)
2. Sign in with your Google account
3. Go to "Get API key" section
@@ -127,12 +133,16 @@ OLLAMA_HOST=http://127.0.0.1:11434
```
**Setup Instructions:**
1. Install Ollama from [ollama.ai](https://ollama.ai/)
2. Pull the embedding model:
```bash
ollama pull nomic-embed-text
```
3. Ensure Ollama is running:
```bash
ollama serve
```
@@ -149,16 +159,18 @@ Copy your Personal Key to replace `your-zilliz-cloud-api-key` in the configurati
```bash
MILVUS_TOKEN=your-zilliz-cloud-api-key
```
```
#### Embedding Batch Size
You can set the embedding batch size to optimize the performance of the MCP server, depending on your embedding model throughput. The default value is 100.
```bash
EMBEDDING_BATCH_SIZE=512
```
#### Custom File Processing (Optional)
You can configure custom file extensions and ignore patterns globally via environment variables:
```bash
@@ -173,7 +185,6 @@ These settings work in combination with tool parameters - patterns from both sou
## Usage with MCP Clients
<details>
<summary><strong>Claude Code</strong></summary>
@@ -189,7 +200,6 @@ See the [Claude Code MCP documentation](https://docs.anthropic.com/en/docs/claud
</details>
<details>
<summary><strong>Gemini CLI</strong></summary>
@@ -248,6 +258,7 @@ Go to: `Settings` -> `Cursor Settings` -> `MCP` -> `Add new global MCP server`
Pasting the following configuration into your Cursor `~/.cursor/mcp.json` file is the recommended approach. You may also install in a specific project by creating `.cursor/mcp.json` in your project folder. See [Cursor MCP docs](https://docs.cursor.com/context/model-context-protocol) for more info.
**OpenAI Configuration (Default):**
```json
{
"mcpServers": {
@@ -265,6 +276,7 @@ Pasting the following configuration into your Cursor `~/.cursor/mcp.json` file i
```
**VoyageAI Configuration:**
```json
{
"mcpServers": {
@@ -283,6 +295,7 @@ Pasting the following configuration into your Cursor `~/.cursor/mcp.json` file i
```
**Gemini Configuration:**
```json
{
"mcpServers": {
@@ -300,6 +313,7 @@ Pasting the following configuration into your Cursor `~/.cursor/mcp.json` file i
```
**Ollama Configuration:**
```json
{
"mcpServers": {
@@ -319,8 +333,6 @@ Pasting the following configuration into your Cursor `~/.cursor/mcp.json` file i
</details>
<details>
<summary><strong>Void</strong></summary>
@@ -536,7 +548,6 @@ Roo Code utilizes a JSON configuration file for MCP servers:
</details>
<details>
<summary><strong>Zencoder</strong></summary>
@@ -596,9 +607,11 @@ npx @zilliz/claude-context-mcp@latest
## 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 even if already indexed (default: false)
- `splitter` (optional): Code splitter to use - 'ast' for syntax-aware splitting with automatic fallback, 'langchain' for character-based splitting (default: "ast")
@@ -606,30 +619,36 @@ Index a codebase directory for hybrid search (BM25 + dense vector).
- `ignorePatterns` (optional): Additional ignore patterns to exclude specific files/directories beyond defaults (e.g., ['static/**', '*.tmp', 'private/**']) (default: [])
### 2. `search_code`
Search the indexed codebase using natural language queries with hybrid search (BM25 + dense vector).
**Parameters:**
- `path` (required): Absolute path to the codebase directory to search in
- `query` (required): Natural language query to search for in the codebase
- `limit` (optional): Maximum number of results to return (default: 10, max: 50)
- `extensionFilter` (optional): List of file extensions to filter results (e.g., ['.ts', '.py']) (default: [])
### 3. `clear_index`
Clear the search index for a specific codebase.
**Parameters:**
- `path` (required): Absolute path to the codebase directory to clear index for
### 4. `get_indexing_status`
Get the current indexing status of a codebase. Shows progress percentage for actively indexing codebases and completion status for indexed codebases.
**Parameters:**
- `path` (required): Absolute path to the codebase directory to check status for
- `path` (required): Absolute path to the codebase directory to check status for
## Contributing
This package is part of the Claude Context monorepo. Please see:
- [Main Contributing Guide](../../CONTRIBUTING.md) - General contribution guidelines
- [MCP Package Contributing](CONTRIBUTING.md) - Specific development guide for this package
@@ -641,4 +660,4 @@ This package is part of the Claude Context monorepo. Please see:
## License
MIT - See [LICENSE](../../LICENSE) for details
MIT - See [LICENSE](../../LICENSE) for details

View File

@@ -9,7 +9,7 @@
"scripts": {
"build": "pnpm clean && tsc --build --force",
"dev": "tsx --watch src/index.ts",
"clean": "rm -rf dist",
"clean": "rimraf dist",
"lint": "eslint src --ext .ts",
"lint:fix": "eslint src --ext .ts --fix",
"typecheck": "tsc --noEmit",

View File

@@ -11,6 +11,7 @@ export interface ContextMcpConfig {
openaiBaseUrl?: string;
voyageaiApiKey?: string;
geminiApiKey?: string;
geminiBaseUrl?: string;
// Ollama configuration
ollamaModel?: string;
ollamaHost?: string;
@@ -123,6 +124,7 @@ export function createMcpConfig(): ContextMcpConfig {
openaiBaseUrl: envManager.get('OPENAI_BASE_URL'),
voyageaiApiKey: envManager.get('VOYAGEAI_API_KEY'),
geminiApiKey: envManager.get('GEMINI_API_KEY'),
geminiBaseUrl: envManager.get('GEMINI_BASE_URL'),
// Ollama configuration
ollamaModel: envManager.get('OLLAMA_MODEL'),
ollamaHost: envManager.get('OLLAMA_HOST'),
@@ -156,6 +158,9 @@ export function logConfigurationSummary(config: ContextMcpConfig): void {
break;
case 'Gemini':
console.log(`[MCP] Gemini API Key: ${config.geminiApiKey ? '✅ Configured' : '❌ Missing'}`);
if (config.geminiBaseUrl) {
console.log(`[MCP] Gemini Base URL: ${config.geminiBaseUrl}`);
}
break;
case 'Ollama':
console.log(`[MCP] Ollama Host: ${config.ollamaHost || 'http://127.0.0.1:11434'}`);
@@ -188,6 +193,7 @@ Environment Variables:
OPENAI_BASE_URL OpenAI API base URL (optional, for custom endpoints)
VOYAGEAI_API_KEY VoyageAI API key (required for VoyageAI provider)
GEMINI_API_KEY Google AI API key (required for Gemini provider)
GEMINI_BASE_URL Gemini API base URL (optional, for custom endpoints)
Ollama Configuration:
OLLAMA_HOST Ollama server host (default: http://127.0.0.1:11434)

View File

@@ -41,7 +41,8 @@ export function createEmbeddingInstance(config: ContextMcpConfig): OpenAIEmbeddi
console.log(`[EMBEDDING] 🔧 Configuring Gemini with model: ${config.embeddingModel}`);
const geminiEmbedding = new GeminiEmbedding({
apiKey: config.geminiApiKey,
model: config.embeddingModel
model: config.embeddingModel,
...(config.geminiBaseUrl && { baseURL: config.geminiBaseUrl })
});
console.log(`[EMBEDDING] ✅ Gemini embedding instance created successfully`);
return geminiEmbedding;
@@ -75,7 +76,7 @@ export function logEmbeddingProviderInfo(config: ContextMcpConfig, embedding: Op
console.log(`[EMBEDDING] VoyageAI configuration - API Key: ${config.voyageaiApiKey ? '✅ Provided' : '❌ Missing'}`);
break;
case 'Gemini':
console.log(`[EMBEDDING] Gemini configuration - API Key: ${config.geminiApiKey ? '✅ Provided' : '❌ Missing'}`);
console.log(`[EMBEDDING] Gemini configuration - API Key: ${config.geminiApiKey ? '✅ Provided' : '❌ Missing'}, Base URL: ${config.geminiBaseUrl || 'Default'}`);
break;
case 'Ollama':
console.log(`[EMBEDDING] Ollama configuration - Host: ${config.ollamaHost || 'http://127.0.0.1:11434'}, Model: ${config.embeddingModel}`);

View File

@@ -109,6 +109,7 @@ MILVUS_TOKEN=your-zilliz-cloud-api-key
- `semanticCodeSearch.embeddingProvider.provider` - Embedding provider (OpenAI/VoyageAI/Gemini/Ollama)
- `semanticCodeSearch.embeddingProvider.model` - Embedding model to use
- `semanticCodeSearch.embeddingProvider.apiKey` - API key for embedding provider
- `semanticCodeSearch.embeddingProvider.baseURL` - Custom API endpoint URL (optional, for OpenAI and Gemini)
- `semanticCodeSearch.embeddingProvider.outputDimensionality` - Output dimension for Gemini (supports 3072, 1536, 768, 256)
- `semanticCodeSearch.milvus.address` - Milvus server address

View File

@@ -167,7 +167,7 @@
"webpack": "pnpm clean && webpack --mode production && node copy-assets.js",
"webpack:dev": "webpack --mode development && node copy-assets.js",
"watch": "tsc -watch -p ./",
"clean": "rm -rf dist",
"clean": "rimraf dist",
"lint": "eslint src",
"lint:fix": "eslint src --fix",
"typecheck": "tsc --noEmit",

View File

@@ -97,6 +97,7 @@ const EMBEDDING_PROVIDERS = {
{ name: 'apiKey', type: 'string', description: 'Google AI API key', inputType: 'password', required: true }
] as FieldDefinition[],
optionalFields: [
{ name: 'baseURL', type: 'string', description: 'Custom API endpoint URL (optional)', inputType: 'url', placeholder: 'https://generativelanguage.googleapis.com/v1beta' },
{ name: 'outputDimensionality', type: 'number', description: 'Output dimension (supports Matryoshka representation)', inputType: 'text', placeholder: '3072' }
] as FieldDefinition[],
defaultConfig: {

View File

@@ -13,6 +13,12 @@ module.exports = {
filename: 'extension.js',
libraryTarget: 'commonjs2'
},
cache: {
type: 'filesystem',
buildDependencies: {
config: [__filename]
}
},
devtool: 'nosources-source-map',
externals: {
vscode: 'commonjs vscode', // the vscode-module is created on-the-fly and must be excluded

21
pnpm-lock.yaml generated
View File

@@ -32,6 +32,9 @@ importers:
os-browserify:
specifier: ^0.3.0
version: 0.3.0
rimraf:
specifier: ^6.0.1
version: 6.0.1
stream-http:
specifier: ^3.2.0
version: 3.2.0
@@ -1233,41 +1236,49 @@ packages:
resolution: {integrity: sha512-vdqBh911wc5awE2bX2zx3eflbyv8U9xbE/jVKAm425eRoOVv/VseGZsqi3A3SykckSpF4wSROkbQPvbQFn8EsA==}
cpu: [arm64]
os: [linux]
libc: [glibc]
'@unrs/resolver-binding-linux-arm64-musl@1.9.0':
resolution: {integrity: sha512-/8JFZ/SnuDr1lLEVsxsuVwrsGquTvT51RZGvyDB/dOK3oYK2UqeXzgeyq6Otp8FZXQcEYqJwxb9v+gtdXn03eQ==}
cpu: [arm64]
os: [linux]
libc: [musl]
'@unrs/resolver-binding-linux-ppc64-gnu@1.9.0':
resolution: {integrity: sha512-FkJjybtrl+rajTw4loI3L6YqSOpeZfDls4SstL/5lsP2bka9TiHUjgMBjygeZEis1oC8LfJTS8FSgpKPaQx2tQ==}
cpu: [ppc64]
os: [linux]
libc: [glibc]
'@unrs/resolver-binding-linux-riscv64-gnu@1.9.0':
resolution: {integrity: sha512-w/NZfHNeDusbqSZ8r/hp8iL4S39h4+vQMc9/vvzuIKMWKppyUGKm3IST0Qv0aOZ1rzIbl9SrDeIqK86ZpUK37w==}
cpu: [riscv64]
os: [linux]
libc: [glibc]
'@unrs/resolver-binding-linux-riscv64-musl@1.9.0':
resolution: {integrity: sha512-bEPBosut8/8KQbUixPry8zg/fOzVOWyvwzOfz0C0Rw6dp+wIBseyiHKjkcSyZKv/98edrbMknBaMNJfA/UEdqw==}
cpu: [riscv64]
os: [linux]
libc: [musl]
'@unrs/resolver-binding-linux-s390x-gnu@1.9.0':
resolution: {integrity: sha512-LDtMT7moE3gK753gG4pc31AAqGUC86j3AplaFusc717EUGF9ZFJ356sdQzzZzkBk1XzMdxFyZ4f/i35NKM/lFA==}
cpu: [s390x]
os: [linux]
libc: [glibc]
'@unrs/resolver-binding-linux-x64-gnu@1.9.0':
resolution: {integrity: sha512-WmFd5KINHIXj8o1mPaT8QRjA9HgSXhN1gl9Da4IZihARihEnOylu4co7i/yeaIpcfsI6sYs33cNZKyHYDh0lrA==}
cpu: [x64]
os: [linux]
libc: [glibc]
'@unrs/resolver-binding-linux-x64-musl@1.9.0':
resolution: {integrity: sha512-CYuXbANW+WgzVRIl8/QvZmDaZxrqvOldOwlbUjIM4pQ46FJ0W5cinJ/Ghwa/Ng1ZPMJMk1VFdsD/XwmCGIXBWg==}
cpu: [x64]
os: [linux]
libc: [musl]
'@unrs/resolver-binding-wasm32-wasi@1.9.0':
resolution: {integrity: sha512-6Rp2WH0OoitMYR57Z6VE8Y6corX8C6QEMWLgOV6qXiJIeZ1F9WGXY/yQ8yDC4iTraotyLOeJ2Asea0urWj2fKQ==}
@@ -3597,6 +3608,11 @@ packages:
resolution: {integrity: sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==}
engines: {iojs: '>=1.0.0', node: '>=0.10.0'}
rimraf@6.0.1:
resolution: {integrity: sha512-9dkvaxAsk/xNXSJzMgFqqMCuFgt2+KsOFek3TMLfo8NCPfWpBmqwyNn5Y+NX56QUYfCtsyhF3ayiboEoUmJk/A==}
engines: {node: 20 || >=22}
hasBin: true
ripemd160@2.0.2:
resolution: {integrity: sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==}
@@ -8221,6 +8237,11 @@ snapshots:
reusify@1.1.0: {}
rimraf@6.0.1:
dependencies:
glob: 11.0.3
package-json-from-dist: 1.0.1
ripemd160@2.0.2:
dependencies:
hash-base: 3.0.5

View File

@@ -0,0 +1,94 @@
#!/usr/bin/env node
/**
* Build performance benchmarking script
* Measures and reports build times for all packages
*/
const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
const BENCHMARK_FILE = 'build-benchmark.json';
function measureBuildTime(command, description) {
console.log(`\n🔄 ${description}...`);
const startTime = Date.now();
try {
execSync(command, { stdio: 'inherit' });
const endTime = Date.now();
const duration = endTime - startTime;
console.log(`${description} completed in ${duration}ms`);
return { success: true, duration, command, description };
} catch (error) {
const endTime = Date.now();
const duration = endTime - startTime;
console.error(`${description} failed after ${duration}ms`);
return { success: false, duration, command, description, error: error.message };
}
}
function saveBenchmark(results) {
const benchmark = {
timestamp: new Date().toISOString(),
platform: process.platform,
nodeVersion: process.version,
results
};
let history = [];
if (fs.existsSync(BENCHMARK_FILE)) {
try {
history = JSON.parse(fs.readFileSync(BENCHMARK_FILE, 'utf8'));
} catch (e) {
console.warn('Could not read existing benchmark file');
}
}
history.push(benchmark);
// Keep only last 10 benchmarks
if (history.length > 10) {
history = history.slice(-10);
}
fs.writeFileSync(BENCHMARK_FILE, JSON.stringify(history, null, 2));
console.log(`\n📊 Benchmark saved to ${BENCHMARK_FILE}`);
}
function main() {
console.log('🚀 Starting build performance benchmark...');
const results = [];
// Clean first
results.push(measureBuildTime('pnpm clean', 'Clean all packages'));
// Build individual packages
results.push(measureBuildTime('pnpm build:core', 'Build core package'));
results.push(measureBuildTime('pnpm build:mcp', 'Build MCP package'));
results.push(measureBuildTime('pnpm build:vscode', 'Build VSCode extension'));
// Full build
results.push(measureBuildTime('pnpm -r --filter="./packages/chrome-extension" build', 'Build Chrome extension'));
const totalTime = results.reduce((sum, result) => sum + result.duration, 0);
const successCount = results.filter(r => r.success).length;
console.log(`\n📈 Benchmark Summary:`);
console.log(` Total time: ${totalTime}ms`);
console.log(` Successful builds: ${successCount}/${results.length}`);
console.log(` Platform: ${process.platform}`);
console.log(` Node version: ${process.version}`);
saveBenchmark(results);
}
if (require.main === module) {
main();
}
module.exports = { measureBuildTime, saveBenchmark };

View File

@@ -18,6 +18,8 @@
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"downlevelIteration": true,
"incremental": true,
"tsBuildInfoFile": ".tsbuildinfo",
"paths": {
"@zilliz/claude-context-core": [
"./packages/core/src"