Content

# DouBaoFreeImageGen
DouBaoFreeImageGen is an intelligent text-to-image service based on the FastMCP framework, deeply integrated with the DouBao client through a browser extension, providing an efficient MCP (Model Context Protocol) service interface that supports unlimited calls to DouBao's text-to-image functionality.
## Core Features
- 🚀 **FastMCP Framework**: Based on modern MCP protocol, providing standardized service interfaces
- 🔄 **Multi-client Support**: Supports multiple browser instances connecting simultaneously with intelligent load balancing
- ⚡ **Efficient Task Scheduling**: Polling algorithm for task allocation, supporting concurrent processing
- 🛡️ **Reliability Assurance**: Task timeout management, automatic reconnection, connection status monitoring
- 🎨 **Image Management**: Built-in image collection, preview, and batch download features
- 📊 **Real-time Monitoring**: Complete connection status and task status query interfaces
- 🔧 **Flexible Configuration**: Supports automatic refresh, cookie management, and other personalized settings
## System Architecture
### Core Components
1. **MCP Server** (`McpServer/`)
- FastMCP framework provides standard MCP interfaces
- WebSocket server handles browser extension connections
- Task queue management and load balancing
- Connection status monitoring and exception handling
2. **Browser Extension** (`DoubaoMcpBrowserProxy/`)
- Chrome extension, integrated with DouBao client
- Automated input of text-to-image commands
- Real-time collection and monitoring of image URLs
- User interface enhancement features
## Demo Video
https://github.com/user-attachments/assets/98ed6c08-1252-4976-90ed-53440ef13280
## System Requirements
- **Python**: Version 3.8 or higher
- **Browser**: Chromium-based browser that supports Chrome extensions
- **DouBao Client**: Latest version
- **Operating System**: Windows / macOS / Linux
## Quick Start
### 1. Project Installation
```bash
# Clone the project
git clone https://github.com/yourusername/DouBaoFreeImageGen.git
cd DouBaoFreeImageGen
# Install Python dependencies
cd McpServer
pip install -r requirements.txt
```
### 2. Install Browser Extension
#### Method 1: Direct Installation (Recommended)
1. Drag and drop the `DoubaoMcpBrowserProxy.crx` file onto the browser extension page (`chrome://extensions/`)
#### Method 2: Developer Mode Installation
1. Open the browser extension page (`chrome://extensions/`)
2. Enable "Developer mode" in the top right corner
3. Click "Load unpacked extension"
4. Select the `DoubaoMcpBrowserProxy` directory
### 3. Configure DouBao Client
For the best experience, it is recommended to add the startup parameter to the DouBao client shortcut:
```
"DouBao client path" --silent-debugger-extension-api
```
Example:
```
"C:\Program Files\Doubao\app\Doubao.exe" --silent-debugger-extension-api
```
### 4. Start the Service
```bash
# Start the service in the McpServer directory
python server.py
```
After the service starts, it will provide:
- **WebSocket Service**: `ws://localhost:8080` (for browser extension connection)
- **MCP Service**: `http://localhost:8081` (for MCP client connection)
> **Note**: If deployed on a server, replace `localhost` with the actual server IP address and ensure the firewall allows access to the corresponding ports.
## User Guide
### MCP Client Access
#### Configure MCP Service Address
Configure the service address in the MCP client:
```
http://192.168.2.192:8081/mcp
```
#### 1. Text-to-Image Interface
**Tool Name**: `draw_image`
**Parameters**:
- `prompt` (string): Text prompt for image generation
**Return Format**:
```json
{
"status": "success",
"image_urls": ["https://...", "https://..."]
}
```
**Usage Example**:
```python
import requests
# Call the text-to-image interface
response = requests.post(
'http://localhost:8081/tools/draw_image',
json={'prompt': 'A cute kitten playing in the garden'}
)
result = response.json()
if result['status'] == 'success':
print(f"Generated {len(result['image_urls'])} images")
for url in result['image_urls']:
print(f"Image URL: {url}")
```
#### 2. Connection Status Query
**Tool Name**: `get_connection_status`
**Return Information**:
- Number and status of connected clients
- Current task queue status
- System operational status
### Browser Extension Features
#### Automation
- Automatically receives text-to-image commands sent by the MCP server
- Simulates user input of prompts in the DouBao client
- Real-time monitoring of generated images and collection of URLs
#### Image Management
- **Real-time Preview**: Popup displays all collected images
- **Individual Download**: Select specific images for download
- **Batch Download**: One-click download of all images
- **List Management**: Clear image list and restart collection
#### Personalized Settings
In the extension options page (`chrome://extensions/` → Extension details → Extension options), you can configure:
- **Auto Refresh**: Whether to automatically refresh the page after task completion
- **Cookie Management**: Whether to automatically clear cookies (to maintain anonymity)
## Advanced Configuration
### Server Configuration
You can adjust the following parameters in `McpServer/server.py`:
```python
# Server configuration
SERVER_HOST = "0.0.0.0" # Server listening address
WS_PORT = 8080 # WebSocket port
MCP_PORT = 8081 # MCP service port
# Task configuration
DEFAULT_TIMEOUT = 60.0 # Default task timeout (seconds)
MAX_TASKS = 50 # Maximum length of task queue
```
### Task Management Strategy
- **Polling Load Balancing**: Tasks are automatically allocated to idle clients
- **Timeout Protection**: Tasks timeout after 60 seconds, automatically releasing resources
- **Status Monitoring**: Real-time monitoring of client connections and task statuses
- **Exception Recovery**: Automatically cleans up related tasks when a client disconnects
## API Detailed Documentation
### MCP Tools
#### `draw_image`
Core tool for generating images
**Parameter Validation**:
- `prompt` must not be empty or consist only of whitespace
- At least one idle browser client connection is required
**Processing Flow**:
1. Validate input parameters
2. Check available clients
3. Create a task and allocate it to an idle client
4. Send instructions to the browser
5. Wait for image generation to complete
6. Return the list of image URLs
**Error Handling**:
- No available clients: `"No idle WebSocket clients available"`
- Task timeout: `"Task timeout"`
- Client disconnect: `"Task cancelled due to client disconnect"`
#### `get_connection_status`
Retrieve system status information
**Return Data Structure**:
```json
{
"total_clients": 2,
"clients": [
{
"id": "client-uuid",
"connected": true,
"status": "idle",
"current_task": null,
"last_active": 1703123456.789,
"url": "https://www.doubao.com/chat/"
}
],
"total_tasks": 5,
"tasks": [
{
"id": "task-uuid",
"client_id": "client-uuid",
"status": "completed",
"create_time": 1703123456.789,
"image_count": 3
}
]
}
```
## Troubleshooting
### Common Issues
1. **Extension cannot connect to the server**
- Check if the server is running (`python server.py`)
- Ensure port 8080 is not occupied
- Check firewall settings
2. **Task timeout or failure**
- Ensure the DouBao client is running properly
- Check network connection stability
- Try refreshing the DouBao page
3. **Images cannot be downloaded**
- Check browser download permissions
- Confirm the validity of image URLs
- Try clearing the browser cache
### Log Debugging
View server logs:
```bash
# Server logs will display detailed connection and task information
python server.py
```
View browser console:
```javascript
// Press F12 on the DouBao page to view Console output
// Search for logs related to "[Script]" or "[WebSocket]"
```
## Notes and Limitations
### Usage Guidelines
⚠️ **Important Notice**:
1. **Privacy Protection**: The extension will automatically clear cookies, ensuring each use is anonymous
2. **Page Refresh**: To ensure functionality, the extension may automatically refresh the DouBao page
3. **Single Task Limitation**: Each client can only handle one text-to-image task at a time
4. **Network Dependency**: A stable network connection is required to ensure service functionality
### Legal and Compliance
- This project is for educational and research purposes only
- Please comply with DouBao's service terms and usage agreements
- Commercial use is prohibited
- Generating illegal or inappropriate content is prohibited
### Performance Considerations
- It is recommended that the number of simultaneously connected clients does not exceed 5
- A large number of concurrent requests may affect the stability of DouBao services
- Regularly restart the service to clear resource usage
## Development Guide
### Project Structure
```
DouBaoFreeImageGen/
├── McpServer/ # MCP Server
│ ├── server.py # Main service file
│ ├── requirements.txt # Python dependencies
│ └── docker-compose.yml # Docker configuration
├── DoubaoMcpBrowserProxy/ # Browser extension
│ ├── manifest.json # Extension configuration
│ ├── content.js # Content script
│ ├── background.js # Background script
│ └── options.html # Settings page
└── README.md
```
### Communication
You can join the Omni-bot developer group, please specify "omni-bot", the bot will automatically approve, and the daily approval limit is limited, please be patient.
<p align="center">
<img src="https://omni-rpa.bmwidget.com/omni-rpa.jpg" alt="Group Chat" width="300">
<img src="https://github.com/user-attachments/assets/16db82a1-6032-4c4b-8287-8dfbb3be70ce" alt="Group Owner Bot" width="300">
</p>
(If this project is useful to you, you can also buy me a cup of coffee ☕️ ~)
<p align="center">
<kbd><img src="https://github.com/user-attachments/assets/195ab37d-bc51-44a2-9330-e4df9dbf67dc" alt="Appreciation Code" width="200"/></kbd>
</p>
### Contributing Code
Contributions are welcome! Please ensure:
1. Code adheres to project standards
2. Necessary test cases are added
3. Relevant documentation is updated
4. All existing tests pass
## Open Source License
This project is open-sourced under the MIT License. Please refer to the [LICENSE](LICENSE) file for details.
## Disclaimer
This project is for educational and research purposes only. Please do not use it for commercial purposes. The user assumes all consequences arising from the use of this project. The author is not responsible for any losses caused by the project.
## Acknowledgments
Thanks to DouBao's powerful text-to-image model for providing technical support for this project.
## Star History
<a href="https://www.star-history.com/#HuChundong/DouBaoFreeImageGen&Date">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=HuChundong/DouBaoFreeImageGen&type=Date&theme=dark" />
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=HuChundong/DouBaoFreeImageGen&type=Date" />
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=HuChundong/DouBaoFreeImageGen&type=Date" />
</picture>
</a>
You Might Also Like
OpenWebUI
Open WebUI is an extensible web interface for customizable applications.

NextChat
NextChat is a light and fast AI assistant supporting Claude, DeepSeek, GPT4...

Continue
Continue is an open-source project for seamless server management.
semantic-kernel
Build and deploy intelligent AI agents with the Semantic Kernel framework.

repomix
Repomix packages your codebase into AI-friendly formats for easy use.
UI-TARS-desktop
UI-TARS-desktop is part of the TARS Multimodal AI Agent stack.