DevMind MCP
](https://www.npmjs.com/package/devmind-mcp)  ](https://nodejs.org) ](https://www.npmjs.com/package/devmind-mcp)
用于AI助手的智能上下文感知存储系统
______________________________________________________________________
为什么选择DevMind MCP?
- 纯MCP工具 -通过模型上下文协议与AI助手无缝集成
- 混合搜索 -语义40%+关键词30%+质量20%+新鲜度10%
- 100%私人 -所有数据本地存储在SQLite中,零云传输
- 15个MCP工具 -用于内存管理和代码库索引的完整工具包
- 交叉平台的 -适用于Claude Code、Cursor和所有MCP兼容客户端
______________________________________________________________________
目录
______________________________________________________________________
概述
什么是DevMind MCP?
DevMind MCP提供 持久存储能力 通过模型上下文协议(MCP)为AI助手提供支持。它使人工智能能够记住对话中的上下文,自动跟踪开发活动,并智能地检索相关信息。
主要特点
核心能力
- 基于类型的自动存储器 -基于上下文类型的简化智能记录
- 第1层:自动记录技术执行(bug_fix、feature_add、code_modify)-静默 - 第2层:带通知的自动记录(解决方案、设计、文档)-可以删除 - 第3层:无自动记录(对话、错误)-除非force_remember=true
- 智能存储器 -通过MCP协议实现AI驱动的上下文记录
- 语义搜索 -基于人工智能的向量嵌入搜索,用于查找相关上下文
- 代码库索引 -索引项目文件以进行语义搜索和代码发现
- 永久存储 -基于SQLite的本地存储,完全保密
- 混合搜索 -结合关键字和语义搜索以获得最佳结果
- 实时响应 -在开发过程中记录,立即检索
- 跨工具支持 -与多个MCP客户端和开发环境兼容
- 统一会议 -每个项目一次主要会议,以保持一致的背景
技术特性
- 完全符合MCP协议
- 统一的会话管理(每个项目一个主会话)
- 自动会话重新激活
- 可定制的存储路径和行为
- 高效处理数千种上下文
- 自动清理和内存优化
- 强大的错误处理和恢复
建筑
┌──────────────────────────────────────────────────────────────┐
│ AI Assistant │
│ (Claude Code / Cursor / etc.) │
└────────────────────────┬─────────────────────────────────────┘
│ MCP Protocol (stdio)
▼
┌──────────────────────────────────────────────────────────────┐
│ DevMind MCP Server │
│ ┌─────────────────┐ ┌─────────────────┐ ┌──────────────┐ │
│ │ 15 MCP Tools │ │ Type-Based │ │ Hybrid Search│ │
│ │ │ │ Auto-Memory │ │ │ │
│ │ • Session (4) │ │ │ │ • Semantic │ │
│ │ • Context (6) │ │ │ │ • Keyword │ │
│ │ • Project (3) │ │ • 3 Tiers │ │ • Quality │ │
│ │ • Codebase (2) │ │ • Smart Types │ │ • Freshness │ │
│ │ • Visualize (1) │ │ • Lazy Scoring │ │ │ │
│ └─────────────────┘ └─────────────────┘ └──────────────┘ │
└────────────────────────┬─────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────┐
│ SQLite Local Storage │
│ Projects • Sessions • Contexts • Relationships • Embeddings │
│ + Auto-generated quality scores (lazy update every 24h) │
└──────────────────────────────────────────────────────────────┘关键部件:
- 15个MCP工具 -会话管理(4)、上下文操作(6)、项目功能(3)、代码库索引(2)、可视化(1)
- 基于类型的自动存储器 -基于上下文类型的简化三层策略
- 混合搜索 -多维评分:语义40%+关键词30%+质量20%+新鲜度10%
- 本地存储 -带向量嵌入和全文搜索索引的SQLite数据库
项目结构
devmind-mcp/
├── src/
│ ├── mcp-server.ts # MCP protocol server
│ ├── database.ts # SQLite storage engine
│ ├── vector-search.ts # Semantic search with embeddings
│ ├── session-manager.ts # Session & context management
│ ├── pending-memory-tracker.ts # Unrecorded file tracking (v2.2.6+)
│ ├── content-extractor.ts # Code analysis & extraction
│ ├── content-quality-assessor.ts # Content quality scoring
│ ├── quality-score-calculator.ts # Multi-dimensional quality scoring
│ ├── auto-record-filter.ts # Smart deduplication
│ ├── context-file-manager.ts # File change tracking
│ ├── performance-optimizer.ts # Performance optimizer (v2.2.0+)
│ ├── search-cache.ts # Search cache
│ ├── smart-confirmation-system.ts # Smart confirmation system
│ ├── types.ts # Type definitions
│ ├── index.ts # Main entry point
│ │
│ ├── memory-graph/ # Memory graph visualization
│ │ ├── index.ts # Main graph generator
│ │ ├── types.ts # Graph type definitions
│ │ ├── data/
│ │ │ ├── GraphDataExtractor.ts # Data extraction from database
│ │ │ ├── NodeBuilder.ts # Node construction & labeling
│ │ │ └── EdgeBuilder.ts # Edge/relationship building
│ │ └── templates/
│ │ ├── HTMLGenerator.ts # HTML visualization generator
│ │ └── HTMLGeneratorCytoscape.ts # Cytoscape graph generator
│ │
│ ├── context-engine/ # Codebase indexing engine
│ │ ├── index.ts # ContextEngine main entry
│ │ ├── FileScanner.ts # File scanning and filtering
│ │ ├── IgnoreProcessor.ts # .gitignore and .augmentignore rules
│ │ └── types.ts # Type definitions
│ │
│ ├── utils/
│ │ ├── file-path-detector.ts # Intelligent file detection
│ │ ├── git-diff-parser.ts # Git diff parsing
│ │ ├── path-normalizer.ts # Cross-platform path handling
│ │ ├── project-root-finder.ts # Project root finder (v2.1.11+)
│ │ ├── language-detector.ts # Programming language detection
│ │ ├── query-enhancer.ts # Search query enhancement (v2.2.0+)
│ │ ├── auto-memory-classifier.ts # Auto memory classification (v2.2.0+)
│ │ ├── context-enricher.ts # Context enrichment (v2.2.0+)
│ │ ├── batch-processor.ts # Batch processor (v2.2.0+)
│ │ └── performance-optimizer.ts # Performance optimization (v2.2.0+)
│
├── dist/ # Compiled output
├── scripts/ # Maintenance scripts
├── docs/zh/ # Chinese documentation
└── tests/ # Test files______________________________________________________________________
快速开始
先决条件
- Node.js ≥ 20.0.0
- MCP兼容客户端 (克劳德代码、光标等)
安装
选择适合您需求的方法:
| 方法 | 命令 | 最适合 | 自动更新 |
|---|---|---|---|
| NPX | npx -y devmind-mcp@latest | 快速测试,首次使用 | 是 |
| 全局安装 | npm install -g devmind-mcp | 日常发展 | 否 |
| 来自源头 | git clone + npm install | 贡献、定制 | 否 |
逐步设置
步骤1:添加到MCP客户端
选项A:使用Claude Code CLI(最简单)
# Install latest version
claude add mcp npx -y devmind-mcp@latest
# Or install specific version
claude add mcp npx -y devmind-mcp@2.4.1选项B:手动配置
编辑MCP客户端配置文件:
配置文件位置:
- 视窗:
C:\Users\\.claude.json或%USERPROFILE%\.claude.json - macOS:
~/.claude.json - Linux:
~/.claude.json
添加此配置:
{
"mcpServers": {
"devmind": {
"command": "npx",
"args": ["-y", "devmind-mcp@latest"]
}
}
}使用全局安装? 替换为: {"command": "devmind-mcp"}
步骤2:重新启动MCP客户端
重新启动Claude Code或MCP客户端以加载DevMind。
第三步:尝试你的第一个命令
在您的AI助手中,尝试:
“使用semantic_search查找有关身份验证的信息”
完成! DevMind现在正在用持久记忆增强你的人工智能。
后续步骤
______________________________________________________________________
AI应该如何使用DevMind
在每个开发会话中遵循以下步骤:
- 会话初始化
- 先打个电话 get_current_session 或者让它自动创建 - 说出“正在检查内存…”并拨打电话 list_contexts(limit: 5)
- 在开发过程中
- 关键的:呼叫 record_context 编辑文件后立即 - 使用类型:bug_fix、feature_add、code_modify(基于工作类型) - 内容必须使用项目语言(中文/英文)
- 在完成任务之前
- 在说“完成”或“完成”之前进行记录 - 使用 files_changed 用于多文件修改
- 当用户询问历史记录时
- 使用 semantic_search 用于智能查询 - 使用 list_contexts 按时间顺序浏览 - 使用 get_context 查看完整详细信息
______________________________________________________________________
使用指南
MCP工具快速参考
DevMind提供 15个强大的工具 对于您的AI助手:
代码库索引
| 工具 | 目的 | 示例使用 |
|---|---|---|
codebase | 为语义搜索的项目文件建立索引 | 为整个代码库建立索引 |
delete_codebase_index | 删除项目的代码库索引 | 清理索引文件 |
备注:The codebase 工具支架 .gitignore 和 .augmentignore 排斥模式。它还包括自动排除常见目录的内置默认值,如 node_modules/, dist/, build/, .git/,以及更多。
项目管理
| 工具 | 目的 | 示例使用 |
|---|---|---|
list_projects | \[推荐\]列出所有带有统计数据的项目 | 概述跟踪的项目 |
cleanup_empty_projects | 清理没有记忆的空项目 | 删除未使用的项目记录 |
会话管理
| 工具 | 目的 | 示例使用 |
|---|---|---|
create_session | 开始新的开发会话 | 开始新功能 |
get_current_session | 获取活动会话信息 | 检查当前上下文 |
end_session | 结束开发会议 | 完成工作 |
delete_session | 删除会话和所有上下文 | 清理旧会话 |
备注:DevMind自动管理每个项目的一个主会话。会话会在需要时自动创建,并在对话中重新激活。
上下文操作
||工具|目的|示例使用| ||------------------|-----------------------------|------------------------| || record_context |存储开发上下文|保存错误修复解决方案| || list_contexts |列出所有上下文|查看项目历史记录| || delete_context |删除特定上下文|删除过时信息| || update_context |更新上下文内容/标签|优化文档|
搜索与发现
||工具|目的|示例使用| ||-------------------|-------------------------------|------------------------------| || semantic_search |基于人工智能的语义搜索|查找相关实现| || get_context |按ID获取上下文|查看完整内存内容|
备注:嵌入是在record_context上自动生成的。在搜索过程中,质量分数每24小时自动更新一次(延迟加载)。
可视化
| 工具 | 目的 | 示例使用 |
|---|---|---|
export_memory_graph | 导出交互式时间线图(v1.19) | 在6列类型的垂直时间线中可视化内存 |
v1.19中的新功能:内存图具有干净的垂直时间线布局,具有固定的节点定位和优化的性能。
ContextEngine(v2.4.9中的新功能)
ContextEngine是一个强大的代码库索引系统,可以自动扫描和索引整个项目,以进行智能搜索和代码发现。
主要特点
- 全面的文件扫描 -递归扫描所有项目文件,支持20多种编程语言
- 智能过滤 -自动应用忽略规则以排除不相关的文件和目录
- 增量索引 -仅基于SHA-256哈希重新索引更改的文件以提高效率
- 独立存储 -使用单独
file_index避免污染开发内存的表 - 二进制文件检测 -自动跳过二进制文件(图像、可执行文件等)
- 语言检测 -自动检测和分类编程语言
运作原理
Project Directory
│
▼
┌─────────────────────┐
│ FileScanner │ 1. Recursively scan all files
│ │ 2. Apply ignore rules
│ - Recursive scan │ 3. Detect file types
│ - File filtering │ 4. Skip binaries
└─────────────────────┘
│
▼
┌─────────────────────┐
│ IgnoreProcessor │ 1. Apply ignore rules
│ │ 2. Filter files
│ - Smart filtering │
└─────────────────────┘
│
▼
┌─────────────────────┐
│ Database Storage │ 1. Store in file_index table
│ │ 2. Generate file hashes
│ - file_index │ 3. Index for search
│ - SHA-256 hashes │
└─────────────────────┘默认排除
ContextEngine会自动排除常见目录和文件:
- 版本控制:
.git/,.svn/,.hg/ - 依赖项:
node_modules/,vendor/,.composer/ - 构建输出:
dist/,build/,out/,.next/,.vite/,target/ - 日志和温度:
*.log,*.tmp,*.temp,.DS_Store,Thumbs.db - IDE文件:
.vscode/,.idea/,*.swp - 覆盖:
coverage/,.nyc_output/,.pytest_cache/
使用示例
// Index your entire codebase
await codebase({
project_path: "/path/to/my-project"
});
// Force re-index all files
await codebase({
project_path: "/path/to/my-project",
force_reindex: true
});
// After indexing, use semantic_search to query
const results = await semantic_search({
query: "How is authentication implemented?",
project_path: "/path/to/my-project"
});与语义搜索集成
一旦被索引,ContextEngine文件就会自动包含在 semantic_search 结果与开发记忆上下文一起。这使得AI助手能够:
- 在代码库中查找特定的实现
- 了解项目的不同部分是如何协同工作的
- 从实际文件中检索代码模式和示例
- 回答有关项目架构的问题
使用示例
存储上下文信息
// Store development context
await record_context({
content: "Implemented user authentication using JWT tokens with refresh token support",
type: "implementation",
tags: ["auth", "jwt", "security", "api"]
});搜索和检索
// Find relevant contexts
const results = await semantic_search({
query: "How did we implement authentication?",
limit: 10
});更新现有上下文
// Update context with new information
await update_context(contextId, {
content: "Updated authentication to support OAuth2 and SAML",
tags: ["auth", "jwt", "oauth2", "saml", "security"]
});上下文搜索
// Search within specific timeframe
const results = await semantic_search({
query: "database optimization",
timeRange: { days: 7 }
});______________________________________________________________________
配置
基本配置(可选)
DevMind使用合理的默认值开箱即用。配置为 完全可选.
如果要自定义行为,请创建 .devmind.json 在项目根目录中:
{
"database_path": "~/.devmind/memory.db",
"quality_threshold": 0.3,
"embedding_model": "local",
"auto_save_interval": 30000,
"ignored_patterns": [
"node_modules/**",
".git/**",
"dist/**",
"build/**"
],
"included_extensions": [
".js",
".ts",
".py",
".go"
]
}配置选项
| 选项 | 类型 | 默认值 | 描述 |
|---|---|---|---|
database_path | 字符串 | ~/.devmind/memory.db | SQLite数据库文件位置 |
quality_threshold | 编号 | 0.3 | 上下文存储的最低质量分数 |
embedding_model | 字符串 | "local" | 向量搜索的嵌入模型 |
auto_save_interval | 编号 | 30000 (30秒) | 自动保存间隔(毫秒) |
ignored_patterns | string\[\] | 见上面的示例 | 要忽略的Glob模式 |
included_extensions | string\[\] | 见上面的示例 | 要包含的文件扩展名 |
推荐的系统提示配置
为确保AI助手自动记录开发上下文,请将其添加到您的系统提示配置中(例如,Kiro指导文件、Claude Desktop配置):
## Core Responsibility
AI assistants should immediately call the record_context tool after each code edit to ensure all changes are properly recorded in the project memory.为什么这是必要的:
- MCP工具不能强制AI行为-需要系统提示
- 这确保了所有开发任务中100%的记录可靠性
- 适用于任何兼容MCP的客户端(Kiro、Claude代码、Cursor等)
完整MCP配置示例
使用NPX(推荐):
{
"mcpServers": {
"devmind": {
"command": "npx",
"args": ["-y", "devmind-mcp@latest"]
}
}
}全球安装:
{
"mcpServers": {
"devmind": {
"command": "devmind-mcp"
}
}
}重要:配置更改后重新启动MCP客户端。
______________________________________________________________________
API 参考
核心方法
record_context(context: ContextData): Promise
存储新的上下文信息。
参数:
content(string)-主要内容文本type(string)-内容类型:solution,code,error,documentation,test,configurationtags(string\[\])-关联标签metadata(对象)-附加元数据
退货: 上下文ID字符串
例子:
const id = await record_context({
content: "Fixed memory leak in WebSocket connection handler",
type: "solution",
tags: ["websocket", "memory-leak", "bug-fix"]
});______________________________________________________________________
codebase(options: CodebaseOptions): Promise
将项目文件索引到内存中以进行语义搜索。
参数:
project_path(string)-要索引的项目目录的路径force_reindex(boolean)-强制重新索引所有文件(默认值:false)
退货: 统计索引结果
例子:
// Index a project
const result = await codebase({
project_path: "./my-project",
force_reindex: true
});______________________________________________________________________
delete_codebase_index(options: DeleteIndexOptions): Promise
删除项目的代码库索引。
参数:
project_path(string)-要删除索引的项目目录的路径
退货: 删除带有统计信息的结果
例子:
// Delete project index
const result = await delete_codebase_index({
project_path: "./my-project"
});______________________________________________________________________
semantic_search(query: SearchQuery): Promise
使用语义理解搜索相关上下文。
参数:
query(string)-搜索查询limit(数字)-最大结果(默认值:20)type(string)-按内容类型筛选tags(string\[\])-按标签筛选timeRange(对象)-时间范围过滤器:{ days: 7 }
退货: 匹配上下文数组
例子:
const results = await semantic_search({
query: "authentication implementation",
limit: 10,
type: "implementation"
});______________________________________________________________________
update_context(id: string, updates: Partial): Promise
更新现有上下文。
例子:
await update_context(contextId, {
tags: ["websocket", "memory-leak", "bug-fix", "resolved"]
});______________________________________________________________________
delete_context(id: string): Promise
按ID删除上下文。
______________________________________________________________________
cleanup_empty_projects(options?: CleanupOptions): Promise
清理没有相关内存的空项目记录。
参数:
dry_run(boolean)-预览要删除的项目,但不实际删除(默认值:true)
退货: 清理结果对象
例子:
// Preview empty projects to be deleted
const preview = await cleanup_empty_projects({ dry_run: true });
console.log(`Will delete ${preview.deleted_count} empty projects`);
// Actually delete empty projects
const result = await cleanup_empty_projects({ dry_run: false });
console.log(`Deleted ${result.deleted_count} empty projects`);______________________________________________________________________
实用方法
cleanup(): Promise
执行数据库清理和优化。
stats(): Promise
获取数据库统计信息和健康信息。
export(format: 'json' | 'csv'): Promise
将所有上下文导出为指定格式。
______________________________________________________________________
用例
软件开发
- 跟踪实施决策和技术选择
- 在开发会议中保持上下文
- 存储和检索代码模式和代码段
- 用基本原理记录架构决策
研究与学习
- 从多个来源积累知识
- 在相关概念之间建立联系
- 在数周或数月内保持研究背景
- 创建可搜索的个人知识库
项目管理
- 跟踪项目进展和关键决策
- 在团队会议中保持上下文
- 存储与项目相关的见解和经验教训
- 记录尸检和回顾
AI助手增强
- 为AI对话提供持久内存
- 启用基于历史的上下文感知响应
- 维护用户偏好和项目细节
- 支持与人工智能建立长期关系
______________________________________________________________________
发展
设置
# Clone repository
git clone https://github.com/JochenYang/Devmind.git
cd Devmind
# Install dependencies
npm install
# Development mode with watch
npm run dev
# Run tests
npm test
# Type checking
npm run type-check
# Linting
npm run lint贡献
我们欢迎对DevMind MCP的贡献!请按照以下步骤操作:
开发过程
- 分叉 存储库
- 创建 特征分支:
git checkout -b feature/amazing-feature - 提交 您的更改:
git commit -m 'Add amazing feature' - 推 分支机构:
git push origin feature/amazing-feature - 打开 拉取请求
代码规范
- 遵循TypeScript的最佳实践
- 保持测试覆盖率在80%以上
- 使用常规提交消息
- 记录所有公共API
- 为新功能添加测试
______________________________________________________________________
📄 许可证
该项目根据MIT许可证获得许可。看 许可证 文件以获取详细信息。
______________________________________________________________________
🔗 支持
- 问题:
- 讨论:
- NPM包: devmind mcp
______________________________________________________________________
DevMind MCP -AI助手的智能上下文感知内存
由...制作❤️ 通过 约亨
