quality-inspection-platform/README.md
qihongkun d810abdcee 初始化仓库:AI 接口自动化测试平台
纳入 FastAPI 后端、Vue 管理端、MCP 桥接与文档;通过 .gitignore 排除本地数据库与构建产物。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-22 15:44:50 +08:00

114 lines
2.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 质量检测平台
一个基于 `FastAPI` 的质量检测平台,提供三类能力:
- 接口定义管理
- Mock 数据管理
- Workflow 流程编排与执行
此外,项目还带了一个 `stdio MCP bridge`,可以把平台里暴露的工具注册成真正的 MCP Server供 Cursor、Claude Desktop、Codex 等客户端调用。
## 技术栈
- Python
- FastAPI
- SQLAlchemy
- Pydantic
- SQLite
- Jinja2
- HTMX
- Drawflow
## 目录结构
```text
app/
main.py FastAPI 入口、页面路由、REST API、MCP HTTP 网关
database.py SQLite engine / session / Base
models.py SQLAlchemy 模型
schemas.py Pydantic 请求与响应模型
services/engine.py Workflow 执行引擎
static/app.js 前端交互逻辑
templates/ Jinja2 页面模板
docs/
mcp_tools_for_ai.md MCP 能力说明AI Agent 首选)
mcp_install.md MCP bridge 安装说明
mcp_quickstart.md MCP 调用说明(人类 / curl
AGENTS.md Codex 等自动加载的项目 Agent 约定
mcp_bridge.py stdio MCP Server 桥接入口
requirements.txt Python 依赖
```
## 安装依赖
建议先进入项目目录,再安装依赖:
```bash
pip install -r requirements.txt
```
如果你使用虚拟环境,也可以先激活 `.venv` 再安装。
## 启动项目
### 方式一:命令行启动后端
```bash
python -m uvicorn app.main:app --host 127.0.0.1 --port 8000 --reload
```
启动后访问:
- 首页:`http://127.0.0.1:8000/`
- API 文档:`http://127.0.0.1:8000/docs`
- MCP 工具列表:`http://127.0.0.1:8000/mcp/tools`
### 方式二:在 PyCharm 里启动
推荐创建一个 `Python` Run Configuration并使用 `Module name` 模式:
- `Module name`: `uvicorn`
- `Parameters`: `app.main:app --host 127.0.0.1 --port 8000 --reload`
- `Working directory`: 项目根目录
注意:`app.main:app` 必须放在 `uvicorn` 后面作为位置参数传入,不能写到最后。
## 启动 MCP Bridge
如果你要把本平台作为 MCP Server 暴露给其他客户端,再额外启动:
```bash
python3 mcp_bridge.py
```
桥接默认读取环境变量:
- `AI_TEST_BASE_URL`,默认值是 `http://127.0.0.1:8000`
完整配置见:
- [`docs/mcp_install.md`](./docs/mcp_install.md)
AI 使用 MCP 前请阅读:
- [`docs/mcp_tools_for_ai.md`](./docs/mcp_tools_for_ai.md)
- 项目根 [`AGENTS.md`](./AGENTS.md)Codex 会自动加载)
## 常用开发命令
```bash
rg --files
rg "workflow_run" app docs
python -m uvicorn app.main:app --host 127.0.0.1 --port 8000 --reload
python3 -m py_compile app/main.py app/services/engine.py mcp_bridge.py
```
## 当前已知情况
- 默认数据库文件是根目录下的 `ai_test.db`
- 项目当前没有现成的 `pytest`、`ruff`、`flake8` 配置
- 前端是模板 + 原生 JS 结构,改动 UI 时通常集中在:
- `app/templates/index.html`
- `app/templates/partials/*.html`
- `app/static/app.js`