Marketplace Hub MCP
by 91wallace
README.md
---
title: Marketplace Hub MCP
emoji: 📦
colorFrom: blue
colorTo: green
sdk: docker
app_port: 7860
---
# Marketplace Hub MCP
Open-source, read-only **FastMCP** server for **Shopee** and **TikTok Shop** e-commerce integrations, supporting **DEMO** (offline synthetic fixtures) and **LIVE** modes, **stdio** and **Streamable HTTP** transports, and an interactive **Gradio** interface.
Derived from the production marketplace connectors of **Loja3D**, a real multi-channel e-commerce management application. The Shopee and TikTok Shop integrations are operationally validated in daily production use; this repository packages a clean, read-only, security-audited MCP layer on top of that architecture for AI agents, portfolio demonstration, and the [Hugging Face MCP Course](https://huggingface.co/learn/mcp-course/unit0/introduction).
- **GitHub Repository:** https://github.com/91wallace/marketplace-hub-mcp
- **License:** Apache 2.0 ([`LICENSE`](LICENSE))
- **Security Policy:** [`SECURITY.md`](SECURITY.md)
```mermaid
flowchart LR
Client[MCP Client / AI Agent] -->|stdio or /mcp| FastMCP
Browser[Browser] -->|/demo| Gradio
FastMCP --> Services[Validated Read-Only Services]
Gradio --> Services
Services --> Registry[Provider Registry]
Registry --> Demo[DEMO Synthetic Fixtures]
Registry --> Live[LIVE Store APIs]
```
## Capabilities
### MCP Tools (Read-Only)
| Tool | Purpose |
| --- | --- |
| `list_marketplaces` | Channels, capabilities, and effective mode (`demo` or `live`) |
| `list_orders` | Minimal paged order records |
| `get_sales_summary` | Estimated gross paid/completed order sales across every page |
| `get_inventory` | SKU and warehouse balances, with unknown stock as `null` |
### MCP Prompts
| Prompt | Purpose |
| --- | --- |
| `sales_analysis_prompt` | Guides AI assistants through currency-safe sales analysis using `list_marketplaces`, `get_sales_summary`, and `list_orders` |
| `inventory_audit_prompt` | Guides AI assistants through stock auditing using `list_marketplaces` and `get_inventory` without summing shared physical stock |
### Tool Parameters
| Parameter | Tools | Meaning |
| --- | --- | --- |
| `channel` | orders, summary, inventory | Optional `shopee` or `tiktok_shop`; omit for all configured channels |
| `start_date`, `end_date` | orders, summary | Optional inclusive ISO dates, `YYYY-MM-DD` |
| `cursor` | orders, inventory | Opaque continuation returned by the previous page |
| `limit` | orders, inventory | Page size from 1 to 100 |
| `sku` | inventory | Optional exact SKU filter |
## Install and Run (Local)
```powershell
py -m venv .venv
.\.venv\Scripts\python.exe -m pip install -r requirements.txt
.\.venv\Scripts\python.exe -m marketplace_hub_mcp
```
### MCP Client Configuration (stdio)
- **Claude Desktop:** [`examples/claude_desktop.json`](examples/claude_desktop.json)
- **Cursor:** [`examples/cursor.json`](examples/cursor.json) (`.cursor/mcp.json`)
```json
{
"mcpServers": {
"marketplace-hub-mcp": {
"command": "C:\\path\\to\\marketplace-hub-mcp\\.venv\\Scripts\\python.exe",
"args": ["-m", "marketplace_hub_mcp"],
"env": { "DEMO_MODE": "true" }
}
}
}
```
### Streamable HTTP + Gradio
Run `python space.py` and open `http://localhost:7860/` (redirects to `/demo/`). Connect MCP clients to `http://localhost:7860/mcp`. `space.py` calls `create_server(force_demo=True)`, so it strictly enforces DEMO mode even if LIVE environment variables are present.
## DEMO vs. LIVE Modes
- **DEMO mode (`DEMO_MODE=true`, default):** Uses exclusively synthetic offline fixtures. Zero credentials, database, or network egress required. Public deployments (`space.py`) always force DEMO mode.
- **LIVE mode (`DEMO_MODE=false`):** Connects to official Shopee and TikTok Shop APIs using store credentials supplied via environment variables or a local `.env` (see [`.env.example`](.env.example)). Set `LIVE_CHANNEL=shopee`, `tiktok_shop`, or `shopee,tiktok_shop`. OAuth/token renewal is handled externally. No demo records are returned on LIVE errors.
## Hugging Face Spaces & MCP Course Alignment
This project is packaged with a `Dockerfile` (`python:3.12-slim`, port `7860`, `DEMO_MODE=true`) for Hugging Face Docker Spaces. Note that hosting Docker or Gradio Spaces on Hugging Face currently requires a Hugging Face PRO subscription (the free tier returns `402 Payment Required` for Docker Spaces).
### MCP Course Mapping
- **Course Enrollment:** https://huggingface.co/mcp-course
- **Unit 1 (Fundamentals Certificate):** Covers MCP architecture, tools, transports, and SDKs. Quiz Space: https://huggingface.co/spaces/mcp-course/unit_1_quiz ([page](https://huggingface.co/learn/mcp-course/unit1/certificate)).
- **Unit 2 (End-to-End Application):** Aligned via `space.py` (Gradio `/demo/` + FastMCP `/mcp`), client configs (`examples/`), and Docker Space packaging (`Dockerfile`).
- **Unit 3 (Advanced MCP Workflows):** Aligned via typed read-only Tools, MCP Prompts (`sales_analysis_prompt`, `inventory_audit_prompt`), and GitHub Actions CI/CD (`.github/workflows/quality.yml`). Certificate of Completion Quiz Space: https://huggingface.co/spaces/mcp-course/unit_3_quiz ([page](https://huggingface.co/learn/mcp-course/unit3/certificate)).
> Publishing this repository does not automatically grant certification; passing the official quiz Spaces while logged into Hugging Face is required.
## Quality & Security Checks
Verified locally and in GitHub Actions (`.github/workflows/quality.yml`):
- `python -m pytest -q` — 20 automated tests passing (unit, regression, and stdio/HTTP transport tests with synthetic HTTP responses)
- `ruff check .` — 0 lint errors
- `pip-audit -r requirements.txt` — 0 known vulnerabilities
- `gitleaks` — 0 secrets/leaks detected
## Future Extensibility
The modular provider registry in [`marketplace_hub_mcp/core.py`](marketplace_hub_mcp/core.py) is designed to support additional marketplaces (such as Mercado Livre, Amazon, and Shein) without changing the MCP tool surface.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues