🚀 TikTok MCP Service
A Model Context Protocol service for TikTok video discovery and metadata extraction. This service provides a powerful interface to search for TikTok videos by tags and extract popular content, with built-in anti-detection measures and error handling.
🚀 Quick Start
The TikTok MCP Service is a robust tool for searching TikTok videos. It offers a range of features such as searching by tags, configurable video counts per search, and built-in anti-robot detection.
✨ Features
- Search for videos using tags.
- Configurable number of videos per search (default: 30).
- Anti-robot detection measures.
- Proxy support.
- Automatic API session management.
- Rate limiting and error handling.
- Health status monitoring.
📦 Installation
Configuration
The service is configured using environment variables. Create a .env
file with the following content:
ms_token=your_tiktok_ms_token # Optional but recommended to avoid anti-robot detection
TIKTOK_PROXY=your_proxy_url # Optional proxy configuration
Installation Steps
# Install dependencies
poetry install
# Install browser automation dependencies
poetry run python -m playwright install
# Start the service
poetry run python -m tiktok_mcp_service.main
💻 Usage Examples
Integration with Claude Desktop
Once the service is running, you can integrate it into Claude Desktop. Since we use Poetry for dependency management, make sure to execute MCP CLI commands via Poetry:
# Navigate to the project directory
cd /path/to/tiktok-mcp-service
# Install the service to Claude Desktop in editable mode
poetry run mcp install tiktok_mcp_service/main.py --with-editable . -f .env
# Optional: Install with a custom name
poetry run mcp install tiktok_mcp_service/main.py --name "TikTok Video Search" --with-editable . -f .env
After installation, the service will be available in Claude Desktop and managed by Poetry for dependencies.
📚 Documentation
API Endpoints
Health Check
GET /health
- Check the service health status and API initialization status.
{
"status": "running",
"api_initialized": true,
"service": {
"name": "TikTok MCP Service",
"version": "0.1.0",
"description": "A Model Context Protocol service for searching TikTok videos"
}
}
Search Videos
POST /search
- Search for videos using tags.
{
"search_terms": ["python", "coding"],
"count": 30 // Optional, default is 30
}
The response includes video URLs, descriptions, and interaction statistics (views, likes, shares, comments).
Resource Management
POST /cleanup
- Clean up resources and API sessions.
Error Handling
The service includes comprehensive error handling for the following situations:
- API initialization failure.
- Anti-robot detection issues.
- Network errors.
- Rate limiting.
- Invalid search terms.
🔧 Technical Details
The service is developed using the following technologies:
- TikTokApi
- FastMCP
- Poetry for dependency management
- Playwright for browser automation
📄 License
This project is licensed under the MIT License.







