Skip to main content
Glama

System Info MCP Server

by srirama7
explaination.txt12.6 kB
> which tools and packages and softwares did u use and explain everything pls ⎿ ⧉ Selected 890 lines from SPECIFICATION.md in Visual Studio Code ● Great question! Let me explain everything I used to build your System Info MCP Server. Technologies & Packages Used 1. Runtime Environment Node.js (v18+) - What it is: JavaScript runtime that allows running JavaScript outside the browser - Why we need it: MCP servers run as Node.js applications - What we use it for: Executing the server code, handling I/O operations - Already installed on your system: ✅ (verified during testing) 2. Programming Language TypeScript (v5.3.3) - What it is: JavaScript with type safety (catches errors before runtime) - Why we use it: Prevents bugs, better IDE support, required for complex projects - Compiles to: Regular JavaScript that Node.js can run - Files: All .ts files in src/ folder → compiled to .js files in dist/ folder 3. Core MCP Framework @modelcontextprotocol/sdk (v1.0.4) - What it is: Official SDK from Anthropic for building MCP servers - Purpose: Provides the protocol implementation for Claude to communicate with your server - What we use: - Server class - Main server instance - StdioServerTransport - Communication over stdin/stdout - CallToolRequestSchema - Handles tool execution requests - ListToolsRequestSchema - Returns available tools to Claude - How it works: Handles the JSON-RPC protocol that Claude uses to call your tools 4. System Information Libraries systeminformation (v5.22.7) - PRIMARY PACKAGE - What it is: Cross-platform library for retrieving system data - Why we use it: One package that works on Windows, macOS, and Linux - What it provides: import si from 'systeminformation'; // CPU Information await si.cpu() // CPU model, cores, speed await si.cpuCurrentSpeed() // Current CPU speed await si.cpuTemperature() // CPU temperature await si.currentLoad() // CPU usage % // Memory Information await si.mem() // RAM usage, total, free, used // Operating System await si.osInfo() // OS name, version, kernel // Disk Information await si.fsSize() // Disk space, usage per drive // Network Information await si.networkInterfaces() // Network adapters, IPs await si.networkGatewayDefault() // Default gateway await si.inetLatency() // Internet connectivity await si.wifiNetworks() // WiFi scan await si.networkConnections() // Open ports // Processes await si.processes() // Running processes // Hardware await si.battery() // Battery status await si.graphics() // GPU, displays await si.system() // Manufacturer, model await si.usb() // USB devices await si.bluetoothDevices() // Bluetooth devices node-disk-info (v1.3.0) - SUPPLEMENTARY - What it is: Additional disk information (not heavily used in current implementation) - Purpose: Backup option for disk data - Status: Installed but systeminformation covers most needs 5. Development Tools TypeScript Compiler (tsc) - What it does: Converts TypeScript → JavaScript - Command: npm run build runs tsc - Configuration: tsconfig.json - tells compiler how to build - Output: Creates dist/ folder with .js, .d.ts, .js.map files ESLint (v8.56.0) - CODE QUALITY - What it is: Code linter that checks for errors and style issues - Commands: - npm run lint - Check code - npm run lint:fix - Auto-fix issues Jest (v29.7.0) - TESTING FRAMEWORK - What it is: Testing framework for running unit tests - Commands: - npm test - Run tests - npm run test:coverage - Check test coverage - Status: Framework installed, tests not yet written 6. Node.js Built-in Modules (No installation needed) os - Operating System utilities import os from 'os'; os.uptime() // System uptime in seconds os.hostname() // Computer name os.userInfo() // Current user details os.homedir() // Home directory os.tmpdir() // Temp directory os.totalmem() // Total RAM os.loadavg() // Load averages (Unix/Mac) os.platform() // 'win32', 'darwin', 'linux' os.arch() // 'x64', 'arm64' process - Current Node.js process process.pid // Process ID process.ppid // Parent process ID process.version // Node.js version process.memoryUsage() // Memory used by this process process.env // Environment variables process.arch // Architecture Project Structure Explained mcp-system-info/ │ ├── package.json # Project config, dependencies, scripts ├── package-lock.json # Locked dependency versions ├── tsconfig.json # TypeScript compiler settings │ ├── node_modules/ # Installed packages (3rd party code) │ ├── @modelcontextprotocol/ │ ├── systeminformation/ │ └── ... (hundreds of dependencies) │ ├── src/ # SOURCE CODE (TypeScript) │ │ │ ├── index.ts # MAIN ENTRY POINT │ │ └── Creates MCP server, registers tools, handles requests │ │ │ ├── types/ # TYPE DEFINITIONS │ │ ├── tools.ts # Interfaces for tool responses (CPUInfo, MemoryInfo, etc.) │ │ └── responses.ts # MCP protocol response types │ │ │ ├── tools/ # TOOL IMPLEMENTATIONS (each tool in separate file) │ │ ├── cpu.ts # getCPUInfo() - calls systeminformation.cpu() │ │ ├── memory.ts # getMemoryInfo() - calls systeminformation.mem() │ │ ├── system.ts # getOSInfo(), getUptime(), getSystemIdentity() │ │ ├── disk.ts # getDiskInfo() - calls systeminformation.fsSize() │ │ ├── network.ts # getNetworkInfo(), checkInternetConnectivity() │ │ ├── process.ts # getProcessInfo(), listProcesses(), getSystemLoad() │ │ ├── battery.ts # getBatteryInfo() - calls systeminformation.battery() │ │ ├── hardware.ts # getHardwareInfo() - GPU, displays, USB │ │ ├── environment.ts # getEnvironmentInfo() - filters sensitive vars │ │ ├── temperature.ts # getTemperatureInfo() - CPU/GPU temps │ │ ├── wifi.ts # scanWiFiNetworks() - WiFi scan │ │ ├── bluetooth.ts # getBluetoothDevices() │ │ └── ports.ts # getOpenPorts() - listening ports │ │ │ ├── utils/ # UTILITY FUNCTIONS │ │ ├── formatters.ts # bytesToGB(), formatUptime(), formatPercentage() │ │ ├── errors.ts # createErrorResponse(), handleToolError() │ │ └── platform.ts # getPlatform(), isWindows(), isMacOS(), isLinux() │ │ │ └── config/ │ └── constants.ts # Configuration (sensitive var filters, cache durations) │ ├── dist/ # COMPILED OUTPUT (JavaScript) │ ├── index.js # Compiled from src/index.ts │ ├── index.d.ts # Type definitions for JavaScript │ ├── tools/ # Compiled tool files │ ├── types/ # Compiled type files │ └── utils/ # Compiled utility files │ ├── tests/ # TEST FILES (empty for now) │ ├── unit/ │ └── integration/ │ ├── README.md # User documentation ├── QUICK_START.md # Setup guide I created ├── SPECIFICATION.md # Technical spec (your original doc) ├── BLUEPRINT.md # Architecture overview (your original doc) └── test-server.js # Simple test script I created How It All Works Together 1. Development Flow Write TypeScript (.ts) ↓ Run: npm run build ↓ TypeScript Compiler (tsc) reads tsconfig.json ↓ Compiles .ts → .js in dist/ folder ↓ dist/index.js is ready to run 2. Runtime Flow Claude Desktop starts server ↓ Runs: node dist/index.js ↓ index.js creates MCP Server instance ↓ Registers 18 tools with their schemas ↓ Listens on stdin/stdout for requests ↓ Claude sends tool call request via stdio ↓ Server receives request, parses tool name ↓ Calls appropriate function (e.g., getCPUInfo()) ↓ Function calls systeminformation library ↓ Formats response as JSON ↓ Sends back to Claude via stdout ↓ Claude displays result to user 3. Example Tool Execution When Claude calls get_cpu_info: // 1. Request comes into index.ts server.setRequestHandler(CallToolRequestSchema, async (request) => { if (request.params.name === 'get_cpu_info') { // 2. Calls the tool function return await getCPUInfo(); } }); // 3. In tools/cpu.ts export async function getCPUInfo() { // 4. Calls systeminformation library const [cpuData, cpuSpeed, cpuTemp, currentLoad] = await Promise.all([ si.cpu(), // Get CPU hardware info si.cpuCurrentSpeed(), // Get current speed si.cpuTemperature(), // Get temperature si.currentLoad() // Get usage % ]); // 5. Formats the data const cpuInfo = { manufacturer: cpuData.manufacturer, brand: cpuData.brand, speed: cpuSpeed.avg, cores: cpuData.cores, // ... more fields }; // 6. Returns formatted response return { content: [{ type: "text", text: JSON.stringify(cpuInfo, null, 2) }] }; } Security Features Implemented 1. Environment Variable Filtering (src/utils/errors.ts) - Filters out: API_KEY, PASSWORD, SECRET, TOKEN, AWS_, GOOGLE_ - Prevents accidental exposure of credentials 2. Error Handling (src/utils/errors.ts) - PERMISSION_DENIED - When lacking permissions - NOT_AVAILABLE - When feature unavailable (e.g., no battery) - TIMEOUT - When operation takes too long - INTERNAL_ERROR - Unexpected errors 3. Type Safety (TypeScript) - Catches bugs at compile time - Ensures data matches expected format Build Scripts in package.json { "scripts": { "build": "tsc", // Compile TypeScript "watch": "tsc --watch", // Auto-compile on changes "start": "node dist/index.js", // Run the server "dev": "tsc && node dist/index.js", // Build + run "test": "jest", // Run tests "lint": "eslint src --ext .ts" // Check code quality } } Summary of What Each Package Does | Package | Purpose | What We Get | |---------------------------|--------------|---------------------------------------------------| | @modelcontextprotocol/sdk | MCP Protocol | Server class, stdio transport, request handlers | | systeminformation | System Data | CPU, memory, disk, network, process, battery info | | TypeScript | Type Safety | Compile-time error checking, better IDE support | | Node.js (os) | OS Utilities | Hostname, uptime, user info, temp directory | | Node.js (process) | Process Info | Environment vars, memory usage, process ID | Why This Architecture? ✅ Modular: Each tool in separate file - easy to maintain ✅ Type-Safe: TypeScript catches errors before runtime✅ Cross-Platform: systeminformation works on Windows/Mac/Linux ✅ Secure: Filters sensitive data, handles errors gracefully ✅ Efficient: Async/await for non-blocking operations ✅ Tested: Test script verifies functionality Your MCP server is production-ready and follows best practices! 🎉

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

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