codeembed
Embeds your codebase into a local vector and graph database and exposes it as an MCP tool, enabling AI assistants to perform fast semantic search over your code using Graph RAG.
README
<p align="center"> <img src="https://raw.githubusercontent.com/robino16/codeembed/main/assets/logo.svg" alt="codeembed" width="420"
</p>
<p align="center"> <a href="https://pypi.org/project/codeembed/"><img src="https://img.shields.io/pypi/v/codeembed" alt="PyPi"></a> <img src="https://github.com/robino16/codeembed/actions/workflows/release.yml/badge.svg" alt="Release Status"> </p>
Embeds your codebase into a local vector and graph database and exposes it as an MCP tool, giving AI assistants like Claude Code fast semantic search over your code using Graph RAG.
Particularly useful for questions like:
- How is X implemented in this repo?
- Where is X defined or used?
- Does this repo already have X?
For other questions, the agent will fall back to normal lookups. CodeEmbed can improve lookup speed and accuracy, especially for finding existing implementations before writing new ones. Note that the biggest bottleneck in coding agents is LLM thinking and token generation — solid prompts and follow-up questions still matter.
Uses ChromaDB for vector storage, SQLite for graph storage, and either Ollama or OpenAI (including OpenAI models via Azure AI Foundry) for LLM analysis.
Prerequisites
Installation
With Ollama:
uv tool install codeembed
With OpenAI / Azure OpenAI:
uv tool install 'codeembed[openai]'
Supply chain safety: To reduce the risk of newly-published malicious packages, consider adding
exclude-newer = "7 days"to your globaluv.toml. This preventsuvfrom installing packages published in the last 7 days.
Manual installation (from source)
git clone https://github.com/robino16/codeembed
cd codeembed
# With Ollama
uv tool install .
# With OpenAI support
uv tool install '.[openai]'
Then run codeembed init inside of your target repository.
Upgrading
uv tool upgrade codeembed
Usage
CodeEmbed is intended to be used within a single project — run all commands from your project root. Each project gets its own local vector database stored in .codeembed/.
Supported file types: .py, .md, .ts, .tsx, .js, .jsx.
1. Initialize (run once in your project root):
codeembed init
Creates a codeembed.toml config and configures your .gitignore. You'll be prompted to select a provider (Ollama or OpenAI) and a model. You'll also be offered the option to automatically configure Claude Code and/or GitHub Copilot.
2. Pre-populate the index:
codeembed embed
Run this before starting the server to pre-populate the index. Searches will return empty results until the first file has been embedded.
CodeEmbed respects your project's .gitignore and also excludes typical environment directories and files (.env, venv, node_modules, etc.) by default.
3. Start the MCP server:
Note: If the MCP server was added to Claude or GitHub Copilot during codeembed init your coding agent will do this step automatically.
codeembed serve
Starts the MCP server.
The serve command will embed your codebase in the background - by default it will scan for changes every 60 seconds.
This embedding interval can be configured in codeembed.toml.
CodeEmbed will only process modified files.
Configuring OpenAI
If you use the OpenAI provider, credentials are read from environment variables. The recommended approach is a .env file. codeembed init will ask for the path.
Standard OpenAI
OPENAI_API_KEY=...
Optionally override the endpoint (for compatible APIs like vLLM, LM Studio, OpenRouter):
OPENAI_API_KEY=...
OPENAI_BASE_URL=...
Azure OpenAI — API key
AZURE_OPENAI_ENDPOINT=https://<your-resource>.openai.azure.com/openai/v1/
AZURE_OPENAI_API_KEY=...
Azure OpenAI — RBAC / Entra ID (keyless)
Set only the endpoint; CodeEmbed will use DefaultAzureCredential, which automatically tries multiple credential sources in order — service principals (via env vars), workload identity, managed identity, VS Code Azure sign-in, az login, Azure PowerShell, and azd auth login — falling back to an interactive browser window if none are found automatically:
AZURE_OPENAI_ENDPOINT=https://<your-resource>.openai.azure.com/openai/v1/
Add to coding agents
codeembed init will offer to configure these automatically. If you prefer to do it manually:
Claude Code — add to .mcp.json in your project root:
{
"mcpServers": {
"codeembed": {
"command": "codeembed",
"args": ["serve"]
}
}
}
And add to .claude/settings.local.json to enable and pre-approve the tool:
{
"enabledMcpjsonServers": ["codeembed"],
"permissions": {
"allow": ["mcp__codeembed__search"]
}
}
GitHub Copilot — add to .vscode/mcp.json:
{
"servers": {
"codeembed": {
"command": "codeembed",
"args": ["serve"]
}
}
}
CodeEmbed - add to opencode.json (or opencode.jsonc):
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"codeembed": {
"type": "local",
"command": ["uv", "run", "codeembed", "serve"],
"enabled": true
}
}
}
The MCP server exposes a single search(query) tool for semantic search over your codebase.
Contributing
Clone this repo with:
git clone git@github.com:robino16/codeembed.git
cd codeembed
uv sync
Check for dependency conflicts with:
uv pip check
Check for package vulnerabilities with:
uv run pip-audit
(Optional) Add Ruff pre-commit with:
pre-commit install
Update init files:
uv run --no-sync scripts/generate_init_files.py
Run linter:
ruff check . --fix
Run formatter:
ruff format .
Run tests:
uv run --no-sync pytest
Build with:
uv build
Validate build with:
uv run twine check dist/*
--no-syncis required for local dev commands when the MCP server is running, as uv holds a lock that blocks sync operations.
License
MIT — see LICENSE.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。