local-brain-mcp
🧠 local-brain-mcp
面向 Claude Code、Cursor、Copilot 和 Windsurf 的本地优先、零延迟、Git 感知的 AI 记忆。
无云端。无 API 密钥。无隐私风险。亚 5 毫秒召回。
为什么选择 local-brain?
云端 AI 记忆工具的问题 | local-brain 的解决方案 |
🐌 每次召回 150–800 毫秒网络延迟 | ⚡ < 5 毫秒 — 本地 SQLite 向量搜索 |
☁️ 你的代码被发送到外部服务器 | 🔒 100% 设备本地运行,零数据外发 |
💸 每次会话的 Token 膨胀 | 📦 每次召回硬性 250 Token 预算上限 |
🗑️ 旧决策带来的过时上下文 | 🔄 Git 差异失效机制将旧记忆标记为 STALE |
🌊 WIP/拼写错误提交污染记忆库 | 🎯 常规提交过滤器只保留高信号经验 |
🏗️ 跨包的 Monorepo 噪音 | 🎯 路径作用域查询,按包命名空间隔离 |
Related MCP server: Heimdall MCP Server
快速开始
# 1. Install
npm install -g local-brain-mcp
# 2. Init — auto-detects Claude Code, Cursor, Copilot, Windsurf
npx local-brain init
# 3. Ingest your git history
cd /path/to/your-project
npx local-brain ingest
# 4. Restart your AI editor — the MCP tools are now availableMCP 工具
brain_recall
对代码库记忆进行语义搜索。结果上限为 250 Token。
{
"query": "JWT auth bug",
"file_path": "src/auth/jwt.ts",
"max_items": 5,
"category": "fix"
}输出示例:
## Brain Recall: "JWT auth bug"
• [src/auth/jwt.ts @ 8a4f12] (fix): JWT refresh race condition — RS256 cert rotates every 24h. Never use HS256 in dev.
• [src/auth/session.ts @ c31d04] (bug): Sessions expire silently on Tuesdays 02:00 UTC — auth service maintenance window.brain_learn
手动存储一条经验或团队约定。
{
"lesson": "Always seed the test DB before running Playwright tests or auth flows break.",
"category": "convention",
"file_path": "tests/setup.ts"
}brain_trace
查看特定文件所有记忆的完整历史。
{
"file_path": "src/db/client.ts"
}brain_prune
移除过期/废弃的记忆。可选地运行完整的 Git 失效检查。
{
"status": "stale",
"run_invalidation": true
}CLI 命令
local-brain init # setup wizard — writes MCP config for all detected editors
local-brain ingest # scan git history and build the brain DB
local-brain ingest --since "6 months ago" --verbose
local-brain status # show DB memory counts
local-brain prune --invalidate # detect + remove stale memories工作原理
git history
↓
[git-ingest.ts] — filters WIP/typo/format commits
↓
[embeddings.ts] — pure-JS TF-IDF feature hashing (sub-1ms, zero network)
↓
[db.ts] — stores in .git/brain.db (Float32Array BLOB vectors in SQLite)
↓ (on file change)
[invalidation.ts] — marks stale if file changed > 30%
↓ (on MCP tool call)
[recall.ts] — in-memory cosine similarity search, scoped to package, capped to 250 tokens
↓
Claude Code / Cursor / Copilot / Windsurf / Zed支持的编辑器
编辑器 | 自动检测配置 |
Claude Code |
|
Cursor |
|
Windsurf |
|
VS Code Copilot |
|
Zed |
|
技术栈
协议:
@modelcontextprotocol/sdk(StdioServerTransport)存储:
better-sqlite3(SQLite WAL 模式,支持 BLOB 向量)嵌入: 纯 JS TF-IDF 特征哈希(384 维,亚 1 毫秒,100% 离线)
Git 引擎:
simple-gitCLI 引擎:
commander
许可证
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
AlicenseNot gradedqualityCmaintenanceProvides persistent memory for AI coding assistants, storing and retrieving architectural decisions, patterns, and solutions across sessions using semantic search, while also offering git integration for commit messages and code expertise mapping.MIT- AlicenseNot gradedqualityDmaintenanceProvides AI coding assistants with persistent, context-rich memory of a codebase, including documentation and git history, enabling recall across sessions.104Apache 2.0
- AlicenseAqualityAmaintenanceProvides persistent memory and a codebase knowledge graph for AI coding assistants, enabling shared context across multiple tools like Claude, Cursor, and ChatGPT, with significant token reduction.525MIT
- AlicenseNot gradedqualityAmaintenanceGives AI coding assistants persistent project memory and semantic code search, running fully locally with no API keys required.MIT
Related MCP Connectors
Your company's brain for AI agents. Cited, permission-aware knowledge across every system.
Give your AI agent a persistent map of your project's structure, dependencies, and bugs.
Git-backed platform for skills, tools, and context for AI agents
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/cosmiccoder200x-sys/local-brain-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server