Skip to main content
Glama
dknell

System Information MCP Server

by dknell

get_memory_info_tool

Retrieve memory usage statistics to monitor system performance and identify resource constraints in real-time.

Instructions

Retrieve memory usage statistics.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The MCP tool handler function for 'get_memory_info_tool'. It is registered using the @app.tool() decorator and executes the tool logic by calling the underlying get_memory_info() helper function.
    @app.tool()
    def get_memory_info_tool() -> Dict[str, Any]:
        """Retrieve memory usage statistics."""
        return get_memory_info()
  • The core helper function implementing the memory information retrieval using psutil.virtual_memory() and psutil.swap_memory(). It includes caching via @cache_result decorator and provides detailed virtual and swap memory statistics.
    @cache_result("memory_info", ttl=1)
    def get_memory_info() -> Dict[str, Any]:
        """Retrieve memory usage statistics."""
        try:
            # Get virtual memory info
            virtual_mem = psutil.virtual_memory()
    
            # Get swap memory info
            swap_mem = psutil.swap_memory()
    
            return {
                "virtual_memory": {
                    "total": virtual_mem.total,
                    "available": virtual_mem.available,
                    "used": virtual_mem.used,
                    "percent": round(virtual_mem.percent, 1),
                    "total_gb": bytes_to_gb(virtual_mem.total),
                    "available_gb": bytes_to_gb(virtual_mem.available),
                    "used_gb": bytes_to_gb(virtual_mem.used),
                },
                "swap_memory": {
                    "total": swap_mem.total,
                    "used": swap_mem.used,
                    "free": swap_mem.free,
                    "percent": round(swap_mem.percent, 1),
                    "total_gb": bytes_to_gb(swap_mem.total),
                },
            }
    
        except Exception as e:
            logger.error(f"Error getting memory info: {e}")
            raise

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/dknell/mcp-system-info'

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