- aitools 共用 runtime:list/describe/schema/query/redis(纯只读,无写确认) - 白名单 ~/.opsxdb/mcp.json;审计 mcp-audit.jsonl;复用 danger.go - 桌面 connections 双写 ~/.opsxdb/connections.json(ox1. 解码) - Cursor 配置示例与任务书验收勾选更新;写操作与 Agent UI 留 P1
80 lines
3.0 KiB
Markdown
80 lines
3.0 KiB
Markdown
> **产品形态**:浏览器 = Gin **官网 + 文档**(`:8788`);**操作只走桌面 Tauri**。
|
||
> `src`(`:5174`)仅是桌面 `devUrl`/打包源,**不是**浏览器客户端。
|
||
> AI / 协作规范见 [AGENTS.md](./AGENTS.md)(短入口 [CLAUDE.md](./CLAUDE.md))。
|
||
|
||
# OpsxDB
|
||
|
||
给运维和开发用的 **数据库桌面客户端**(连接管理 / SQL 工作台 / AI 写 SQL)。
|
||
|
||
## 架构
|
||
|
||
```
|
||
src/ React 桌面界面、状态、API 与驱动图标
|
||
src-tauri/ Tauri 2 原生壳、能力配置与本机 sidecar
|
||
server/ Gin 官网/docs + health + 驱动 API(:8788)
|
||
homepage/ 落地页(保持独立)
|
||
connection-types/ 数据库引擎注册表
|
||
agents/ JDBC agent 桥
|
||
```
|
||
|
||
## 怎么跑
|
||
|
||
```bash
|
||
export PATH="$HOME/.nvm/versions/node/v24.19.0/bin:/opt/homebrew/bin:$PATH"
|
||
export OPSXDB_SERVER_PORT=8788 OPSXDB_WEB_PORT=5174
|
||
|
||
npm install
|
||
# npm run dev:Tauri 开发;npm run build:完整桌面包
|
||
# npm run build:ui / npm test:前端构建与测试
|
||
./run.sh web # 仅官网 + docs → http://127.0.0.1:8788/
|
||
./run.sh gui # 桌面操作入口(推荐)
|
||
```
|
||
|
||
```bash
|
||
curl -s http://127.0.0.1:8788/health
|
||
open http://127.0.0.1:8788/ # 官网
|
||
open http://127.0.0.1:8788/docs # 文档
|
||
```
|
||
|
||
## 日常怎么用(桌面)
|
||
|
||
1. `./run.sh gui` → Dock 打开 OpsxDB
|
||
2. **新建连接** → 选类型 / 粘贴 URL → **测试** → **保存并连接**
|
||
3. 左侧对象树点库/表;编辑器 **⌘/Ctrl+Enter** 执行
|
||
4. 结果集:复制 / CSV / 粘贴 / 行删(有主键)
|
||
|
||
## 已做(摘要)
|
||
|
||
- 桌面工作台:对象树、SQL、多 Tab、结果编辑、Redis 键浏览(单机)
|
||
- Redis Sentinel/Cluster:表单 + 后端(真拓扑待环境)
|
||
- 自绘右键(编辑器 / 库·表·键);拦系统菜单
|
||
- Gin 官网 + docs;驱动注册表见 `connection-types/`
|
||
- 新引擎接入并本机验收:Elasticsearch(原生 SQL API)、InfluxDB(原生 HTTP+Flux)、ZooKeeper / MongoDB(JVM agent)、达梦(JDBC agent 桥已验证,待实例)
|
||
- 驱动管理弹框(连接列表页 ⚙):agent 驱动状态/预装/离线包导入/JDK 检测;开源驱动首次连接自动下载到 ~/.opsxdb/drivers/
|
||
|
||
## 端口
|
||
|
||
| 服务 | 端口 | 说明 |
|
||
|------|------|------|
|
||
| Gin 官网/docs/API | 8788 | 浏览器只看站点和文档 |
|
||
| Vite(桌面源) | 5174 | 仅 `gui`/打包用,非产品入口 |
|
||
|
||
## 待开发
|
||
|
||
见 [docs/BACKLOG.md](docs/BACKLOG.md)。AI/MCP 任务书:[docs/15-AI-MCP-Agent.md](docs/15-AI-MCP-Agent.md)。
|
||
|
||
## MCP(P0 只读)
|
||
|
||
外部 Agent(Cursor / Claude Code 等)可通过本机 stdio MCP 安全查库:
|
||
|
||
```bash
|
||
cd server && go build -o ../bin/opsxdb-mcp ./cmd/opsxdb-mcp
|
||
```
|
||
|
||
1. 桌面保存连接后会双写 `~/.opsxdb/connections.json`
|
||
2. 配置 `~/.opsxdb/mcp.json`(见 `docs/mcp.json.example`):`allowed_connection_ids` 为空则拒绝全部
|
||
3. Cursor 配置见 `docs/mcp-cursor.example.json`
|
||
|
||
工具层在 `server/internal/aitools`,内部 Agent(P1)将共用同一 runtime。任务书:`docs/15-AI-MCP-Agent.md`。
|
||
|