tokopedia-mcp
MCP server for searching Tokopedia products, retrieving product details and reviews, designed for use from LLM clients like Claude Desktop.
README
tokopedia-mcp
Disclaimer: Proyek ini dibuat untuk tujuan edukasi semata. Penulis tidak berafiliasi dengan Tokopedia dan tidak bertanggung jawab atas penyalahgunaan proyek ini. Gunakan dengan bijak.
Server MCP untuk pencarian produk Tokopedia — mencakup pencarian produk, detail produk, dan ulasan pelanggan — yang dapat langsung digunakan dari klien LLM (Claude Desktop, Claude Code, Cursor, dan lainnya).
Dibangun dengan mcp 2.x (MCPServer), curl-cffi (untuk impersonasi sidik
jari TLS), dan model pydantic. Seluruh harga dalam Rupiah (IDR).
Tools
| Tool | Fungsi |
|---|---|
search_products |
Mencari produk berdasarkan kata kunci dengan filter opsional (rentang harga, kondisi, tipe toko, rating minimum, produk baru, gratis ongkir, diskon, COD, dan lainnya). Mengembalikan {products, count}. |
get_product_details |
Mengambil detail lengkap satu produk berdasarkan id atau URL: harga, deskripsi, varian, stok, media, dan toko. |
get_product_reviews |
Mengambil ulasan pelanggan: pesan, rating, informasi pengguna, dan balasan penjual. Mengembalikan {reviews, count}. |
Instalasi
Membutuhkan Python >= 3.10. Pasang uv terlebih
dahulu (di Arch: sudo pacman -S uv, di macOS: brew install uv, atau lewat
installer resmi dari astral.sh), lalu:
uv sync # membuat .venv sekaligus memasang dependensi
Tidak memakai uv? Bisa juga dengan pip biasa:
python -m venv .venv
.venv/bin/pip install -e '.[dev]'
Menjalankan
Menggunakan transport stdio (default — untuk klien MCP):
uv run tokopedia-mcp
# atau: uv run python -m tokopedia_mcp
Untuk transport jaringan:
uv run tokopedia-mcp --transport sse --port 8000
uv run tokopedia-mcp --transport streamable-http --port 8000
Contoh konfigurasi di Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"tokopedia": {
"command": "/absolute/path/to/tokopedia-mcp/.venv/bin/tokopedia-mcp"
}
}
}
Pengujian
uv run pytest # pengujian offline memakai fixture terekam, tanpa internet
uv run pytest -m live # pengujian end-to-end: menjalankan server dan memanggil Tokopedia langsung
Cara kerja
Tokopedia tidak menyediakan API pencarian produk publik, sehingga server ini berkomunikasi langsung dengan GraphQL API internal yang digunakan aplikasi iOS resmi:
POST gql.tokopedia.com/graphql/SearchResult/getProductResult— pencarianPOST gql.tokopedia.com/graphql/ProductDetails/getPDPLayout— detail produkPOST gql.tokopedia.com/graphql/ProductReview/getProductReviewReadingList— ulasan
Lapisan edge (Akamai) menolak permintaan yang tidak menyerupai aplikasi asli.
Karena itu setiap permintaan membawa header khusus aplikasi beserta
identitas perangkat acak yang segar (user id, Bd-Device-Id, payload
fingerprint, timestamp) dan sidik jari TLS Safari melalui impersonasi
curl-cffi. Klien juga otomatis melakukan retry pada kegagalan sementara
(backoff eksponensial) dan membuang duplikat hasil pencarian antar halaman.
Struktur proyek
src/tokopedia_mcp/
queries.py # query GraphQL dan path endpoint
models.py # model pydantic: Product, Shop, Review, SearchFilters
extractors.py # parsing murni: payload API -> model (dapat diuji offline)
client.py # TokopediaClient: HTTP asinkron, retry, paginasi
server.py # MCPServer + definisi tools
__main__.py # titik masuk CLI (stdio / sse / streamable-http)
tests/
fixtures/ # respons asli yang terekam, dipakai pengujian offline
Kredit
Query GraphQL beserta format permintaannya diambil dari tokopaedi karya Hilmi Azizi. Terima kasih!
Lisensi
MIT
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
Neon Database
MCP server for interacting with Neon Management API and databases
E2B
Using MCP to run code via e2b.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.