code-context-mcp
Multi-provider embedding MCP server with local Milvus for semantic code search. Works with Claude Code, Cursor, Windsurf, and other MCP-compatible IDEs.
README
Code Context MCP
A multi-provider embedding MCP server with local Milvus for semantic code search. Works with Claude Code, Cursor, Windsurf, and other MCP-compatible IDEs.
Features
- Multi-provider embeddings: Local Qwen (free), OpenAI, or DeepSeek
- Dimension mismatch detection: Warns before indexing if dimensions don't match
- Zero cloud dependency: Use local Qwen for completely offline operation
- Dual deployment: Docker or local with pnpm
Architecture
┌─────────────────┐ ┌────────────────────┐ ┌─────────────────┐
│ Your Codebase │────▶│ Embedding Provider │────▶│ Local Milvus │
│ │ │ (Qwen/OpenAI/etc) │ │ (Vector Store) │
└─────────────────┘ └────────────────────┘ └─────────────────┘
│ │
│ ┌────────────────────────────┐ │
└────────▶│ code-context-mcp │◀─────────┘
│ (MCP Server) │
└────────────────────────────┘
│
┌─────────────┴─────────────┐
▼ ▼ ▼
Claude Code Cursor Windsurf
Quick Start
Option A: Docker (Recommended)
# 1. Configure
cp .env.example .env
# Edit .env with your settings
# 2. Start all services
docker-compose up -d
# 3. Verify (~60 seconds to initialize)
curl http://localhost:9091/healthz # Milvus
curl http://localhost:3100/health # MCP Server
IDE Configuration (Docker):
{
"mcpServers": {
"code-context": {
"url": "http://localhost:3100/sse"
}
}
}
Option B: Local Development
# 1. Start only Milvus in Docker
docker-compose up -d milvus
# 2. Install and build
pnpm install
pnpm build
# 3. Configure IDE (see below)
IDE Configuration (Local):
{
"mcpServers": {
"code-context": {
"command": "node",
"args": ["/path/to/code-context-mcp/dist/index.js"],
"env": {
"EMBEDDING_PROVIDER": "qwen-local",
"QWEN_LOCAL_BASE_URL": "http://172.18.35.123:8001/v1",
"QWEN_LOCAL_MODEL": "Qwen3-Embedding-4B",
"MILVUS_ADDRESS": "127.0.0.1:19530"
}
}
}
}
MCP Tools
| Tool | Description |
|---|---|
index_codebase |
Index a directory into Milvus |
search_code |
Semantic search across indexed code |
check_dimensions |
Check provider/collection dimension compatibility |
drop_collection |
Delete a collection (for re-indexing) |
get_provider_info |
Show current provider configuration |
Usage:
index_codebase /path/to/your/project
search_code "authentication logic"
check_dimensions
Embedding Providers
| Provider | Model | Dimensions | Cost |
|---|---|---|---|
qwen-local |
Qwen3-Embedding-4B | 2560 | Free |
openai |
text-embedding-3-small | 1536 | $0.02/1M tokens |
openai |
text-embedding-3-large | 3072 | $0.13/1M tokens |
deepseek |
deepseek-embedding-v2 | 768 | Paid |
Environment Variables
| Variable | Description | Default |
|---|---|---|
EMBEDDING_PROVIDER |
openai, qwen-local, deepseek |
openai |
MILVUS_ADDRESS |
Milvus server address | 127.0.0.1:19530 |
DIMENSION_CHECK_ENABLED |
Check dimensions before indexing | true |
MCP_TRANSPORT |
stdio or http |
stdio |
MCP_PORT |
HTTP port (http mode) | 3100 |
Provider-specific:
| Provider | Variables |
|---|---|
| Local Qwen | QWEN_LOCAL_BASE_URL, QWEN_LOCAL_MODEL |
| OpenAI | OPENAI_API_KEY, OPENAI_BASE_URL, OPENAI_EMBEDDING_MODEL |
| DeepSeek | DEEPSEEK_API_KEY, DEEPSEEK_BASE_URL, DEEPSEEK_EMBEDDING_MODEL |
Dimension Mismatch Handling
Different providers produce different dimensions. Switching providers requires re-indexing:
drop_collection code_context confirm=true
index_codebase /path/to/project
Docker Commands
docker-compose up -d # Start all
docker-compose up -d milvus # Start only Milvus
docker-compose logs -f # View logs
docker-compose down # Stop all
docker-compose down -v # Reset (delete data)
docker-compose build --no-cache # Rebuild
Local Development
pnpm install # Install dependencies
pnpm build # Build TypeScript
pnpm dev # Run in dev mode
pnpm start # Run production build
Project Structure
code-context-mcp/
├── docker-compose.yml # Milvus + MCP server
├── Dockerfile
├── package.json
├── tsconfig.json
├── .env.example
└── src/
├── index.ts # Entry point (stdio + HTTP)
├── config.ts # Configuration
├── providers/ # Embedding providers
│ ├── base.ts
│ ├── openai.ts
│ ├── qwen-local.ts
│ └── deepseek.ts
├── milvus/ # Milvus integration
│ ├── client.ts
│ └── dimension-checker.ts
└── tools/ # MCP tools
├── index-codebase.ts
├── search-code.ts
└── check-dimensions.ts
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。