Skip to main content
Glama

summarize_text

Generate concise summaries from text content using LLM models. Specify custom instructions to tailor summaries for specific needs.

Instructions

Summarize text using an LLM model.

⚠️ COST WARNING: This tool makes an API call to Whissle which may incur costs. Only use when explicitly requested by the user.

Args:
    content (str): The text to summarize
    model_name (str, optional): The LLM model to use. Defaults to "openai"
    instruction (str, optional): Specific instructions for summarization

Returns:
    TextContent with the summary.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYes
model_nameNoopenai
instructionNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYes
typeYes
_metaNo
annotationsNo

Implementation Reference

  • The handler function for the 'summarize_text' tool, decorated with @mcp.tool for registration. It uses the Whissle client's llm_text_summarizer method to generate summaries, includes input validation, logging, retry logic for API errors, and returns a TextContent object with the summary.
    @mcp.tool(
        description="""Summarize text using an LLM model.
    
        ⚠️ COST WARNING: This tool makes an API call to Whissle which may incur costs. Only use when explicitly requested by the user.
    
        Args:
            content (str): The text to summarize
            model_name (str, optional): The LLM model to use. Defaults to "openai"
            instruction (str, optional): Specific instructions for summarization
    
        Returns:
            TextContent with the summary.
        """
    )
    def summarize_text(
        content: str,
        model_name: str = "openai",
        instruction: Optional[str] = None,
    ) -> TextContent:
        try:
            if not content:
                logger.error("Empty content provided for summarization")
                return make_error("Content is required")
            
            # Log the request details
            logger.info(f"Summarizing text using model: {model_name}")
            logger.info(f"Text length: {len(content)} characters")
            
            retry_count = 0
            max_retries = 2  # Increased from 1 to 2
            
            while retry_count <= max_retries:
                try:
                    logger.info(f"Attempting summarization (Attempt {retry_count+1}/{max_retries+1})")
                    response = client.llm_text_summarizer(
                        content=content,
                        model_name=model_name,
                        instruction=instruction,
                    )
                    
                    if response and response.response:
                        logger.info("Summarization successful")
                        return TextContent(
                            type="text",
                            text=f"Summary:\n{response.response}",
                        )
                    else:
                        logger.error("No summary was returned from the API")
                        return make_error("No summary was returned from the API")
                except Exception as api_error:
                    error_msg = str(api_error)
                    logger.error(f"Summarization error: {error_msg}")
                    
                    # Handle API errors with retries
                    error_result = handle_api_error(error_msg, "summarization", retry_count, max_retries)
                    if error_result is not None:  # If we should not retry
                        return error_result  # Return the error message
                    
                    retry_count += 1
            
            # If we get here, all retries failed
            logger.error(f"All summarization attempts failed after {max_retries+1} attempts")
            return make_error(f"Failed to summarize text after {max_retries+1} attempts")
        except Exception as e:
            logger.error(f"Unexpected error during summarization: {str(e)}")
            return make_error(f"Failed to summarize text: {str(e)}")
  • The @mcp.tool decorator registers the 'summarize_text' tool with MCP, including schema description for parameters: content (str), model_name (str, optional), instruction (Optional[str]), and return type TextContent.
    @mcp.tool(
        description="""Summarize text using an LLM model.
    
        ⚠️ COST WARNING: This tool makes an API call to Whissle which may incur costs. Only use when explicitly requested by the user.
    
        Args:
            content (str): The text to summarize
            model_name (str, optional): The LLM model to use. Defaults to "openai"
            instruction (str, optional): Specific instructions for summarization
    
        Returns:
            TextContent with the summary.
        """
    )
  • The tool description provides the input schema: content (required str), model_name (optional str default 'openai'), instruction (optional str), and output as TextContent with summary.
        description="""Summarize text using an LLM model.
    
        ⚠️ COST WARNING: This tool makes an API call to Whissle which may incur costs. Only use when explicitly requested by the user.
    
        Args:
            content (str): The text to summarize
            model_name (str, optional): The LLM model to use. Defaults to "openai"
            instruction (str, optional): Specific instructions for summarization
    
        Returns:
            TextContent with the summary.
        """
    )
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively adds context beyond basic functionality: it warns about API costs and specifies the external service ('Whissle'), which are crucial behavioral traits. It doesn't cover rate limits, authentication needs, or error handling, but provides valuable operational context.

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 well-structured and appropriately sized. It front-loads the core purpose, follows with a critical warning, and then details parameters and returns in a clear format. Every sentence earns its place, with no redundant or verbose language.

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 (3 parameters, no annotations, but with output schema), the description is reasonably complete. It covers purpose, cost implications, parameters, and return type. The output schema handles return values, so the description doesn't need to explain them. It could benefit from more parameter details or error scenarios, but it's largely adequate.

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 all three parameters (content, model_name, instruction) with brief explanations, adding meaning beyond the bare schema. However, it doesn't elaborate on parameter constraints (e.g., model options, instruction format) or provide examples, leaving some semantic gaps.

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 text using an LLM model.' This specifies the verb ('summarize'), resource ('text'), and method ('LLM model'), making it immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'translate_text' or 'speech_to_text' beyond the core function.

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

Usage Guidelines4/5

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

The description provides clear usage guidance with the cost warning: 'Only use when explicitly requested by the user.' This establishes a specific context for when to use the tool. However, it doesn't mention when NOT to use it (e.g., for simple text extraction) or name alternatives among sibling tools.

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/WhissleAI/whissle-mcp'

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