vertexAI-供应链风险代理
一个使用Claude AI和模型上下文协议(MCP)的智能库存管理系统,用于自动化机械制造的供应链监控。
特性
- 🤖 人工智能聊天界面 -库存数据的自然语言查询
- 📊 实时监控 -低库存商品的自动警报
- 💬 持久内存 -跨会话的上下文感知对话
- ⚡ MCP集成 -基于工具的数据库和API安全访问
技术栈
- 后端:Node.js、TypeScript、Express
- 前端:React、Vite
- 数据库:PostgreSQL
- 人工智能:Claude API(Anthropic),模型上下文协议
- 基础设施:Docker
建筑
┌─────────────────┐
│ Web UI │ React + Vite
└────────┬────────┘
│
▼
┌─────────────────┐
│ Agent Service │ Express + Claude API
└────────┬────────┘
│
▼
┌─────────────────┐
│ MCP Server │ Inventory Tools
└────────┬────────┘
│
▼
┌─────────────────┐
│ PostgreSQL │ Inventory + Agent DBs
└─────────────────┘先决条件
- Node.js 18+
- Docker&Docker编写
- 无烟煤API密钥(在这里买一个)
安装
1.克隆存储库
git clone https://github.com/SukhuChiku/vertexAI
cd vertex2.安装依赖项
# Install dependencies for all services
cd mcp-server && npm install
cd ../agent-service && npm install
cd ../web-ui && npm install
cd ..3.设置环境变量
# Copy example env files
cp mcp-server/.env.example mcp-server/.env
cp agent-service/.env.example agent-service/.env
cp web-ui/.env.example web-ui/.env
# Edit the .env files and add your credentials
# IMPORTANT: Add your Anthropic API key in agent-service/.env所需的环境变量:
ANTHROPIC_API_KEY-从 拟人控制台DB_PASSWORD-PostgreSQL密码(默认值:your_vertex_password)
4.启动PostgreSQL
docker-compose up -d等待PostgreSQL初始化10秒。
5.运行数据库迁移
# Inventory database
cd mcp-server
npm run migrate
npm run seed
# Agent database
cd ../agent-service
npm run migrate6.启动服务
打开3个终端窗口:
1号航站楼-代理服务:
cd agent-service
npm run dev终端2-Web用户界面:
cd web-ui
npm run dev终端3-验证一切是否正在运行:
# Check database
docker exec -it vertex-postgres psql -U vertex -d vertex_inventory -c "SELECT COUNT(*) FROM parts;"
# Should show: 16 parts7.访问应用程序
打开浏览器: http://localhost:3000
试着问:
- “目前哪些零件库存不足?”
- “告诉我关于JIG-001部分的情况”
- “给我看看所有钢制部件”
项目结构
vertex/
├── mcp-server/ # MCP Server for inventory tools
│ ├── src/
│ │ ├── tools/ # MCP tool implementations
│ │ ├── db/ # Database client and migrations
│ │ └── index.ts # MCP server entry point
│ └── package.json
│
├── agent-service/ # Main AI agent backend
│ ├── src/
│ │ ├── routes/ # Express routes (chat, alerts)
│ │ ├── services/ # Agent orchestration, memory
│ │ ├── mcp/ # MCP client
│ │ └── index.ts # Express server
│ └── package.json
│
├── web-ui/ # React frontend
│ ├── src/
│ │ ├── components/ # Chat, Alerts, Dashboard
│ │ ├── api/ # API client
│ │ └── App.tsx # Main app component
│ └── package.json
│
└── docker-compose.yml # PostgreSQL setup可用的MCP工具
该系统包括6个库存管理工具:
- get_inventory_levels -获取当前库存水平
- get_part_details -获取详细的零件信息
- 搜索零件 -按描述或编号搜索零件
- get_low-stock_items -查找低于再订购点的零件
- get_sumption_history -分析使用趋势
- update_reorder_point -修改重新排序阈值
发展
为生产而建
# Build MCP server
cd mcp-server && npm run build
# Build agent service
cd ../agent-service && npm run build
# Build web UI
cd ../web-ui && npm run build数据库管理
# View tables
docker exec -it vertex-postgres psql -U vertex -d vertex_inventory -c "\dt"
# Reset database
docker-compose down -v
docker-compose up -d
cd mcp-server && npm run migrate && npm run seed故障排除
端口5432已在使用中
如果你有另一个PostgreSQL正在运行:
# Check what's using port 5432
lsof -i :5432
# Stop local PostgreSQL (if using Homebrew)
brew services stop postgresql
# Or kill the process
kill
MCP工具不工作
# Verify MCP server can connect to database
cd mcp-server
npx tsx test-tools.ts代理服务启动失败
检查:
- PostgreSQL正在运行:
docker ps | grep postgres .env文件存在于agent-service/ANTHROPIC_API_KEY设置正确- 没有其他服务正在使用端口4000
安全说明
⚠️ 用于生产用途:
默认数据库密码(your_vertex_password)只适合当地发展。
对于生产部署:
- 在PostgreSQL中更改数据库密码
- 集
DB_PASSWORD在你的.env文件 - 永远不要将PostgreSQL端口5432暴露在互联网上
- 使用强大、唯一的密码
未来的增强功能
- \[\]添加供应商MCP服务器进行供应商管理
- \[\]实施RAG进行历史模式分析
- \[\]添加多代理编排(LangGraph/CrewAI)
- \[\]关键警报的电子邮件/Slack通知
- \[\]采购订单生成和审批工作流程
- \[\]用于多模型支护的AWS基岩集成
贡献
欢迎拉取请求!对于重大更改,请先打开一个问题来讨论您想要更改的内容。
许可证
麻省理工学院
