create_task
Initiate an asynchronous video enhancement task by providing a video source (URL or local file) and selecting a target resolution.
Instructions
创建视频增强任务(异步)
支持两种上传方式:
URL 上传:提供视频 URL
本地上传:提供本地文件路径,MCP Server 自动上传到 TOS 对象存储
参数说明:
video_source: 视频 URL 或本地文件路径
type: "url" 或 "local"
resolution: 目标分辨率
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| video_source | Yes | 视频URL地址或本地文件路径 | |
| type | No | 上传类型:url=网络视频,local=本地文件 | url |
| resolution | No | 目标分辨率,默认720p | 720p |
Implementation Reference
- src/server.ts:39-43 (schema)Zod schema for create_task tool input validation: defines video_source (string), type (enum: url/local, default: url), and resolution (enum: 480p/540p/720p/1080p/2k, default: 720p)
const CreateTaskSchema = z.object({ video_source: z.string().describe('视频URL地址或本地文件路径'), type: z.enum(['url', 'local']).default('url').describe('上传类型:url=网络视频,local=本地文件'), resolution: z.enum(['480p', '540p', '720p', '1080p', '2k']).default('720p').describe('目标分辨率,默认720p'), }); - src/server.ts:90-131 (registration)Registration of the 'create_task' tool with MCP server, including its description, schema reference, and async handler that delegates to this.createTask()
// create_task tool this.server.tool( 'create_task', `创建视频增强任务(异步) 支持两种上传方式: 1. URL 上传:提供视频 URL 2. 本地上传:提供本地文件路径,MCP Server 自动上传到 TOS 对象存储 参数说明: - video_source: 视频 URL 或本地文件路径 - type: "url" 或 "local" - resolution: 目标分辨率`, CreateTaskSchema.shape, async (args) => { try { const result = await this.createTask( args.video_source, args.type, args.resolution ); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: 'text', text: JSON.stringify({ success: false, error: errorMessage }, null, 2), }, ], }; } } ); - src/server.ts:307-351 (handler)Core handler logic for create_task: handles local file upload (check file, get TOS signature, upload to TOS) or URL upload, then sends POST request to /api/v3/contents/generations/tasks to create the enhancement task
private async createTask( videoSource: string, sourceType: string, resolution: string ): Promise<any> { let contentItem: any; if (sourceType === 'local') { // 本地上传:检查文件、获取 TOS 签名、直传文件 const fileInfo = this.checkLocalFile(videoSource); const signatureData = await this.getTosSignature(fileInfo.fileName); await this.uploadToTos(videoSource, signatureData); const fileId = this.parseFileIdFromUrl(signatureData.url); contentItem = { type: 'video_file', file_id: fileId, file_name: fileInfo.fileName, }; } else { // URL 上传 contentItem = { type: 'video_url', video_url: { url: videoSource }, }; } const payload = { model: 'avc-enhance', content: [contentItem], resolution, }; const response = await this.client.post('/api/v3/contents/generations/tasks', payload); const data = response.data; if (data.code !== 0 && data.code !== 200) { return { success: false, error: data.message }; } return { success: true, task_id: data.data.task_id, status: data.data.status, }; }