Skip to main content
Glama
saksham0712

MCP Complete Implementation Guide

by saksham0712

get_system_info

Retrieve system information to monitor performance, check resources, and diagnose issues in MCP server implementations.

Instructions

Get system information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that implements get_system_info tool logic, collecting system details using platform and psutil libraries and returning as JSON.
    async def get_system_info(self) -> list[types.TextContent]:
        """Get system information"""
        info = {
            "platform": platform.system(),
            "arch": platform.machine(),
            "hostname": platform.node(),
            "cpus": psutil.cpu_count(),
            "totalMemory": f"{round(psutil.virtual_memory().total / (1024**3))} GB",
            "freeMemory": f"{round(psutil.virtual_memory().available / (1024**3))} GB",
            "uptime": f"{round(psutil.boot_time())} seconds",
            "pythonVersion": sys.version,
            "currentDirectory": str(Path.cwd()),
        }
        return [types.TextContent(type="text", text=json.dumps(info, indent=2))]
  • The handler function implementing get_system_info tool, gathering Node.js os module system information and returning formatted JSON response.
    async getSystemInfo() {
      const info = {
        platform: os.platform(),
        arch: os.arch(),
        hostname: os.hostname(),
        cpus: os.cpus().length,
        totalMemory: Math.round(os.totalmem() / 1024 / 1024 / 1024) + ' GB',
        freeMemory: Math.round(os.freemem() / 1024 / 1024 / 1024) + ' GB',
        uptime: Math.round(os.uptime() / 3600) + ' hours',
        nodeVersion: process.version,
        currentDirectory: process.cwd(),
      };
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(info, null, 2),
          },
        ],
      };
    }
  • Schema definition for the get_system_info tool in the list_tools handler, specifying no input parameters.
    types.Tool(
        name="get_system_info",
        description="Get system information",
        inputSchema={
            "type": "object",
            "properties": {},
        },
    ),
  • Schema for get_system_info tool returned by listToolsRequestHandler, with empty properties indicating no args needed.
    {
      name: 'get_system_info',
      description: 'Get system information',
      inputSchema: {
        type: 'object',
        properties: {},
      },
    },
  • server.py:181-182 (registration)
    Registration/dispatch in the call_tool handler for invoking get_system_info.
    elif name == "get_system_info":
        return await self.get_system_info()

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/saksham0712/MCP'

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