Taobao Query Skill
This skill enables interacting with Taobao through an MCP (Model Context Protocol) server to query products, manage cart/orders, and communicate with sellers.
⚠️ Prerequisites - IMPORTANT
This skill requires a running Taobao MCP server.
Setup Required
- 1. Install Taobao Desktop Client (淘宝桌面版) on your local machine
- Enable MCP service in the client settings
- Configure MCP URL in your OpenClaw config (see below)
Default Configuration
Default MCP Server: INLINECODE0
If your MCP server runs on a different address, configure it via environment variable:
CODEBLOCK0
Or set it in OpenClaw config:
CODEBLOCK1
When to Use This Skill
Use this skill when the user:
- - Asks about product prices on Taobao (e.g., "iPhone 16 淘宝价格")
- Wants to search for items and compare prices
- Asks to view shopping cart contents
- Wants to check order status or history
- Needs to contact seller/customer service via 旺旺
- Requests product links from Taobao
- Mentions "销量" (sales volume), "店铺" (shop), "价格" (price), "购物车" (cart), "订单" (order)
🔴 RESTRICTION - IMPORTANT
NEVER perform the following operations:
- - Payment or checkout operations
- Confirming orders
- Any financial transactions
- Authorizing payments
- Auto-buying with stored payment methods
Permitted operations:
- - Search products
- View cart/orders (read-only)
- Add items to cart
- Browse products
- Chat with customer service
- Navigate pages
Query Strategy Based on User Input
Case 1: Specific Product Model Given
When user provides a specific model (e.g., "iPhone 16 Pro Max 256GB", "MacBook Air M4 13寸 16GB+512GB", "AirPods Pro 2"):
- 1. Search with exact keywords provided by user
- Filter results:
- Remove accessories, cases, protective films
- Remove single-ear replacements, charging case only listings
- Remove second-hand items (二手)
- Remove suspiciously low prices (e.g., iPhone for ¥1000)
- 3. Sort by price (ascending)
- Return top 5-8 results showing:
- Different stores and their prices
- Any subsidies (政府补贴, 百亿补贴) applied
- Official store for reference
Case 2: General Product Category Only
When user asks about a general category without specific model (e.g., "iPhone", "MacBook Air", "蓝牙耳机", "机械键盘"):
- 1. Search with broad keywords
- Analyze all results to identify:
- Different models/variants available
- Different specifications (storage, color, size, etc.)
- Price distribution across variants
- 3. Categorize by specifications:
- Group similar products together
- Identify entry-level, mid-range, high-end variants
- 4. Provide comprehensive report:
- Price range for each specification tier
- Popular/recommended variants
- Purchase advice based on use case
MCP Configuration
Server URL: ${TAOBAO_MCP_URL:-http://127.0.0.1:3654/mcp}
Transport: streamableHttp
Server Name: INLINECODE3
MCP Call Process
The MCP server uses streamable HTTP transport. Standard call process:
- 1. Initialize connection to get session ID:
CODEBLOCK2
- 2. Extract session ID from response headers: INLINECODE4
- 3. Call tools with session ID in header: INLINECODE5
Available Tools
Product Search & Browsing
- - searchproducts - Search products by keyword
- navigate - Navigate to Taobao pages (home, cart, order, tmall, my, etc.)
- navigatetourl - Open any URL
- readpagecontent - Read visible page text
- scrollpage - Scroll page
- scanpageelements - Scan interactive elements
- clickelement - Click page element
- inputtext - Input text to fields
Cart & Orders (Read-Only)
- - navigate with
page: cart or INLINECODE7 - readpagecontent - View cart/order details
- addtocart - Add items to cart (safe, no payment)
Customer Service
- - openchat - Open Wangwang chat and send message
- sendchat_message - Send additional messages in chat
Utility
- - getbrowsehistory - Get browsing history (product/search/shop)
- getcurrenttab - Get current page info
- closepage - Close current page
- inspectpage - Diagnose page DOM state
Output Formats
Format A: Specific Model Search Results
Use when user provided specific model:
CODEBLOCK3
Format B: General Category Analysis
Use when user asked about a category without specific model:
CODEBLOCK4
Filtering Rules
Always filter out:
- - Price = 0 or null
- Missing shop name
- Clearly mismatched products (e.g., searching for iPhone but getting cases)
- Used/second-hand items (二手, 翻新) unless specifically requested
- Accessories when searching for main product (cases, chargers, etc.)
- Suspiciously low prices (e.g., MacBook for ¥2000)
- Service listings (安装系统, 数据恢复, 租赁)
Link format:
- - Extract itemId from productUrl
- Tmall: INLINECODE8
- Taobao: INLINECODE9
Connection Health Detection
MCP service may disconnect. Detect and handle connection issues:
Connection Error Patterns
Connection failed indicators:
- -
Connection failed or Connection refused errors - Timeout errors (no response after 10+ seconds)
- INLINECODE12 header missing from initialize response
- Empty or malformed JSON responses
- HTTP status codes: 500, 502, 503, 504
Session expired indicators:
- - Error message: "未提供有效的会话ID" (invalid session ID)
- Error code:
-32000 with session-related message - Previously working session suddenly returns auth errors
Connection Recovery Steps
When connection fails:
- 1. First failure:
⚠️ MCP 服务连接失败,正在尝试重新连接...
- Retry initialize with new session
- If succeeds, continue with operation
- 2. Second failure (persistent):
❌ MCP 服务暂时不可用
可能原因:
- 淘宝桌面客户端未运行
- 网络连接问题
- MCP 服务需要重启
建议操作:
1. 检查淘宝桌面客户端是否已打开
2. 确认电脑网络连接正常
3. 重启淘宝桌面客户端后重试
当前配置的 MCP 地址: ${TAOBAO_MCP_URL:-http://127.0.0.1:3654/mcp}
- Stop attempting further MCP calls
- Inform user clearly about the issue
- Provide actionable troubleshooting steps
- 3. Session expired mid-operation:
- Detect "invalid session" errors
- Automatically re-initialize with new session
- Retry the failed operation once
- If still fails, treat as connection failure (step 2)
Proactive Health Check
Before major operations (e.g., viewing cart with many items), optionally verify connection:
CODEBLOCK7
Error Handling
If the MCP server is unreachable or returns an error:
- 1. Detect error type (connection vs. session vs. operational)
- For connection errors: Follow Connection Recovery Steps above
- For session errors: Attempt re-initialization once, then follow recovery steps
- For operational errors: Inform user of specific error, suggest alternatives
- Never make up fake product data or pretend operation succeeded
Safety Reminders
- - Never proceed to payment or checkout
- Never click "立即购买" (Buy Now) if it leads to payment
- Never confirm orders on behalf of the user
- Cart operations (add/view) are safe - payment is the red line
Example Interactions
User: "iPhone 16 Pro Max 256GB 多少钱"
→ Specific model given → Search exact keywords → Filter accessories → Return top 5-8 prices
User: "MacBook Air 推荐"
→ Category only → Search broadly → Analyze all M3/M4/M5 variants → Provide price ranges for each spec → Give purchase advice
User: "看看我的购物车"
→ Use navigate to cart → read_page_content → Show items
淘宝查询技能
该技能通过MCP(模型上下文协议)服务器与淘宝进行交互,实现商品查询、购物车/订单管理以及与卖家沟通的功能。
⚠️ 前置条件 - 重要提示
此技能需要运行中的淘宝MCP服务器。
设置要求
- 1. 在本地电脑安装淘宝桌面版客户端
- 在客户端设置中启用MCP服务
- 在OpenClaw配置中配置MCP URL(见下文)
默认配置
默认MCP服务器: http://127.0.0.1:3654/mcp
如果MCP服务器运行在不同的地址,可通过环境变量进行配置:
bash
添加到OpenClaw环境或shell配置文件
export TAOBAO
MCPURL=http://your-server-ip:3654/mcp
或在OpenClaw配置中设置:
json
{
env: {
TAOBAOMCPURL: http://192.168.100.20:3654/mcp
}
}
何时使用此技能
当用户出现以下情况时使用此技能:
- - 询问淘宝上的商品价格(例如:iPhone 16 淘宝价格)
- 想要搜索商品并比较价格
- 要求查看购物车内容
- 想要查看订单状态或历史记录
- 需要通过旺旺联系卖家/客服
- 请求淘宝商品链接
- 提及销量、店铺、价格、购物车、订单等关键词
🔴 限制 - 重要提示
严禁执行以下操作:
- - 支付或结账操作
- 确认订单
- 任何金融交易
- 授权支付
- 使用已保存的支付方式自动购买
允许的操作:
- - 搜索商品
- 查看购物车/订单(只读)
- 添加商品到购物车
- 浏览商品
- 与客服聊天
- 页面导航
基于用户输入的查询策略
情况1:指定具体产品型号
当用户提供具体型号时(例如:iPhone 16 Pro Max 256GB、MacBook Air M4 13寸 16GB+512GB、AirPods Pro 2):
- 1. 使用用户提供的精确关键词进行搜索
- 过滤结果:
- 移除配件、保护壳、保护膜
- 移除单耳替换、仅充电盒的列表
- 移除二手商品
- 移除价格异常低的商品(例如:iPhone售价¥1000)
- 3. 按价格排序(升序)
- 返回前5-8个结果,显示:
- 不同店铺及其价格
- 适用的任何补贴(政府补贴、百亿补贴)
- 官方店铺作为参考
情况2:仅提供通用产品类别
当用户询问通用类别而未指定具体型号时(例如:iPhone、MacBook Air、蓝牙耳机、机械键盘):
- 1. 使用宽泛关键词进行搜索
- 分析所有结果,识别:
- 可用的不同型号/变体
- 不同规格(存储、颜色、尺寸等)
- 各变体的价格分布
- 3. 按规格分类:
- 将相似产品分组
- 识别入门级、中端、高端变体
- 4. 提供综合报告:
- 各规格层级的价格范围
- 热门/推荐变体
- 基于使用场景的购买建议
MCP配置
服务器URL: ${TAOBAOMCPURL:-http://127.0.0.1:3654/mcp}
传输方式: streamableHttp
服务器名称: taobao-native
MCP调用流程
MCP服务器使用可流式HTTP传输。标准调用流程:
- 1. 初始化连接以获取会话ID:
bash
curl -X POST ${TAOBAO
MCPURL:-http://127.0.0.1:3654/mcp} \
-H Content-Type: application/json \
-H Accept: application/json, text/event-stream \
-d {
jsonrpc: 2.0,
id: 1,
method: initialize,
params: {
protocolVersion: 2024-11-05,
capabilities: {},
clientInfo: {
name: openclaw-agent,
version: 1.0.0
}
}
}
- 2. 从响应头中提取会话ID: mcp-session-id:
- 3. 在请求头中使用会话ID调用工具: mcp-session-id:
可用工具
商品搜索与浏览
- - searchproducts - 按关键词搜索商品
- navigate - 导航至淘宝页面(首页、购物车、订单、天猫、我的等)
- navigatetourl - 打开任意URL
- readpagecontent - 读取页面可见文本
- scrollpage - 滚动页面
- scanpageelements - 扫描交互元素
- clickelement - 点击页面元素
- inputtext - 向输入框输入文本
购物车与订单(只读)
- - navigate 使用 page: cart 或 page: order
- readpagecontent - 查看购物车/订单详情
- addtocart - 添加商品到购物车(安全,不涉及支付)
客服
- - openchat - 打开旺旺聊天并发送消息
- sendchat_message - 在聊天中发送更多消息
实用工具
- - getbrowsehistory - 获取浏览历史(商品/搜索/店铺)
- getcurrenttab - 获取当前页面信息
- closepage - 关闭当前页面
- inspectpage - 诊断页面DOM状态
输出格式
格式A:具体型号搜索结果
当用户提供具体型号时使用:
🛍️ [产品型号] 价格查询结果
价格对比(从低到高)
| 排名 | 店铺 | 价格 | 优惠/补贴 | 链接 |
|---|
| 1 | [店铺名] | ¥XXXX | 政府补贴15% | 查看 |
| 2 |
[店铺名] |
¥XXXX | 百亿补贴 |
查看 |
| 3 | [店铺名] |
¥XXXX | 无 |
查看 |
购买建议
- - 最优惠: [店铺名] ¥XXXX(有政府补贴,需确认资格)
- 官方保障: Apple Store 官方旗舰店 ¥XXXX
- 注意事项: [任何需要提醒的事项]
格式B:通用类别分析
当用户询问类别而未指定具体型号时使用:
🛍️ [产品类别] 价格分析
查询到 [N] 款在售商品,按规格分类如下:
📱 规格分类与价格区间
| 规格/型号 | 价格区间 | 推荐入手价 | 说明 |
|---|
| 入门款/基础版 | ¥X,XXX - ¥X,XXX | ¥X,XXX | 适合日常使用 |
| 中端款/Pro版 |
¥X,XXX - ¥X,XXX |
¥X,XXX | 性价比最高 |
| 旗舰款/Max版 | ¥X,XXX - ¥X,XXX |
¥X,XXX | 专业需求 |
💰 具体价格参考
[规格A]
- - 最低价:¥XXXX([店铺名])
- 官方价:¥XXXX(官方旗舰店)
- 百亿补贴价:¥XXXX(如适用)
[规格B]
🎯 购买建议
预算有限: 选择 [规格A],推荐 [店铺] ¥XXXX
追求性价比: 选择 [规格B],推荐 [店铺] ¥XXXX
要官方保障: 选择官方旗舰店 [规格] ¥XXXX
注意事项:
- - [提醒1: 如政府补贴需要资格]
- [提醒2: 如百亿补贴库存有限]
- [提醒3: 如新品即将发布等]
过滤规则
始终过滤掉:
- - 价格为0或空值
- 缺少店铺名称
- 明显不匹配的商品(例如:搜索iPhone却得到保护壳)
- 二手/翻新商品,除非特别要求
- 搜索主产品时的配件(保护壳、充电器等)
- 价格异常低的商品(例如:MacBook售价¥2000)
- 服务类列表(安装系统、数据恢复、租赁)
链接格式: