Tokopedia MCP Server
Enables AI assistants to search for products and manage order history on Tokopedia using the Model Context Protocol. It supports advanced filtering, sorting discovery, and authenticated session management via a dual MCP and web interface.
README
Tokopedia MCP Server
A Model Context Protocol (MCP) server that provides AI assistants with tools to interact with Tokopedia's product search and order management APIs. This server offers both MCP tool integration and a web interface for easy setup and monitoring.
Features
- Product Search: Search Tokopedia products with advanced filtering options
- Filter & Sort Discovery: Get available filters and sorting options for any search query
- Order History: Retrieve user's order history with pagination support
- Dual Interface: MCP protocol for AI assistants + HTTP web interface
- Docker Support: Containerized deployment with multi-stage builds
- Session Management: Support for authenticated Tokopedia sessions
Available Tools
search_product
Search for products on Tokopedia with comprehensive filtering options.
Parameters:
query(string): The search queryorderBy(optional): Sort order (23=relevance, 3=price low-high, 4=price high-low)condition(optional): Product condition (1=new, 2=used)rating(optional): Minimum rating (1-5, comma-separated for multiple)priceMin(optional): Minimum pricepriceMax(optional): Maximum pricelocation(optional): Location ID (comma-separated for multiple)
get_available_product_filters_and_sorts
Retrieve available filters and sorting options for a specific search query.
Parameters:
query(string): The search query
get_order_history
Get user's order history from Tokopedia (requires authenticated session).
Parameters:
page(number): Page number for paginationlimit(number): Number of orders per page
Setup
Prerequisites
- Bun (for local development)
- Docker (for containerized deployment)
- Tokopedia session cookie (for authenticated features)
Environment Variables
Create a .env file in the project root:
# Required for order history and personalized features
TOKO_SESSION=your_tokopedia_session_cookie_here
# Optional: Custom port (defaults to 3000)
PORT=3000
To get your TOKO_SESSION:
- Log into Tokopedia in your browser
- Open browser dev tools (F12)
- Go to Application/Storage → Cookies → tokopedia.com
- Copy the entire cookie string (all cookies concatenated with semicolons)
Local Development
-
Install dependencies:
bun install -
Build the project:
bun run build -
Run the server:
bun run serve # or directly: node build/index.js -
Access the web interface: Open http://localhost:3000 in your browser
Docker Deployment
Option 1: Build and run locally
# Build the Docker image
docker build -t tokopedia-mcp .
# Run with environment variables
docker run -d \
--name tokopedia-mcp \
-p 3000:3000 \
-e TOKO_SESSION="your_session_cookie_here" \
tokopedia-mcp
Option 2: Docker Compose
Create docker-compose.yml:
version: '3.8'
services:
tokopedia-mcp:
build: .
ports:
- '3000:3000'
environment:
- TOKO_SESSION=${TOKO_SESSION}
- PORT=3000
restart: unless-stopped
Run with:
docker-compose up -d
Remote Deployment
The server can be deployed to any platform that supports Node.js or Docker:
- Railway: Connect your GitHub repo and deploy automatically
- Render: Use the included Dockerfile for container deployment
- Fly.io: Deploy with
flyctl deployusing Docker - DigitalOcean App Platform: Deploy directly from GitHub
- AWS/GCP/Azure: Use container services or App Engine
For cloud deployment, make sure to:
- Set the
TOKO_SESSIONenvironment variable - Configure the correct
PORTif needed - Ensure the MCP endpoint
/mcpis accessible
Usage Examples
cURL Examples
Search Products
curl -X POST http://localhost:3000/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "search_product",
"arguments": {
"query": "laptop gaming",
"orderBy": 4,
"priceMin": 5000000,
"priceMax": 15000000
}
}
}'
Get Available Filters
curl -X POST http://localhost:3000/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "get_available_product_filters_and_sorts",
"arguments": {
"query": "smartphone"
}
}
}'
Get Order History
curl -X POST http://localhost:3000/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "get_order_history",
"arguments": {
"page": 1,
"limit": 10
}
}
}'
MCP Client Integration
Claude Desktop Integration
Add to your Claude Desktop configuration:
claude mcp add tokopedia http://localhost:3000/mcp
Or manually add to your claude_desktop_config.json:
{
"mcpServers": {
"tokopedia": {
"command": "node",
"args": ["/path/to/tokopedia-mcp/build/index.js"],
"env": {
"TOKO_SESSION": "your_session_cookie_here"
}
}
}
}
Cursor Integration
- Install the MCP extension in Cursor
- Add server configuration:
{ "tokopedia": { "url": "http://localhost:3000/mcp", "type": "http" } }
API Schema & Payloads
Search Product Schema
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "search_product",
"arguments": {
"query": "string (required)",
"orderBy": "number (optional: 23|3|4)",
"condition": "number (optional: 1|2)",
"rating": "string (optional: '1,2,3,4,5')",
"priceMin": "number (optional)",
"priceMax": "number (optional)",
"location": "string (optional: comma-separated IDs)"
}
}
}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"content": [
{
"type": "text",
"text": "Products for laptop gaming:\n\nName: ASUS ROG Strix G15\nPrice: Rp 12.999.000\nRating: 4.8\nURL: https://www.tokopedia.com/...\n---\n..."
}
]
}
}
Get Filters Schema
Request:
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "get_available_product_filters_and_sorts",
"arguments": {
"query": "string (required)"
}
}
}
Response:
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"content": [
{
"type": "text",
"text": "Filters and sorts for smartphone:\n\n{\n \"filter\": [...],\n \"sort\": [...]\n}"
}
]
}
}
Order History Schema
Request:
{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "get_order_history",
"arguments": {
"page": "number (required)",
"limit": "number (required)"
}
}
}
Response:
{
"jsonrpc": "2.0",
"id": 3,
"result": {
"content": [
{
"type": "text",
"text": "Order history for page 1:\n\nOrder ID: abc123\nName: Product Name\nPrice: Rp 500.000\nStatus: completed\nURL: https://www.tokopedia.com/...\nPurchased At: 2024-01-15\n---\n..."
}
]
}
}
MCP Registration Commands
Claude Desktop
# Add server via CLI
claude mcp add tokopedia http://localhost:3000/mcp
# Or add with custom configuration
claude mcp add tokopedia http://localhost:3000/mcp --config '{
"env": {
"TOKO_SESSION": "your_session_here"
}
}'
Cursor
- Open Cursor Settings → Extensions → MCP
- Add new server:
- Name:
tokopedia - URL:
http://localhost:3000/mcp - Type:
HTTP
- Name:
Development
Project Structure
src/
├── index.ts # Main entry point
├── server/
│ ├── app.ts # Express app setup
│ ├── mcp.ts # MCP server and tools
│ └── routes.ts # HTTP routes
├── templates/ # HTML templates for web UI
├── types/ # TypeScript type definitions
└── utils/
├── template-renderer.ts
└── tokopedia-api.ts # Tokopedia API integration
Building
# TypeScript compilation + template copying
bun run build
# Development with watch mode
bun --watch src/index.ts
Testing Tools
You can test individual tools using the web interface or cURL commands shown above.
Troubleshooting
Common Issues
1. "Failed to retrieve search data"
- Check your internet connection
- Verify Tokopedia is accessible from your network
- Try without filters first to test basic connectivity
2. "Failed to retrieve order history" / Authentication errors
- Ensure
TOKO_SESSIONenvironment variable is set correctly - Session cookies may expire - get a fresh session from your browser
- Make sure you're logged into Tokopedia in the browser where you got the session
3. Port already in use
- Change the PORT environment variable:
PORT=3001 - Or kill the process using the port:
lsof -ti:3000 | xargs kill
4. Docker build issues
- Make sure Docker daemon is running
- Clear Docker cache:
docker system prune -a - Check that all source files are included in the build context
5. MCP connection issues
- Verify the server is running and accessible
- Check firewall settings if accessing remotely
- Ensure the MCP client supports HTTP transport
Debug Mode
Set environment variable for verbose logging:
DEBUG=1 node build/index.js
Contributing
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and test thoroughly
- Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Disclaimer
This project is not officially affiliated with Tokopedia. It's an unofficial tool that interacts with Tokopedia's public APIs. Please use responsibly and in accordance with Tokopedia's Terms of Service.
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.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
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.