deal-watcher
Enables monitoring Amazon.sa product prices with Telegram alerts, using a two-step approval process for tracking products.
README
Deal Watcher
Deal Watcher is an educational prototype for monitoring product prices on Amazon.sa and sending Telegram alerts when a configured condition is met. It combines a Playwright-based scraper, a persistent SQLite store, a background worker, a command-line interface, and Model Context Protocol (MCP) tools with explicit human approval before tracking begins.
[!IMPORTANT] This project supports Amazon.sa only. It does not buy products, add items to a cart, request Amazon credentials, or bypass CAPTCHA and other site protections.
Project Overview
Deal Watcher lets a user preview an Amazon.sa product, review its current price and alert settings, explicitly approve the tracking plan, and then monitor the product at a configurable interval. Price observations and tracking state are stored locally so monitoring can resume after a restart.
Problem
Product prices can change frequently, and repeatedly checking product pages is inconvenient. Deal Watcher automates periodic checks while keeping the user in control of sensitive actions such as starting, pausing, or resuming monitoring.
Key Features
- Amazon.sa URL validation and ASIN extraction.
- Product title and price extraction with Playwright and Chromium.
- Target-price alerts and optional alerts for any price decrease.
- Telegram notifications containing the old price, new price, decrease, reason, and product URL.
- SQLite persistence for products, price history, pending approvals, errors, and scheduling state.
- A long-running worker with retry scheduling and a Windows single-instance lock.
- Two-step, human-approved product registration.
- CLI commands for local operation.
- MCP tools for agent integrations.
- Windows Scheduled Task helpers for starting the worker at user logon.
Workflow
<img width="611" height="645" alt="deal watcher agent workflow" src="https://github.com/user-attachments/assets/843baabe-987e-4321-be66-e0a0b207e90f" />
The main modules are deliberately separated by responsibility:
src/amazon_scraper.py: marketplace validation, ASIN extraction, price parsing, Playwright navigation, and CAPTCHA detection.src/database.py: SQLite schema and persistence operations.src/tracker_worker.py: scheduling, checks, alert evaluation, retries, logging, and single-instance locking.src/telegram_notify.py: Telegram Bot API delivery.src/cli.py: local command-line interface.src/mcp_server.py: MCP tools for agent-driven workflows.src/config.py: relative project paths and environment-based settings.
Workflow
- A user supplies an Amazon.sa product URL and optional target price.
- The application validates the marketplace and uses Playwright to extract the product title and current price.
- A preview is returned with an approval token. The product is not yet tracked.
- The user reviews the product, current price, target price, and any-drop setting.
- Tracking starts only after explicit confirmation using the approval token.
- The worker checks due products, evaluates alert conditions, records the result, and schedules the next check.
- When an alert condition is satisfied, a message is sent through the Telegram Bot API.
If Amazon displays a CAPTCHA or verification page, Deal Watcher stops that extraction attempt, records the failure, and retries later. It does not attempt a bypass.
Technology Stack
- Python 3.11+
- Playwright with Chromium
- SQLite with WAL journaling
- Model Context Protocol (
mcp/ FastMCP) - Telegram Bot API
- PowerShell and Windows Task Scheduler helpers
pytest-style tests
Project Structure
deal-watcher/
├── .env.example
├── .gitignore
├── README.md
├── README_AR.md
├── requirements.txt
├── requirements-dev.txt
├── setup.ps1
├── install-autostart.ps1
├── uninstall-autostart.ps1
├── run-worker.cmd
├── hermes/
│ └── skills/
│ └── amazon-price-tracker/
│ └── SKILL.md
├── src/
│ ├── __init__.py
│ ├── amazon_scraper.py
│ ├── cli.py
│ ├── config.py
│ ├── database.py
│ ├── mcp_server.py
│ ├── telegram_notify.py
│ └── tracker_worker.py
└── tests/
└── test_price_parser.py
Runtime-only content such as .env, .venv/, data/tracker.db, SQLite sidecar files, logs, caches, credentials, and local Hermes profiles is excluded from Git.
Installation
Windows setup script
Requirements:
- Windows 10 or later
- Python 3.11 or later available as
pythonorpy - PowerShell
From the project directory:
Set-ExecutionPolicy -Scope Process Bypass
.\setup.ps1
The script creates .venv, installs Python dependencies, installs Playwright Chromium, initializes the SQLite database, and creates .env from .env.example when needed.
Manual setup
python -m venv .venv
.\.venv\Scripts\python.exe -m pip install --upgrade pip
.\.venv\Scripts\python.exe -m pip install -r requirements.txt
.\.venv\Scripts\python.exe -m playwright install chromium
Copy-Item .env.example .env
.\.venv\Scripts\python.exe -m src.cli init
Telegram Configuration
- Create a bot through Telegram's official BotFather.
- Obtain the destination chat ID using a method appropriate for your own bot and chat.
- Copy
.env.exampleto.env. - Set the following values locally:
TELEGRAM_BOT_TOKEN=
TELEGRAM_CHAT_ID=
CHECK_INTERVAL_HOURS=6
Do not commit .env, paste credentials into documentation, or share the bot token. Deal Watcher does not need an Amazon username, password, payment details, or cookies.
Additional settings:
| Variable | Default | Purpose |
|---|---|---|
CHECK_INTERVAL_HOURS |
6 |
Hours between successful checks |
WORKER_POLL_SECONDS |
60 |
Delay while waiting for due products |
FAILURE_RETRY_MINUTES |
60 |
Delay after a failed Amazon check |
PLAYWRIGHT_HEADLESS |
true |
Run Chromium without a visible window |
Usage
Preview a product
A preview extracts product data and creates a short-lived approval token; it does not start tracking:
.\.venv\Scripts\python.exe -m src.cli preview "https://www.amazon.sa/dp/PRODUCT_ASIN" --target 250
Use --no-any-drop if alerts should only be based on the target price.
Confirm tracking
After reviewing the preview and explicitly approving it:
.\.venv\Scripts\python.exe -m src.cli confirm APPROVAL_TOKEN
Approval tokens expire after 15 minutes and are single-use.
Manage products
.\.venv\Scripts\python.exe -m src.cli list
.\.venv\Scripts\python.exe -m src.cli pause PRODUCT_ID
.\.venv\Scripts\python.exe -m src.cli resume PRODUCT_ID
.\.venv\Scripts\python.exe -m src.cli check-now PRODUCT_ID
.\.venv\Scripts\python.exe -m src.cli delete PRODUCT_ID
Pause, resume, delete, and configuration changes should be performed only after clear user approval in an agent-driven workflow.
Run the worker
.\run-worker.cmd
Stop it with Ctrl+C.
Start at Windows logon
Set-ExecutionPolicy -Scope Process Bypass
.\install-autostart.ps1
Remove the scheduled task with:
.\uninstall-autostart.ps1
MCP Tools
Run the MCP server with:
.\.venv\Scripts\python.exe -m src.mcp_server
Available tools:
| Tool | Purpose |
|---|---|
preview_amazon_tracking |
Scrape an Amazon.sa URL and return a proposed tracking plan plus approval token |
confirm_amazon_tracking |
Persist the previously previewed product after explicit approval |
list_tracked_products |
List stored products and their current state |
pause_tracked_product |
Pause checks for a product after approval |
resume_tracked_product |
Resume checks for a product after approval |
check_product_now |
Mark a product as due for the worker's next cycle |
Human-in-the-Loop
Starting monitoring is a two-step action:
preview_amazon_trackingperforms a read-only product preview and creates a pending action.confirm_amazon_trackingconsumes the approval token and stores the product only after the user clearly approves the displayed plan.
Agent integrations should also require explicit approval before pausing, resuming, deleting, changing a target price, or changing the check interval. Previously approved periodic checks and alerts do not need approval on every cycle.
Data Persistence
The application stores local state in data/tracker.db using SQLite. The database contains tracked products, price history, pending approval actions, last errors, and next-check timestamps. WAL mode may also create tracker.db-wal and tracker.db-shm while the database is active.
The database and its sidecar files are intentionally excluded from Git. Back up local runtime data separately if needed.
A powered-off computer cannot perform checks or send alerts. When the worker starts again, it loads persisted state and immediately processes products whose scheduled check time has passed. For continuous monitoring, run the worker on an always-on machine or a hosted environment.
Testing
Install the development dependencies:
.\.venv\Scripts\python.exe -m pip install -r requirements-dev.txt
Run the tests:
.\.venv\Scripts\python.exe -m pytest -q
Check all Python files for syntax errors:
.\.venv\Scripts\python.exe -m compileall -q src tests
The current tests cover English and Arabic price parsing and ASIN extraction. Broader scraper, database, worker, and notification tests are recommended before production use.
Security
- Secrets are loaded from a local
.envfile that is excluded from Git. .env.examplecontains no credential values.- SQLite data, logs, caches, OAuth artifacts, private keys, and local Hermes profiles are excluded from Git.
- Public project files use relative paths rather than user-specific absolute paths.
- Amazon credentials and payment information are neither requested nor required.
- CAPTCHA and verification pages are detected but never bypassed.
- The project never purchases products or adds items to a shopping cart.
- Review staged files and run a secret scanner before every public release.
- If a credential is ever committed, revoke or rotate it immediately; deleting it from the latest commit is not sufficient.
Limitations
- This is an educational prototype, not a production service or an official Amazon integration.
- Only
amazon.saandwww.amazon.saare accepted. - Extraction depends on Amazon's page structure and may break when the site changes.
- CAPTCHA, verification challenges, unavailable products, and network failures can delay checks.
- Local execution means no checks occur while the computer is powered off or the worker is stopped.
- Telegram delivery depends on valid local credentials and network availability.
- The test suite is currently small.
- No purchase or cart functionality is provided.
Future Improvements
- Add unit tests for scheduling, database transitions, and alert de-duplication.
- Add mocked integration tests for Telegram and Playwright extraction paths.
- Add structured migrations for future database schema changes.
- Add configurable per-product intervals and richer notification policies.
- Add observability, health checks, and safer log rotation.
- Add container and hosted deployment options for continuous operation.
- Add CI checks for tests, syntax, formatting, and secret scanning.
- Add support for additional marketplaces only after marketplace-specific validation and testing.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。