Skip to main content
Glama
xhjiang1998
by xhjiang1998

xianyu-buyer-mcp

Xianyu (Goofish) buyer-side inquiry MCP Server. Supports searching products, batch sending inquiry messages, and automatically collecting seller replies.

Features

Tool

Description

login

Log in to Xianyu by scanning a QR code (required on first use; cookies are reused automatically afterward)

check_login

Check the login status

search

Search products and return a product list + seller IDs

send_inquiry

Send an inquiry message to a single seller

batch_send_inquiry

Send inquiry messages in batch

get_conversations

Get the IM conversation list and view all seller replies

get_conversation_detail

Get the complete chat history with a specific seller

Related MCP server: goofish-cli

Installation

Prerequisites

  • Python 3.11+

  • Xianyu/Taobao app (for QR-code login)

  • Xianyu web version / Taobao desktop client (for receiving and replying to messages)

Steps

# 1. 克隆项目
git clone https://github.com/<your-username>/xianyu-buyer-mcp.git
cd xianyu-buyer-mcp

# 2. 安装依赖
pip install -e .

# 3. 安装 Chromium 浏览器
playwright install chromium

Optional Configuration

Copy the environment variable template and modify it as needed:

cp .env.example .env

Variable

Default

Description

PLAYWRIGHT_HEADLESS

false

Whether to run in headless mode (it is recommended to keep false so you can scan the QR code)

PROXY

(empty)

HTTP proxy address

COOKIES_PATH

~/.xianyu-buyer-mcp/cookies.json

Cookie storage path

XIANYU_HOME_URL

https://www.goofish.com

Xianyu homepage URL

Use with MCP Clients

Claude Desktop / Cursor / QoderWork

Add the following to the MCP configuration file:

{
  "mcpServers": {
    "xianyu-buyer": {
      "command": "python",
      "args": ["/path/to/xianyu-buyer-mcp/server.py"]
    }
  }
}

First-Time Use

  1. Call the login tool in the AI assistant

  2. A browser window automatically pops up to the Xianyu login page

  3. Scan the QR code with the Xianyu or Taobao app

  4. Cookies are automatically saved to ~/.xianyu-buyer-mcp/cookies.json

  5. No need to scan again on subsequent uses

Typical Workflow

cp .env.example .env
# 1. 登录
login()

# 2. 搜索商品
search("MacBook Pro M1 16G 512G", max_price=5000)

# 3. 批量询价
batch_send_inquiry(
  items='[{"itemId": "xxx", "sellerId": "yyy"}, ...]',
  message="你好,还在吗?"
)

# 4. 查看回复
get_conversations()

# 5. 查看某个对话详情
get_conversation_detail(item_id="xxx", seller_id="yyy")

Technical Details

  • Anti-detection: Uses playwright-stealth + custom UA + navigator spoofing to reduce the risk of being identified as a bot

  • CAPTCHA avoidance: Seller information queries go through the lib.mtop.request SDK on the IM page, avoiding slider CAPTCHA triggers on product detail pages

  • Rate limiting: Batch messages are sent 2 seconds apart to avoid triggering platform risk controls

  • Thread safety: All browser operations are serialized and executed in a single-threaded executor

Notes

  • Xianyu has anti-scraping mechanisms. Do not make high-frequency calls or use it for large-scale data collection

  • Cookies have a limited validity period and you will need to scan the QR code again after they expire

  • This project is for learning and research purposes only. Please comply with the Xianyu platform terms of use

License

MIT

Related MCP Connectors

Related MCP Servers