DEV Community

BuyWhere
BuyWhere

Posted on • Originally published at buywhere.ai

Real-time price monitoring with MCP and LangGraph

Build a price-monitoring agent with MCP and LangGraph

Price drops happen fast. This post shows how to build a LangGraph agent that monitors products and notifies you when prices change.

The agent pattern

We use a stateful LangGraph agent with the BuyWhere MCP server. The agent runs on a schedule, checks prices, compares with previous values, and reports changes.

Setup

pip install langgraph langchain-mcp-adapters langchain-anthropic mcp
Enter fullscreen mode Exit fullscreen mode

The monitoring agent

import asyncio
from langchain_mcp_adapters.client import MultiServerMCPClient
from langchain_anthropic import ChatAnthropic

BUYWHERE_API_KEY = "sk-buywhere-your-key"
ANTHROPIC_API_KEY = "sk-ant-your-key"

async def monitor_prices():
    async with MultiServerMCPClient({
        "buywhere": {
            "command": "npx",
            "args": ["-y", "@buywhere/mcp-server"],
            "env": {"BUYWHERE_API_KEY": BUYWHERE_API_KEY},
            "transport": "stdio",
        }
    }) as client:
        tools = await client.get_tools()
        model = ChatAnthropic(model="claude-sonnet-4-6", api_key=ANTHROPIC_API_KEY).bind_tools(tools)
        result = await model.ainvoke([
            ("user", "Check the current price of Sony WH-1000XM5 across all SG retailers.")
        ])
        print(result.content)

asyncio.run(monitor_prices())
Enter fullscreen mode Exit fullscreen mode

Extending to real monitoring

Add a scheduler and price comparison store. The key insight is that MCP tool calls return structured JSON, so you can log prices and compare them across runs.

What's next

  • Add Telegram alerts for price drops >5%
  • Track multiple products via config file
  • Deploy as a scheduled serverless function

Full source: github.com/BuyWhere/buywhere-mcp


Get a free API key at buywhere.ai/api-keys

Top comments (0)