pitstop-cli 1.1.1__tar.gz → 1.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. {pitstop_cli-1.1.1 → pitstop_cli-1.2.0}/.github/workflows/ci.yml +10 -3
  2. {pitstop_cli-1.1.1 → pitstop_cli-1.2.0}/.github/workflows/release.yml +22 -7
  3. {pitstop_cli-1.1.1 → pitstop_cli-1.2.0}/CHANGELOG.md +31 -0
  4. {pitstop_cli-1.1.1 → pitstop_cli-1.2.0}/PKG-INFO +27 -13
  5. {pitstop_cli-1.1.1 → pitstop_cli-1.2.0}/README.md +24 -10
  6. {pitstop_cli-1.1.1 → pitstop_cli-1.2.0}/evals/agent/recipes.json +36 -8
  7. {pitstop_cli-1.1.1 → pitstop_cli-1.2.0}/evals/agent/tasks.json +20 -2
  8. {pitstop_cli-1.1.1 → pitstop_cli-1.2.0}/pyproject.toml +3 -3
  9. pitstop_cli-1.2.0/scripts/smoke-installed.py +63 -0
  10. {pitstop_cli-1.1.1 → pitstop_cli-1.2.0}/skills/pitstop/SKILL.md +11 -2
  11. pitstop_cli-1.2.0/src/pitstop/cache.py +36 -0
  12. {pitstop_cli-1.1.1 → pitstop_cli-1.2.0}/src/pitstop/chargers.py +36 -6
  13. {pitstop_cli-1.1.1 → pitstop_cli-1.2.0}/src/pitstop/cli.py +89 -37
  14. {pitstop_cli-1.1.1 → pitstop_cli-1.2.0}/src/pitstop/core.py +64 -24
  15. {pitstop_cli-1.1.1 → pitstop_cli-1.2.0}/src/pitstop/cpo_tariffs.py +2 -2
  16. pitstop_cli-1.2.0/src/pitstop/geocoding.py +254 -0
  17. {pitstop_cli-1.1.1 → pitstop_cli-1.2.0}/src/pitstop/mcp_server.py +66 -38
  18. {pitstop_cli-1.1.1 → pitstop_cli-1.2.0}/src/pitstop/overpass.py +43 -17
  19. pitstop_cli-1.2.0/src/pitstop/results.py +22 -0
  20. pitstop_cli-1.2.0/src/pitstop/validation.py +52 -0
  21. pitstop_cli-1.2.0/src/pitstop/version.py +1 -0
  22. {pitstop_cli-1.1.1 → pitstop_cli-1.2.0}/tests/test_chargers.py +46 -3
  23. {pitstop_cli-1.1.1 → pitstop_cli-1.2.0}/tests/test_core.py +25 -0
  24. pitstop_cli-1.2.0/tests/test_geocoding.py +79 -0
  25. pitstop_cli-1.2.0/tests/test_query_reuse.py +39 -0
  26. pitstop_cli-1.2.0/tests/test_validation.py +59 -0
  27. pitstop_cli-1.1.1/src/pitstop/geocoding.py +0 -146
  28. pitstop_cli-1.1.1/src/pitstop/version.py +0 -1
  29. {pitstop_cli-1.1.1 → pitstop_cli-1.2.0}/.github/workflows/upstream-smoke.yml +0 -0
  30. {pitstop_cli-1.1.1 → pitstop_cli-1.2.0}/.gitignore +0 -0
  31. {pitstop_cli-1.1.1 → pitstop_cli-1.2.0}/LICENSE +0 -0
  32. {pitstop_cli-1.1.1 → pitstop_cli-1.2.0}/evals/agent/README.md +0 -0
  33. {pitstop_cli-1.1.1 → pitstop_cli-1.2.0}/evals/agent/results/.gitkeep +0 -0
  34. {pitstop_cli-1.1.1 → pitstop_cli-1.2.0}/scripts/run-agent-evals.sh +0 -0
  35. {pitstop_cli-1.1.1 → pitstop_cli-1.2.0}/src/pitstop/__init__.py +0 -0
  36. {pitstop_cli-1.1.1 → pitstop_cli-1.2.0}/src/pitstop/__main__.py +0 -0
@@ -20,15 +20,20 @@ jobs:
20
20
  - run: pip install -e ".[dev]"
21
21
  - run: pytest -q
22
22
 
23
- mcp-import:
23
+ mcp-protocol:
24
24
  runs-on: ubuntu-latest
25
+ strategy:
26
+ matrix:
27
+ mcp-requirement: ["mcp==1.12.0", "mcp<2"]
25
28
  steps:
26
29
  - uses: actions/checkout@v4
27
30
  - uses: actions/setup-python@v5
28
31
  with:
29
32
  python-version: "3.12"
30
- - run: pip install -e ".[mcp]"
31
- - run: python -c "import pitstop.mcp_server; print('mcp server imports OK')"
33
+ - run: pip install ".[mcp]" "$MCP_REQUIREMENT"
34
+ env:
35
+ MCP_REQUIREMENT: ${{ matrix.mcp-requirement }}
36
+ - run: python scripts/smoke-installed.py
32
37
 
33
38
  build:
34
39
  runs-on: ubuntu-latest
@@ -39,6 +44,8 @@ jobs:
39
44
  python-version: "3.12"
40
45
  - run: pip install build
41
46
  - run: python -m build
