内容
# Context Engineering MCP Server
🚀 **一个综合的 MCP server,可以自动执行 Cole Medin 的上下文工程方法,用于创建高质量的产品需求提示 (PRP)。**
[]()
[]()
[]()
[]()
[]()
## 🎯 概述
这个 MCP server 实现了 **[Cole Medin](https://github.com/coleam00)** 在他的 [Context Engineering Introduction repository](https://github.com/coleam00/context-engineering-intro) 中创建的上下文工程方法。它为创建全面的产品需求提示提供了智能自动化,这些提示考虑了您现有的代码库上下文。
### 这个服务器做什么
Context Engineering MCP Server 智能地分析您现有的代码库并自动生成:
- 🔍 基于检测到的模式和框架的**上下文问题**
- 📋 遵循 Cole 方法的**全面的 INITIAL.md** 文档
- 📝 使用经过验证的模板的**产品需求提示** (PRP)
- 🎯 带有代理推荐和任务分解的**执行指南**
- 💾 用于管理 PRP 和项目上下文的**持久存储**
- 🔗 用于无缝任务和知识管理的 **Archon Integration**
### 为什么使用这个服务器?
无需从空白需求文档开始:
1. **分析您现有的代码**以了解架构和模式
2. **提出特定于您的技术堆栈和领域的智能问题**
3. **将见解综合**成全面的文档
4. **生成可操作的 PRP**,这些 PRP 考虑了您当前的上下文
5. **为长期项目管理提供存储和版本控制**
## 📋 MCP 工具 (9 Available)
### 核心上下文工程工具
1. **`list_templates`** - 列出所有可用的 PRP 模板,并可选择类别过滤
2. **`generate_prp`** - 根据模板和项目上下文生成产品需求提示
3. **`validate_prp`** - 根据上下文工程最佳实践验证 PRP
4. **`search_templates`** - 按名称、描述或标签搜索模板
5. **`create_custom_template`** - 创建新的自定义 PRP 模板
6. **`analyze_context`** - 分析项目上下文以推荐合适的模板和改进
### 存储和管理工具
7. **`list_prps`** - 列出所有存储的 PRP,具有过滤和搜索功能
8. **`update_prp`** - 使用版本跟踪更新现有 PRP
9. **`manage_storage`** - 管理存储操作、备份和维护
## 📚 MCP 资源 (5 Available)
- **Templates** (`context-engineering://templates`) - PRP 模板集合
- **Patterns** (`context-engineering://patterns`) - 代码分析模式和规则
- **Initial** (`context-engineering://initial`) - INITIAL.md 生成模板
- **Rules** (`context-engineering://rules`) - 全局上下文工程规则
- **PRPs** (`context-engineering://prps`) - 存储的产品需求提示
## 🚀 快速开始
### 安装
```bash
# Clone the repository
git clone https://github.com/locomotive-agency/context-engineering-mcp.git
cd context-engineering-mcp
# Install dependencies
npm install
# Build the TypeScript code
npm run build
# Start the MCP server
npm start
```
### 演示集成
```bash
# Run the comprehensive demo
node demo-integration.js
```
## ⚙️ Claude Desktop 配置
将此配置添加到您的 Claude Desktop `claude_desktop_config.json`:
```json
{
"mcpServers": {
"context-engineering": {
"command": "node",
"args": ["/path/to/context-engineering-mcp-server/dist/index.js"],
"env": {
"TEMPLATES_DIR": "/path/to/context-engineering-mcp-server/templates",
"EXTERNAL_TEMPLATES_DIR": "/path/to/context-engineering-mcp-server/external/context-engineering-intro",
"DATA_DIR": "/path/to/context-engineering-mcp-server/data"
}
}
}
}
```
### Claude Code 集成
```bash
# Add to Claude Code via MCP
claude-code mcp add context-engineering /path/to/context-engineering-mcp-server/dist/index.js
```
## 🔧 配置选项
### 环境变量
- `TEMPLATES_DIR` - 包含内部模板的目录(默认:`./templates`)
- `EXTERNAL_TEMPLATES_DIR` - Cole 的外部模板的目录(默认:`./external/context-engineering-intro`)
- `DATA_DIR` - 用于持久存储的目录(默认:`./data`)
- `NODE_ENV` - 环境模式(`development`、`production`、`test`)
### 服务器功能
- **Archon Integration** - 与 Archon MCP 自动集成,用于任务和知识管理
- **Version Control** - 具有差异生成的 PRP 的完整版本跟踪
- **Concurrent Operations** - 支持最多 10 个并发存储操作
- **Template Synchronization** - 与 Cole 的上游模板自动同步
## 📖 使用示例
### 基本 PRP 生成
```javascript
// List available templates
const templates = await mcp.call('list_templates', { category: 'web-app' });
// Generate a PRP for a Next.js project
const prp = await mcp.call('generate_prp', {
templateId: 'nextjs-app-template',
projectContext: {
name: 'E-commerce Platform',
domain: 'retail',
stakeholders: ['Product Manager', 'Engineering Team', 'Design Team'],
objectives: ['Build scalable e-commerce platform', 'Implement modern UX'],
constraints: ['Budget: $50k', 'Timeline: 3 months']
},
saveToStorage: true,
outputFormat: 'markdown'
});
```
### 上下文分析工作流程
```javascript
// Analyze project context
const analysis = await mcp.call('analyze_context', {
projectContext: {
name: 'Mobile Banking App',
domain: 'fintech',
description: 'Secure mobile banking application with real-time transactions',
stakeholders: ['Bank Executives', 'Compliance Team', 'Customers'],
constraints: ['PCI DSS Compliance', 'SOX Compliance', 'High Security Requirements']
}
});
// Use recommended template
const prp = await mcp.call('generate_prp', {
templateId: analysis.recommendedTemplates[0].id,
projectContext: analysis.enhancedContext
});
```
### 存储管理
```javascript
// List stored PRPs
const prps = await mcp.call('list_prps', {
category: 'fintech',
status: 'active',
limit: 10
});
// Update a PRP
const updated = await mcp.call('update_prp', {
id: 'prp-123',
updates: {
status: 'completed',
metadata: { version: '2.0' }
},
comment: 'Updated requirements based on stakeholder feedback'
});
```
## 🏗️ 架构
### 传输和协议
- **Protocol**: MCP (Model Context Protocol) v0.6.0
- **Transport**: 用于客户端通信的 StdioServerTransport
- **Security**: 使用 Zod 模式进行输入验证
### 核心组件
#### TemplateManager
- 从内部和外部目录加载模板
- 提供搜索、过滤和分类
- 处理模板验证和缓存
- 与 Cole Medin 的上游存储库同步
#### PRPGenerator
- 从具有上下文替换的模板生成 PRP
- 支持多种输出格式(Markdown、JSON、HTML)
- 处理自定义部分和元数据
- 与存储和版本控制集成
#### StorageSystem
- 用于 PRP 和项目上下文的持久存储
- 具有差异生成的版本跟踪
- 并发操作管理
- 备份和恢复功能
#### IntegrationsManager
- 与 Archon MCP server 无缝集成
- 从 PRP 部分自动创建任务
- 知识同步
- 健康监控和回退处理
### 外部集成
该项目使用 git subtree 来集成 Cole Medin 的原始模板:
```bash
# Sync with upstream templates
./scripts/sync-templates.sh
```
## 🧪 测试
该项目遵循测试驱动开发 (TDD) 原则:
```bash
# Run all tests
npm test
# Run tests with coverage
npm run test:coverage
# Run specific test suites
npm run test:unit # Unit tests
npm run test:integration # Integration tests
npm run test:e2e # End-to-end tests
npm run test:performance # Performance tests
# Watch mode for development
npm run test:watch
```
### 测试覆盖率
- **项目结构测试**:验证目录结构和配置
- **单元测试**:测试单个组件和函数
- **集成测试**:测试 MCP 工具和资源处理程序
- **端到端测试**:测试完整的工作流程
- **性能测试**:在负载和压力条件下进行测试
当前测试状态:**58 tests passing** 具有全面的覆盖率。
## 🛠️ 开发
### 先决条件
- Node.js 18+
- npm 或 yarn
- TypeScript 5.3+
### 开发命令
```bash
# Watch mode for development
npm run dev
# Type checking
npm run type-check
# Linting and formatting
npm run lint
npm run lint:fix
npm run format
npm run format:check
# Validation pipeline
npm run validate # Runs lint + type-check + all tests
# Template synchronization
npm run sync-templates
```
### 项目结构
```
├── src/
│ ├── tools/ # MCP tool implementations (9 tools)
│ │ ├── generate-prp.ts
│ │ ├── validate-prp.ts
│ │ ├── list-templates.ts
│ │ ├── search-templates.ts
│ │ ├── create-custom-template.ts
│ │ ├── analyze-context.ts
│ │ ├── list-prps.ts
│ │ ├── update-prp.ts
│ │ └── manage-storage.ts
│ ├── resources/ # MCP resource handlers (5 resources)
│ │ ├── handlers/
│ │ └── resource-manager.ts
│ ├── lib/ # Core logic components
│ │ ├── template-manager.ts
│ │ ├── prp-generator.ts
│ │ ├── storage.ts
│ │ ├── change-tracker.ts
│ │ ├── integrations.ts
│ │ └── execution-guidance.ts
│ ├── types/ # TypeScript type definitions
│ └── index.ts # Main server entry point
├── templates/ # Internal PRP templates
├── external/ # Git subtree for Cole's templates
│ └── context-engineering-intro/
├── data/ # Persistent storage directory
├── scripts/ # Utility scripts
│ ├── sync-templates.sh # Template synchronization
│ └── test-coverage-report.js
├── test/ # Test suites
│ ├── unit/
│ ├── integration/
│ ├── e2e/
│ └── performance/
└── dist/ # Built JavaScript output
```
## 🤝 贡献
欢迎贡献!这个项目建立在 Cole Medin 的卓越基础上。
### 开发工作流程
1. 遵循 TDD 方法 - 首先编写测试
2. 使用严格模式的 TypeScript
3. 遵循 ESLint 和 Prettier 配置
4. 添加新功能时更新测试
5. 通过 git subtree 保持外部模板同步
6. 确保所有 CI 检查通过
### 代码风格
- 启用 TypeScript 严格模式
- ESLint + Prettier 用于一致的格式
- 全面的类型定义
- 需要广泛的测试覆盖率
- 所有公共 API 的文档
## 🙏 鸣谢和归属
该项目建立在 **[Cole Medin](https://github.com/coleam00)** 创建的出色的上下文工程方法之上:
- **Original Repository**: [context-engineering-intro](https://github.com/coleam00/context-engineering-intro)
- **Methodology**: Cole Medin 的 PRP 生成上下文工程方法
- **Templates**: 通过 git subtree 从 Cole 的存储库集成
- **Inspiration**: Cole 的系统化需求工程方法
### 贡献者
- **[Cole Medin](https://github.com/coleam00)** - 原始上下文工程方法和模板
- **Claude/Anthropic** - MCP server 实现和自动化
- **[croakingtoad](https://github.com/croakingtoad)** - 项目协调和测试
## 📄 许可证
MIT License - 有关详细信息,请参见 [LICENSE](LICENSE) 文件。
该项目包含来自 Cole Medin 的 [context-engineering-intro](https://github.com/coleam00/context-engineering-intro) 存储库的模板和方法,并在开源原则下使用归属。
## 🔗 相关资源
- **[MCP Specification](https://spec.modelcontextprotocol.io/)** - Model Context Protocol 文档
- **[Cole's Context Engineering](https://github.com/coleam00/context-engineering-intro)** - 原始方法
- **[Archon MCP](https://github.com/JakeVdub/archon-mcp)** - 任务和知识管理集成
- **[Claude Desktop](https://claude.ai/download)** - 主要 MCP 客户端
## 📞 支持和问题
- **Issues**: 通过 GitHub Issues 报告错误和功能请求
- **Discussions**: 使用 GitHub Discussions 提出问题和想法
- **Documentation**: `/docs` 目录中的综合文档(即将推出)
---
**由 Locomotive Agency 团队用 ❤️ 制作,建立在 Cole Medin 的卓越基础上**
连接信息
猜你喜欢
X视频文案提取
X / Twitter 视频文案提取 MCP Server — 专注解析 X 平台公开视频链接(x.com / twitter.com status...
MarkItDown
将文件和办公文档转换为Markdown的Python工具。
hyperframes
编写HTML。渲染视频。为代理而建。
claude-flow
Claude-Flow v2.7.0 是一个企业级AI编排平台。
ai-engineering-from-scratch
学习它。构建它。交付给他人。最全面的开源AI工程课程:200多节课程,内容涵盖从线性代数到自主代理集群,支持Python、TypeScript、Rust和Julia。
oh-my-opencode
背景代理 · 精心挑选的代理,如 oracle、librarians、frontend engineer · 预构建工具,如 LSP/AST ·...