TikTok Shop MCP
by mochridha
README.md
# TikTok Shop MCP
Remote MCP server (read only) for the TikTok Shop Open API, so Claude can read a TikTok Shop's
orders, products, stock, returns and settlements. Same stack and layout as `shopee-mcp`:
Next.js on **Vercel** + **Supabase**.
```
Seller ──► your-app.vercel.app ──► TikTok Shop authorize ──► /api/auth/callback ──► API key tmcp_… (shown once)
Claude ──(/api/mcp/<key> or Authorization: Bearer tmcp_…)──► /api/mcp ──► TikTok Shop Open API
```
## Tools
| Tool | What it does |
| --- | --- |
| `list_shops` | Shops on this key |
| `list_orders` | Orders created/updated in a date range, filter by status |
| `get_order_details` | Up to 50 orders by id |
| `list_products`, `get_product` | Products, SKUs, prices, stock |
| `get_inventory` | Stock per SKU and warehouse |
| `list_returns` | Return/refund requests |
| `list_statements` | Settlement statements |
| `call_api` | Any other read endpoint (GET, or POST to …/search, …/query) |
Dates are `YYYY-MM-DD` (read as Asia/Jakarta) or unix seconds. Tokens refresh automatically.
Every call is written to `tts_audit_log`.
## Setup (Bahasa Indonesia)
1. **Supabase.** Buka project Supabase yang dipakai shopee-mcp (boleh project yang sama), masuk
**SQL Editor**, tempel isi `supabase/migrations/0001_init.sql`, lalu **Run**. Semua tabel berawalan
`tts_`, jadi tidak bentrok dengan tabel Shopee.
2. **Vercel.** Add New → Project → import repo ini. Isi Environment Variables:
| Variable | Ambil dari |
| --- | --- |
| `TIKTOK_APP_KEY`, `TIKTOK_APP_SECRET`, `TIKTOK_SERVICE_ID` | Partner Center → App & Service → hbz_tiktok_api → Manage |
| `SUPABASE_URL`, `SUPABASE_SERVICE_ROLE_KEY` | Supabase → Project Settings → API (sama seperti shopee-mcp) |
Deploy, lalu catat domainnya, misalnya `https://tiktok-shop-mcp-xxx.vercel.app`.
3. **Redirect URL.** Di Partner Center → Manage app, ganti Redirect URL jadi
`https://<domain-vercel>/api/auth/callback`, lalu simpan.
4. **Hubungkan toko.** Buka `https://<domain-vercel>`, klik **Connect with TikTok Shop**, login sebagai
seller Humblezing, lalu Authorize. Halaman berikutnya menampilkan API key `tmcp_…` **sekali saja**.
5. **Tambahkan di Claude.** Settings → Connectors → Add custom connector, tempel URL
`https://<domain-vercel>/api/mcp/<key>` yang ditampilkan di langkah 4.
Cabut key kapan saja:
`curl -X POST https://<domain-vercel>/api/keys/revoke -H "Authorization: Bearer tmcp_…"`
## Development
```
npm install
npm test # Supabase and TikTok faked at the fetch level, no credentials needed
npm run typecheck
npm run build
```
API reference: https://partner.tiktokshop.com/docv2