47
+ - run: pip install --no-deps dist/*.whl
48
+ - run: python scripts/smoke-installed.py
42
49
 
43
50
  # Offline half of the eval suite: the eval files match the shipped parser, so a
44
51
  # recipe or task can never name a command the CLI cannot run. The live half
@@ -7,7 +7,7 @@ on:
7
7
  workflow_dispatch:
8
8
  inputs:
9
9
  version:
10
- description: Existing tag to release, for example v1.0.2
10
+ description: Existing tag to release, for example v1.2.0
11
11
  required: true
12
12
  type: string
13
13
 
@@ -15,6 +15,9 @@ permissions:
15
15
  contents: write
16
16
  id-token: write
17
17
 
18
+ env:
19
+ RELEASE_TAG: ${{ inputs.version || github.ref_name }}
20
+
18
21
  jobs:
19
22
  build:
20
23
  name: Build distributions
@@ -22,18 +25,34 @@ jobs:
22
25
  steps:
23
26
  - uses: actions/checkout@v4
24
27
  with:
25
- ref: ${{ github.event.inputs.version || github.ref_name }}
28
+ ref: ${{ github.event_name == 'workflow_dispatch' && format('refs/tags/{0}', inputs.version) || github.ref }}
26
29
 
27
30
  - uses: actions/setup-python@v5
28
31
  with:
29
32
  python-version: "3.12"
30
33
 
34
+ - name: Check tag and package versions agree
35
+ run: |
36
+ python - <<'PY'
37
+ import os, runpy, tomllib
38
+ from pathlib import Path
39
+ tag = os.environ["RELEASE_TAG"]
40
+ package = tomllib.loads(Path("pyproject.toml").read_text())["project"]["version"]
41
+ runtime = runpy.run_path("src/pitstop/version.py")["__version__"]
42
+ if tag != f"v{package}" or runtime != package:
43
+ raise SystemExit(f"Version mismatch: tag={tag}, package={package}, runtime={runtime}")
44
+ PY
45
+
31
46
  - run: python -m pip install --upgrade build twine
32
47
 
33
48
  - run: python -m build
34
49
 
35
50
  - run: python -m twine check dist/*
36
51
 
52
+ - run: python -m pip install --no-deps dist/*.whl
53
+
54
+ - run: python scripts/smoke-installed.py
55
+
37
56
  - uses: actions/upload-artifact@v4
38
57
  with:
39
58
  name: pitstop-cli-dist
@@ -51,11 +70,7 @@ jobs:
51
70
 
52
71
  - name: Resolve release tag
53
72
  run: |
54
- if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
55
- echo "VERSION=${{ inputs.version }}" >> "$GITHUB_ENV"
56
- else
57
- echo "VERSION=${GITHUB_REF_NAME}" >> "$GITHUB_ENV"
58
- fi
73
+ echo "VERSION=$RELEASE_TAG" >> "$GITHUB_ENV"
59
74
 
60
75
  - name: Publish release
61
76
  env:
@@ -4,6 +4,37 @@ All notable changes to this project are documented here. The format is based on
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project aims
5
5
  to follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [1.2.0] - 2026-09-10
8
+
9
+ ### Added
10
+
11
+ - Municipality discovery through `pitstop places` and the `find_places` MCP tool;
12
+ charger searches accept province and ISTAT ID and report the resolved location.
13
+ - Search coverage counts and cache timestamps in JSON and GeoJSON envelopes.
14
+ - Read-only MCP annotations and structured results; installed CLI/MCP checks
15
+ cover the minimum supported SDK (1.12) and the current 1.x SDK.
16
+ - Standard `--version` shortcut and charger download timeout/cache-age flags.
17
+
18
+ ### Fixed
19
+
20
+ - Replace Alperia and Neogy tariff links that returned HTTP 404 with their
21
+ current official charging-offer and direct-payment pages.
22
+ - CLI and MCP searches reject non-finite or out-of-range coordinates,
23
+ nonpositive radii, and negative limits before fetching data. Invalid CLI
24
+ searches return exit code 2 instead of empty results or invalid JSON.
25
+ - Freshness filters exclude prices with missing, unparseable, or future update
26
+ dates. Unfiltered queries still include those reported prices.
27
+ - Charger municipality centers come from OSM administrative relations keyed by
28
+ ISTAT ID, correcting the misplaced Bolzano reference. Duplicate town names
29
+ require disambiguation instead of silently selecting a different province.
30
+ - Fuel queries no longer mutate shared station/price objects. Parsed datasets
31
+ and statistics are reused between MCP calls and invalidated after a refresh.
32
+ - Cache writes use unique temporary files; malformed Overpass caches are retried
33
+ and valid empty caches retain their provenance during an upstream failure.
34
+ - Charger results exclude invalid coordinates and centers outside the radius.
35
+ - Release workflows check out the requested tag and verify that tag, package,
36
+ and runtime versions agree before publication.
37
+
7
38
  ## [1.1.1] - 2026-09-07
8
39
 
9
40
  ### Fixed
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: pitstop-cli
3
- Version: 1.1.1
3
+ Version: 1.2.0
4
4
  Summary: JSON-first CLI + MCP server for Italian fuel-station prices and EV charging — MIMIT, OpenStreetMap, ISTAT.
5
5
  Project-URL: Homepage, https://github.com/galjos/pitstop-cli
6
6
  Project-URL: Repository, https://github.com/galjos/pitstop-cli
@@ -44,10 +44,10 @@ Classifier: Topic :: Scientific/Engineering :: GIS
44
44
  Classifier: Topic :: Utilities
45
45
  Requires-Python: >=3.10
46
46
  Provides-Extra: dev
47
- Requires-Dist: mcp<2,>=1.0; extra == 'dev'
47
+ Requires-Dist: mcp<2,>=1.12; extra == 'dev'
48
48
  Requires-Dist: pytest>=7; extra == 'dev'
49
49
  Provides-Extra: mcp
50
- Requires-Dist: mcp<2,>=1.0; extra == 'mcp'
50
+ Requires-Dist: mcp<2,>=1.12; extra == 'mcp'
51
51
  Description-Content-Type: text/markdown
52
52
 
53
53
  # pitstop
@@ -58,11 +58,11 @@ Description-Content-Type: text/markdown
58
58
 
59
59
  A JSON-first CLI and MCP server for **Italian fuel-station prices** and **EV charging stations**, designed for AI agents, scripts, and humans.
60
60
 
61
- Italy publishes per-station fuel prices daily (MIMIT *Osservaprezzi Carburanti* open data) and OpenStreetMap maps every EV charger in the country, but raw access means downloading multi-megabyte CSVs, joining files, sorting through misreports, and translating between Italian comune names and the ones a user actually types. `pitstop` does all of that locally and returns a small, well-formed JSON envelope.
61
+ Italy publishes per-station fuel prices daily (MIMIT *Osservaprezzi Carburanti* open data), and OpenStreetMap provides EV charger locations and capabilities. Raw access means downloading multi-megabyte CSVs, joining files, sorting through misreports, and translating municipality names. `pitstop` handles those steps locally and returns JSON or a readable table.
62
62
 
63
63
  Built for questions like:
64
64
  - *"What's the cheapest diesel near Rome right now?"* → `pitstop stations --fuel Gasolio --near 41.9,12.5 --cheapest`
65
- - *"Where can I fast-charge my EV in Bolzano?"* → `pitstop chargers --comune Bozen --fast`
65
+ - *"Where can I fast-charge my EV in Bolzano?"* → `pitstop chargers --near 46.498,11.354 --fast`
66
66
  - *"Are these station prices statistically reliable?"* → every price says whether it was screened against its local market; screened ones carry a `regional_median`, a `deviation_pct`, and `outlier: true` when the price looks like a misreport.
67
67
 
68
68
  International city names work out of the box (`Rome`, `Milan`, `Bozen`, `Mailand`, `Venise`, …).
@@ -78,8 +78,9 @@ Unofficial community project. Not affiliated with or endorsed by MIMIT. Fuel dat
78
78
  - **Coverage:** Italy only (by design, for now).
79
79
  - **Known caveats:**
80
80
  - Some operators report placeholder values (e.g. `1.000`); use `--min-price` (e.g. `1.2`) to drop them.
81
- - Some price records are **stale** (a few were last updated years ago); use `--fresh-within-days` and check the `UPDATED` column / `updated` field.
82
- - Some stations are **mis-geocoded** in the registry. As of v0.4.0 `pitstop` joins a second data source (ISTAT-derived comune coordinates from [opendatasicilia/comuni-italiani](https://github.com/opendatasicilia/comuni-italiani), 97.5% match) to validate each station's coordinate against its declared comune's *true* location. Stations >30 km off are flagged `coordinate_suspect` (`*` in the table), and `--near` excludes stations whose declared comune is geographically too far from the query point — even single-station comuni like RASUN-ANTERSELVA. Pass `--no-comune-validate` to disable.
81
+ - Some price records are **stale** (a few were last updated years ago); use `--fresh-within-days` and check the `UPDATED` column / `updated` field. When enabled, the freshness filter also excludes missing, unparseable, and future update dates.
82
+ - Some stations are **mis-geocoded** in the registry. `pitstop` uses station clusters and a second coordinate reference from [opendatasicilia/comuni-italiani](https://github.com/opendatasicilia/comuni-italiani) to flag discrepancies over 30 km as `coordinate_suspect` (`*` in the table). `--near` also excludes stations whose declared comune is geographically too far from the query point. Pass `--no-comune-validate` to disable the second reference.
83
+ - **Municipality reference coordinates can also be wrong.** Charger searches resolve a municipality's ISTAT ID to its mapped OpenStreetMap administrative center. JSON includes the selected `location`, its source link, cache age, and warnings when it differs from the reference coordinates. Ambiguous names require `--provincia` or `--comune-id`. If no mapped center is available, supply `--near lat,lon`.
83
84
 
84
85
  ## Install
85
86
 
@@ -119,10 +120,19 @@ pitstop stations --near 46.498,11.354 --radius 5 --fuel Benzina --self --json
119
120
  pitstop fuels
120
121
 
121
122
  # Fast EV chargers (≥50 kW) within 5 km of Bolzano
122
- pitstop chargers --near 46.498,11.354 --radius 5 --fast --json
123
+ pitstop chargers --comune Bozen --radius 5 --fast --public --json
124
+
125
+ # Discover municipality IDs and disambiguate duplicate names
126
+ pitstop places Livo --json
127
+ pitstop chargers --comune Livo --provincia TN --json
128
+ pitstop chargers --comune-id 021008 --radius 5 --fast --json
123
129
  ```
124
130
 
125
- `stations` flags: `--comune`, `--provincia`, `--brand`, `--near "lat,lon"`, `--radius`, `--fuel` (substring, case-insensitive), `--self`, `--served`, `--cheapest` (needs `--fuel`), `--min-price` (drop values below a floor; e.g. `1.2` to skip placeholders), `--fresh-within-days` (drop stale prices), `--max-deviation-pct` (drop prices more than N% below their fuel's provincial median — catches misreports), `--no-comune-validate`, `--limit`, `--json`. Loading flags (`--refresh`, `--max-age`, `--timeout`) apply to the MIMIT data commands (`stations`, `fuels`, `stats`); `chargers` uses its own OSM cache and takes only `--refresh`.
131
+ `stations` flags: `--comune`, `--provincia`, `--brand`, `--near "lat,lon"`, `--radius`, `--fuel` (substring, case-insensitive), `--self`, `--served`, `--cheapest` (needs `--fuel`), `--min-price`, `--fresh-within-days`, `--max-deviation-pct`, `--no-comune-validate`, `--limit`, `--json`, `--geojson`. Choose one output format. `--limit 0` returns every match.
132
+
133
+ Distances and radii are straight-line measurements, not driving distances or travel times.
134
+
135
+ Loading flags (`--refresh`, `--max-age` in seconds, `--timeout` in seconds) apply to MIMIT commands and charger searches. The default caches last 24 hours for MIMIT, seven days for OSM, and 30 days for the municipality reference. `--refresh` also refreshes a charger's municipality lookup; `--max-age` controls its charger results. `--max-age 0` accepts cached files of any age. `places` supports `--refresh` and `--timeout`.
126
136
 
127
137
  Every returned price carries a `median_basis`. A `screened` price also carries `regional_median` and `deviation_pct`, plus `outlier: true` when it is >15% below the local median **or** below the Tukey lower fence Q1−1.5·IQR (the Tukey rule catches misreports in tight markets that the percent rule alone misses). The `outlier` key is emitted **only when it is true**, so read it as optional. Pass `--drop-outliers` to remove flagged prices entirely.
128
138
 
@@ -130,7 +140,7 @@ A price is `unscreened` when its (fuel, provincia) bucket holds too few samples
130
140
 
131
141
  ## MCP server
132
142
 
133
- For agents that speak MCP, the same data is exposed as tools (`list_fuels`, `find_stations`, `find_cheapest`, `find_chargers`, `get_stats`) over the shared core:
143
+ For agents that speak MCP, the same data is exposed as six tools (`list_fuels`, `find_stations`, `find_cheapest`, `find_chargers`, `find_places`, `get_stats`) over the shared core. Tools advertise read-only behavior and return structured JSON alongside text. Repeated fuel searches reuse parsed files and provincial statistics until the cached files change.
134
144
 
135
145
  ```bash
136
146
  pip install "pitstop-cli[mcp]" # or: uv tool install "pitstop-cli[mcp]"
@@ -150,19 +160,23 @@ Machine-readable command recipes, with the caveats that belong with each answer,
150
160
  ```bash
151
161
  pip install -e ".[dev]"
152
162
  pytest -q
163
+ python scripts/smoke-installed.py # installed entry points and stdio MCP, offline
153
164
  ```
154
165
 
155
166
  ## Automation contract
156
167
 
157
168
  - `stdout` is command output; `stderr` is diagnostics.
158
- - `--json` emits a stable object with `source`, `*_extraction_date`, `generated_at`, `query`, `count`, `quality`, `stations[]`, and `disclaimer`.
169
+ - `stations --json` emits a stable object with `source`, `*_extraction_date`, `generated_at`, `query`, `count`, `quality`, `stations[]`, and `disclaimer`.
170
+ - Fuel and charger search envelopes include `coverage`: `fetched_count`, `matched_count` before the limit, `returned_count`, and `truncated`. These counts describe the downloaded data; OSM coverage is not an exhaustive charger inventory.
171
+ - `freshness` records local `fetched_at` and `age_seconds`: separately for the fuel registry and prices, or for the charger response. Charger `cache_status` is `hit`, `miss`, `stale_fallback`, `partial`, or `unavailable`. A partial/unavailable response has no successful fetch timestamp; an `error` explains degraded results. Fetch time does not establish current prices or charger availability.
172
+ - Charger municipality searches add `location` with the selected name, province, ISTAT ID, coordinates, provenance, and warnings. GeoJSON carries these envelope fields under `metadata`.
159
173
  - Exit codes: `0` success, `1` runtime error, `2` usage error.
160
- - Source files are cached (default 24h) under `$XDG_CACHE_HOME/pitstop`; use `--refresh` to bypass.
174
+ - Source files are cached under `$XDG_CACHE_HOME/pitstop` (or `~/.cache/pitstop`); use `--refresh` to bypass.
161
175
  - Non-interactive; no hidden browser state or scraping.
162
176
 
163
177
  ## Status & roadmap
164
178
 
165
- v1.1.1 — stable public release: fuel-price core (registry+price join, filters, proximity, cheapest, `--min-price` floor, `--fresh-within-days` freshness, combined 15% + Tukey IQR outlier rule, ISTAT comune-coordinate validation, JSON) + **EV charging stations via OSM Overpass** (operator, plug types, max kW, fee, access — `pitstop chargers`) + **operator tariff-page URLs** attached to each EV result. Includes **multi-fuel query support**, **international municipality mapping** (EN/FR/DE), **macro price statistics** (`pitstop stats`), and **navigation/GeoJSON support**. MCP server, agent skill, tests, CI.
179
+ v1.2.0 adds municipality discovery, province and ISTAT-ID selection for chargers, search coverage and cache timestamps, and structured MCP results. Fuel prices, EV charger locations, statistics, navigation links, and GeoJSON remain available through the CLI and MCP server. See [CHANGELOG.md](CHANGELOG.md) for fixes and compatibility details.
166
180
 
167
181
  Planned, roughly in order:
168
182
  - per-station **EV tariff data** if a source `pitstop` can read starts publishing per-kWh prices (today it parses only OSM's `fee` yes/no flag, no price field);
@@ -6,11 +6,11 @@
6
6
 
7
7
  A JSON-first CLI and MCP server for **Italian fuel-station prices** and **EV charging stations**, designed for AI agents, scripts, and humans.
8
8
 
9
- Italy publishes per-station fuel prices daily (MIMIT *Osservaprezzi Carburanti* open data) and OpenStreetMap maps every EV charger in the country, but raw access means downloading multi-megabyte CSVs, joining files, sorting through misreports, and translating between Italian comune names and the ones a user actually types. `pitstop` does all of that locally and returns a small, well-formed JSON envelope.
9
+ Italy publishes per-station fuel prices daily (MIMIT *Osservaprezzi Carburanti* open data), and OpenStreetMap provides EV charger locations and capabilities. Raw access means downloading multi-megabyte CSVs, joining files, sorting through misreports, and translating municipality names. `pitstop` handles those steps locally and returns JSON or a readable table.
10
10
 
11
11
  Built for questions like:
12
12
  - *"What's the cheapest diesel near Rome right now?"* → `pitstop stations --fuel Gasolio --near 41.9,12.5 --cheapest`
13
- - *"Where can I fast-charge my EV in Bolzano?"* → `pitstop chargers --comune Bozen --fast`
13
+ - *"Where can I fast-charge my EV in Bolzano?"* → `pitstop chargers --near 46.498,11.354 --fast`
14
14
  - *"Are these station prices statistically reliable?"* → every price says whether it was screened against its local market; screened ones carry a `regional_median`, a `deviation_pct`, and `outlier: true` when the price looks like a misreport.
15
15
 
16
16
  International city names work out of the box (`Rome`, `Milan`, `Bozen`, `Mailand`, `Venise`, …).
@@ -26,8 +26,9 @@ Unofficial community project. Not affiliated with or endorsed by MIMIT. Fuel dat
26
26
  - **Coverage:** Italy only (by design, for now).
27
27
  - **Known caveats:**
28
28
  - Some operators report placeholder values (e.g. `1.000`); use `--min-price` (e.g. `1.2`) to drop them.
29
- - Some price records are **stale** (a few were last updated years ago); use `--fresh-within-days` and check the `UPDATED` column / `updated` field.
30
- - Some stations are **mis-geocoded** in the registry. As of v0.4.0 `pitstop` joins a second data source (ISTAT-derived comune coordinates from [opendatasicilia/comuni-italiani](https://github.com/opendatasicilia/comuni-italiani), 97.5% match) to validate each station's coordinate against its declared comune's *true* location. Stations >30 km off are flagged `coordinate_suspect` (`*` in the table), and `--near` excludes stations whose declared comune is geographically too far from the query point — even single-station comuni like RASUN-ANTERSELVA. Pass `--no-comune-validate` to disable.
29
+ - Some price records are **stale** (a few were last updated years ago); use `--fresh-within-days` and check the `UPDATED` column / `updated` field. When enabled, the freshness filter also excludes missing, unparseable, and future update dates.
30
+ - Some stations are **mis-geocoded** in the registry. `pitstop` uses station clusters and a second coordinate reference from [opendatasicilia/comuni-italiani](https://github.com/opendatasicilia/comuni-italiani) to flag discrepancies over 30 km as `coordinate_suspect` (`*` in the table). `--near` also excludes stations whose declared comune is geographically too far from the query point. Pass `--no-comune-validate` to disable the second reference.
31
+ - **Municipality reference coordinates can also be wrong.** Charger searches resolve a municipality's ISTAT ID to its mapped OpenStreetMap administrative center. JSON includes the selected `location`, its source link, cache age, and warnings when it differs from the reference coordinates. Ambiguous names require `--provincia` or `--comune-id`. If no mapped center is available, supply `--near lat,lon`.
31
32
 
32
33
  ## Install
33
34
 
@@ -67,10 +68,19 @@ pitstop stations --near 46.498,11.354 --radius 5 --fuel Benzina --self --json
67
68
  pitstop fuels
68
69
 
69
70
  # Fast EV chargers (≥50 kW) within 5 km of Bolzano
70
- pitstop chargers --near 46.498,11.354 --radius 5 --fast --json
71
+ pitstop chargers --comune Bozen --radius 5 --fast --public --json
72
+
73
+ # Discover municipality IDs and disambiguate duplicate names
74
+ pitstop places Livo --json
75
+ pitstop chargers --comune Livo --provincia TN --json
76
+ pitstop chargers --comune-id 021008 --radius 5 --fast --json
71
77
  ```
72
78
 
73
- `stations` flags: `--comune`, `--provincia`, `--brand`, `--near "lat,lon"`, `--radius`, `--fuel` (substring, case-insensitive), `--self`, `--served`, `--cheapest` (needs `--fuel`), `--min-price` (drop values below a floor; e.g. `1.2` to skip placeholders), `--fresh-within-days` (drop stale prices), `--max-deviation-pct` (drop prices more than N% below their fuel's provincial median — catches misreports), `--no-comune-validate`, `--limit`, `--json`. Loading flags (`--refresh`, `--max-age`, `--timeout`) apply to the MIMIT data commands (`stations`, `fuels`, `stats`); `chargers` uses its own OSM cache and takes only `--refresh`.
79
+ `stations` flags: `--comune`, `--provincia`, `--brand`, `--near "lat,lon"`, `--radius`, `--fuel` (substring, case-insensitive), `--self`, `--served`, `--cheapest` (needs `--fuel`), `--min-price`, `--fresh-within-days`, `--max-deviation-pct`, `--no-comune-validate`, `--limit`, `--json`, `--geojson`. Choose one output format. `--limit 0` returns every match.
80
+
81
+ Distances and radii are straight-line measurements, not driving distances or travel times.
82
+
83
+ Loading flags (`--refresh`, `--max-age` in seconds, `--timeout` in seconds) apply to MIMIT commands and charger searches. The default caches last 24 hours for MIMIT, seven days for OSM, and 30 days for the municipality reference. `--refresh` also refreshes a charger's municipality lookup; `--max-age` controls its charger results. `--max-age 0` accepts cached files of any age. `places` supports `--refresh` and `--timeout`.
74
84
 
75
85
  Every returned price carries a `median_basis`. A `screened` price also carries `regional_median` and `deviation_pct`, plus `outlier: true` when it is >15% below the local median **or** below the Tukey lower fence Q1−1.5·IQR (the Tukey rule catches misreports in tight markets that the percent rule alone misses). The `outlier` key is emitted **only when it is true**, so read it as optional. Pass `--drop-outliers` to remove flagged prices entirely.
76
86
 
@@ -78,7 +88,7 @@ A price is `unscreened` when its (fuel, provincia) bucket holds too few samples
78
88
 
79
89
  ## MCP server
80
90
 
81
- For agents that speak MCP, the same data is exposed as tools (`list_fuels`, `find_stations`, `find_cheapest`, `find_chargers`, `get_stats`) over the shared core:
91
+ For agents that speak MCP, the same data is exposed as six tools (`list_fuels`, `find_stations`, `find_cheapest`, `find_chargers`, `find_places`, `get_stats`) over the shared core. Tools advertise read-only behavior and return structured JSON alongside text. Repeated fuel searches reuse parsed files and provincial statistics until the cached files change.
82
92
 
83
93
  ```bash
84
94
  pip install "pitstop-cli[mcp]" # or: uv tool install "pitstop-cli[mcp]"
@@ -98,19 +108,23 @@ Machine-readable command recipes, with the caveats that belong with each answer,
98
108
  ```bash
99
109
  pip install -e ".[dev]"
100
110
  pytest -q
111
+ python scripts/smoke-installed.py # installed entry points and stdio MCP, offline
101
112
  ```
102
113
 
103
114
  ## Automation contract
104
115
 
105
116
  - `stdout` is command output; `stderr` is diagnostics.
106
- - `--json` emits a stable object with `source`, `*_extraction_date`, `generated_at`, `query`, `count`, `quality`, `stations[]`, and `disclaimer`.
117
+ - `stations --json` emits a stable object with `source`, `*_extraction_date`, `generated_at`, `query`, `count`, `quality`, `stations[]`, and `disclaimer`.
118
+ - Fuel and charger search envelopes include `coverage`: `fetched_count`, `matched_count` before the limit, `returned_count`, and `truncated`. These counts describe the downloaded data; OSM coverage is not an exhaustive charger inventory.
119
+ - `freshness` records local `fetched_at` and `age_seconds`: separately for the fuel registry and prices, or for the charger response. Charger `cache_status` is `hit`, `miss`, `stale_fallback`, `partial`, or `unavailable`. A partial/unavailable response has no successful fetch timestamp; an `error` explains degraded results. Fetch time does not establish current prices or charger availability.
120
+ - Charger municipality searches add `location` with the selected name, province, ISTAT ID, coordinates, provenance, and warnings. GeoJSON carries these envelope fields under `metadata`.
107
121
  - Exit codes: `0` success, `1` runtime error, `2` usage error.
108
- - Source files are cached (default 24h) under `$XDG_CACHE_HOME/pitstop`; use `--refresh` to bypass.
122
+ - Source files are cached under `$XDG_CACHE_HOME/pitstop` (or `~/.cache/pitstop`); use `--refresh` to bypass.
109
123
  - Non-interactive; no hidden browser state or scraping.
110
124
 
111
125
  ## Status & roadmap
112
126
 
113
- v1.1.1 — stable public release: fuel-price core (registry+price join, filters, proximity, cheapest, `--min-price` floor, `--fresh-within-days` freshness, combined 15% + Tukey IQR outlier rule, ISTAT comune-coordinate validation, JSON) + **EV charging stations via OSM Overpass** (operator, plug types, max kW, fee, access — `pitstop chargers`) + **operator tariff-page URLs** attached to each EV result. Includes **multi-fuel query support**, **international municipality mapping** (EN/FR/DE), **macro price statistics** (`pitstop stats`), and **navigation/GeoJSON support**. MCP server, agent skill, tests, CI.
127
+ v1.2.0 adds municipality discovery, province and ISTAT-ID selection for chargers, search coverage and cache timestamps, and structured MCP results. Fuel prices, EV charger locations, statistics, navigation links, and GeoJSON remain available through the CLI and MCP server. See [CHANGELOG.md](CHANGELOG.md) for fixes and compatibility details.
114
128
 
115
129
  Planned, roughly in order:
116
130
  - per-station **EV tariff data** if a source `pitstop` can read starts publishing per-kWh prices (today it parses only OSM's `fee` yes/no flag, no price field);
@@ -22,7 +22,7 @@
22
22
  },
23
23
  {
24
24
  "id": "cheapest-fuel-near-place",
25
- "question_pattern": "Cheapest fuel within driving distance of a coordinate.",
25
+ "question_pattern": "Cheapest fuel within a straight-line radius of a coordinate.",
26
26
  "commands": [
27
27
  "pitstop stations --near 41.9028,12.4964 --radius 5 --fuel Gasolio --cheapest --min-price 1.2 --fresh-within-days 30 --limit 5 --json",
28
28
  "pitstop stations --near 41.9028,12.4964 --radius 5 --fuel Gasolio --cheapest --min-price 1.2 --fresh-within-days 30 --drop-outliers --limit 5 --json"
@@ -43,7 +43,8 @@
43
43
  "`--min-price 1.2` drops the 1.000 placeholder some operators report; leave it off for GPL, whose real prices sit below that floor.",
44
44
  "`--fresh-within-days` drops prices whose `updated` timestamp is older than N days; without it a years-old row can win the ranking.",
45
45
  "A station flagged `coordinate_suspect` sits more than 30 km from where its declared comune's other stations are (their median coordinate, or the ISTAT reference point when the comune has fewer than three stations), or outside Italy altogether. Its `distance_km` is unreliable even when its price is not.",
46
- "Italy only."
46
+ "Italy only.",
47
+ "distance_km is straight-line distance, not a driving route or journey time."
47
48
  ]
48
49
  },
49
50
  {
@@ -130,14 +131,18 @@
130
131
  "stations[].operator",
131
132
  "stations[].access",
132
133
  "stations[].distance_km",
133
- "stations[].navigation_url"
134
+ "stations[].navigation_url",
135
+ "coverage",
136
+ "freshness",
137
+ "location.warnings[] (when a municipality was used)"
134
138
  ],
135
139
  "caveats": [
136
140
  "Source is OpenStreetMap via Overpass. Coverage, power, and plug fields are what mappers entered; present them as unverified and name OSM.",
137
141
  "`--fast` is `--min-power 50` over the station's highest tagged socket output, so a charger whose mapper left the power untagged is filtered out rather than reported as slow.",
138
142
  "A populated `error` means the Overpass query failed. With `count: 0` that is \"unknown\", never \"no chargers nearby\"; retry or say the lookup failed.",
139
- "`--comune` centres the search on the municipality's ISTAT reference point, not its town centre. For territorially large municipalities that is far off — Bolzano's sits about 20 km up-valley from the city — so prefer `--near lat,lon` whenever the location is known.",
140
- "Availability is not in this data: it says where chargers are, not whether one is free now."
143
+ "`--comune` resolves an ISTAT municipality ID to its mapped OSM administrative center. Inspect `location` and its warnings. Duplicate names need `--provincia` or `--comune-id`; use explicit `--near` when the intended point is known.",
144
+ "Availability is not in this data: it says where chargers are, not whether one is free now.",
145
+ "Surface cache age and upstream errors. Counts describe inspected OSM data, not an exhaustive or live inventory."
141
146
  ]
142
147
  },
143
148
  {
@@ -151,13 +156,36 @@
151
156
  "stations[].tariff_info_url",
152
157
  "stations[].operator",
153
158
  "disclaimer",
154
- "error"
159
+ "error",
160
+ "coverage",
161
+ "freshness",
162
+ "location.warnings[] (when a municipality was used)"
155
163
  ],
156
164
  "caveats": [
157
165
  "pitstop returns no per-kWh price for any charger: it parses OpenStreetMap's `fee` yes/no flag and no price field. There is no number to report and none to infer.",
158
- "`fee` is absent when OSM carries no `fee` tag — that is unknown, not free. `--free` keeps every charger not marked `fee=yes`, untagged ones included, so check the field per station.",
166
+ "`fee` is absent when OSM carries no `fee` tag — that is unknown, not free. `--free` requires `fee=no`; unknown fees are excluded. This mapper-entered flag is not a current operator price quote.",
159
167
  "`tariff_info_url` links to the operator's own tariff page and is present only for operators in pitstop's curated list; it is the honest answer to a price question.",
160
- "Never carry a figure over from `stations`: fuel prices and charging tariffs are different data from different sources."
168
+ "Never carry a figure over from `stations`: fuel prices and charging tariffs are different data from different sources.",
169
+ "Surface cache age and upstream errors. Counts describe inspected OSM data, not an exhaustive or live inventory."
170
+ ]
171
+ },
172
+ {
173
+ "id": "municipality-discovery",
174
+ "question_pattern": "Find chargers in a municipality whose name may be shared by multiple provinces.",
175
+ "commands": [
176
+ "pitstop places Livo --json",
177
+ "pitstop chargers --comune Livo --provincia TN --limit 5 --json"
178
+ ],
179
+ "parse": [
180
+ "places[].comune_id",
181
+ "places[].provincia",
182
+ "location",
183
+ "coverage",
184
+ "freshness"
185
+ ],
186
+ "caveats": [
187
+ "Select the intended province before searching. An ambiguous name is a usage error.",
188
+ "A missing mapped center is reported; provide explicit coordinates rather than substituting another municipality."
161
189
  ]
162
190
  }
163
191
  ]
@@ -197,8 +197,8 @@
197
197
  ],
198
198
  "pass_criteria": [
199
199
  "Checks each returned station's `fee` field instead of trusting the flag name.",
200
- "States that `--free` keeps every charger not marked `fee=yes`, so results with no `fee` field are unknown rather than free.",
201
- "Separates the chargers explicitly mapped `fee=no` from the untagged ones in the answer.",
200
+ "States that `--free` requires an explicit `fee=no`; missing fees are excluded.",
201
+ "If comparing against the unfiltered query, labels missing fee tags as unknown.",
202
202
  "Repeats that pitstop reports no per-kWh price and points at `tariff_info_url` where present."
203
203
  ],
204
204
  "common_failures": [
@@ -207,6 +207,24 @@
207
207
  "Promises a free charge from a mapper-entered flag with no date behind it.",
208
208
  "Invents a tariff for the chargers that do charge."
209
209
  ]
210
+ },
211
+ {
212
+ "id": "ambiguous-municipality",
213
+ "prompt": "Find fast public chargers near Livo in Trentino. Show the selected location and whether the results are complete.",
214
+ "expected_command_path": [
215
+ "pitstop places Livo --json",
216
+ "pitstop chargers --comune Livo --provincia TN --fast --public --limit 5 --json"
217
+ ],
218
+ "pass_criteria": [
219
+ "Selects LIVO in TN, ISTAT 022106, rather than LIVO in CO.",
220
+ "Reads the resolved location and source; does not invent coordinates when resolution fails.",
221
+ "Reports coverage, cache age, and upstream errors without calling OSM exhaustive or live."
222
+ ],
223
+ "common_failures": [
224
+ "Selects the first substring match without checking province.",
225
+ "Presents an empty degraded response as proof that no chargers exist.",
226
+ "Uses the old Bolzano reference coordinate as a standing workaround."
227
+ ]
210
228
  }
211
229
  ]
212
230
  }
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "pitstop-cli"
7
- version = "1.1.1"
7
+ version = "1.2.0"
8
8
  description = "JSON-first CLI + MCP server for Italian fuel-station prices and EV charging — MIMIT, OpenStreetMap, ISTAT."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -40,8 +40,8 @@ Issues = "https://github.com/galjos/pitstop-cli/issues"
40
40
  [project.optional-dependencies]
41
41
  # Upper bound is load-bearing: mcp 2.0.0 (2026-07-28) removed mcp.server.fastmcp,
42
42
  # which mcp_server.py imports. Lift it only together with that migration.
43
- mcp = ["mcp>=1.0,<2"]
44
- dev = ["pytest>=7", "mcp>=1.0,<2"]
43
+ mcp = ["mcp>=1.12,<2"]
44
+ dev = ["pytest>=7", "mcp>=1.12,<2"]
45
45
 
46
46
  [project.scripts]
47
47
  pitstop = "pitstop.cli:main"
@@ -0,0 +1,63 @@
1
+ """Exercise the installed CLI and optional stdio MCP server without network access."""
2
+
3
+ import asyncio
4
+ import importlib.util
5
+ import json
6
+ import os
7
+ import subprocess
8
+ import sys
9
+ import tempfile
10
+ from pathlib import Path
11
+
12
+
13
+ async def check_mcp(env):
14
+ from mcp import ClientSession, StdioServerParameters
15
+ from mcp.client.stdio import stdio_client
16
+
17
+ params = StdioServerParameters(command=sys.executable, args=["-m", "pitstop.mcp_server"], env=env)
18
+ async with stdio_client(params) as (read, write):
19
+ async with ClientSession(read, write) as session:
20
+ await session.initialize()
21
+ tools = (await session.list_tools()).tools
22
+ assert {t.name for t in tools} == {
23
+ "find_stations", "find_cheapest", "find_chargers", "find_places", "list_fuels", "get_stats"
24
+ }
25
+ assert all(t.annotations and t.annotations.readOnlyHint and
26
+ t.annotations.destructiveHint is False for t in tools)
27
+ result = await session.call_tool("find_places", {"query": "Livo"})
28
+ assert not result.isError and result.structuredContent["matched_count"] == 2
29
+ assert {p["provincia"] for p in result.structuredContent["places"]} == {"CO", "TN"}
30
+ result = await session.call_tool("find_chargers", {"near": "nan,11"})
31
+ assert result.isError
32
+ print("Installed MCP: six read-only tools, structured discovery, invalid-input error passed")
33
+
34
+
35
+ def main():
36
+ from pitstop.version import __version__
37
+
38
+ with tempfile.TemporaryDirectory(prefix="pitstop-install-smoke-") as directory:
39
+ cache = Path(directory) / "pitstop"
40
+ cache.mkdir()
41
+ (cache / "comuni_main.csv").write_text(
42
+ "comune,pro_com_t,lat,long,sigla\n"
43
+ "Livo,013130,46.17,9.30,CO\nLivo,022106,46.40,11.02,TN\n"
44
+ )
45
+ env = dict(os.environ, XDG_CACHE_HOME=directory)
46
+ cli = [str(Path(sys.executable).parent / "pitstop")]
47
+ version = subprocess.run([*cli, "--version"], env=env, capture_output=True, text=True, check=True, timeout=15)
48
+ assert __version__ in version.stdout
49
+ places = subprocess.run([*cli, "places", "Livo", "--json"], env=env,
50
+ capture_output=True, text=True, check=True, timeout=15)
51
+ assert json.loads(places.stdout)["matched_count"] == 2
52
+ invalid = subprocess.run([*cli, "stations", "--near", "nan,11", "--json"],
53
+ env=env, capture_output=True, text=True, timeout=15)
54
+ assert invalid.returncode == 2 and invalid.stdout == ""
55
+ print("Installed CLI: version, municipality discovery, invalid-input error passed")
56
+ if importlib.util.find_spec("mcp"):
57
+ asyncio.run(asyncio.wait_for(check_mcp(env), timeout=30))
58
+ else:
59
+ print("MCP extra absent; base installation passed")
60
+
61
+
62
+ if __name__ == "__main__":
63
+ main()
@@ -13,14 +13,14 @@ metadata:
13
13
  {
14
14
  "id": "uvx",
15
15
  "kind": "uvx",
16
- "package": "pitstop-cli>=1.1.1",
16
+ "package": "pitstop-cli>=1.2.0",
17
17
  "bins": ["pitstop"],
18
18
  "label": "Run pitstop on demand (uvx)",
19
19
  },
20
20
  {
21
21
  "id": "pipx",
22
22
  "kind": "pipx",
23
- "package": "pitstop-cli>=1.1.1",
23
+ "package": "pitstop-cli>=1.2.0",
24
24
  "bins": ["pitstop"],
25
25
  "label": "Install pitstop (pipx)",
26
26
  },
@@ -58,6 +58,9 @@ pitstop stations --comune ROME --fuel Gasolio --geojson
58
58
 
59
59
  # Find EV chargers with error reporting
60
60
  pitstop chargers --comune Venice --json
61
+
62
+ # Public CCS chargers rated at least 50 kW
63
+ pitstop chargers --comune Bozen --radius 5 --socket ccs --fast --public --json
61
64
  ```
62
65
 
63
66
  Key flags:
@@ -65,15 +68,21 @@ Key flags:
65
68
  - `--fuel`: Substring search. Supports **comma-separated lists** (e.g. `Benzina,Gasolio`).
66
69
  - `--geojson`: Emits a standard GeoJSON FeatureCollection with properties and geometry.
67
70
  - Other flags: `--provincia`, `--brand`, `--near`, `--radius`, `--self`/`--served`, `--cheapest`, `--min-price`, `--fresh-within-days`, `--limit`, `--json`.
71
+ - Charger power uses `--min-power` in kW; `--fast` means at least 50 kW and `--ultra-fast` at least 150 kW. Inspect the matching socket's power as well as the station maximum.
68
72
 
69
73
  ## JSON / GeoJSON contract
70
74
 
71
75
  - `stations --json` returns a stable envelope with `stations[]`, `query`, and a `quality` block (how many returned prices were screened against a local median). Each station includes a `navigation_url` (Google Maps).
72
76
  - `stations --geojson` returns a `FeatureCollection`. Geometry is `Point` [lon, lat]. Properties include all station metadata.
73
77
  - `chargers` output includes an `error` field in the envelope when the external Overpass API fails.
78
+ - Search `coverage` distinguishes fetched rows, matches before the limit, and returned rows. Read `freshness` for cache age; `generated_at` is response time, not source freshness. Surface stale-cache and partial-result errors.
79
+ - For chargers, use `pitstop places <name> --json` to discover municipality IDs. Resolve duplicate names with `--provincia` or use `--comune-id`. The returned `location` identifies the mapped OSM administrative center and any coordinate discrepancy; surface its warnings. If no center is available, request explicit coordinates.
74
80
 
75
81
  ## Advice for Agents
76
82
 
83
+ - **Discover fuel names:** Run `pitstop fuels --json`; ordinary diesel is `Gasolio`. Substring matches also include premium blends, so compare exact `prices[].fuel` values when a specific fuel is requested.
84
+ - **Choose a useful stop:** When ranking within a bounded area, inspect every match (`--limit 0`) and break equal-price ties by distance. Distances are straight-line; a navigation link provides the next step for checking the driving route.
85
+ - **Follow the tariff handoff:** Open the official `tariff_info_url` when answering charging-cost questions. Check membership requirements, location, and payment method; a contract rate is not automatically the walk-up price. Report failed links rather than quoting an unverified tariff.
77
86
  - **Use International Names:** You can pass "Rome" or "Milan" directly to `--comune`; the tool handles the translation to the Italian dataset keys.
78
87
  - **Batch Fuel Queries:** To compare Petrol and Diesel, use `--fuel "Benzina,Gasolio"` in a single call.
79
88
  - **Surface Maps:** Always include the `navigation_url` in your response so the user can navigate to the station immediately.
@@ -0,0 +1,36 @@
1
+ """Atomic cache writes and source-fetch timestamps."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ import tempfile
7
+ import time
8
+ from datetime import datetime, timezone
9
+ from pathlib import Path
10
+
11
+
12
+ def write_atomic(path: Path, data: bytes) -> None:
13
+ path.parent.mkdir(parents=True, exist_ok=True)
14
+ name = None
15
+ try:
16
+ with tempfile.NamedTemporaryFile(dir=path.parent, prefix=path.name + ".", delete=False) as f:
17
+ name = f.name
18
+ f.write(data)
19
+ os.replace(name, path)
20
+ finally:
21
+ if name is not None:
22
+ Path(name).unlink(missing_ok=True)
23
+
24
+
25
+ def file_metadata(path: Path, status: str | None = None) -> dict:
26
+ return fetch_metadata(path.stat().st_mtime, status)
27
+
28
+
29
+ def fetch_metadata(fetched: float, status: str | None = None) -> dict:
30
+ result = {
31
+ "fetched_at": datetime.fromtimestamp(fetched, timezone.utc).isoformat(),
32
+ "age_seconds": max(0, int(time.time() - fetched)),
33
+ }
34
+ if status is not None:
35
+ result["cache_status"] = status
36
+ return result