克劳德代码+n8n+MCP集成项目
一个全面的设置集成 n8n工作流自动化 随着 克劳德代码 和 模型上下文协议(MCP)服务器 用于智能项目管理、自动内存转储和人工智能驱动的开发工作流程。
🌟 特性
- 🔄 n8n工作流自动化:用于复杂自动化的可视化工作流生成器
- 🤖 Claude代码集成:支持MCP的AI驱动编码助手
- 💾 持久存储系统:项目状态和知识保存
- 📄 自动倾倒:每日摘要和停机备份
- 🎯 目标目录管理:跨多个目录有组织地生成代码
- 🛠️ 开发工具:自动化、监控和维护脚本
- 🔧 Windows兼容的:针对MINGW64/Git Bash环境进行了优化
📁 项目结构```
my-project-n8n/
├── 📄 README.md # This file
├── 🔧 .env # Environment configuration
├── ⚙️ .mcp.json # MCP server configuration
├── 📦 package.json # Project dependencies and scripts
├── 🚫 .gitignore # Git ignore rules
│
├── 🤖 mcp-servers/ # Custom MCP servers
│ ├── memory-dump-server.js # Memory management server
│ └── package.json # MCP server dependencies
│
├── 🔄 automation/ # Automation scripts
│ ├── auto-dump.sh # Memory dump automation
│ ├── setup-cron.sh # Cron job setup (Linux/Mac)
│ ├── check-dumps.sh # System status checker
│ └── windows-fix.sh # Windows compatibility fixes
│
├── 💾 memory-dumps/ # Automated memory dumps
│ ├── daily-summary-.md # Daily project summaries
│ ├── memory-dump-.md # Full memory dumps
│ └── shutdown-backup-.json # Emergency backups
│
├── 💿 backups/ # Compressed backups
│ └── .json.gz # Timestamped backup files
│
├── 📊 logs/ # System logs
│ ├── project.log # Main project log
│ ├── dump.log # Dump operation log
│ └── cron.log # Cron job logs
│
├── 🗂️ workflows/ # n8n workflow exports
│ └── *.json # Exported n8n workflows
│
└── 🎯 [Target Directories]/ # Code generation targets
├── frontend/ # Frontend applications
├── backend/ # Backend APIs
├── shared/ # Shared libraries
└── docs/ # Documentation
## 🚀 快速开始
### 先决条件
- **Node.js** 18.0.0或更高
- **npm** 8.0.0或更高
- **Git**
- **Claude Pro/团队订阅** (适用于克劳德代码)
- **视窗**:建议使用Git Bash或WSL2
### 1.安装```bash
# Clone or download the project
git clone
cd my-project-n8n
# Install dependencies
npm install
# Run setup scripts
./automation/windows-fix.sh # Windows users
./setup-targets.sh # Set target directories
2.配置环境```bash
Edit .env file with your settings
cp .env.example .env
nano .env
Key settings to update:
- N8N_API_KEY=your_api_key_here
- N8N_BASIC_AUTH_PASSWORD=your_password
- TARGET_PROJECT_DIR=/c/Workspace/MyProject
### 3.启动服务```bash
# Start n8n
npm run start &
# Authenticate Claude Code (one-time setup)
claude auth
claude --dangerously-skip-permissions
# Start Claude Code with MCP
claude
4.验证设置```bash
Check system status
npm run check:dumps
Test MCP servers
claude "/mcp"
Test code generation
claude "Create a simple README.md in the target directory"
## 🔧 配置
### 环境变量(.env)```bash
# Project Configuration
PROJECT_NAME=My Awesome Project
PROJECT_VERSION=1.0.0
# n8n Configuration
N8N_HOST=http://localhost:5678
N8N_API_KEY=your_api_key_here
N8N_BASIC_AUTH_USER=admin
N8N_BASIC_AUTH_PASSWORD=your_secure_password
# Code Generation Targets
TARGET_PROJECT_DIR=/c/Workspace/MyProject
FRONTEND_DIR=/c/Workspace/MyProject/frontend
BACKEND_DIR=/c/Workspace/MyProject/backend
SHARED_DIR=/c/Workspace/MyProject/shared
# Memory & Dumps
MEMORY_FILE=./project-memory.json
DUMP_DIR=./memory-dumps
BACKUP_DIR=./backups
AUTO_DUMP=true
# Automation
CRON_ENABLED=true
DAILY_DUMP_TIME=18:00
BACKUP_INTERVAL=4h
CLEANUP_DAYS=30
# Logging
LOG_LEVEL=info
LOG_FILE=./logs/project.log
MCP服务器(.MCP.json)```json
{
"mcpServers": {
"memory-dump": {
"command": "node",
"args": ["./mcp-servers/memory-dump-server.js"],
"env": {
"MEMORY_FILE": "./project-memory.json",
"DUMP_DIR": "./memory-dumps",
"AUTO_DUMP": "true"
}
},
"filesystem-target": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "${TARGET_PROJECT_DIR}"],
"env": {}
},
"filesystem-current": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "./"],
"env": {}
}
}
}
## 🎯 使用示例
### 项目管理```bash
# Add tasks and track progress
claude "Add todo: Implement user authentication, high priority, due tomorrow"
claude "Update project status to development with 75% progress"
claude "Record decision: Use PostgreSQL for database with rationale: better performance for complex queries"
# Get project insights
claude "Get project overview with details"
claude "What are my next recommended actions?"
claude "Show me all high priority pending tasks"
代码生成```bash
Frontend development
claude "Create a React UserProfile component with TypeScript in the frontend directory"
claude "Generate a responsive dashboard layout in the frontend/src/pages directory"
Backend development
claude "Create Express API routes for user CRUD operations in the backend directory"
claude "Generate Mongoose models for User and Product in the backend/models directory"
Full-stack features
claude "Create a complete authentication system with React frontend, Express backend, and shared TypeScript types"
### n8n工作流集成```bash
# Workflow documentation
claude "Show me available n8n nodes for HTTP requests"
claude "Create a workflow that triggers when a GitHub issue is created and sends a Slack notification"
# Workflow management
claude "List all n8n workflows and their status"
claude "Export the user-registration workflow to the workflows directory"
内存管理```bash
Manual dumps
claude "Create memory dump with type full"
claude "Create daily summary with metrics and tomorrow's plan"
Search and insights
claude "Search memory for 'authentication' across all types"
claude "What decisions have we made about the database?"
claude "Show me recent learnings from the past week"
## 📜 可用脚本```bash
# n8n Management
npm run start # Start n8n server
npm run start:docker # Start with Docker
npm run stop:docker # Stop Docker containers
# Claude Code
npm run claude # Start Claude Code
npm run test:mcp # Test MCP server connections
# Memory & Dumps
npm run dump:manual # Create manual memory dump
npm run dump:daily # Create daily summary
npm run dump:shutdown # Create shutdown dump
# System Management
npm run check:dumps # Check system status
npm run setup:cron # Setup automation (Linux/Mac)
npm run change-target # Change target directory
npm run test:targets # Test target directory access
# Logs
npm run logs:n8n # View n8n logs
npm run logs:project # View project logs
🤖 MCP服务器功能
内存转储服务器
- 项目状态管理:跟踪阶段、进度、里程碑
- 待办事项管理:添加、更新、完成具有优先级的任务
- 知识库:记录决策、学习和见解
- 自动倾卸系统:事件自动记忆保存
- 搜索和分析:在项目历史记录中查找信息
文件系统服务器
- 多目录访问:针对不同的项目领域
- 有组织代码生成:前端、后端、共享代码
- 文件操作:读取、写入、搜索和管理文件
- 项目结构:维护有组织的目录层次结构
🔄 自动化功能
日常自动化
- 下午6点:每日摘要生成
- 晚上11:30:完整内存转储和备份
- 每4小时:增量备份(工作日)
- 周刊:综合项目报告
事件触发的倾倒
- 任务完成:任务标记为完成时自动转储
- 里程碑成就:里程碑综合转储
- 关机检测:系统停机时的紧急转储
- 错误恢复:针对严重错误创建备份
清理和维护
- 日志轮转:自动日志文件管理
- 备份清理:删除超过30天的备份
- 内存优化:压缩旧转储和备份
- 健康监测:系统状态检查和警报
🛠️ 开发工作流程
1.日常发展```bash
Morning: Check project status
npm run check:dumps
claude "Get project overview and next actions"
Development: Use AI assistance
claude "Add todo: Implement password reset feature"
claude "Create React component for password reset form"
Evening: Review and dump
claude "Update project status with today's progress"
npm run dump:daily
### 2.功能开发```bash
# Planning
claude "Add upcoming feature: Real-time notifications with medium priority"
claude "Break down the implementation steps for real-time notifications"
# Implementation
claude "Create WebSocket server in backend for real-time features"
claude "Generate React hooks for WebSocket connection in frontend"
# Completion
claude "Complete task with notes: Real-time notifications implemented successfully"
claude "Record learning: WebSocket implementation requires careful connection management"
3.团队协作```bash
Documentation
claude "Create API documentation for the authentication endpoints"
claude "Generate team update report for the past sprint"
Knowledge Sharing
claude "Record decision: Use Redis for session storage with rationale and alternatives"
claude "Export project report for stakeholder meeting"
## 🚨 故障排除
### 常见问题
#### MCP服务器未连接```bash
# Check MCP status
claude "/mcp"
# Restart Claude Code
# Exit and restart in project directory
cd /path/to/project
claude
n8n不可访问```bash
Check if n8n is running
curl http://localhost:5678/rest/health
Restart n8n
npm run start
#### 文件权限问题```bash
# Fix script permissions
chmod +x automation/*.sh
chmod +x mcp-servers/*.js
# Fix directory permissions
chmod 755 memory-dumps backups logs
Windows路径问题```bash
Run Windows fix script
./automation/windows-fix.sh
Convert paths manually
C:\Workspace\Project -> /c/Workspace/Project
### 调试信息```bash
# System check
./automation/check-dumps.sh
# View logs
tail -f logs/project.log
tail -f logs/dump.log
# Test individual components
node mcp-servers/memory-dump-server.js
curl http://localhost:5678/rest/health
📚 文档
API文档
- n8n API:访问地址
http://localhost:5678/rest/ - MCP协议: 模型上下文协议文档
- 克劳德代码: Claude代码文档
配置文件
.env:环境变量和设置.mcp.json:MCP服务器配置package.json:依赖关系和脚本- 项目记忆:存储在
project-memory.json
生成的文件
- 内存转储:Markdown文件在
memory-dumps/ - 备份:压缩JSON
backups/ - 日志:操作登录
logs/ - 工作流:n8n年出口量
workflows/
🤝 贡献
添加新的MCP服务器
- 在中创建服务器
mcp-servers/目录 - 将配置添加到
.mcp.json - 更新文档
- 使用Claude代码进行测试
扩展自动化
- 将脚本添加到
automation/目录 - 更新
package.json脚本 - README中的文档用法
- 在目标平台上进行测试
改善记忆系统
- 扩展内存转储服务器功能
- 添加新工具功能
- 更新自动转储触发器
- 增强搜索和分析
📄 许可证
此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。
🆘 支持
获取帮助
- 检查文件:查看此README和内联注释
- 运行诊断:使用
npm run check:dumps以及调试脚本 - 检查日志:查看登录
logs/目录 - 社区资源:
- n8n社区
- 人类矛盾
- MCP GitHub
报告问题
报告问题时,包括:
- 系统信息(操作系统、Node.js版本)
- 错误消息和日志
- 重现步骤
- 配置文件(不含敏感数据)
功能请求
改进建议:
- 新的MCP服务器功能
- 其他自动化功能
- 更好的Windows兼容性
- 增强文档
🎉 致谢
- Anthropic 用于Claude Code和MCP协议
- n8n 优秀的工作流自动化平台
- 社区贡献者 用于MCP服务器和工具
- 开放源代码库 这使得这种整合成为可能
快乐编码! 🚀
内置于❤️ 使用n8n、克劳德码和MCP
