CodeBrain
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@CodeBrainsearch for how user authentication is implemented"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
CodeBrain
CodeBrain(代码知识库大脑)is a local AI assistant that understands your codebase. It uses RAG (Retrieval-Augmented Generation) with a local embedding model and local LLM (Ollama/DeepSeek), exposes an MCP server for external AI tools, and provides a simple Gradio web UI.
Features
Codebase indexing: auto-scan Python / Java / Go / JavaScript / TypeScript repositories
Semantic search: vectorize code chunks (functions, classes, modules) with
sentence-transformersLocal vector DB: persist embeddings with ChromaDB
Natural-language Q&A: retrieve relevant snippets and generate answers with line-number citations
Incremental updates: re-index only changed files; optional file-system watcher
MCP server: expose
codebrain_searchandcodebrain_statustools to Cursor / Claude Code / ClineWeb UI: chat + index project + view status
Related MCP server: Acemcp
Quick Start
1. Install
pip install -r requirements.txt2. Start Ollama and pull a code model
ollama pull deepseek-coder:6.7b
ollama serveYou can change the model in config.yaml.
3. Index your codebase
python -m codebrain index /path/to/your/codebaseAdd --watch to monitor file changes:
python -m codebrain index /path/to/your/codebase --watch4. Ask questions
python -m codebrain ask "用户登录功能在哪个文件里实现的?"5. Launch web UI
python -m codebrain webOpen http://127.0.0.1:7860.
Configuration (config.yaml)
project:
supported_languages:
- python
- java
- go
- javascript
- typescript
ignore_patterns:
- node_modules
- .git
- __pycache__
- .venv
- venv
- dist
- build
- target
- .idea
- .vscode
- .codebrain
- ".mypy_cache"
- ".pytest_cache"
indexer:
embedding_model: all-MiniLM-L6-v2 # sentence-transformers model
chunk_size: 512
chunk_overlap: 50
vector_store:
provider: chromadb
persist_directory: .codebrain/chroma_db
collection_name: codebrain
llm:
provider: ollama
model: deepseek-coder:6.7b
base_url: http://localhost:11434
temperature: 0.1
max_tokens: 2048
web:
host: 127.0.0.1
port: 7860
mcp:
transport: stdioKey options
Section | Option | Description |
|
| Languages to index |
|
| Glob patterns for directories/files to skip |
|
| HuggingFace sentence-transformers model name |
|
| Where ChromaDB stores vectors |
|
| Ollama model tag |
|
| Ollama server URL |
|
| Gradio server bind address |
MCP Server Setup
CodeBrain implements an MCP server over stdio. Tools exposed:
codebrain_search(query, top_k=5, language="")— search the knowledge basecodebrain_status()— show index statistics
Cursor
Add to ~/.cursor/mcp.json:
{
"mcpServers": {
"codebrain": {
"command": "python",
"args": ["-m", "codebrain", "mcp"],
"cwd": "/absolute/path/to/codebrain"
}
}
}Claude Code
Add to ~/.claude-code/settings.json:
{
"mcpServers": {
"codebrain": {
"command": "python",
"args": ["-m", "codebrain", "mcp"]
}
}
}Cline
Add to Cline MCP settings:
{
"mcpServers": {
"codebrain": {
"command": "python",
"args": ["-m", "codebrain", "mcp"],
"env": {},
"disabled": false,
"autoApprove": ["codebrain_search", "codebrain_status"]
}
}
}CLI Reference
python -m codebrain --help
python -m codebrain index <path> [--watch]
python -m codebrain status
python -m codebrain ask "question" [--language python]
python -m codebrain web
python -m codebrain mcpArchitecture
codebrain/
├── config.py # Configuration loading
├── models.py # CodeChunk / RetrievalResult dataclasses
├── indexer/
│ ├── parser.py # Python AST + regex-based parser for Java/Go/JS/TS
│ ├── embedder.py # sentence-transformers wrapper
│ ├── store.py # ChromaDB wrapper
│ ├── indexer.py # Scan / embed / upsert orchestration
│ └── watcher.py # File-system watcher for incremental updates
├── rag/
│ ├── llm.py # Ollama client
│ └── engine.py # RAG retrieval + generation
├── mcp_server/
│ └── server.py # MCP server implementation
├── web/
│ └── app.py # Gradio chat UI
└── main.py # CLI entry pointNotes
First indexing downloads the embedding model and may take a few minutes.
Make sure Ollama is running before using
ask/web/ MCP tools.The vector store is stored locally in
.codebrain/chroma_dbby default.
License
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityDmaintenanceEnables semantic code search across multiple repositories using natural language queries. Provides intelligent code discovery, symbol lookups, and cross-repo dependency analysis for AI coding agents.Last updatedMIT
- AlicenseAqualityFmaintenanceEnables semantic code search across codebases with automatic incremental indexing. Searches return relevant code snippets with file paths and line numbers based on natural language queries.Last updated1810Apache 2.0
- AlicenseAqualityFmaintenanceProvides code repository indexing and semantic search capabilities, allowing natural language queries to find relevant code snippets with automatic incremental indexing and multi-language support.Last updated129358ISC
- Alicense-qualityCmaintenanceProvides semantic code search and retrieval capabilities for AI agents, enabling them to query codebases using natural language with automatic learning, hybrid search, and intelligent chunking of functions and classes.Last updated3929ISC
Related MCP Connectors
Enterprise code intelligence for M&A, security audits, and tech debt. Hosted server with 200k free.
Search your knowledge bases from any AI assistant using hybrid RAG.
Provide your AI coding tools with token-efficient access to up-to-date technical documentation for…
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/liuwanwan1/CodeBrain'
If you have feedback or need assistance with the MCP directory API, please join our Discord server