Skip to main content
Glama

Show output directory stats

show_output_stats
Read-only

View statistics for generated images and output directory contents to monitor image creation activity and track results.

Instructions

Show statistics about the output directory and recently generated images.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function for the 'show_output_stats' tool. It fetches statistics from the file image service, handles errors, formats a markdown summary, and returns a ToolResult with text content and structured data.
    def show_output_stats(
        ctx: Context = None,
    ) -> ToolResult:
        """
        Show statistics about the output directory and recently generated images.
        """
        logger = logging.getLogger(__name__)
    
        try:
            logger.info("Getting output directory stats")
    
            file_service = get_file_image_service()
            stats = file_service.get_output_stats()
    
            if "error" in stats:
                return ToolResult(
                    content=[
                        TextContent(
                            type="text", text=f"❌ Error getting output stats: {stats['error']}"
                        )
                    ],
                    structured_content=stats,
                )
    
            if stats["total_images"] == 0:
                summary = (
                    f"📁 **Output Directory:** `{stats['output_directory']}`\n\n"
                    f"📊 **Stats:** No images found in output directory."
                )
            else:
                summary = (
                    f"📁 **Output Directory:** `{stats['output_directory']}`\n\n"
                    f"📊 **Stats:**\n"
                    f"- Total images: {stats['total_images']}\n"
                    f"- Total size: {stats['total_size_mb']} MB\n\n"
                    f"🕒 **Recent Images:**\n"
                )
    
                for filename in stats.get("recent_images", []):
                    summary += f"- `{filename}`\n"
    
            return ToolResult(
                content=[TextContent(type="text", text=summary)], structured_content=stats
            )
    
        except Exception as e:
            logger.error(f"Failed to get output stats: {e}")
            raise
  • The registration function that defines and registers the 'show_output_stats' tool on the FastMCP server using a decorator with metadata annotations.
    def register_output_stats_tool(server: FastMCP):
        """Register output statistics tool with the FastMCP server."""
    
        @server.tool(
            annotations={
                "title": "Show output directory stats",
                "description": "Show statistics about the IMAGE_OUTPUT_DIR and recently generated images",
                "readOnlyHint": True,
            }
        )
  • The call site in the main server class where the output_stats tool registration function is imported and invoked during server initialization.
    from ..tools.output_stats import register_output_stats_tool
    from ..tools.upload_file import register_upload_file_tool
    
    register_generate_image_tool(self.server)
    register_upload_file_tool(self.server)
    register_output_stats_tool(self.server)
  • Supporting helper method in FileImageService that scans the output directory for image files, computes totals and lists recent ones; called by the tool handler.
    def get_output_stats(self) -> dict[str, Any]:
        """Get statistics about the output directory."""
        try:
            image_files = (
                list(self.output_dir.glob("*.png"))
                + list(self.output_dir.glob("*.jpg"))
                + list(self.output_dir.glob("*.jpeg"))
            )
    
            total_size = sum(f.stat().st_size for f in image_files)
    
            return {
                "output_directory": str(self.output_dir),
                "total_images": len(image_files),
                "total_size_bytes": total_size,
                "total_size_mb": round(total_size / (1024 * 1024), 2),
                "recent_images": [
                    str(f.name)
                    for f in sorted(image_files, key=lambda x: x.stat().st_mtime, reverse=True)[:5]
                ],
            }
        except Exception as e:
            self.logger.error(f"Failed to get output stats: {e}")
            return {"output_directory": str(self.output_dir), "error": str(e)}
Behavior3/5

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

Annotations already declare readOnlyHint=true, so the agent knows this is a safe read operation. The description adds useful context about what statistics are shown (output directory and recently generated images), but doesn't disclose behavioral details like performance characteristics, data freshness, or error conditions. With annotations covering safety, this meets baseline expectations.

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 a single, efficient sentence that clearly states the tool's purpose without any wasted words. It's appropriately sized for a simple tool with no parameters and gets straight to the point.

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?

For a read-only tool with no parameters and no output schema, the description provides adequate context about what statistics are shown. However, it doesn't explain what specific statistics are included or the format of the output, leaving some gaps in understanding the tool's full behavior.

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 tool has zero parameters with 100% schema description coverage, so the schema fully documents the input requirements. The description appropriately doesn't waste space discussing parameters, earning a high baseline score for not adding unnecessary information.

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 with specific verbs ('Show statistics') and resources ('output directory and recently generated images'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'maintenance' which might also provide directory information, keeping it from 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 like 'maintenance' or 'generate_image', nor does it mention any prerequisites or context for usage. It simply states what the tool does without indicating appropriate scenarios.

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/zengwenliang416/banana-image-mcp'

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