Skip to main content
Glama
output_stats.pyβ€’2.33 kB
""" Tool for getting output directory statistics. """ import logging from fastmcp import Context, FastMCP from fastmcp.tools.tool import ToolResult from mcp.types import TextContent from ..services import get_file_image_service 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, } ) 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

Implementation Reference

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