Competitor Price Tracker MCP Server

Competitor Price Tracker MCP Server

Enables querying price history and undercut alerts for tracked competitors, allowing an assistant to check if a competitor has recently undercut your prices.

Category
访问服务器

README

Competitor Price Tracker

A small, working competitor-price tracker built on the ScrapingBee API. Companion to the article How to Track Competitor Prices Using Web Scraping. Clone it, point it at your competitors, and get a Slack ping when one undercuts you.

It fetches Amazon and Walmart via ScrapingBee's dedicated parsers and any other retailer via the HTML API with AI extraction, normalizes everything into one schema, stores snapshots, and alerts on undercuts.

Status: a point-in-time companion (last tested June 2026), not a maintained product. Dependencies, GitHub Actions versions, and the ScrapingBee API surface move over time — bump them as needed. The patterns are the durable part; the version pins and exact field names are not.

Setup

Requires Python 3.10+.

pip install -r requirements.txt          # core: requests, beautifulsoup4, python-dotenv
cp .env.example .env                      # put your key in .env — it's auto-loaded
# ...or skip .env and: export SCRAPINGBEE_API_KEY=...

Get a key (free trial, no card) at https://www.scrapingbee.com/.

Use

  1. Edit targets.csv — one row per competitor product:

    column meaning
    our_sku your internal SKU
    source amazon (ASIN), walmart (item id), or generic (full URL)
    identifier the ASIN / item id / URL
    our_price your current price, for the undercut comparison
  2. Run it:

    python tracker.py
    

    Output (real run):

    MOUSE-001    amazon   USD 12.15 (ours 14.99)  <-- UNDERCUT 18.9%
    MOUSE-002    walmart  USD 13.83 (ours 14.99)  <-- UNDERCUT 7.7%
    HOODIE-009   generic  USD 69.0 (ours 75.0)  <-- UNDERCUT 8.0% [OUT OF STOCK]
    

    (Prices are live, so yours will differ.) Snapshots append to history.csv. Set SLACK_WEBHOOK_URL to post alerts to Slack; otherwise they print. The out-of-stock row is flagged but not alerted.

  3. Schedule it: the included .github/workflows/track.yml is manual by default (so a cloned repo never spends credits unattended). Uncomment its schedule: block to run every 6 hours, and add SCRAPINGBEE_API_KEY / SLACK_WEBHOOK_URL as repo secrets. It commits each snapshot back to the repo (git-scraping). Or use cron / a serverless cron.

Files

file what it does
tracker.py fetch → normalize → store → alert (the main script)
matcher.py SKU matching: GTIN-first, then model code, then fuzzy title (with confidence)
build_targets.py search a keyword + match results to your product → suggested targets.csv rows
mcp_server.py exposes the history as an MCP tool (undercuts) an assistant can call
test_tracker.py deterministic tests for the alert logic (no API) — python test_tracker.py
targets.csv your watch list

Match before you trust the numbers

A competitor's "Logitech Wireless Mouse" may not be your SKU — comparing different products is a bug, not an insight. matcher.py matches on GTIN/UPC when both sides have one (ScrapingBee's Walmart parser returns gtin; Amazon's product_details often carries a UPC), then on model code — the real discriminator, since "M185" and "M510" have near-identical titles but are different products — and only then falls back to fuzzy title matching with a confidence score:

python matcher.py
#  [MATCH   ] conf=0.95 via model :: Logitech M185 Wireless Mouse, 2.4GHz with USB Mini Rece
#  [no match] conf=0.44 via title :: Logitech Silent Wireless Mouse, Blue/Gray, Walmart Excl
#  [no match] conf=0.1  via model :: Logitech M510 Wireless Mouse, 2.4 GHz USB Unifying Rece

Auto-accept high-confidence matches; queue needs_review pairs for a human. This matcher is a starting point, not a finished system — it handles the demo cleanly, but real catalogs (thousands of SKUs, missing GTINs, variants, bundles, refurb-vs-new) need more than a regex and difflib. Treat it as the skeleton to build on, and lean on GTIN/UPC whenever your data has it.

Matching is a setup-time step, so it isn't in the tracking loop — you decide what to track once. build_targets.py does that step for you: it searches a keyword, matches each result to your product, and prints the targets.csv rows worth keeping.

python build_targets.py "Logitech M185 Wireless Mouse" "logitech wireless mouse" 14.99
# LOGITECH-B004YA,amazon,B004YAVF8I,14.99    # conf=0.95 via model [ok] M185 Wireless Mouse, 2.4GHz ...

How it behaves

  • Generic rows are JSON-LD-first. fetch_generic parses a schema.org/Product block first (deterministic, 1 credit, no JS) and only falls back to AI extraction if the page has none. That dodges the biggest reliability problem: AI extraction sometimes returns HTTP 200 with "Sorry, couldn't get the response from AI" instead of JSON — and still bills. Even so, a site with neither JSON-LD nor AI-extractable content will fail; the tracker logs it and moves on rather than crashing.
  • Alerts fire on change, not every run. You're pinged when a competitor newly undercuts you (or drops further) and is in stock — not every 6 hours for a competitor that's been cheaper all week. Change detection needs prior history, which is why CI commits history.csv back (below).
  • History accumulates via git-scraping. history.csv is tracked on purpose: the GitHub Actions job checks it out, appends the new run, and commits it back, so price history builds up in git (diffable over time). Running locally also appends to it — that's expected. Trade-offs: it adds a commit (and grows the CSV) every run, so over a year of 6-hourly runs the repo carries ~1,500 small commits (squash or roll to a database if that bothers you); and the bot pushes to the default branch, so if you protect that branch, point the workflow at an unprotected data branch or a database instead.
  • Cross-currency is not compared. Prices are compared only within OUR_CURRENCY (default USD); there's no FX conversion. A competitor priced in another currency is recorded and flagged [currency …≠USD, not compared] rather than silently mis-compared (€63 is not "cheaper" than $75). Add FX if you track multiple currencies.
  • Marketplace prices move; Walmart varies by store. One item id returned $13.83 / $13.52 / $9.88 across calls. Walmart's store_id is meant to pin a store for like-for-like comparison, but in testing it was slow/intermittent — verify it before relying on it.
  • US-centric by design. The Walmart parser is US-only and the worked example is Amazon.com/USD. Outside the US, use Amazon's domain and the generic path; Walmart won't apply.

Cost — do the math before you scale

scope credits/run rough monthly (daily run)
3 SKUs (this demo) ~20–25 negligible
100 SKUs ~500–1,500 ~15k–45k
500 SKUs ~2,500–7,500 ~75k–225k

(Amazon/Walmart parsers 5–15 each; HTML API 1 no-JS / 5 JS; +5 for AI extraction.) The free trial's 1,000 credits is enough to evaluate, not to run a real catalog — budget a paid plan for production, and check spend at https://app.scrapingbee.com/api/v1/usage.

Troubleshooting

  • 401 / "check SCRAPINGBEE_API_KEY" → key missing or wrong; the tracker exits with that message.
  • 429 → you exceeded your plan's concurrency cap; the session already retries with backoff.
  • pip install fails on a very new/locked-down Python → install the core only (pip install requests beautifulsoup4 python-dotenv); duckdb/fastmcp are needed only for mcp_server.py.

Tests

python test_tracker.py

Covers the parts that are easy to get wrong — alert-on-change (no every-run spam), in-stock gating, cross-currency safety, history accumulation — with mocked fetchers, so it runs offline and costs no credits.

License

MIT — see LICENSE. Use it, fork it, ship it.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选