Skip to main content
Glama
avclabs

@avclabs.ai/enhance-mcp

Official
by avclabs

enhance_video_sync

Synchronously enhances video quality by upscaling to a chosen resolution. Supports video input via URL or local file path.

Instructions

同步增强视频(阻塞等待完成)

支持两种上传方式:

  1. URL 上传:提供视频 URL

  2. 本地上传:提供本地文件路径,MCP Server 自动上传到 TOS 对象存储

参数说明:

  • video_source: 视频 URL 或本地文件路径

  • type: "url" 或 "local"

  • resolution: 目标分辨率

  • poll_interval: 轮询间隔(秒)

  • timeout: 超时时间(秒)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
video_sourceYes视频URL地址或本地文件路径
typeNo上传类型:url=网络视频,local=本地文件url
resolutionNo目标分辨率,默认720p720p
poll_intervalNo轮询间隔(秒),默认5
timeoutNo超时时间(秒),默认600

Implementation Reference

  • The `enhanceVideoSync` private method that contains the core logic: creates a task, then polls for status completion (or failure), with timeout handling. This is the main implementation of the tool.
    private async enhanceVideoSync(
      videoSource: string,
      sourceType: string,
      resolution: string,
      pollInterval: number,
      timeout: number
    ): Promise<any> {
      // 创建任务
      const createResult = await this.createTask(videoSource, sourceType, resolution);
    
      if (!createResult.success) {
        return createResult;
      }
    
      const taskId = createResult.task_id;
    
      // 轮询等待完成
      const startTime = Date.now();
      while (true) {
        const status = await this.getTaskStatus(taskId);
        if (!status.success) {
          return status;
        }
    
        if (status.status === 'completed' || status.status === 'failed') {
          return status;
        }
    
        const elapsed = (Date.now() - startTime) / 1000;
        if (elapsed >= timeout) {
          return {
            success: false,
            error: `任务超时: ${taskId}`,
            task_id: taskId,
          };
        }
    
        await this.sleep(pollInterval * 1000);
      }
    }
  • Zod schema for input validation of the enhance_video_sync tool, defining video_source, type, resolution, poll_interval, and timeout fields.
    const EnhanceVideoSyncSchema = 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'),
      poll_interval: z.number().default(5).describe('轮询间隔(秒),默认5'),
      timeout: z.number().default(600).describe('超时时间(秒),默认600'),
    });
  • src/server.ts:163-208 (registration)
    Registration of the 'enhance_video_sync' tool via `this.server.tool()`, binding the schema and the async handler that calls `this.enhanceVideoSync()`. Called within `setupTools()`.
        // enhance_video_sync tool
        this.server.tool(
          'enhance_video_sync',
          `同步增强视频(阻塞等待完成)
    
    支持两种上传方式:
    1. URL 上传:提供视频 URL
    2. 本地上传:提供本地文件路径,MCP Server 自动上传到 TOS 对象存储
    
    参数说明:
    - video_source: 视频 URL 或本地文件路径
    - type: "url" 或 "local"
    - resolution: 目标分辨率
    - poll_interval: 轮询间隔(秒)
    - timeout: 超时时间(秒)`,
          EnhanceVideoSyncSchema.shape,
          async (args) => {
            try {
              const result = await this.enhanceVideoSync(
                args.video_source,
                args.type,
                args.resolution,
                args.poll_interval,
                args.timeout
              );
              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),
                  },
                ],
              };
            }
          }
        );
  • The `sleep` helper utility used by the polling loop to wait between status checks.
    private sleep(ms: number): Promise<void> {
      return new Promise((resolve) => setTimeout(resolve, ms));
    }
  • The `createTask` private method called by `enhanceVideoSync` to initiate the video enhancement task (handles both URL and local file upload via TOS).
    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,
      };
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description discloses blocking behavior and automatic upload to TOS for local files, but lacks details on error handling, side effects, or required permissions. Without annotations, the description carries the full burden but still provides moderate transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise with a clear front-loaded purpose and well-structured bullet points for parameters. Every sentence adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description covers all 5 parameters, behavior (blocking), and upload methods. It omits expected return value and prerequisites, but given the lack of output schema, it is sufficiently complete for invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, baseline 3. The description adds value by grouping parameters and explaining the two upload methods, which goes beyond the schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool synchronously enhances video and blocks until completion. It distinguishes itself from siblings like create_task and get_task_status by focusing specifically on video enhancement.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description does not explicitly guide when to use this tool over alternatives, nor does it mention when not to use it. However, the context of video enhancement is clear, and the sibling tools handle different tasks, so usage is implied.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/avclabs/enhance-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server