Skip to main content
Glama
h382110229

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 个结果
ParametersJSON Schema
NameRequiredDescriptionDefault
keywordYes
page_sizeNo

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A4.1/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It adds valuable operational details beyond the schema: the tool searches platforms concurrently and globally sorts results by coupon-adjusted price in ascending order. This goes beyond a generic 'compare prices' statement, though it does not mention potential latency or platform coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely compact: one leading sentence summarizes the tool's core behavior and sorting guarantee, followed by two concise parameter explanations. Every sentence carries necessary information, and the most important purpose is front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the presence of an output schema, the description does not need to explain return values. It covers the tool's operational behavior, sort order, and parameter semantics sufficiently for an agent to invoke it correctly. It falls short only in not providing explicit routing guidance against sibling tools.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, but the description fully compensates by explaining keyword as the search term and page_size as the number of top results taken per platform. This adds functional meaning that the raw schema lacks, making parameter intent unambiguous.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states a specific function: compare prices across multiple platforms, with concurrent search and global ascending sorting by coupon-adjusted price. This distinguishes it from generic search or detail tools, though it does not explicitly contrast with the sibling 'parse_and_compare'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies the tool is for multi-platform price comparison and sorting by final price after coupons, which conveys a clear use case. However, it does not explicitly state when to prefer this tool over alternatives like search_products or parse_and_compare, nor does it mention exclusions or prerequisites.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_couponsB

搜索优惠券。

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

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

B3.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It only states that it searches coupons and lists parameters, without describing return behavior, pagination semantics, or any side effects or limitations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is short and front-loaded with the main purpose, followed by a compact parameter list. It is efficient, though the parameter section is formatted as a docstring-style Args block rather than prose, which is acceptable for tool descriptions.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The presence of an output schema reduces the need to explain return values, and the parameter explanations are mostly adequate. However, the description lacks usage guidance and behavioral context, leaving an agent to infer when and how to invoke this tool among similar siblings.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, but the description compensates by explaining each parameter, including the platform enum values (all/taobao/jd/pdd) and that keyword can be a keyword or product ID. This adds real meaning beyond the raw schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a clear verb and resource ('搜索优惠券' / search coupons), making the core purpose understandable. However, it does not differentiate from the sibling tool search_products, which could overlap in intent.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage through its name and action, and the parameter list suggests filtering by keyword and platform. But it does not explicitly state when to prefer get_coupons over search_products or any other sibling, nor does it mention exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_product_detailA

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

Args:
    product_id: 平台侧商品 ID
    platform: 平台 (taobao / jd / pdd)
ParametersJSON Schema
NameRequiredDescriptionDefault
platformYes
product_idYes

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A3.5/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the behavioral burden. It communicates a read-oriented retrieval and a notable output trait ('含优惠券信息'), but it does not explicitly state read-only behavior, platform-specific return differences, authorization needs, or error behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is compact and front-loaded: one clear purpose line followed by two parameter lines. Every element earns its place and there is no filler or repetition.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple two-parameter detail lookup, the description plus the provided output schema covers the core invocation requirements: required parameters, platform values, and the inclusion of coupon data. The main missing piece is usage guidance, but the operational context an agent needs to call the tool is present.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the Args section compensates meaningfully: it defines product_id as the platform-side product ID and spells out the platform values (taobao / jd / pdd). This adds real semantics beyond the bare parameter names in the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource ('获取单品详情', getting single-item details) and adds that coupon information is included. This clearly indicates the tool retrieves one product's full detail rather than searching or comparing, distinguishing it from siblings like search_products and compare_prices.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no explicit guidance about when to use this tool versus the sibling tools. The existence of get_coupons, search_products, compare_prices, and parse_and_compare suggests a detail lookup, but the description does not state when to prefer get_product_detail over those alternatives or mention any prerequisites.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

parse_and_compareA

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

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

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

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the burden, and it does describe the actual behavior: extracting identifiers, querying the original product price, cross-platform search, and producing a comparison report. It omits edge-case behavior such as unparseable input or unavailable matches, but the core side-effect-free workflow is transparent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is compact and well-structured: a one-sentence summary, a short workflow expansion, and an Args section. Every sentence adds needed information without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with two simple parameters, an output schema, and no annotations, the description covers the essential input semantics and result concept (比价报告). It only lacks failure-mode and unsupported-input guidance, which would make selection and invocation fully robust.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description fully compensates by explaining raw_text as the share text containing the link/passcode and page_size as the number of same-product results taken per platform. This adds real meaning beyond the bare type definitions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb-resource pair: parse shared text and compare prices across platforms. It names the input types (淘口令/京东链接/拼多多链接) and the workflow (extract identifier, query original price, find same products, output report), which clearly distinguishes it from sibling tools like search_products or compare_prices.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It clearly establishes the context for use: when the agent receives shared text containing a shopping link or code. It does not explicitly name alternatives or state when not to use this tool relative to siblings, so it falls short of a full 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

search_productsA

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

Args:
    keyword: 搜索关键词
    platform: 平台筛选 (all / taobao / jd / pdd)
    page: 页码
    page_size: 每页数量
ParametersJSON Schema
NameRequiredDescriptionDefault
pageNo
keywordYes
platformNoall
page_sizeNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.5/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must carry behavioral disclosure. It adds a useful behavioral cue ('并发请求', meaning concurrent requests) and clarifies cross-platform scope, but it does not explicitly confirm read-only behavior, side-effect freedom, rate limits, or failure modes. Search semantics imply safety, yet the disclosure is not complete.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is compact and front-loaded with the core purpose, followed by a clean annotated parameter list. Every line earns its place and there is no redundant or filler content.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the schema provides defaults and an output schema exists, the description covers the essential inputs and behavior sufficiently. It explains all parameters and adds the concurrency note, though richer guidance around pagination conventions or when the result set spans multiple platforms would have rounded it out.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, and the description compensates by explaining every parameter: keyword, platform (with allowed values all/taobao/jd/pdd), page, and page_size. It adds value beyond the bare property names, especially for platform options which the schema does not enumerate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a clear verb and resource: '跨平台商品搜索' (cross-platform product search), which distinguishes it from the sibling tools like get_product_detail, compare_prices, and get_coupons. However, it does not explicitly differentiate itself by name from those siblings, so it stops short of a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives such as get_product_detail or compare_prices. It implies a broad searching use case but does not state exclusions, preferred context, or scenarios where a sibling would be more appropriate.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

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

  1. 5 tool updatesv0.2.0
    • First observedcompare_prices
    • First observedget_coupons
    • First observedget_product_detail
    • First observedparse_and_compare
    • First observedsearch_products

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

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables affiliate marketing and product promotion across Taobao, JD.com, and Pinduoduo platforms with link conversion, product search, and order tracking capabilities.
    15 npm
    122
    ISC
  • A
    license
    Not graded
    quality
    D
    maintenance
    多多进定全平台 MCP 服务是一个基于 Model Context Protocol (MCP) 的服务,支持拼多多大电商平台的链接转换和商品推广功能,商品搜索等等一系列工具
    15 npm
    ISC