pitstop-cli 1.0.1__tar.gz → 1.1.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 (23) hide show
  1. pitstop_cli-1.1.0/.github/workflows/release.yml +93 -0
  2. pitstop_cli-1.1.0/.github/workflows/upstream-smoke.yml +280 -0
  3. {pitstop_cli-1.0.1 → pitstop_cli-1.1.0}/.gitignore +2 -0
  4. {pitstop_cli-1.0.1 → pitstop_cli-1.1.0}/CHANGELOG.md +50 -0
  5. {pitstop_cli-1.0.1 → pitstop_cli-1.1.0}/PKG-INFO +18 -11
  6. {pitstop_cli-1.0.1 → pitstop_cli-1.1.0}/README.md +15 -9
  7. {pitstop_cli-1.0.1 → pitstop_cli-1.1.0}/pyproject.toml +5 -3
  8. {pitstop_cli-1.0.1 → pitstop_cli-1.1.0}/skills/pitstop/SKILL.md +6 -5
  9. {pitstop_cli-1.0.1 → pitstop_cli-1.1.0}/src/pitstop/chargers.py +10 -14
  10. {pitstop_cli-1.0.1 → pitstop_cli-1.1.0}/src/pitstop/cli.py +45 -7
  11. {pitstop_cli-1.0.1 → pitstop_cli-1.1.0}/src/pitstop/core.py +61 -10
  12. {pitstop_cli-1.0.1 → pitstop_cli-1.1.0}/src/pitstop/cpo_tariffs.py +2 -11
  13. {pitstop_cli-1.0.1 → pitstop_cli-1.1.0}/src/pitstop/mcp_server.py +14 -9
  14. {pitstop_cli-1.0.1 → pitstop_cli-1.1.0}/src/pitstop/overpass.py +46 -0
  15. pitstop_cli-1.1.0/src/pitstop/version.py +1 -0
  16. {pitstop_cli-1.0.1 → pitstop_cli-1.1.0}/tests/test_chargers.py +140 -3
  17. {pitstop_cli-1.0.1 → pitstop_cli-1.1.0}/tests/test_core.py +171 -0
  18. pitstop_cli-1.0.1/src/pitstop/version.py +0 -1
  19. {pitstop_cli-1.0.1 → pitstop_cli-1.1.0}/.github/workflows/ci.yml +0 -0
  20. {pitstop_cli-1.0.1 → pitstop_cli-1.1.0}/LICENSE +0 -0
  21. {pitstop_cli-1.0.1 → pitstop_cli-1.1.0}/src/pitstop/__init__.py +0 -0
  22. {pitstop_cli-1.0.1 → pitstop_cli-1.1.0}/src/pitstop/__main__.py +0 -0
  23. {pitstop_cli-1.0.1 → pitstop_cli-1.1.0}/src/pitstop/geocoding.py +0 -0
