Skip to main content
Glama
Alex-Smith-1234

讯飞智文PPT生成服务MCP Server

create_ppt_task

Generate PowerPoint presentations using iFlytek's AI by providing content descriptions and selecting templates, with options for automatic images, speaker notes, and web search enhancement.

Instructions

创建PPT生成任务。

使用说明:
1. 在调用本工具前,必须先调用get_theme_list获取有效的template_id。
2. 工具会返回任务ID(sid),需用get_task_progress轮询查询进度。
3. 任务完成后,可从get_task_progress结果中获取PPT下载地址。
4. 需先设置环境变量AIPPT_APP_ID和AIPPT_API_SECRET。

参数:
- text: PPT生成的内容描述,用于生成PPT的主题和内容。
- template_id: PPT模板ID,需通过get_theme_list获取。
- author: PPT作者名称,将显示在生成的PPT中。
- is_card_note: 是否生成PPT演讲备注,True表示生成,False表示不生成。
- search: 是否联网搜索,True表示联网搜索补充内容,False表示不联网。
- is_figure: 是否自动配图,True表示自动配图,False表示不配图。
- ai_image: AI配图类型,仅在is_figure为True时生效。可选值:normal-普通配图(20%正文配图),advanced-高级配图(50%正文配图)。

返回:
成功时返回包含sid的字典,失败时抛出异常。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYes
template_idYes
authorNoXXXX
is_card_noteNo
searchNo
is_figureNo
ai_imageNonormal

Implementation Reference

  • The handler function for 'create_ppt_task' tool. Decorated with @mcp.tool() for registration. Implements the core logic by sending a multipart POST request to the xfyun API to create a PPT task and returns the task ID (sid). Includes input schema via type hints and detailed docstring describing parameters and usage.
    @mcp.tool()
    def create_ppt_task(
        ctx: Context,
        text: str,
        template_id: str,
        author: str = "XXXX",
        is_card_note: bool = True,
        search: bool = False,
        is_figure: bool = True,
        ai_image: str = "normal"
    ) -> Dict[str, Any]:
        """
        创建PPT生成任务。
        
        使用说明:
        1. 在调用本工具前,必须先调用get_theme_list获取有效的template_id。
        2. 工具会返回任务ID(sid),需用get_task_progress轮询查询进度。
        3. 任务完成后,可从get_task_progress结果中获取PPT下载地址。
        4. 需先设置环境变量AIPPT_APP_ID和AIPPT_API_SECRET。
        
        参数:
        - text: PPT生成的内容描述,用于生成PPT的主题和内容。
        - template_id: PPT模板ID,需通过get_theme_list获取。
        - author: PPT作者名称,将显示在生成的PPT中。
        - is_card_note: 是否生成PPT演讲备注,True表示生成,False表示不生成。
        - search: 是否联网搜索,True表示联网搜索补充内容,False表示不联网。
        - is_figure: 是否自动配图,True表示自动配图,False表示不配图。
        - ai_image: AI配图类型,仅在is_figure为True时生效。可选值:normal-普通配图(20%正文配图),advanced-高级配图(50%正文配图)。
        
        返回:
        成功时返回包含sid的字典,失败时抛出异常。
        """
        url = 'https://zwapi.xfyun.cn/api/ppt/v2/create'
        form_data = MultipartEncoder(
            fields={
                "query": text,
                "templateId": template_id,
                "author": author,
                "isCardNote": str(is_card_note),
                "search": str(search),
                "isFigure": str(is_figure),
                "aiImage": ai_image
            }
        )
        headers = get_headers(form_data.content_type)
        response = requests.post(url, data=form_data, headers=headers)
    
        if response.status_code != 200:
            raise Exception(f"调用失败: {response.text}")
    
        resp = json.loads(response.text)
        if resp['code'] == 0:
            return {"sid": resp['data']['sid']}
        else:
            raise Exception(f"调用失败: {response.text}")
    
    @mcp.tool()
  • Helper function to generate authentication headers required for all API calls, including create_ppt_task. Computes timestamp and signature using app credentials.
    def get_headers(content_type: str = "application/json; charset=utf-8") -> dict:
        if not AIPPT_APP_ID or not AIPPT_API_SECRET:
            raise Exception("请先设置环境变量AIPPT_APP_ID和AIPPT_API_SECRET")
        timestamp = int(time.time())
        signature = get_signature(AIPPT_APP_ID, AIPPT_API_SECRET, timestamp)
        return {
            "appId": AIPPT_APP_ID,
            "timestamp": str(timestamp),
            "signature": signature,
            "Content-Type": content_type
        }
  • Helper function to generate the API signature used in headers for authentication in create_ppt_task and other tools.
    def get_signature(app_id: str, api_secret: str, ts: int) -> str:
        """生成讯飞API签名"""
        auth = hashlib.md5((app_id + str(ts)).encode('utf-8')).hexdigest()
        return base64.b64encode(
            hmac.new(api_secret.encode('utf-8'), auth.encode('utf-8'), hashlib.sha1).digest()
        ).decode('utf-8')
Behavior4/5

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

With no annotations provided, the description carries full burden and does well by explaining the asynchronous nature (returns task ID for polling), error behavior (throws exceptions on failure), and environmental requirements (AIPPT_APP_ID and AIPPT_API_SECRET). It doesn't mention rate limits or specific permission requirements, keeping it from a perfect score.

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

Conciseness4/5

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

Well-structured with clear sections (使用说明, 参数, 返回) and bullet points, but could be slightly more concise. Every sentence earns its place by providing essential information, though some redundancy exists in the parameter explanations.

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

Completeness5/5

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

Given the complexity (7 parameters, asynchronous workflow, no annotations, no output schema), the description provides comprehensive coverage including prerequisites, parameter details, workflow steps, return value explanation, and error handling. It addresses all necessary context for proper tool usage.

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

Parameters5/5

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

With 0% schema description coverage for 7 parameters, the description fully compensates by providing detailed explanations for each parameter including purpose, constraints (template_id must come from get_theme_list), dependencies (ai_image only works when is_figure is True), and enum values for ai_image. This adds significant value beyond the bare schema.

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 specific action ('创建PPT生成任务' - create PPT generation task) and resource (PPT task). It distinguishes from siblings like create_outline or create_ppt_by_outline by focusing on task creation rather than outline creation or direct PPT generation from outlines.

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

Usage Guidelines5/5

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

The description provides explicit usage instructions including prerequisites (must call get_theme_list first, must set environment variables), workflow dependencies (need to poll with get_task_progress), and clear alternatives (different tools for different purposes like create_outline).

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/Alex-Smith-1234/zwppt-mcp'

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