be-amsa-reporter-te
README.md
# be-amsa-reporter-te
MCP server that automates a **BE AMSA review** end-to-end. Trigger it in chat with:
> create a backend amsa report
Refactored, optimized and watchdog-guarded successor to `be-amsa-manager-te`. It keeps only
the proven, active automation path, runs the whole multi-minute pipeline on a worker thread
behind a hard timeout (so the chat can never hang), and stages all EFF/report I/O on local
disk to avoid slow SMB round-trips.
## What it does
1. Lists the sub-folders under
`\\Mucsdn31\ATV_Power_Pro\MOSFET_TE\Test_program_status_tracking\Copilot_BE_AMSA\effdata`
and asks which one to analyse.
2. **Validates** the chosen folder: exactly one `.eff` file ending in each of `_S1R1`,
`_S1R2`, `_S2R1`, `_S2R2` (no duplicates). If not, it returns an actionable message.
3. Stages the four EFFs locally and drives **AMSA 5.1**:
- Launches it from a clean slate (kills any stale `GageAnalysis.exe`) and dismisses the
*Precondition failed* popup with **Yes**.
- `File > New` → Setup Dialog → adds the four EFF files with `TestSetup` = 1, 1, 2, 2.
- Sets the option groups (Test ID *by Name and Number*, Device *no further
identification*, Unit *no rescaling* + *dB/log(A) linearisation*, *Override die
coordinates*).
- `Start` → ticks the listed **Test Nr** to exclude → *Continue* → *Continue* → *OK*.
- Reads the results grid, sorts by GrR, **self-calibrates the row geometry**, and for
every test with **GrR ≥ 10 %** ensures both **S** (Scatter) and **P** (Probability)
are marked; unmarks any below threshold. Marks are **verified** and re-tried until
they converge.
- `Configuration > Setup information` → sets each row's *Description* to its EFF file
name (matched by Setup No / Rep No).
- `Results > Write HTML-Report` → writes the report + a `Graphs\` sub-folder of JPGs.
4. Copies the report + Graphs back to the share and builds a **PowerPoint** into
`Copilot_BE_AMSA\generatedppt\<folder>.pptx`:
- Slide 1: `<folder> AMSA Review`
- Slide 2: Data Description (the four EFF file names)
- Slide 3: GrR Summary (`Gr&R > 25 %` and `10 % ≤ Gr&R ≤ 25 %`)
- Slide 4: GrR Summary (all tests) — bar chart with 10 %/25 % red boundary lines
- Slide 5+: one slide per test with GrR ≥ 10 %, scatter + probability JPG + assessment.
## Why it will not hang
The `create_backend_amsa_report` tool only `await`s the folder pick on the event loop; the
entire blocking pipeline runs on a worker thread (`anyio.to_thread.run_sync`). A watchdog
(`BEAR_RUN_TIMEOUT`, default 20 min) wraps the run — on timeout the worker is abandoned,
AMSA is force-killed and a clear `timeout` result is returned. A progress heartbeat
(`BEAR_HEARTBEAT_SECONDS`, default 10 s) reports the current phase so the run never looks
stuck.
## Install
```pwsh
cd C:\Users\maunahan\.copilot\MCPservers\be-amsa-reporter-te
python3.11 -m pip install -r requirements.txt
```
## Registration (`mcp.json`)
Registered in `C:\Users\maunahan\AppData\Roaming\Code\User\mcp.json`:
```jsonc
"be-amsa-reporter-te": {
"type": "stdio",
"command": "C:/Users/maunahan/AppData/Local/Microsoft/WindowsApps/python3.11.exe",
"args": ["-m", "be_amsa_reporter_te.server"],
"cwd": "C:/Users/maunahan/.copilot/MCPservers/be-amsa-reporter-te",
"env": {
"BEAR_BASE_ROOT": "\\\\Mucsdn31\\ATV_Power_Pro\\MOSFET_TE\\Test_program_status_tracking\\Copilot_BE_AMSA",
"BEAR_AMSA_LNK": "C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\AMSA 5.1\\AMSA 5.1.lnk"
}
}
```
Restart the MCP server (Command Palette → *MCP: List Servers* → **be-amsa-reporter-te** →
*Restart*) after any code/config edit — a running server keeps the old modules in memory.
## Configuration
Everything is overridable via `BEAR_*` environment variables (no code changes needed).
Common knobs: `BEAR_MAIN_WINDOW_TITLE_RE`, `BEAR_UI_BACKEND`, `BEAR_EXCLUDE_TEST_NRS`,
`BEAR_GRR_PLOT_THRESHOLD`, `BEAR_GRR_HIGH_THRESHOLD`, `BEAR_RUN_TIMEOUT`,
`BEAR_HEARTBEAT_SECONDS`, and the results-grid geometry / control IDs in `config.py`.
## Modules
- `config.py` — all paths/selectors/tunables from `BEAR_*` env.
- `folders.py` — list + validate effdata folders.
- `amsa_driver.py` — pywinauto automation of AMSA 5.1 (active path only).
- `html_report.py` — parse the generated HTML for Test Nr / name / GrR / limits.
- `ppt_report.py` — build the review PowerPoint from the HTML + `Graphs\` JPGs.
- `server.py` — FastMCP server exposing `create_backend_amsa_report`, worker thread +
watchdog + heartbeat.
This server cannot be deployed
Maintenance
ActivitySlowing
ResponsivenessNo issues