使用说明
光标好友MCP
🤖 保持AI代理的上下文感知和一致性
将您的AI助手转变为一个了解项目标准、惯例和历史的上下文感知编码合作伙伴。
🎯 为什么选择Cursor Buddy MCP?
🧠 情境感知AI你的人工智能助手可以立即了解你的编码标准、架构模式和项目惯例 📚 集中的知识所有项目文件和指南都在一个可搜索的位置 ✅ 进度跟踪自动待办事项管理和实施历史跟踪 |
🔄 实时更新文件监控确保您的AI始终拥有最新信息 🚀 零设置摩擦直接与MCP集成的Docker容器 🔍 智能搜索在所有项目环境中快速、相关的结果 |
📋 目录
🏗️ 建筑
graph TB
A[AI Assistant] --> B[MCP Client]
B --> C[Cursor Buddy MCP Server]
C --> D[.buddy Directory]
D --> E[Rules]
D --> F[Knowledge]
D --> G[Todos]
D --> H[Database]
D --> I[History]
D --> J[Backups]
C --> K[Search Engine]
C --> L[File Monitor]
C --> M[Backup Manager]
style A fill:#e1f5fe
style C fill:#f3e5f5
style K fill:#e8f5e8
建立在 模型上下文协议(MCP) 使用Go SDK mark3labs/mcp go.使用JSON-RPC 2.0通过stdin/stdout进行通信,使其与Claude Desktop等MCP客户端兼容。
🎨 特性
| 特性 | 描述 |
|---|---|
| 🔧 工具 | 6个用于管理项目上下文的交互式工具 |
| 📊 资源 | 具有完整项目状态的项目上下文资源 |
| 🔄 标准运输 | 标准输入/输出通信 |
| ⚡ 实时更新 | 具有自动重新加载功能的文件监控 |
| 🔍 全文搜索 | 对所有内容进行Bleve驱动的搜索 |
| 💾 自动备份 | 具有回滚功能的安全文件修改 |
🚀 快速开始
1.️⃣ 从GitHub注册表中提取
docker pull ghcr.io/omar-haris/cursor-buddy-mcp:latest
2.️⃣ 配置光标
增添 .cursor/mcp.json:
⚠️ 重要:替换
/path/to/your/project/使用您的实际项目目录路径!
{
"mcpServers": {
"cursor-buddy-mcp": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-v", "/path/to/your/project/.buddy:/home/buddy/.buddy",
"-e", "BUDDY_PATH=/home/buddy/.buddy",
"ghcr.io/omar-haris/cursor-buddy-mcp:latest"
]
}
}
}
示例:
- Linux/macOS:
"/home/user/myproject/.buddy:/home/buddy/.buddy" - 窗户:
"C:/Users/User/myproject/.buddy:/home/buddy/.buddy" - 当前目录:
"${PWD}/.buddy:/home/buddy/.buddy"
💡 如何找到您的项目路径:
# Navigate to your project directory and run:
pwd
# Copy the output and replace /path/to/your/project/ with: {output}/.buddy
3.️⃣ 创建.baddy结构
导航到项目目录并运行:
mkdir -p .buddy/{rules,knowledge,todos,database,history,backups}
📁 这将创建:
your-project/
├── .buddy/
│ ├── rules/
│ ├── knowledge/
│ ├── todos/
│ ├── database/
│ ├── history/
│ └── backups/
4.️⃣ 添加您的内容
在中创建文件 .buddy/ 以下文件夹 文档 在......下面
🔧 可用工具
📋 buddy_get_rules获取编码标准和指南
🔍 buddy_search_知识搜索项目文档
✅ buddy_manage_todos列出/更新任务并跟踪进度
|
🗄️ buddy_get_database_info获取架构信息并验证查询
📚 兄弟_历史跟踪实施更改和搜索历史记录
💾 buddy_backup创建和管理文件备份
|
💡 使用示例
问你的AI助手一些问题,比如:
| 🎯 类别 | 💬 示例问题 |
|---|---|
| 📋 编码标准 | “我们的错误处理编码标准是什么?” |
| ✅ 项目进度 | “显示身份验证功能的当前待办事项” |
| 📖 文档 | “搜索有关用户终结点的API文档” |
| 🗄️ 数据库 | “用户表的数据库架构是什么?” |
| 📚 历史 | “我们上个月是如何实现JWT身份验证的?” |
| 🔧 建筑 | “我应该为这个功能使用什么设计模式?” |
📚 文档
📋 规则文件
地点:
.buddy/rules/
目的: 定义编码标准、架构模式和指导方针
📝 格式要求
- ✅ 使用markdown格式(
.md) - ✅ 包括元数据:
category和priority - ✅ 组织清晰的章节和小节
🔧 示例:编码标准
Click to expand coding standards example
# Coding Standards
- category: coding
- priority: critical
## Overview
Core coding standards and best practices for the project.
## Go-Specific Standards
- Follow Go naming conventions (camelCase, PascalCase)
- Use `gofmt` for code formatting
- Handle errors explicitly, don't ignore them
- Use interfaces for abstraction
## Error Handling
- Always check and handle errors
- Use structured error types
- Wrap errors with context using `fmt.Errorf`
- Return meaningful error messages
## Testing
- Write unit tests for all public functions
- Use table-driven tests for multiple test cases
- Achieve minimum 80% code coverage
🏗️ 示例:架构模式
Click to expand architecture patterns example
# Architecture Patterns
- category: architecture
- priority: critical
## Design Principles
- **Single Responsibility**: Each component has one reason to change
- **Dependency Inversion**: Depend on abstractions, not concretions
## Recommended Patterns
### Repository Pattern
- Encapsulate data access logic
- Provide consistent interface for data operations
- Enable easy testing with mock implementations
### Layered Architecture
┌─────────────────────┐
│ Presentation │ ← HTTP handlers, CLI
├─────────────────────┤
│ Business Logic │ ← Domain models, use cases
├─────────────────────┤
│ Data Access │ ← Repositories, databases
└─────────────────────┘
📖 知识档案
地点:
.buddy/knowledge/
目的: 存储项目文档、API规范和技术信息
📝 格式要求
- ✅ 使用markdown格式(
.md) - ✅ 包括元数据:
category可选tags - ✅ 标题和示例清晰的结构
🌐 示例:API文档
Click to expand API documentation example
# API Documentation
- category: architecture
- tags: api, rest, authentication
## Authentication Endpoints
### POST /auth/login
**Request:**
```json
{
"email": "user@example.com",
"password": "secure_password"
}
答复:
{
"token": "jwt_token_here",
"user": {
"id": 123,
"email": "user@example.com",
"role": "user"
}
}
获取/验证/我
标题: Authorization: Bearer <token>
答复:
{
"user": {
"id": 123,
"email": "user@example.com",
"role": "user"
}
}
错误处理
所有端点均以以下格式返回错误:
{
"error": "error_code",
"message": "Human readable message"
}
</details>
---
### ✅ Todo Files
> **Location:** `.buddy/todos/`
> **Purpose:** Track tasks, features, and project progress
#### 📝 Format Requirements
- ✅ Use markdown format (`.md`)
- ✅ Use checkbox syntax: `- [ ]` (incomplete) or `- [x]` (complete)
- ✅ Group related tasks under clear headings
- ✅ Include context and details for each task
#### 🔐 Example: Feature Development
<details>
<summary>Click to expand feature development example</summary>
```markdown
# Authentication Feature
## Backend Implementation
- [x] Set up JWT library
- [x] Create user model and database migration
- [x] Implement password hashing with bcrypt
- [ ] Create login endpoint
- [ ] Create registration endpoint
- [ ] Add middleware for protected routes
- [ ] Write unit tests for auth service
- [ ] Add integration tests for auth endpoints
## Frontend Implementation
- [ ] Create login form component
- [ ] Create registration form component
- [ ] Implement JWT token storage
- [ ] Add authentication context
- [ ] Create protected route wrapper
- [ ] Handle token refresh logic
## Security & Testing
- [ ] Add rate limiting to auth endpoints
- [ ] Implement account lockout after failed attempts
- [ ] Add password strength validation
- [ ] Security audit of auth implementation
- [ ] Load testing for auth endpoints
🗄️ 数据库文件
地点:
.buddy/database/
目的: 存储SQL模式定义、迁移和查询示例
📝 示例:架构定义
Click to expand database schema example
-- Users table
CREATE TABLE users (
id SERIAL PRIMARY KEY,
email VARCHAR(255) UNIQUE NOT NULL,
password_hash VARCHAR(255) NOT NULL,
role VARCHAR(50) DEFAULT 'user',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Sessions table for JWT blacklisting
CREATE TABLE sessions (
id SERIAL PRIMARY KEY,
user_id INTEGER REFERENCES users(id) ON DELETE CASCADE,
token_hash VARCHAR(255) UNIQUE NOT NULL,
expires_at TIMESTAMP NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Indexes for performance
CREATE INDEX idx_users_email ON users(email);
CREATE INDEX idx_sessions_token_hash ON sessions(token_hash);
CREATE INDEX idx_sessions_expires_at ON sessions(expires_at);
💎 最佳实践
| 🎯 练习 | 📝 描述 |
|---|---|
| 🔍 具体 | 包括具体示例和代码片段 |
| 🔄 保持更新 | 定期审查和更新您的文件 |
| 📐 格式一致 | 在相似的文件中遵循相同的结构 |
| 💡 包括上下文 | 添加规则或模式存在的原因的解释 |
| 🔗 链接信息 | 参考相关文件或外部文档 |
| 📊 版本控制 | 保持你的 .buddy 版本控制中的文件夹 |
| 🔄 定期评论 | 安排对知识库的定期审查 |
🔧 高级功能
🔍 文件监视
服务器会自动监视您的 .buddy 用于实时更改和重新加载内容的目录。
🔎 搜索集成
使用Bleve全文搜索,在所有项目上下文中快速获得相关结果。
💾 备份管理
在修改之前自动创建重要文件的备份。
🏗️ 可扩展架构
使用Go构建,具有高性能和易于扩展的新工具和功能。
🤝 贡献
我们欢迎捐款!以下是您可以提供帮助的方式:
🎉 准备好开始了吗?
你的人工智能助手现在将对你的代码库有深入的了解,并可以提供一致、知情的回应。
由以下材料制成❤️ 由开发者,为开发者
