实践MCP工作流程
旨在演示应用于实际工程工作流程的人工智能:MCP,RAG和代理。
建筑
┌─────────────────────────────────────────────────────────────┐
│ Microsserviços │
├─────────────────────────────────────────────────────────────┤
│ │
│ billing-service :3001 → Descontos, faturas, pagamentos │
│ orders-service :3002 → Pedidos, checkout, fraude │
│ shipping-service :3003 → Frete, rastreamento │
│ inventory-service :3004 → Estoque, reservas │
│ crm-service :3005 → Clientes, suporte, fidelidade │
│ │
│ notifications-service :3006 → 🔨 A IMPLEMENTAR NO HANDS-ON │
│ │
└─────────────────────────────────────────────────────────────┘快速开始
# Setup completo (docker + install + start)
make all
# Ou passo a passo
make docker-up # Sobe Postgres + Redis
make install # Instala dependências
make start # Inicia serviços
# Verificar status
make status
# Ver comandos disponíveis
make help项目结构
hands-on-mcp-workflow/
├── services/ # Microsserviços NestJS
│ ├── billing-service/ # Descontos, faturas
│ ├── orders-service/ # Pedidos, checkout
│ ├── shipping-service/ # Frete, entregas
│ ├── inventory-service/ # Estoque
│ └── crm-service/ # Clientes, suporte
├── docker/ # Docker Compose + init.sql
├── docs/ # Documentação
│ ├── prd/ # Product Requirements
│ ├── trd/ # Technical Reference
│ ├── rfc/ # Request for Comments
│ ├── adr/ # Architecture Decisions
│ └── diagrams/ # Mermaid diagrams
├── hands-on/ # Guias do hands-on
├── scripts/ # Scripts úteis
├── .claude/skills/ # Agent Skills
├── .cursor/mcp.json # Configuração MCP
├── .github/workflows/ # CI/CD
└── Makefile # Comandos úteis服务
| 服务 | 门 | Swagger | 描述 |
|---|---|---|---|
| 计费服务 | 3001 | /api 折扣,发票,税收。 | |
| 订单服务 | 3002 | /api 订单,付款,欺诈 | |
| 航运服务 | 3003 | /api 运输,跟踪。 | |
| 库存服务 | 3004 | /api 库存,储备。 | |
| 客户关系管理服务 | 3005 | /api 客户,支持,积分 |
RAG - 商业规则
该项目包括 48 商业规则 在 pgvector 中进行语义查询 。
# Listar todas as regras
make rag-list
# Buscar por termo
make rag-search q="desconto"
make rag-search q="vip"
make rag-search q="pagamento"
# Contar por serviço
make rag-count规则示例
| 服务 | 规则 | 影响 |
|---|---|---|
| 结算 | 折扣 > 30% 需要批准 | 高 |
| 订单 | 订单 > R$10k 需要 KYC | 关键 |
| 送货 | VIP + 3 项目 = 免费送货 | 中等 |
| 库存 | 负库存阻碍销售 | 关键 |
| crm | VIP SLA = 2h 支持 | 高 |
MCP(模型上下文协议)
配置
档案 .cursor/mcp.json:
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": { "GITHUB_TOKEN": "${GITHUB_TOKEN}" }
},
"postgres": {
"command": "npx",
"args": ["-y", "mcp-server-postgres",
"postgresql://postgres:postgres@localhost:5432/hands_on_mcp"]
},
"context7": {
"command": "npx",
"args": ["-y", "@context7/mcp-server"]
}
}
}通过MCP使用RAG
> Usando o MCP Postgres, busque regras de negócio sobre clientes VIP代理技能
可用的技能 .claude/skills/:
- 文件编制/ -Gerar PRD、TRD、RFC、ADR
- 代码库阅读器/ 分析代码结构
- 美人鱼发电机/ - 创建图表
- 代码审查/ Code Review 指令
动手
实践就是实施 notifications-service 从零开始,使用:
- 主控程序 阅读问题并创建PRs
- 检索增强生成 查看现有业务规则
- 代理技能 生成文档
规格
版本: 文档/通知-服务-规格.md
指南
- 00-GUIA-COMPLETO.md
- 01-mcp-configuracao.md
- 02-agent-skills.md
- 03-design-docs.md
- 04-rag-规则-业务.md
- 05-工作流程完成.md
- CHEATSHEET.md
Comandos制造
make help # Lista todos os comandos
# Setup
make install # Instalar dependências
make all # Setup completo
# Docker
make docker-up # Subir containers
make docker-down # Parar containers
make db-reset # Recriar banco
# Serviços
make start # Iniciar serviços
make stop # Parar serviços
make status # Verificar status
make restart # Reiniciar
# Testes
make test # Rodar testes
make test-e2e # Testes E2E
make test-api # Testar APIs
# RAG
make rag-list # Listar regras
make rag-search q="termo"
make rag-count # Contar por serviço
# Docs
make swagger # Abrir Swagger
make docs # Gerar documentaçãoCI/CD
GitHub操作配置:
- 构建与测试 - 所有服务
- 生成文档 自动更新文档
- 安全扫描 - 检查秘密 (故意失败演示)
技术
- NestJS -框架Node.js
- PostgreSQL+pgvector 数据库 + RAG
- 瑞迪斯 -缓存
- Docker Compose 本地基础设施
- GitHub操作 -CI/CD
- 昂首阔步 API 文档
- 美人鱼 - 图表
推荐型号
| 任务 | 模型 |
|---|---|
| PRD、TRD、RFC | 克劳德作品4.5 |
| ADR,美人鱼 | 克劳德十四行诗4 |
| RAG查询 | 克劳德作品4.5 |
| 实施 | Claude Opus 4.5 |
