Mercari MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
pip install -e .
2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add mercari-mcp -- node "<FULL_PATH_TO_MERCARI_MCP>/dist/index.js"

Replace <FULL_PATH_TO_MERCARI_MCP>/dist/index.js with the actual folder you prepared in step 1.

README.md

An MCP agent tool for searching products on the Mercari marketplace.

Mercari MCP 服务器

一个用于搜索Mercari商品的MCP(Model Context Protocol)智能体工具。

功能特性

  • 🔍 关键词搜索:根据关键词搜索Mercari商品
  • 📋 商品详情:获取特定商品的详细信息
  • 🏷️ 分类搜索:按商品分类进行搜索
  • 💰 价格筛选:支持价格范围过滤
  • 📦 状态筛选:根据商品状态筛选
  • 📊 排序选项:支持多种排序方式
  • 🔄 分页浏览:支持分页查看搜索结果

依赖项

  • Python 3.8+
  • MCP SDK
  • mercapi
  • pydantic
  • httpx

安装

  1. 克隆项目:
git clone <repository-url>
cd mercari-mcp
  1. 安装依赖:
pip install -e .

或者使用虚拟环境:

python -m venv .venv
source .venv/bin/activate  # 在Windows上使用: .venv\Scripts\activate
pip install -e .

使用方法

作为MCP服务器运行

1. stdio模式(标准输入输出)
python -m mercari_mcp.server
2. SSE模式(Server-Sent Events)
python scripts/run_sse_server.py

或者指定端口和主机:

python scripts/run_sse_server.py --host 127.0.0.1 --port 8000

SSE模式提供以下端点:

工具列表

1. search_mercari_items

搜索Mercari商品

参数:

  • keyword (必需): 搜索关键词
  • category_id (可选): 分类ID
  • brand_id (可选): 品牌ID
  • price_min (可选): 最低价格
  • price_max (可选): 最高价格
  • condition (可选): 商品状态 (new, like_new, good, fair, poor)
  • sort (可选): 排序方式 (created_time, price, popular)
  • order (可选): 排序顺序 (asc, desc)
  • page (可选): 页码
  • limit (可选): 每页数量

示例:

{
  "keyword": "iPhone",
  "price_min": 10000,
  "price_max": 50000,
  "condition": "like_new",
  "sort": "price",
  "order": "asc"
}
2. get_mercari_item_detail

获取商品详情

参数:

  • item_id (必需): 商品ID

示例:

{
  "item_id": "m12345678"
}
3. search_mercari_by_category

按分类搜索商品

参数:

  • category_name (必需): 分类名称
  • price_min (可选): 最低价格
  • price_max (可选): 最高价格
  • condition (可选): 商品状态
  • sort (可选): 排序方式
  • page (可选): 页码
  • limit (可选): 每页数量

示例:

{
  "category_name": "电子产品",
  "price_min": 5000,
  "price_max": 30000
}

配置

MCP客户端配置

stdio模式配置

在您的MCP客户端配置中添加以下内容:

{
  "mcpServers": {
    "mercari-mcp": {
      "command": "python",
      "args": ["-m", "mercari_mcp.server"]
    }
  }
}
SSE模式配置

在您的MCP客户端配置中添加以下内容:

{
  "mcpServers": {
    "mercari-mcp-sse": {
      "url": "http://127.0.0.1:8000/sse",
      "description": "Mercari商品搜索MCP服务器(SSE模式)",
      "transport": "sse"
    }
  }
}

环境变量

目前暂无特殊环境变量需要设置。

开发

项目结构

mercari-mcp/
├── src/
│   └── mercari_mcp/
│       ├── __init__.py
│       ├── server.py          # MCP服务器主文件
│       └── mercapi_client.py  # Mercapi客户端包装器
├── pyproject.toml
├── README.md
└── requirements.txt

开发环境设置

  1. 安装开发依赖:
pip install -e ".[dev]"
  1. 运行测试:
pytest
  1. 代码格式化:
black src/
isort src/
  1. 类型检查:
mypy src/

测试

测试stdio模式
python scripts/test_mcp.py
测试SSE模式

首先启动SSE服务器:

python scripts/run_sse_server.py

然后在另一个终端运行测试:

python scripts/test_sse_server.py

故障排除

常见问题

  1. 模块导入错误

    • 确保已正确安装所有依赖
    • 检查Python路径和虚拟环境
  2. API调用失败

    • 检查网络连接
    • 确认mercapi库是否正确安装
  3. MCP连接问题

    • 检查MCP客户端配置
    • 确认服务器正在运行

调试

启用调试日志:

export PYTHONPATH=src
python -m mercari_mcp.server --log-level DEBUG

许可证

MIT License

贡献

欢迎提交问题和合并请求!

  1. Fork项目
  2. 创建功能分支
  3. 提交更改
  4. 推送到分支
  5. 创建Pull Request

更新日志

v0.1.0

  • 初始版本
  • 基本的商品搜索功能
  • 商品详情获取功能
  • 分类搜索功能

Tools (3)

search_mercari_itemsSearch for products on Mercari using keywords and various filters.
get_mercari_item_detailRetrieve detailed information for a specific Mercari item.
search_mercari_by_categorySearch for products on Mercari by category name with optional filters.

Configuration

claude_desktop_config.json
{"mcpServers": {"mercari-mcp": {"command": "python", "args": ["-m", "mercari_mcp.server"]}}}

Try it

Search for an iPhone in like-new condition priced between 10000 and 50000 yen.
Find the latest listings in the electronics category under 30000 yen.
Get the full details for the Mercari item with ID m12345678.
Show me popular items matching the keyword 'vintage camera' sorted by price.

Frequently Asked Questions

What are the key features of Mercari MCP?

Keyword-based product search on Mercari. Detailed item information retrieval. Category-based product browsing. Advanced filtering by price, condition, and sorting options. Pagination support for search results.

What can I use Mercari MCP for?

Automating price tracking for specific items on the Mercari marketplace.. Integrating marketplace search capabilities directly into AI-assisted shopping workflows.. Quickly retrieving item specifications and status for potential purchases.. Filtering large categories to find specific deals based on budget and item condition..

How do I install Mercari MCP?

Install Mercari MCP by running: pip install -e .

What MCP clients work with Mercari MCP?

Mercari MCP works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Mercari MCP docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare