Skip to main content
Glama

summarize_content

Summarize any content to a specified length ratio (default 20%) for concise understanding. Ideal for condensing information efficiently using controlled compression settings.

Instructions

将任意内容总结为指定比例的长度(默认20%)

Args:
    content: 要总结的内容
    target_ratio: 目标压缩比例,0.1-1.0之间

Returns:
    总结后的内容

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYes
target_ratioNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The primary MCP tool handler for 'summarize_content'. It is registered via @mcp.tool() decorator, includes input validation (schema-like), logging via ctx, and delegates to the helper summarizer.
    @mcp.tool()
    async def summarize_content(content: str, ctx: Context, target_ratio: float = 0.2) -> str:
        """
        将任意内容总结为指定比例的长度(默认20%)
        
        Args:
            content: 要总结的内容
            target_ratio: 目标压缩比例,0.1-1.0之间
        
        Returns:
            总结后的内容
        """
        try:
            # 验证参数
            if not 0.1 <= target_ratio <= 1.0:
                return "错误: target_ratio 必须在 0.1 到 1.0 之间"
            
            ctx.info(f"开始总结内容,目标比例: {target_ratio*100}%")
            
            summary = await summarizer.summarize_content(content, target_ratio)
            
            ctx.info("内容总结完成")
            return summary
            
        except Exception as e:
            logger.error(f"内容总结失败: {e}")
            return f"内容总结失败: {str(e)}"
  • The core helper function in ContentSummarizer class that performs the actual summarization using OpenAI/MiniMax API. Called by the tool handler and other tools.
        async def summarize_content(self, content: str, target_ratio: float = 0.2, 
                                  custom_prompt: str = None) -> str:
            """
            使用大模型总结内容
            
            Args:
                content: 要总结的内容
                target_ratio: 目标压缩比例 (默认20%)
                custom_prompt: 自定义总结提示词
            
            Returns:
                总结后的内容
            """
            try:
                # 检查内容长度,避免超出限制
                if len(content) > MAX_INPUT_TOKENS * 3:  # 粗略估算token
                    content = content[:MAX_INPUT_TOKENS * 3]
                    logger.warning("内容过长,已截断")
                
                # 构建总结提示词
                if custom_prompt:
                    prompt = custom_prompt
                else:
                    target_length = min(max(int(len(content) * target_ratio), 100), 1000)
    
                    prompt = f"""请将以下内容总结为约{target_length}字的精炼版本,保留核心信息和关键要点:
    
    {content}
    
    总结要求:
    1. 保持原文的主要观点和逻辑结构
    2. 去除冗余和次要信息
    3. 使用简洁明了的语言
    4. 确保信息的准确性和完整性"""
    
                response = self.client.chat.completions.create(
                    model=OPENAI_MODEL,
                    messages=[
                        {"role": "system", "content": "你是一个专业的内容总结专家,擅长将长文本压缩为精炼的摘要。"},
                        {"role": "user", "content": prompt}
                    ],
                    max_tokens=MAX_OUTPUT_TOKENS,
                    temperature=0.1
                )
                
                return response.choices[0].message.content.strip()
                
            except Exception as e:
                logger.error(f"内容总结失败: {e}")
                return f"总结失败: {str(e)}"
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the default ratio (20%) and parameter ranges (0.1-1.0), but lacks critical details: it doesn't specify the summarization method (e.g., extractive vs. abstractive), quality expectations, handling of different content types, or potential limitations like length constraints. This leaves significant gaps in understanding how the tool behaves.

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 highly concise and well-structured: a single sentence states the purpose, followed by clearly labeled sections for Args and Returns. Every sentence earns its place, with no redundant information, making it easy to parse and understand quickly.

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

Completeness3/5

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

Given the tool's moderate complexity (2 parameters, no annotations, but with an output schema), the description is partially complete. It covers the basic purpose and parameters adequately, and the output schema handles return values. However, it lacks behavioral details (e.g., summarization approach, error cases) and usage context relative to siblings, leaving room for improvement in guiding the agent effectively.

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?

The description adds meaningful semantics beyond the input schema, which has 0% description coverage. It explains that 'content' is '要总结的内容' (content to summarize) and 'target_ratio' is '目标压缩比例,0.1-1.0之间' (target compression ratio between 0.1-1.0), including the default value of 0.2. This compensates well for the schema's lack of descriptions, though it doesn't detail format expectations for 'content'.

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

Purpose4/5

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

The description clearly states the tool's purpose: '将任意内容总结为指定比例的长度' (summarize any content to a specified ratio length). It specifies the verb '总结' (summarize) and the resource '任意内容' (any content), making the function unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'summarize_webpage' or 'topic_based_summary', which prevents a perfect score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'summarize_webpage' and 'topic_based_summary' available, it fails to indicate scenarios where this general-purpose summarizer is preferred over more specialized tools, leaving the agent without usage context.

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

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/yzfly/fullscope-mcp-server'

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