feat: nutrient_cost tool — cheapest fertilizer per lb of N/P/K (#1)
CI / test (push) Successful in 18s
CI / build-push (push) Successful in 5s

Co-authored-by: claude <claude@jpaul.io>
Co-committed-by: claude <claude@jpaul.io>
This commit was merged in pull request #1.
This commit is contained in:
2026-06-04 15:58:59 -04:00
committed by Claude (agent)
parent fb50c103d3
commit bb4219da87
4 changed files with 123 additions and 0 deletions
+21
View File
@@ -411,6 +411,27 @@ def input_cost_series(
return fmt.fmt_price_series(client.input_cost_series(item=it, geo=g))
@mcp.tool()
def nutrient_cost(
geo: Annotated[
str | None,
Field(description="Fertilizer region (default 'Cornbelt'). Same regions as "
"input_cost_trend (e.g. 'U.S. Gulf NOLA', 'Northern Plains')."),
] = None,
) -> str:
"""Cheapest fertilizer per POUND of nutrient — "what's the best value for N (or P/K)?".
Converts each fertilizer's regional $/ton (USDA AgTransport, latest month) into
$/lb of N, P2O5, and K2O from its grade, ranks them, and names the cheapest
source of each nutrient (anhydrous usually wins on N; DAP/MAP are phosphate
buys; potash is the K source). Use THIS — not input_cost_trend ($/ton only) —
whenever the grower asks which fertilizer is the best buy / best nitrogen value.
UAN grade is assumed 32-0-0."""
g = geo.strip() if geo else None
with track("nutrient_cost", geo=g or ""):
return fmt.fmt_nutrient_cost(client.nutrient_cost(geo=g))
@mcp.tool()
def list_sources() -> str:
"""All active scrapers + their last-success timestamps and any pending failures."""