使用说明
MCP后端
Node.js/Express中的REST API,带有Prometheus检测的性能指标,并使用Gemini AI进行自动分析。作为内容管理系统的监控后端构建。
他是做什么的?
- 公开用于身份验证、库和类别的REST端点
- 性能测量仪器 普罗米修斯 (
/metrics) - 使用 API双子星 (
/api/gemini/metrics) - 用于可用性监测的集成健康检查
堆栈
要求
- Node.js>=20
- 运行并可访问MySQL
- 普罗米修斯(包括在
/prometheus-3.5.0.windows-amd64/)
安装
git clone https://github.com/JxsueMd16/MCP_BACKEND.git
cd MCP_BACKEND
npm install
创建新文件 .env 基于根 .env.example:
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=tu_password
DB_NAME=mcp_db
GEMINI_API_KEY=tu_api_key
PORT=3000
电梯工程
1.伊尼西亚普罗米修斯
cd prometheus-3.5.0.windows-amd64\prometheus-3.5.0.windows-amd64
.\prometheus.exe --config.file=prometheus.yml --web.enable-lifecycle
普罗米修斯可用 http://localhost:9090.El目标 http://localhost:3000/metrics 它必须显示为 上.
2. 启动后端
node src/server.js
可用服务器 http://localhost:3000.
端点
健康检查
| 方法 | 路径 | 描述 |
|---|---|---|
GET |
/health |
服务器状态 |
认证
| 方法 | 路线 | 身体 |
|---|---|---|
POST |
/api/auth/register |
{ nombre, usuario, clave } |
POST |
/api/auth/login |
{ usuario, clave } |
图书馆
| 方法 | 路径 | 描述 |
|---|---|---|
GET |
/api/biblioteca/libros |
列出书籍 |
POST |
/api/biblioteca/libros |
图书馆 |
PUT |
/api/biblioteca/libros/:id 更新书籍。 |
|
DELETE |
/api/biblioteca/libros/:id |
删除书 |
GET |
/api/biblioteca/categorias |
列出类别 |
POST |
/api/biblioteca/categorias 创建类别 |
Metricas
| 方法 | 路径 | 描述 |
|---|---|---|
GET |
/metrics |
普罗米修斯格式的指标 |
GET |
/api/gemini/metrics |
使用Gemini AI分析度量 |
结构
MCP_BACKEND/
├── src/
│ └── server.js # Punto de entrada
├── prometheus-3.5.0.windows-amd64/
│ └── prometheus.yml # Configuración de Prometheus
├── .env.example # Variables de entorno requeridas
├── .gitignore
├── package.json
└── README.md