# v2rmp Agentic Automation Plan
This document outlines the MCP tools available for autonomous GIS automation and the recommended workflows for agents (like DeepSeek-TUI).
## MCP Tools Summary
| `list_r2_bucket` | Lists objects in Cloudflare R2 | `bucket`, `prefix` |
| `upload_to_r2` | Uploads a local file to R2 | `local_path`, `r2_path` |
| `download_from_r2` | Downloads an R2 object to local | `r2_path`, `local_path` |
| `query_supabase` | Executes SQL on Supabase | `query` |
| `v2rmp_extract` | Extracts road data (OSM/Overture) | `source`, `min_lon`, `min_lat`, ... |
| `v2rmp_compile` | Compiles GeoJSON to .rmp binary | `input_geojson`, `output_rmp` |
| `v2rmp_optimize` | Runs route optimization on .rmp | `map_path`, `u_turn_penalty`, ... |
## 1. Autonomous GIS ETL Pipeline
**Goal:** Automatically process raw GIS data dropped into R2 and update the system metadata.
**Workflow:**
1. **Monitor:** Agent calls `list_r2_bucket(prefix: "raw/")` to find new `.geojson` or `.osm.pbf` files.
2. **Ingest:** Agent calls `download_from_r2` to bring the raw file to the local environment.
3. **Process:**
* If raw data: `v2rmp_extract` to get clean road networks.
* Then: `v2rmp_compile(remove_isolates: true)` to create the routable `.rmp` binary.
4. **Store:** Agent calls `upload_to_r2` to save the `.rmp` file to `processed/`.
5. **Log:** Agent calls `query_supabase` to insert map metadata (e.g., `INSERT INTO maps (name, r2_path, node_count) VALUES (...)`).
## 2. Intelligent Route-on-Demand Assistant
**Goal:** High-level natural language control of complex route optimization.
**Workflow:**
1. **Understand:** User asks for a "wide truck route in the North sector."
2. **Locate:** Agent calls `query_supabase(query: "SELECT bbox, r2_path FROM sectors WHERE name = 'North'")`.
3. **Fetch:** Agent calls `download_from_r2` to get the sector's `.rmp` map.
4. **Execute:** Agent calls `v2rmp_optimize`:
* `u_turn_penalty: 25.0` (set high because the truck is wide).
* `db_export_table: 'active_assignments'`.
5. **Verify:** Agent confirms the route was saved and informs the user of the total distance.