floorpilot-mcp
by iyervijay21
README.md
# FloorPilot
**Ask a warehouse floor what happened.** FloorPilot is a small crew of agents that answers questions such as
*"Send me the safety report for yesterday"* or *"What happened in the walkway this morning?"* from indoor
positioning (RTLS) data of forklifts and people. The agents work through an **MCP server** of spatial
analytics tools and follow **skills** (one `SKILL.md` per task). Every number in an answer is checked
against the tool results before it is shown or emailed.
No vendor platform underneath: positions live in SQLite, zones are polygons, and the analytics
(near misses, speeding per zone, walkway intrusions, hotspots, trip times) are plain NumPy.
A simulator generates realistic shifts so everything runs on a laptop.
```mermaid
flowchart LR
Q([question]) --> R[Router<br/>picks a skill]
R --> S[(skills/*/SKILL.md<br/>triggers · tools · writing rules)]
R --> A[Analyst<br/>clock → time window,<br/>zone, entity]
A -- MCP tool calls --> M[[floorpilot-mcp<br/>current_time · fleet_kpis · near_misses<br/>speed_violations · zone_intrusions<br/>zone_activity · trip_times · hotspots]]
M --> DB[(SQLite positions<br/>1 Hz RTLS)]
A --> W[Writer<br/>LLM or template]
W --> C{Checker<br/>every number<br/>in evidence?}
C -- yes --> O[markdown · PDF with floor map · email]
C -- no --> W2[template answer<br/>replaces LLM draft]
W2 --> O
```
## Quick start
```bash
pip install -e ".[dev]"
floorpilot simulate --db floor.db --start 2026-12-01 --days 2 # 2 shifts, 4 forklifts, 8 people
floorpilot ask "Send me the safety report for yesterday" --db floor.db --email ops@example.com
floorpilot ask "What happened in the Walkway yesterday?" --db floor.db
floorpilot ask "How busy was Aisle A in the last shift?" --db floor.db --mcp # tools over MCP
```
`--email` writes an `.eml` with the PDF attached; add `--send` with `SMTP_HOST`, `SMTP_USER`,
`SMTP_PASSWORD` set to really send it. `--llm` lets an OpenAI-compatible model write the answer
(`LLM_BASE_URL`, `LLM_MODEL`, `LLM_API_KEY`); without it the skill's template writes it.
## Skills
| Skill | Picked for | Tools it calls | Output |
|---|---|---|---|
| `daily-safety-report` | report, summary, safety, kpi, email | fleet_kpis, hotspots, near_misses, speed_violations, zone_intrusions | PDF + floor map |
| `incident-review` | what happened, near miss, incident, intrusion | near_misses, speed_violations, zone_intrusions (filtered by zone / forklift) | timeline |
| `zone-utilization` | busy, traffic, trips, time spent | zone_activity, trip_times, fleet_kpis | note |
A skill is a folder: YAML frontmatter with `triggers`, a default time window and the tool calls
(with `{start}`, `{end}`, `{zone}`, `{entity}` placeholders), then the writing instructions.
Adding a capability means adding a folder, not code.
## How the agents work
- **Router** scores the question against each skill's triggers. An LLM is consulted only on a tie.
- **Analyst** first calls `current_time` (the warehouse clock, i.e. the latest position received), then
resolves "yesterday", "last shift", "last 3 hours" or a date in code, finds zone and forklift names in
the question, and runs the skill's tool calls. The model never guesses dates.
- **Writer** follows the skill's instructions: with an LLM if configured, else a deterministic template.
- **Checker** extracts every number from the answer and requires it in the evidence (allowing rounding,
shares as percentages and seconds as minutes). An LLM draft that fails is replaced by the template answer
and kept in the run log (`*.run.json`) for review; a failed answer is never emailed.
## Use the tools from any MCP client
```json
{ "mcpServers": { "floorpilot": { "command": "floorpilot-mcp", "args": ["--db", "/path/to/floor.db"] } } }
```
## Example: one simulated shift (2026-12-01, seed 0)
| | |
|---|---|
| positions | 345k rows (12 tags, 1 Hz, 8 h) |
| near misses (moving forklift < 2 m from a person) | 62 (Main aisle 45, Walkway 17) |
| speed violations (≥ 3 s over the zone limit) | 52 |
| walkway intrusions | 10 |
| distance driven | 64.8 km |
| end-to-end answer time | ~3 s (incident review) to ~8 s (full safety report with PDF) |

Sample output: [docs/sample-safety-report.md](docs/sample-safety-report.md).
## Layout
```
src/floorpilot/
layout.py zones (polygons, speed limits, forklifts allowed)
store.py SQLite position store
simulate.py shift simulator: trips, rushing, walkway shortcuts, pickers crossing the main aisle
analytics.py near misses, speed violations, intrusions, zone activity, trip times, hotspots
tools.py tool functions + LocalTools / MCPTools
mcp_server.py FastMCP server
skills/ one SKILL.md per task
agents.py Router, Analyst, Writer, Checker
report.py markdown, PDF and floor map; notify.py email
tests/ 25 tests: analytics on hand-built tracks, routing, time windows, checker, MCP parity, PDF + email
```
## Tests
```bash
pytest -q
```
## License
MIT
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues