MCP service for Xianyu (闲鱼) with Playwright browser automation
Wellknown found it in public sources; nobody has proven control of it yet. Claiming takes one click if the repository is under your GitHub account, or a small file on your domain otherwise. Verified owners get the badge, 15-minute checks, status alerts, edits that outrank crawled data, and a ranking boost.
Agents can do it too: POST https://wellknown.network/api/v1/claims with {"agent":"xianyu-mcp","method":"well_known_file"} — machine-readable steps at claim.json, guide at /docs/claim.
Everything here was measured by our prober or read from a registry. Nothing is self-reported.
Attributed to the source that supplied each field. Treated as claims, not facts.
# xianyu-mcp `xianyu-mcp` 是一个面向 MCP 客户端使用者的闲鱼 MCP Server。它通过 Playwright 和闲鱼网页能力,提供登录、商品发布、收藏管理、商品查询、卖家主页读取等能力。 你可以把它接入支持 MCP 的客户端,例如 Codex、Claude Code、MCP Inspector,或任何兼容 `stdio` / `streamable_http` 的 MCP 工具。 ## 它能做什么 - 登录闲鱼账号,获取扫码二维码并轮询登录结果 - 登录二维码会保存到本地 `screenshots/` 目录,并返回可供用户打开的图片文件提示 - 发布商品、下架商品、删除商品 - 搜索商品、读取商品详情、读取首页推荐 - 添加收藏、取消收藏、读取收藏列表 - 读取我发布的商品列表、读取卖家主页信息 - 通过 `analyze_goods` 工具生成商品分析提示词和分析上下文数据 当前项目实际注册了 **16 个 MCP tools**。 ## 环境要求 - Python 3.10 或更高版本 - 可正常启动的 Chromium 浏览器环境 - 能访问闲鱼网页 ## 通过 uvx 使用(推荐) 无需手动安装,uvx 会自动处理。 ### Claude Code 配置 ```bash claude mcp add xianyu -e MCP_TRANSPORT=stdio -- uvx xianyu-mcp ``` ### 首次运行 首次运行会自动安装 Playwright Chromium(约需 1-2 分钟)。 --- ## 快速开始 ### 方式一:默认作为 `stdio` MCP Server 运行 默认启动方式是 `stdio`,适合 Claude Code 等 MCP 客户端以子进程方式拉起。 ```sh xianyu-mcp ``` 如果命令行入口不可用,也可以这样启动: ```sh python -m xianyu_mcp ``` ### 方式二:作为本地 `streamable_http` MCP Server 运行 如果需要常驻服务供多个客户端复用,可切换到 `streamable_http`: ```env MCP_TRANSPORT=streamable_http ``` 然后启动服务: ```sh xianyu-mcp ``` 默认地址为: ```text http://127.0.0.1:18000/mcp ``` ## 配置 你可以通过环境变量或 `.env` 文件调整运行行为。常用项如下: | 变量 | 默认值 | 说明 | |---|---|---| | `HEADLESS` | `true` | 是否使用无头浏览器 | | `PAGE_TIMEOUT` | `30000` | 页面操作超时,单位毫秒 | | `SLOW_MO` | `0` | 浏览器慢动作延时,单位毫秒 | | `COOKIE_AUTO_SYNC_ENABLED` | `true` | 是否开启 Cookie 自动同步 | | `COOKIE_SYNC_INTERVAL_SECONDS` | `600` | Cookie 同步间隔,单位秒 | | `COOKIE_SYNC_TIMEOUT_SECONDS` | `30` | 单次 Cookie 同步超时,单位秒 | | `AUTO_SCREENSHOT` | `false` | 是否自动截图 | | `SCREENSHOT_DIR` | `./screenshots` | 截图目录 | | `LOG_LEVEL` | `INFO` | 日志级别 | | `MCP_TRANSPORT` | `stdio` | 传输模式:`stdio` 或 `streamable_http` | | `MCP_TOOL_TIMEOUT_SECONDS` | `10` | 单个工具调用超时,单位秒 | | `MCP_HTTP_HOST` | `127.0.0.1` | HTTP 模式监听地址 | | `MCP_HTTP_PORT` | `18000` | HTTP 模式监听端口 | | `MCP_STREAMABLE_HTTP_PATH` | `/mcp` | HTTP 模式路径 | 例如,如果你想看到浏览器界面: ```env HEADLESS=false ``` ## Tools 一览 ### 账号登录 - `check_login_status`:检查当前是否已登录 - `get_login_qrcode`:获取登录二维码(二维码图片保存到本地 `screenshots/`) - `check…
Mapped onto the structured taxonomy from declared text and observed tool names. Confidence shown for derived entries.
Every source is kept verbatim. Field changes are logged as events.