Skip to main content
Glama
Suixinlei

Tongyi Wanxiang MCP Server

by Suixinlei

wanx-t2v-video-generation

Generate videos from text prompts using Alibaba Cloud's Tongyi Wanxiang API. Initiate the process and use the result-fetching tool to retrieve the output once complete.

Instructions

使用阿里云万相文生视频大模型的文生视频能力,由于视频生成耗时比较久,需要调用 wanx-t2v-video-generation-result 工具获取结果

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYes

Implementation Reference

  • src/index.ts:52-62 (registration)
    Registers the MCP tool 'wanx-t2v-video-generation' with description, input schema {prompt: z.string()}, and handler that calls generateVideo and returns task info.
    server.tool(
      "wanx-t2v-video-generation",
      "使用阿里云万相文生视频大模型的文生视频能力,由于视频生成耗时比较久,需要调用 wanx-t2v-video-generation-result 工具获取结果",
      { prompt: z.string() },
      async ({ prompt }) => {
        const result = await generateVideo(prompt);
        return {
          content: [{ type: "text", text: JSON.stringify(result) }],
        };
      }
    );
  • Input schema using Zod for the tool parameters.
    { prompt: z.string() },
  • Core handler function 'generateVideo' that makes async API call to Aliyun Dashscope to initiate video generation task and returns the task_id.
    export async function generateVideo(prompt: string) {  
      const apiKey = config.api.apiKey;
      const url = 'https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis'; 
      const headers = {  
        'X-DashScope-Async': 'enable',
        'Authorization': `Bearer ${apiKey}`,  
        'Content-Type': 'application/json'  
      };  
      const payload = {  
        model: 'wanx2.1-t2v-turbo',  
        input: { prompt },
        parameters: {
          size: '832*480',
          duration: 5,
          prompt_extend: true,
        },
      };
    
      try {  
        const res = await axios.post(url, payload, { headers });  
        const taskId = res.data?.output?.task_id;  
        if (taskId) return taskId;  
        // 如果响应里没有task_id,说明有错误  
        throw res.data;  
      } catch (err: any) {  
        // err.response?.data 可能含详细错误  
        throw err.response?.data || err.message;  
      }  
    }  

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

Related 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/Suixinlei/tongyi-wanx-mcp-server'

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