2025-07-11 18:02:44 +08:00
# CapCutAPI
2025-08-01 16:13:21 +08:00
Open source CapCut API tool with MCP (Model Context Protocol) support.
2025-07-11 18:02:44 +08:00
2025-07-30 18:52:42 +08:00
Try It: https://www.capcutapi.top
2025-07-30 18:51:17 +08:00
2025-08-01 16:13:21 +08:00
[中文说明 ](https://github.com/sun-guannan/CapCutAPI/blob/main/README-zh.md ) | [MCP Documentation ](./MCP_Documentation_English.md ) | [MCP 中文文档 ](./MCP_文档_中文.md )
2025-07-12 09:49:46 +08:00
2025-08-01 16:13:21 +08:00
## 🎬 Gallery
2025-07-31 09:19:57 +08:00
**Connect AI generated via CapCutAPI**
[](https://www.youtube.com/watch?v=IF1RDFGOtEU)
[](https://www.youtube.com/watch?v=rGNLE_slAJ8)
2025-08-01 16:13:21 +08:00
## 🚀 Project Features
2025-07-11 18:02:44 +08:00
2025-08-01 16:13:21 +08:00
This project is a Python-based CapCut processing tool that offers comprehensive video editing capabilities through multiple interfaces:
2025-07-11 18:02:44 +08:00
2025-08-01 16:13:21 +08:00
### 🎯 Core Features
2025-07-11 18:02:44 +08:00
2025-07-12 09:47:42 +08:00
- **Draft File Management**: Create, read, modify, and save CapCut draft files
- **Material Processing**: Support adding and editing various materials such as videos, audios, images, texts, stickers, etc.
- **Effect Application**: Support adding multiple effects like transitions, filters, masks, animations, etc.
- **API Service**: Provide HTTP API interfaces to support remote calls and automated processing
- **AI Integration**: Integrate multiple AI services to support intelligent generation of subtitles, texts, and images
2025-08-01 16:13:21 +08:00
- **🆕 MCP Support**: Model Context Protocol integration for seamless AI assistant integration
2025-07-11 18:02:44 +08:00
2025-08-01 16:13:21 +08:00
### 📡 Available Interfaces
2025-07-11 18:02:44 +08:00
2025-08-01 16:13:21 +08:00
#### HTTP API Endpoints
2025-07-12 09:47:42 +08:00
- `/create_draft` : Create a draft
- `/add_video` : Add video material to the draft
- `/add_audio` : Add audio material to the draft
- `/add_image` : Add image material to the draft
- `/add_text` : Add text material to the draft
- `/add_subtitle` : Add subtitles to the draft
- `/add_effect` : Add effects to materials
- `/add_sticker` : Add stickers to the draft
- `/save_draft` : Save the draft file
2025-07-11 18:02:44 +08:00
2025-08-01 16:13:21 +08:00
#### 🆕 MCP Tools (11 Tools Available)
- `create_draft` : Create new video draft project
- `add_video` : Add video track with transitions and effects
- `add_audio` : Add audio track with volume control
- `add_image` : Add image assets with animations
- `add_text` : Add text with shadows, backgrounds, and multi-styles
- `add_subtitle` : Add SRT subtitles with styling
- `add_effect` : Add visual effects
- `add_sticker` : Add sticker elements
- `add_video_keyframe` : Add keyframe animations
- `get_video_duration` : Get video duration
- `save_draft` : Save draft project
2025-07-11 18:02:44 +08:00
2025-08-01 16:13:21 +08:00
## 🛠️ Installation & Setup
2025-07-11 18:02:44 +08:00
2025-08-01 16:13:21 +08:00
### Prerequisites
2025-07-11 18:02:44 +08:00
2025-08-01 16:13:21 +08:00
#### ffmpeg
This project depends on ffmpeg. Ensure ffmpeg is installed and added to your system's PATH.
#### Python Environment
Requires Python 3.8.20 or higher. Ensure the correct Python version is installed.
### Installation Steps
1. **Clone the repository **
```bash
git clone https://github.com/sun-guannan/CapCutAPI.git
cd CapCutAPI
```
2025-07-11 18:02:44 +08:00
2025-08-01 16:13:21 +08:00
2. **Install dependencies **
```bash
# For HTTP API server
pip install -r requirements.txt
# For MCP server (additional)
pip install -r requirements-mcp.txt
```
3. **Configuration **
2025-07-11 18:02:44 +08:00
```bash
cp config.json.example config.json
2025-08-01 16:13:21 +08:00
# Edit config.json as needed
2025-07-11 18:02:44 +08:00
```
2025-08-01 16:13:21 +08:00
## 🚀 Usage
2025-07-11 18:02:44 +08:00
2025-08-01 16:13:21 +08:00
### HTTP API Server
2025-07-12 09:52:23 +08:00
2025-08-01 16:13:21 +08:00
Start the HTTP API server:
2025-07-12 09:52:23 +08:00
2025-08-01 16:13:21 +08:00
```bash
python capcut_server.py
```
2025-07-11 18:02:44 +08:00
2025-08-01 16:13:21 +08:00
### 🆕 MCP Server
2025-07-11 18:02:44 +08:00
2025-08-01 16:13:21 +08:00
The MCP server provides seamless integration with AI assistants and other MCP-compatible clients.
2025-07-11 18:02:44 +08:00
2025-08-01 16:13:21 +08:00
#### Quick Start
2025-07-11 18:02:44 +08:00
2025-08-01 16:13:21 +08:00
1. **Start MCP Server **
2025-07-11 18:02:44 +08:00
```bash
2025-08-01 16:13:21 +08:00
python mcp_server.py
2025-07-11 18:02:44 +08:00
```
2025-08-01 16:13:21 +08:00
2. **Configure MCP Client **
Create or update your `mcp_config.json` :
```json
{
"mcpServers": {
"capcut-api": {
"command": "python3",
"args": ["mcp_server.py"],
"cwd": "/path/to/CapCutAPI",
"env": {
"PYTHONPATH": "/path/to/CapCutAPI"
}
}
}
}
```
2025-07-11 18:02:44 +08:00
2025-08-01 16:13:21 +08:00
3. **Test MCP Connection **
2025-07-11 18:02:44 +08:00
```bash
2025-08-01 16:13:21 +08:00
python test_mcp_client.py
2025-07-11 18:02:44 +08:00
```
2025-08-01 16:13:21 +08:00
#### MCP Features
2025-07-11 18:02:44 +08:00
2025-08-01 16:13:21 +08:00
- **🎨 Advanced Text Styling**: Multi-color text, shadows, backgrounds
- **🎬 Video Processing**: Keyframe animations, transitions, effects
- **🔊 Audio Control**: Volume adjustment, speed control
- **📱 Multi-format Support**: Various video dimensions and formats
- **⚡ Real-time Processing**: Immediate draft updates and previews
2025-07-11 18:02:44 +08:00
2025-08-01 16:13:21 +08:00
## 📖 Usage Examples
2025-07-11 18:02:44 +08:00
2025-08-01 16:13:21 +08:00
### HTTP API Examples
#### Adding a Video
2025-07-11 18:02:44 +08:00
```python
import requests
2025-07-19 17:25:12 +08:00
response = requests.post("http://localhost:9001/add_video", json={
2025-07-11 18:02:44 +08:00
"video_url": "http://example.com/video.mp4",
"start": 0,
"end": 10,
"width": 1080,
"height": 1920
})
print(response.json())
```
2025-08-01 16:13:21 +08:00
#### Adding Text
2025-07-11 18:02:44 +08:00
```python
import requests
2025-07-19 17:25:12 +08:00
response = requests.post("http://localhost:9001/add_text", json={
2025-07-12 09:47:42 +08:00
"text": "Hello, World!",
2025-07-11 18:02:44 +08:00
"start": 0,
"end": 3,
2025-07-20 14:35:06 +08:00
"font": "ZY_Courage",
2025-07-11 18:02:44 +08:00
"font_color": "#FF0000 ",
"font_size": 30.0
})
print(response.json())
```
2025-08-01 16:13:21 +08:00
#### Saving a Draft
2025-07-12 09:52:23 +08:00
```python
import requests
2025-07-19 17:25:12 +08:00
response = requests.post("http://localhost:9001/save_draft", json={
2025-07-12 09:52:23 +08:00
"draft_id": "123456",
"draft_folder": "your capcut draft folder"
})
print(response.json())
```
2025-08-01 16:13:21 +08:00
### 🆕 MCP Usage Examples
2025-07-12 09:52:23 +08:00
2025-08-01 16:13:21 +08:00
#### Basic Workflow
```python
# Create a new draft
draft = mcp_client.call_tool("create_draft", {
"width": 1080,
"height": 1920
})
2025-07-12 09:52:23 +08:00
2025-08-01 16:13:21 +08:00
# Add text with advanced styling
mcp_client.call_tool("add_text", {
"text": "Welcome to CapCut!",
"start": 0,
"end": 5,
"draft_id": draft["draft_id"],
"font_size": 48,
"shadow_enabled": True,
"background_color": "#000000 "
})
# Save the project
mcp_client.call_tool("save_draft", {
"draft_id": draft["draft_id"]
})
```
#### Advanced Features
```python
# Add video with keyframe animation
mcp_client.call_tool("add_video_keyframe", {
"draft_id": draft_id,
"track_name": "main_video",
"property_types": ["scale_x", "scale_y", "alpha"],
"times": [0, 2, 4],
"values": ["1.0", "1.5", "0.8"]
})
```
### Testing with REST Client
You can use the `rest_client_test.http` file with REST Client IDE plugins for HTTP testing.
### Draft Management
Calling `save_draft` generates a folder starting with `dfd_` in the server's current directory. Copy this folder to your CapCut draft directory to access the generated draft in CapCut.
## 📚 Documentation
2025-07-12 09:52:23 +08:00
2025-08-01 16:13:21 +08:00
- **[MCP English Documentation ](./MCP_Documentation_English.md )**: Complete MCP server usage guide
- **[MCP 中文文档 ](./MCP_文档_中文.md )**: 完整的 MCP 服务器使用指南
- **[API Reference ](./example.py )**: More usage examples including audio and effects
2025-07-12 09:52:23 +08:00
2025-08-01 16:13:21 +08:00
## 🌟 Project Highlights
2025-07-11 18:02:44 +08:00
2025-08-01 16:13:21 +08:00
- **🌍 Cross-platform Support**: Supports both CapCut China version and CapCut International version
- **🤖 Automated Processing**: Supports batch processing and automated workflows
- **🔌 Rich APIs**: Provides comprehensive API interfaces for easy integration
- **⚙️ Flexible Configuration**: Achieve flexible function customization through configuration files
- **🧠 AI Enhancement**: Integrate multiple AI services to improve video production efficiency
- **🆕 MCP Integration**: Seamless integration with AI assistants and automation tools
2025-08-01 16:05:15 +08:00
2025-08-01 16:13:21 +08:00
## 🔧 Advanced Configuration
### MCP Server Configuration
For production use, you can configure the MCP server with additional options:
```json
{
"mcpServers": {
"capcut-api": {
"command": "python3",
"args": ["mcp_server.py"],
"cwd": "/path/to/CapCutAPI",
"env": {
"PYTHONPATH": "/path/to/CapCutAPI",
"DEBUG": "1"
}
}
}
}
```
### Environment Variables
- `DEBUG` : Enable debug logging
- `CAPCUT_PATH` : Custom CapCut installation path
- `DRAFT_OUTPUT_PATH` : Custom draft output directory
## 🤝 Contributing
We welcome contributions! Please feel free to submit issues and pull requests.
## 📈 Star History
2025-08-01 16:05:15 +08:00
[](https://www.star-history.com/#sun -guannan/CapCutAPI&Date)
2025-08-01 16:13:21 +08:00
## 📄 License
This project is open source. Please check the license file for details.
---
**🎉 New**: Now with MCP support for seamless AI assistant integration! Try the MCP server for advanced video editing automation.