Skip to main content
Glama
price-hunter

price-hunter

by h382110229

🎯 Price Hunter — 全网比价聚合搜索服务

基于 MCP (Model Context Protocol) 的全网比价聚合引擎,对接淘宝联盟、京东联盟、多多进宝三大电商联盟 API,提供统一的商品搜索、优惠券查询与跨平台比价能力。

架构

Client (LLM / Agent)
  │  MCP Protocol (stdio / SSE)
  ▼
MCPServer (server.py)
  │
  ├── config.py          # pydantic-settings 凭据加载
  ├── models.py          # 统一数据模型 (Product, Coupon, CompareResult)
  └── engines/
      ├── base.py        # 引擎基类 (签名、重试、Mock/Dry-run)
      ├── taobao.py      # 淘宝联盟 TOP API
      ├── jd.py          # 京东联盟 API
      └── pdd.py         # 多多进宝 API

Related MCP server: tk_mcp

快速开始

# 1. 安装依赖
uv sync

# 2. 配置凭据
cp .env.example .env
# 编辑 .env 填入联盟 API Key(见下方生产配置)

# 3. 检查连通性
uv run python scripts/check_keys.py

# 4. 启动 MCP Server
uv run python -m src.server

生产配置

三大联盟 API 凭据获取指南详见 docs/union_api_guide.md。

.env 文件格式:

TB_APP_KEY=你的淘宝AppKey
TB_APP_SECRET=你的淘宝AppSecret
TB_ADZONE_ID=你的推广位ID

JD_APP_KEY=你的京东AppKey
JD_APP_SECRET=你的京东AppSecret
JD_SITE_ID=你的推广位SiteID

PDD_CLIENT_ID=你的拼多多ClientID
PDD_CLIENT_SECRET=你的拼多多ClientSecret
PDD_PID=你的推广位PID

连通性探测

uv run python scripts/check_keys.py

输出示例:

╔══════════════════════════════════════════════════════╗
║       Price Hunter — 联盟 API 连通性探测             ║
╠══════════════════════════════════════════════════════╣

  🟢  淘宝联盟 (TOP API)
     已连通 — 返回 1 条结果
  🟡  京东联盟 (JD Union)
     未配置 (Dry-run 运行中)
  🔴  多多进宝 (PDD DDK)
     签名错误: ...

╠══════════════════════════════════════════════════════╣
║  汇总: 🟢 1 连通  🟡 1 未配置  🔴 1 失败    ║
╚══════════════════════════════════════════════════════╝

图标

含义

🟢

真实 API 已连通

🟡

未配置凭据 (Dry-run 模式)

🔴

鉴权失败 / 签名错误 / 网络错误

MCP Tools

Tool

说明

search_products

跨平台商品搜索 (并发)

get_product_detail

单品详情 + 优惠券信息

compare_prices

多平台比价 (并发 + 排序 + 摘要)

get_coupons

按商品/关键词搜索优惠券

容错机制

  • 自动重试: 网络超时/连接失败自动重试 2 次 (指数退避 1s → 3s)

  • 错误分类: 明确区分「未配置密钥」「网络超时」「签名错误」「限流」

  • Mock/Dry-run: 无凭据时自动返回真实结构的模拟数据,测试无需 API Key

  • 生产级超时: 连接 5s、读取 10s

开发状态

  • Phase 1 ✅ 工程脚手架与安全基线

  • Phase 2 ✅ 三大平台联盟 API 签名算法与比价核心

  • Phase 3 ✅ MCP 接入与端到端验证

  • Phase 4 ✅ 生产级错误处理与连通性探测

License

MIT

Available Tools

5 tools
compare_pricesA

多平台比价 — 并发搜索 + 按券后价全局升序排序。

Args:
    keyword: 搜索关键词
    page_size: 每平台取前 N 个结果

Inputs: keyword (required), page_size. Returns: object

get_couponsB

搜索优惠券。

Args:
    keyword: 关键词或商品 ID
    platform: 平台筛选 (all / taobao / jd / pdd)
    page: 页码

Inputs: keyword (required), page, platform. Returns: result

get_product_detailA

获取单品详情 (含优惠券信息)。

Args:
    product_id: 平台侧商品 ID
    platform: 平台 (taobao / jd / pdd)

Inputs: platform (required), product_id (required). Returns: object

parse_and_compareA

解析分享链接/淘口令,自动找全网同款并比价。

从用户分享的文本中提取商品标识 (淘口令/京东链接/拼多多链接),
查询原品价格,然后跨平台搜索同款,输出比价报告。

Args:
    raw_text: 包含商品链接或口令的分享文本
    page_size: 每平台取前 N 个同款结果

Inputs: raw_text (required), page_size. Returns: object

search_productsA

跨平台商品搜索 (并发请求)。

Args:
    keyword: 搜索关键词
    platform: 平台筛选 (all / taobao / jd / pdd)
    page: 页码
    page_size: 每页数量

Inputs: keyword (required), page, platform, page_size. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 5 tools

    Disambiguation2/5

    search_products and compare_prices both perform keyword searches and largely overlap, with compare_prices essentially being a sorted multi-platform version of search_products. get_product_detail already includes coupon information while get_coupons re-searches coupons separately, and parse_and_compare is compare_prices with link parsing added. Agents may struggle to choose the correct tool for a given task.

    Naming Consistency4/5

    Most tools follow a clear verb_noun snake_case pattern: search_products, get_product_detail, compare_prices, get_coupons. parse_and_compare breaks the noun-object pattern with a compound verb, but the naming is still readable and generally predictable.

    Tool Count5/5

    Five tools is well-scoped for a cross-platform price-hunting server. Each tool maps to a meaningful user workflow such as searching, viewing detail, comparing prices, finding coupons, and parsing shared links, without bloating the surface.

    Completeness4/5

    The core price-hunting workflow is covered: search, product detail, coupon lookup, multi-platform comparison, and share-link parsing. Minor gaps exist, such as comparing by a specific product ID across platforms or a dedicated coupon-detail endpoint, but agents can generally work around these.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      多多进定全平台 MCP 服务是一个基于 Model Context Protocol (MCP) 的服务,支持拼多多大电商平台的链接转换和商品推广功能,商品搜索等等一系列工具
      ISC
    • F
      license
      Not graded
      quality
      B
      maintenance
      Enables searching Taobao products, retrieving item details, and turning listings or official campaign pages into affiliate promotion links, Taobao share codes (淘口令), and short URLs. It calls the official Taobao Alliance open API directly with your own AppKey, requiring no third-party wrapper services, so agents can generate commission-earning shopping links on demand.
      1
      -