Repository navigation
fix: read catalog stock bands (availability) instead of exact counts - #10
Merged
Merged
Conversation
The catalog API is adding a stock band (in_stock/low_stock/out_of_stock) alongside the legacy exact count and will stop sending the count. Every in-stock check (find_cheapest, price checks) now reads the band via a shared helper, falling back to count thresholds only for older payloads, and tool output carries the band string instead of any exact integer. Also aligns package.json/server.json/.plugin/plugin.json on 1.3.3 (server.json had drifted from package.json, which the existing version-consistency test now catches). Commit-Author: sub-agent Task-Source: user-prompt Reason: the backend is removing the exact per-country stock count from its API response; without this change every installed copy of the MCP would read every country as out of stock once that happens.
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The catalog API now returns a stock band (
in_stock/low_stock/out_of_stock) alongside the legacy exact per-country count, and will stop sending the count entirely soon. This PR moves every in-stock check in the server onto the band:src/stock.ts:catalogStockBand(row)readsavailabilitywhen present, falls back to count thresholds for older payloads, and returnsunknown(never in stock) when neither field is present.isCatalogInStock(row)wraps that into a boolean.CatalogCountry.countis now optional;availabilityis the new authoritative field.find_cheapestand the price-check stock guard both use the shared helper. Tool output now carries anavailabilityband string per country instead of an exact stock integer or a barestock: trueflag.src/resources.ts,README.md) updated to tell agents to readavailability, notcount.package.json,server.json(root +packages[0]),.plugin/plugin.json, and the lockfile. This also fixes a pre-existing drift betweenpackage.json(1.3.1) andserver.json(1.3.2) that the repo's ownversion-consistency.test.tswas already failing on.Out of scope: rental tools (
/api/v1/rentals/*,RentalCatalogService.physical_count) — those are a separate stock model and untouched.Deviation from the original brief, flagged for review: the brief's "Tests" section assumed no test runner existed and asked for a new
test/stock.test.mjson Node's built-in runner, replacing thetestnpm script. That assumption doesn't hold — this repo already has a working Vitest suite (src/__tests__/**, 107 tests) wired tonpm test. Replacing the test script would have silently stopped that whole suite from running in CI. Instead, the new coverage was added assrc/stock.test.tsin the existing Vitest convention, and thetestscript/config were left untouched.Test plan
npm cinpm run buildnpm test(Vitest) — 11 files, 113 tests passed, including the newly-addedsrc/stock.test.ts(6 tests) and the previously-failingversion-consistency.test.ts(now fixed by the aligned version bump)grep -rnE "\.count\b|count >|count <=|'count'|\"count\"" src | grep -v -i "rental\|endpoint\|params.count\|args.count"— every remaining hit is transaction pagination (TransactionsPage.count), proxy-location result count, or the intentional legacy fallback insidesrc/stock.ts/client.ts's catalog mapping — none leak an exact catalog stock integer into tool output🤖 Generated with Claude Code