
lozzi1910/douyin-mcp
Developer toolsThis page was translated automatically. Technical details may differ from the original. View the original
MCP Server for Douyin — let AI search users, read and send Douyin direct messages
Overview
Exposing Douyin's web version's private message/chat features as MCP (Model Context Protocol) tools, allowing AI assistants to search users, read, and send Douyin private messages. 1. After launching the service, the browser will automatically open the Douyin login page. 2. The terminal will display the screenshot path of the QR code. 3. Scan the QR code with the Douyin app on your phone. 4. After successful login, the login mode will automatically be saved to ~/.douyin_mcp/storage.json 5. Afterwards, the login mode will automatically resume when you start the program — Search for Douyin users - Search for specified keywords on the Douyin search page - returns the user's nickname, Douyin ID, bio, and follower count — List private message sessions - extract the session list from the /messages page - return each session's nickname, last message, and unread mark — Read private messages - locate contacts in the session list - extract message text and sender information from the DOM — Send a private message - find a user in the session list - inject text via Draft.js JS - click the send button to complete the send The TikTok chat input box is Draft.js-based and cannot use standard fill() or type(). Injecting the ClipboardEvent('paste') event via page.evaluate() triggers the onChange callback of Draft.js. Use Playwright's storage_state() to save cookies and localStorage to ~/.douyin_mcp/storage.json, then automatically restore after launch.
Overview (machine translated)
Exposing Douyin’s web version’s private message/chat features as MCP (Model Context Protocol) tools, allowing AI assistants to search users, read, and send Douyin private messages.
Core Features
| # | Features | MCP Tools | Implementation Methods |
|---|---|---|---|
| 1 | 🔍 Search Users | search_user(keyword) |
Search page → DOM extracts user information |
| 2 | 📥 Read Private Messages | read_messages(contact, limit) |
DOM extracts message text (zero cost) |
| 3 | 📤 Send Private Message | send_message(user_id, text) |
Draft.js JS injection + click send |
| 4 | 📋 Session List | list_conversations() |
DOM extracts session items (nickname, last message, unread) |
Technical Architecture
Get Started Quickly
Prerequisites
- Python 3.10+
- Mobile Douyin App (for QR code login)
Installation
Startup
Docker deployment
First Deployment
Connecting to MCP Host
Docker Compose Configuration
Administrative Commands
User Guide
First Launch
For the first run, you need to scan the Douyin QR code to log in:
- After launching the service, the browser will automatically open the Douyin login page
- The terminal displays the QR code screenshot path
- Scan the QR code with the Douyin app on your phone
- After successful login, the login state is automatically saved to
~/.douyin_mcp/storage.json - Automatically restores login mode after subsequent startup
Tool Description
search_user (keyword) — Search for Douyin users
- Search for specific keywords on the Douyin search page
- Returns user nickname, Douyin ID, bio, and follower count
list_conversations() — List private message conversations
- Extract the session list from the
/messagespage - Returns the nickname, last message, and unread mark for each session
read_messages(contact, limit=20) — Read private messages
- Locate contacts in the conversation list
- Extract message text and sender information from the DOM
send_message(user_id, text) — Send a private message
- Find users in the session list
- Inject text into Draft.js JS
- Click the send button to complete the send
Project Structure
Key Technical Implementations
Draft.js input
The Douyin chat input box is based on Draft.js and cannot use the standard fill() or type().
Through 'page.
This page was translated automatically. Technical details may differ from the original.
Install
This server does not publish a one-line install command.
Open the repository installation guide New to MCP? Start with the mcpskill.org guide →