Add input_cost_trend / input_cost_series MCP tools (EIA diesel)
CI / test (push) Successful in 17s
CI / build-push (push) Successful in 6s

Real input price + WoW/YoY change + seasonal for diesel ($/gal). Formatters now
handle the item/label payload shape. Changelog updated.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-30 12:35:32 -04:00
parent 47cac9b521
commit 457cdad2fb
5 changed files with 81 additions and 8 deletions
+36
View File
@@ -303,6 +303,42 @@ def price_series(
return fmt.fmt_price_series(payload)
VALID_INPUTS = {"diesel"}
@mcp.tool()
def input_cost_trend(
item: Annotated[
str, Field(description="Input to price. Currently: 'diesel' (U.S. retail $/gal).")
],
years: Annotated[
int, Field(ge=1, le=120, description="Baseline window for the seasonal normal/percentile."),
] = 10,
) -> str:
"""Real input cost with the change — e.g. U.S. retail diesel ($/gal).
Latest real price + week-over-week and year-over-year moves + seasonal
percentile/range. Fills the input-cost side for the advisor (fuel). For
current fertilizer $/ton use current_input_price."""
it = item.strip().lower()
with track("input_cost_trend", item=it, years=years):
if it not in VALID_INPUTS:
return f"`item` must be one of: {sorted(VALID_INPUTS)}"
return fmt.fmt_price_trend(client.input_cost_trend(item=it, years=years))
@mcp.tool()
def input_cost_series(
item: Annotated[str, Field(description="Input: 'diesel'.")],
) -> str:
"""Raw historical series for a tracked input cost (diesel, $/gal)."""
it = item.strip().lower()
with track("input_cost_series", item=it):
if it not in VALID_INPUTS:
return f"`item` must be one of: {sorted(VALID_INPUTS)}"
return fmt.fmt_price_series(client.input_cost_series(item=it))
@mcp.tool()
def list_sources() -> str:
"""All active scrapers + their last-success timestamps and any pending failures."""