@@ -0,0 +1,93 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+ workflow_dispatch:
8
+ inputs:
9
+ version:
10
+ description: Existing tag to release, for example v1.0.2
11
+ required: true
12
+ type: string
13
+
14
+ permissions:
15
+ contents: write
16
+ id-token: write
17
+
18
+ jobs:
19
+ build:
20
+ name: Build distributions
21
+ runs-on: ubuntu-latest
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+ with:
25
+ ref: ${{ github.event.inputs.version || github.ref_name }}
26
+
27
+ - uses: actions/setup-python@v5
28
+ with:
29
+ python-version: "3.12"
30
+
31
+ - run: python -m pip install --upgrade build twine
32
+
33
+ - run: python -m build
34
+
35
+ - run: python -m twine check dist/*
36
+
37
+ - uses: actions/upload-artifact@v4
38
+ with:
39
+ name: pitstop-cli-dist
40
+ path: dist/*
41
+
42
+ publish-github:
43
+ name: Publish GitHub release
44
+ runs-on: ubuntu-latest
45
+ needs: build
46
+ steps:
47
+ - uses: actions/download-artifact@v4
48
+ with:
49
+ name: pitstop-cli-dist
50
+ path: dist
51
+
52
+ - name: Resolve release tag
53
+ 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
59
+
60
+ - name: Publish release
61
+ env:
62
+ GH_TOKEN: ${{ github.token }}
63
+ run: |
64
+ if gh release view "$VERSION" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
65
+ gh release edit "$VERSION" \
66
+ --repo "$GITHUB_REPOSITORY" \
67
+ --title "$VERSION" \
68
+ --notes "Automated pitstop-cli release for $VERSION."
69
+ gh release upload "$VERSION" dist/* \
70
+ --repo "$GITHUB_REPOSITORY" \
71
+ --clobber
72
+ else
73
+ gh release create "$VERSION" dist/* \
74
+ --repo "$GITHUB_REPOSITORY" \
75
+ --title "$VERSION" \
76
+ --notes "Automated pitstop-cli release for $VERSION." \
77
+ --verify-tag
78
+ fi
79
+
80
+ publish-pypi:
81
+ name: Publish PyPI package
82
+ runs-on: ubuntu-latest
83
+ needs: build
84
+ environment: pypi
85
+ steps:
86
+ - uses: actions/download-artifact@v4
87
+ with:
88
+ name: pitstop-cli-dist
89
+ path: dist
90
+
91
+ - uses: pypa/gh-action-pypi-publish@release/v1
92
+ with:
93
+ skip-existing: true
@@ -0,0 +1,280 @@
1
+ name: Upstream smoke
2
+
3
+ # Weekly canary over the live upstreams. A red run must mean "pitstop is broken",
4
+ # so nothing the maintainer cannot act on may turn it red. MIMIT failures are
5
+ # therefore hard failures; Overpass is a free community endpoint where transient
6
+ # 5xx is normal operation, so it is retried and then downgraded to a warning —
7
+ # but pitstop's *handling* of that failure is still asserted on every run.
8
+
9
+ on:
10
+ schedule:
11
+ - cron: "17 5 * * 1"
12
+ workflow_dispatch:
13
+
14
+ permissions:
15
+ contents: read
16
+
17
+ jobs:
18
+ live-data:
19
+ name: Live data smoke
20
+ runs-on: ubuntu-latest
21
+ timeout-minutes: 15
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+
25
+ - uses: actions/setup-python@v5
26
+ with:
27
+ python-version: "3.12"
28
+
29
+ - run: python -m pip install --upgrade pip
30
+
31
+ - run: pip install -e ".[mcp]"
32
+
33
+ - name: Check fuel prices
34
+ run: |
35
+ pitstop stations --comune ROMA --fuel Gasolio --cheapest --min-price 1.2 --fresh-within-days 120 --drop-outliers --limit 3 --json > fuel.json
36
+ python - <<'PY'
37
+ import json
38
+
39
+ with open("fuel.json", encoding="utf-8") as fh:
40
+ payload = json.load(fh)
41
+
42
+ assert payload["count"] > 0, payload
43
+ assert payload["source"].startswith("MIMIT"), payload["source"]
44
+ for station in payload["stations"]:
45
+ assert station["prices"], station
46
+ assert station["prices"][0]["price"] >= 1.2, station
47
+ PY
48
+
49
+ - name: Check MIMIT feed freshness
50
+ run: |
51
+ pitstop stations --comune ROMA --fuel Gasolio --limit 1 --json > freshness.json
52
+ python - <<'PY'
53
+ import json
54
+ import re
55
+ from datetime import date, datetime, timezone
56
+
57
+ # MIMIT publishes daily at ~06:45 UTC; at this job's pre-dawn hour the
58
+ # extraction date always lags exactly 2 days, weekends and holidays
59
+ # included (measured over nine archived samples, Dec 2025 - Jul 2026).
60
+ # 7 lets a stalled publish or two stay green while a frozen feed still
61
+ # goes red within one weekly run.
62
+ MAX_PRICE_AGE_DAYS = 7
63
+
64
+ with open("freshness.json", encoding="utf-8") as fh:
65
+ payload = json.load(fh)
66
+
67
+ price_date = payload["price_extraction_date"]
68
+ registry_date = payload["registry_extraction_date"]
69
+
70
+ # Both dates come straight off line 0 of the CSV, so a well-formed date
71
+ # here is also the cheapest proof we got the file and not MIMIT's
72
+ # maintenance page (whose line 0 is "<!DOCTYPE html>").
73
+ iso_date = re.compile(r"^\d{4}-\d{2}-\d{2}$")
74
+ for label, value in (("price", price_date), ("registry", registry_date)):
75
+ assert iso_date.match(str(value)), \
76
+ f"{label}_extraction_date is not a date: {value!r} -- MIMIT served something that is not the CSV"
77
+
78
+ today = datetime.now(timezone.utc).date()
79
+ age_days = (today - date.fromisoformat(price_date)).days
80
+ assert age_days <= MAX_PRICE_AGE_DAYS, (
81
+ f"MIMIT price feed looks frozen: price_extraction_date={price_date} "
82
+ f"is {age_days} days old (limit {MAX_PRICE_AGE_DAYS}); the feed normally "
83
+ f"lags 2 days at this hour"
84
+ )
85
+ # A future date means the line was misparsed, not that the feed is fresh;
86
+ # one day of slack absorbs the UTC/CET boundary.
87
+ assert age_days >= -1, f"price_extraction_date={price_date} is in the future (today={today})"
88
+
89
+ print(f"price_extraction_date={price_date} ({age_days}d old), "
90
+ f"registry_extraction_date={registry_date}, today={today}")
91
+ PY
92
+
93
+ - name: Check MIMIT dataset schema
94
+ run: |
95
+ pitstop stations --limit 0 --json > all.json
96
+ python - <<'PY'
97
+ import collections
98
+ import json
99
+ import statistics
100
+
101
+ # Every threshold sits an order of magnitude clear of what the live feed
102
+ # carried on 2026-08-01 (in brackets), so only a layout change that guts
103
+ # the parse can turn this red — not ordinary churn.
104
+ MIN_STATIONS = 10_000 # [23_917]
105
+ MAX_STATIONS = 200_000 # [23_917] -- catches a duplicated/garbage parse
106
+ MIN_PRICED_STATIONS = 5_000 # [21_697]
107
+ MIN_PRICE_ROWS = 20_000 # [93_007]
108
+ MIN_PROVINCE_CODES = 80 # [107 of Italy's 107]
109
+ MIN_IN_BBOX_SHARE = 0.90 # [0.9954]
110
+ MIN_ROWS_PER_MAIN_FUEL = 1_000 # [Benzina 34_267, Gasolio 34_146]
111
+ # Deliberately wide: catches a column shift or a lost decimal, not the
112
+ # market. [Benzina 1.999, Gasolio 2.099, GPL 0.739, Metano 1.599]
113
+ PRICE_BAND = (0.3, 6.0)
114
+
115
+ # The four structural MIMIT categories. The other ~55 values are brand
116
+ # names (Blue Diesel, HVOlution, ...) that come and go, so they are
117
+ # counted but not required.
118
+ CORE_FUELS = ("Benzina", "Gasolio", "GPL", "Metano")
119
+
120
+ STATION_FIELDS = ("id", "operator", "brand", "type", "name", "address",
121
+ "comune", "provincia", "lat", "lon", "prices")
122
+ PRICE_FIELDS = ("fuel", "price", "self_service", "updated", "median_basis")
123
+
124
+ ITALY_BBOX = (35.0, 47.6, 6.0, 19.0) # min_lat, max_lat, min_lon, max_lon
125
+
126
+ with open("all.json", encoding="utf-8") as fh:
127
+ payload = json.load(fh)
128
+
129
+ stations = payload["stations"]
130
+ assert payload["count"] == len(stations), (payload["count"], len(stations))
131
+ assert MIN_STATIONS <= len(stations) <= MAX_STATIONS, (
132
+ f"registry parsed to {len(stations)} stations, outside the plausible "
133
+ f"{MIN_STATIONS}..{MAX_STATIONS} band -- suspect an anagrafica layout change"
134
+ )
135
+
136
+ price_rows = 0
137
+ priced_stations = 0
138
+ province_codes = set()
139
+ in_bbox = 0
140
+ by_fuel = collections.defaultdict(list)
141
+
142
+ for st in stations:
143
+ missing = [f for f in STATION_FIELDS if f not in st]
144
+ assert not missing, f"station is missing {missing}: {st}"
145
+ prov = str(st["provincia"]).strip()
146
+ # The registry carries some dirty provincia values (full comune names
147
+ # instead of the 2-letter code), so count the well-formed ones rather
148
+ # than requiring every row to be clean.
149
+ if len(prov) == 2 and prov.isalpha():
150
+ province_codes.add(prov.upper())
151
+ lat, lon = st["lat"], st["lon"]
152
+ if ITALY_BBOX[0] <= lat <= ITALY_BBOX[1] and ITALY_BBOX[2] <= lon <= ITALY_BBOX[3]:
153
+ in_bbox += 1
154
+ if st["prices"]:
155
+ priced_stations += 1
156
+ for p in st["prices"]:
157
+ missing = [f for f in PRICE_FIELDS if f not in p]
158
+ assert not missing, f"price row is missing {missing}: {p}"
159
+ assert isinstance(p["price"], (int, float)) and not isinstance(p["price"], bool), p
160
+ assert isinstance(p["self_service"], bool), p
161
+ by_fuel[str(p["fuel"]).strip()].append(float(p["price"]))
162
+ price_rows += 1
163
+
164
+ assert priced_stations >= MIN_PRICED_STATIONS, priced_stations
165
+ assert price_rows >= MIN_PRICE_ROWS, price_rows
166
+ assert len(province_codes) >= MIN_PROVINCE_CODES, sorted(province_codes)
167
+ bbox_share = in_bbox / len(stations)
168
+ assert bbox_share >= MIN_IN_BBOX_SHARE, (
169
+ f"only {bbox_share:.2%} of stations sit inside the Italy bbox -- "
170
+ f"suspect the lat/lon columns moved"
171
+ )
172
+
173
+ for fuel in CORE_FUELS:
174
+ prices = by_fuel.get(fuel, [])
175
+ assert prices, f"core fuel {fuel!r} vanished from the price feed"
176
+ median = statistics.median(prices)
177
+ assert PRICE_BAND[0] <= median <= PRICE_BAND[1], (
178
+ f"{fuel} median {median} is outside {PRICE_BAND} -- suspect a "
179
+ f"column shift or a lost decimal"
180
+ )
181
+
182
+ for fuel in ("Benzina", "Gasolio"):
183
+ assert len(by_fuel[fuel]) >= MIN_ROWS_PER_MAIN_FUEL, (fuel, len(by_fuel[fuel]))
184
+
185
+ print(f"stations={len(stations)} priced={priced_stations} price_rows={price_rows} "
186
+ f"province_codes={len(province_codes)} in_bbox={bbox_share:.2%} "
187
+ f"distinct_fuels={len(by_fuel)}")
188
+ for fuel in CORE_FUELS:
189
+ print(f" {fuel}: rows={len(by_fuel[fuel])} median={statistics.median(by_fuel[fuel]):.3f}")
190
+ PY
191
+
192
+ - name: Check price statistics
193
+ run: |
194
+ pitstop stats --fuel Gasolio --json > stats.json
195
+ python - <<'PY'
196
+ import json
197
+
198
+ with open("stats.json", encoding="utf-8") as fh:
199
+ payload = json.load(fh)
200
+
201
+ gasolio = payload["stats"]["Gasolio"]
202
+ assert gasolio["national"]["count"] > 1000, gasolio["national"]
203
+ assert gasolio["national"]["median"] > 1.0, gasolio["national"]
204
+ PY
205
+
206
+ - name: Check EV charger discovery
207
+ run: |
208
+ set -uo pipefail
209
+
210
+ # Exit 0 -> Overpass answered and the data assertions passed.
211
+ # Exit 75 -> Overpass is degraded but pitstop reported it correctly; retryable.
212
+ # Exit 1 -> pitstop itself is wrong. Never retried, never downgraded.
213
+ cat > check_chargers.py <<'PY'
214
+ import json
215
+ import re
216
+ import sys
217
+
218
+ with open("chargers.json", encoding="utf-8") as fh:
219
+ payload = json.load(fh)
220
+
221
+ # Holds whether or not Overpass answered.
222
+ assert payload["source"].startswith("OpenStreetMap"), payload["source"]
223
+ assert payload["count"] == len(payload["stations"]), payload
224
+
225
+ error = payload.get("error")
226
+ if error:
227
+ # Degraded upstream, but pitstop must still fail honestly: a populated
228
+ # error and no invented data. Hard failure even on a day Overpass is down.
229
+ assert isinstance(error, str) and error.strip(), repr(error)
230
+ # 429 is exempt: rate-limiting is Overpass shedding load, not a bad request.
231
+ assert not re.search(r"HTTP Error 4(?!29)\d\d", error), (
232
+ f"Overpass rejected the request: {error} -- a 4xx is pitstop asking the "
233
+ f"wrong question (query syntax, endpoint URL, user agent), not an "
234
+ f"upstream outage; see src/pitstop/overpass.py"
235
+ )
236
+ if payload["count"] == 0:
237
+ assert payload["stations"] == [], payload
238
+ with open("overpass_error.txt", "w", encoding="utf-8") as fh:
239
+ fh.write(error.strip())
240
+ print(f"Overpass degraded, no data returned: {error}")
241
+ sys.exit(75)
242
+ # A timed-out query can still hand back a partial element set; those
243
+ # rows are held to the same assertions as a clean run.
244
+ print(f"Overpass degraded but returned {payload['count']} station(s): {error}")
245
+ else:
246
+ # No error means pitstop is vouching for the result, so hold it to that.
247
+ assert payload["count"] > 0, payload
248
+
249
+ for station in payload["stations"]:
250
+ assert station.get("max_power_kw", 0) >= 50, station
251
+
252
+ print(f"ok: {payload['count']} fast charger(s)")
253
+ PY
254
+
255
+ rc=99
256
+ attempt=0
257
+ # Overpass sheds load with a 504 that clears in under a minute. 0+45+120s
258
+ # of backoff plus three 60s fetch timeouts fits the 15-minute job budget.
259
+ for delay in 0 45 120; do
260
+ attempt=$((attempt + 1))
261
+ if [ "$delay" -gt 0 ]; then
262
+ echo "Retrying in ${delay}s (attempt ${attempt}/3)..."
263
+ sleep "$delay"
264
+ fi
265
+ if ! pitstop chargers --near 46.498,11.354 --radius 8 --fast --limit 5 --json > chargers.json; then
266
+ echo "pitstop chargers exited non-zero -- that is a pitstop failure, not an upstream one"
267
+ exit 1
268
+ fi
269
+ rc=0
270
+ python check_chargers.py || rc=$?
271
+ [ "$rc" -eq 75 ] || break
272
+ done
273
+
274
+ if [ "$rc" -eq 75 ]; then
275
+ reason="$(cat overpass_error.txt 2>/dev/null || echo 'unknown')"
276
+ echo "::warning title=Overpass unavailable, EV charger data assertions skipped::Overpass failed ${attempt} attempts (${reason}) — transient 5xx from a free community endpoint, not a pitstop defect. pitstop's failure envelope was verified well-formed (populated error, count 0, no stations); only the charger data assertions were skipped. The MIMIT fuel-price, freshness and schema assertions all ran."
277
+ exit 0
278
+ fi
279
+
280
+ exit "$rc"
@@ -9,4 +9,6 @@ venv/
9
9
  .pytest_cache/
10
10
  .ruff_cache/
11
11
  .mypy_cache/
12
+ .coverage
12
13
  .DS_Store
14
+ uv.lock
@@ -4,6 +4,55 @@ 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.1.0] - 2026-08-02
8
+
9
+ Correctness release: closes gaps between what `pitstop` claimed and what it
10
+ returned.
11
+
12
+ ### Fixed
13
+
14
+ - `pitstop-mcp` was dead on a fresh install — `mcp` 2.0.0 removed
15
+ `mcp.server.fastmcp`. The `mcp` extra is now pinned `mcp>=1.0,<2`; lift the
16
+ bound only together with a 2.x migration.
17
+ - A failed Overpass response could poison the charger cache for 7 days (its
18
+ failures arrive as HTTP 200 plus a `remark` and were cached unvalidated),
19
+ after which every call returned `count: 0` and no error. Such bodies are now
20
+ never cached, a stale cache wins over them, and partial results come back
21
+ alongside the error.
22
+ - A MIMIT maintenance page (also HTTP 200) could poison the fuel cache for 24
23
+ hours. A download must now carry the `Estrazione del ...` header to be cached.
24
+ - The charger table dropped the Overpass error the JSON path reported, so a
25
+ degraded answer looked complete.
26
+
27
+ ### Changed
28
+
29
+ - The CLI legend, agent skill and MCP tool description documented only the
30
+ percentage half of the outlier rule; all now state the Tukey lower fence too,
31
+ and that `outlier` is present only when true.
32
+ - The stations table marks unscreened prices `~` and prints its source and
33
+ extraction dates.
34
+ - EV tariff wording now describes what `pitstop` parses (OSM's `fee` yes/no
35
+ flag, no price field) rather than asserting what OpenStreetMap contains.
36
+ - Withdrawn: the agent skill claimed unscreened prices were "a small minority,
37
+ concentrated in methane, HVO, GPL". That was measured from a single snapshot
38
+ and shipped as standing fact. Read the `quality` block instead — it reports
39
+ the real figure for the answer you got.
40
+
41
+ ### Added
42
+
43
+ - `quality` block in the JSON envelope plus a per-price `median_basis`: a price
44
+ in a thin (fuel, provincia) bucket gets no outlier verdict and now says so,
45
+ instead of serializing like a screened-and-clean price. Purely additive.
46
+ - The weekly upstream canary asserts MIMIT freshness and schema shape, and
47
+ tolerates transient Overpass 5xx (a 4xx still fails).
48
+
49
+ ## [1.0.2] - 2026-06-26
50
+
51
+ Documentation/package-description patch. The README status section still
52
+ described the v0.9.0 milestone even though the current public release line is
53
+ 1.0.x. This release updates the packaged README to match v1.0.2, corrects a CLI
54
+ example that used an MCP tool name, and lists the full MCP tool surface.
55
+
7
56
  ## [1.0.1] - 2026-06-10
8
57
 
9
58
  Metadata-only patch. The 1.0.0 wheel on PyPI was built and uploaded before the
@@ -267,6 +316,7 @@ Initial release.
267
316
  - `--fuel` is a substring match, so `Gasolio` also matches variants such as
268
317
  `Gasolio Alpino`.
269
318
 
319
+ [1.0.2]: https://github.com/galjos/pitstop-cli/releases/tag/v1.0.2
270
320
  [1.0.1]: https://github.com/galjos/pitstop-cli/releases/tag/v1.0.1
271
321
  [1.0.0]: https://github.com/galjos/pitstop-cli/releases/tag/v1.0.0
272
322
  [0.9.0]: https://github.com/galjos/pitstop-cli/releases/tag/v0.9.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pitstop-cli
3
- Version: 1.0.1
3
+ Version: 1.1.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,21 +44,26 @@ 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
48
  Requires-Dist: pytest>=7; extra == 'dev'
48
49
  Provides-Extra: mcp
49
- Requires-Dist: mcp>=1.0; extra == 'mcp'
50
+ Requires-Dist: mcp<2,>=1.0; extra == 'mcp'
50
51
  Description-Content-Type: text/markdown
51
52
 
52
53
  # pitstop
53
54
 
55
+ [![CI](https://github.com/galjos/pitstop-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/galjos/pitstop-cli/actions/workflows/ci.yml)
56
+ [![Release](https://github.com/galjos/pitstop-cli/actions/workflows/release.yml/badge.svg)](https://github.com/galjos/pitstop-cli/actions/workflows/release.yml)
57
+ [![Upstream smoke](https://github.com/galjos/pitstop-cli/actions/workflows/upstream-smoke.yml/badge.svg)](https://github.com/galjos/pitstop-cli/actions/workflows/upstream-smoke.yml)
58
+
54
59
  A JSON-first CLI and MCP server for **Italian fuel-station prices** and **EV charging stations**, designed for AI agents, scripts, and humans.
55
60
 
56
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.
57
62
 
58
63
  Built for questions like:
59
- - *"What's the cheapest diesel near Rome right now?"* → `pitstop find_cheapest --fuel Gasolio --near 41.9,12.5`
64
+ - *"What's the cheapest diesel near Rome right now?"* → `pitstop stations --fuel Gasolio --near 41.9,12.5 --cheapest`
60
65
  - *"Where can I fast-charge my EV in Bolzano?"* → `pitstop chargers --comune Bozen --fast`
61
- - *"Are these station prices statistically reliable?"* → every price carries a `regional_median`, `deviation_pct`, and `outlier` flag.
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.
62
67
 
63
68
  International city names work out of the box (`Rome`, `Milan`, `Bozen`, `Mailand`, `Venise`, …).
64
69
 
@@ -117,13 +122,15 @@ pitstop fuels
117
122
  pitstop chargers --near 46.498,11.354 --radius 5 --fast --json
118
123
  ```
119
124
 
120
- `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 any data command.
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`.
126
+
127
+ 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.
121
128
 
122
- Every returned price carries `regional_median`, `deviation_pct`, and an `outlier` flag (true when >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). Pass `--drop-outliers` to remove flagged prices entirely.
129
+ A price is `unscreened` when its (fuel, provincia) bucket holds too few samples for a median, so **no outlier check ran on it** and it is returned as reported (the table marks these `~`). The `--json` envelope's `quality` block counts screened vs unscreened prices for the answer you got.
123
130
 
124
131
  ## MCP server
125
132
 
126
- For agents that speak MCP, the same data is exposed as tools (`list_fuels`, `find_stations`, `find_cheapest`) over the shared core:
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:
127
134
 
128
135
  ```bash
129
136
  pip install "pitstop-cli[mcp]" # or: uv tool install "pitstop-cli[mcp]"
@@ -146,18 +153,18 @@ pytest -q
146
153
  ## Automation contract
147
154
 
148
155
  - `stdout` is command output; `stderr` is diagnostics.
149
- - `--json` emits a stable object with `source`, `*_extraction_date`, `generated_at`, `query`, `count`, `stations[]`, and `disclaimer`.
156
+ - `--json` emits a stable object with `source`, `*_extraction_date`, `generated_at`, `query`, `count`, `quality`, `stations[]`, and `disclaimer`.
150
157
  - Exit codes: `0` success, `1` runtime error, `2` usage error.
151
158
  - Source files are cached (default 24h) under `$XDG_CACHE_HOME/pitstop`; use `--refresh` to bypass.
152
159
  - Non-interactive; no hidden browser state or scraping.
153
160
 
154
161
  ## Status & roadmap
155
162
 
156
- v0.9.0 — 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, Claude skill, tests, CI.
163
+ v1.1.0 — 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.
157
164
 
158
165
  Planned, roughly in order:
159
- - **EV charging** (locations via Open Charge Map; prices via the AFIR National Access Point / DATEX II as that data matures);
160
- - additional countries behind a per-country source adapter (e.g. Germany Tankerkönig, France/Spain official feeds).
166
+ - 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);
167
+ - additional countries behind a per-country source adapter, only where the source's own terms permit the bulk download and locally derived ranking `pitstop` does.
161
168
 
162
169
  ## Data sources & attributions
163
170
 
@@ -1,13 +1,17 @@
1
1
  # pitstop
2
2
 
3
+ [![CI](https://github.com/galjos/pitstop-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/galjos/pitstop-cli/actions/workflows/ci.yml)
4
+ [![Release](https://github.com/galjos/pitstop-cli/actions/workflows/release.yml/badge.svg)](https://github.com/galjos/pitstop-cli/actions/workflows/release.yml)
5
+ [![Upstream smoke](https://github.com/galjos/pitstop-cli/actions/workflows/upstream-smoke.yml/badge.svg)](https://github.com/galjos/pitstop-cli/actions/workflows/upstream-smoke.yml)
6
+
3
7
  A JSON-first CLI and MCP server for **Italian fuel-station prices** and **EV charging stations**, designed for AI agents, scripts, and humans.
4
8
 
5
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.
6
10
 
7
11
  Built for questions like:
8
- - *"What's the cheapest diesel near Rome right now?"* → `pitstop find_cheapest --fuel Gasolio --near 41.9,12.5`
12
+ - *"What's the cheapest diesel near Rome right now?"* → `pitstop stations --fuel Gasolio --near 41.9,12.5 --cheapest`
9
13
  - *"Where can I fast-charge my EV in Bolzano?"* → `pitstop chargers --comune Bozen --fast`
10
- - *"Are these station prices statistically reliable?"* → every price carries a `regional_median`, `deviation_pct`, and `outlier` flag.
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.
11
15
 
12
16
  International city names work out of the box (`Rome`, `Milan`, `Bozen`, `Mailand`, `Venise`, …).
13
17
 
@@ -66,13 +70,15 @@ pitstop fuels
66
70
  pitstop chargers --near 46.498,11.354 --radius 5 --fast --json
67
71
  ```
68
72
 
69
- `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 any data command.
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`.
74
+
75
+ 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.
70
76
 
71
- Every returned price carries `regional_median`, `deviation_pct`, and an `outlier` flag (true when >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). Pass `--drop-outliers` to remove flagged prices entirely.
77
+ A price is `unscreened` when its (fuel, provincia) bucket holds too few samples for a median, so **no outlier check ran on it** and it is returned as reported (the table marks these `~`). The `--json` envelope's `quality` block counts screened vs unscreened prices for the answer you got.
72
78
 
73
79
  ## MCP server
74
80
 
75
- For agents that speak MCP, the same data is exposed as tools (`list_fuels`, `find_stations`, `find_cheapest`) over the shared core:
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:
76
82
 
77
83
  ```bash
78
84
  pip install "pitstop-cli[mcp]" # or: uv tool install "pitstop-cli[mcp]"
@@ -95,18 +101,18 @@ pytest -q
95
101
  ## Automation contract
96
102
 
97
103
  - `stdout` is command output; `stderr` is diagnostics.
98
- - `--json` emits a stable object with `source`, `*_extraction_date`, `generated_at`, `query`, `count`, `stations[]`, and `disclaimer`.
104
+ - `--json` emits a stable object with `source`, `*_extraction_date`, `generated_at`, `query`, `count`, `quality`, `stations[]`, and `disclaimer`.
99
105
  - Exit codes: `0` success, `1` runtime error, `2` usage error.
100
106
  - Source files are cached (default 24h) under `$XDG_CACHE_HOME/pitstop`; use `--refresh` to bypass.
101
107
  - Non-interactive; no hidden browser state or scraping.
102
108
 
103
109
  ## Status & roadmap
104
110
 
105
- v0.9.0 — 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, Claude skill, tests, CI.
111
+ v1.1.0 — 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.
106
112
 
107
113
  Planned, roughly in order:
108
- - **EV charging** (locations via Open Charge Map; prices via the AFIR National Access Point / DATEX II as that data matures);
109
- - additional countries behind a per-country source adapter (e.g. Germany Tankerkönig, France/Spain official feeds).
114
+ - 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);
115
+ - additional countries behind a per-country source adapter, only where the source's own terms permit the bulk download and locally derived ranking `pitstop` does.
110
116
 
111
117
  ## Data sources & attributions
112
118
 
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "pitstop-cli"
7
- version = "1.0.1"
7
+ version = "1.1.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"
@@ -38,8 +38,10 @@ Changelog = "https://github.com/galjos/pitstop-cli/blob/main/CHANGELOG.md"
38
38
  Issues = "https://github.com/galjos/pitstop-cli/issues"
39
39
 
40
40
  [project.optional-dependencies]
41
- mcp = ["mcp>=1.0"]
42
- dev = ["pytest>=7"]
41
+ # Upper bound is load-bearing: mcp 2.0.0 (2026-07-28) removed mcp.server.fastmcp,
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
45
 
44
46
  [project.scripts]
45
47
  pitstop = "pitstop.cli:main"