Skip to main content
Glama

topic_based_summary

Generate concise, topic-focused summaries from provided content using a targeted query. Ideal for extracting key insights and relevant information efficiently.

Instructions

主题汇总功能 - 基于给定资料和查询主题,返回最相关的内容总结(2k字符内)

Args:
    content: 资料内容
    query: 查询的主题或问题

Returns:
    基于主题的相关内容总结

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYes
queryYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The primary handler for the 'topic_based_summary' tool, registered via @mcp.tool() decorator. It wraps the RAGProcessor's topic_summary method, handling context logging and errors.
    @mcp.tool()
    async def topic_based_summary(content: str, query: str, ctx: Context) -> str:
        """
        主题汇总功能 - 基于给定资料和查询主题,返回最相关的内容总结(2k字符内)
        
        Args:
            content: 资料内容
            query: 查询的主题或问题
        
        Returns:
            基于主题的相关内容总结
        """
        try:
            ctx.info(f"开始主题汇总,查询: {query}")
            
            summary = await rag_processor.topic_summary(content, query)
            
            ctx.info("主题汇总完成")
            return summary
            
        except Exception as e:
            logger.error(f"主题汇总失败: {e}")
            return f"主题汇总失败: {str(e)}"
  • Core helper function in RAGProcessor class that performs the topic-based summarization by crafting a specialized prompt for the LLM and generating the response.
        async def topic_summary(self, content: str, query: str) -> str:
            """
            基于主题查询的内容总结
            
            Args:
                content: 资料内容
                query: 查询主题/问题
                
            Returns:
                相关内容的总结(2k字符内)
            """
            try:
                # 构建RAG样式的提示词
                prompt = f"""基于以下资料内容,针对查询主题进行总结分析:
    
    查询主题: {query}
    
    资料内容:
    {content}
    
    请根据查询主题,从资料中提取最相关的信息,并总结为2000字以内的内容。要求:
    1. 重点关注与查询主题相关的内容
    2. 保持信息的准确性和逻辑性
    3. 如果资料中没有相关信息,请明确说明
    4. 提供具体的细节和要点"""
    
                response = self.summarizer.client.chat.completions.create(
                    model=OPENAI_MODEL,
                    messages=[
                        {"role": "system", "content": "你是一个专业的信息分析师,擅长从大量资料中提取特定主题的相关信息。"},
                        {"role": "user", "content": prompt}
                    ],
                    max_tokens=min(MAX_OUTPUT_TOKENS, 120000),  # 限制在120k左右
                    temperature=0.1
                )
                
                result = response.choices[0].message.content.strip()
                
                return result
                
            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 full burden. It mentions the 2k character limit, which is useful behavioral context. However, it doesn't disclose other important traits like whether this is a read-only operation, potential rate limits, error conditions, or how 'most relevant' is determined. For a tool with no annotation coverage, this leaves significant behavioral gaps.

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?

The description is appropriately concise with three sentences that each serve a purpose: stating the tool's function, listing parameters, and describing the return value. It's front-loaded with the core purpose. The bilingual formatting is slightly distracting but doesn't significantly impact clarity.

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?

Given the tool's moderate complexity (2 parameters, topic-based summarization), the description covers the essential purpose and parameters. The presence of an output schema means the description doesn't need to explain return values in detail. However, with no annotations and sibling tools present, more usage guidance would improve completeness.

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

Parameters3/5

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

Schema description coverage is 0%, so the description must compensate. It lists both parameters ('content' and 'query') with brief explanations, adding meaning beyond the bare schema. However, it doesn't provide format expectations, constraints, or examples for either parameter, leaving some semantic gaps despite covering both parameters.

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: '基于给定资料和查询主题,返回最相关的内容总结' (based on given content and query topic, returns the most relevant content summary). It specifies the verb '返回' (return) and resource '内容总结' (content summary), though it doesn't explicitly differentiate from sibling tools like 'summarize_content' or 'summarize_webpage' beyond mentioning the topic-based aspect.

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 sibling tools like 'summarize_content' and 'summarize_webpage' available, there's no indication of when this topic-based approach is preferred over general summarization tools or when it should be avoided.

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