We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/jmagar/homelab-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
/**
* Calculate image statistics from Docker disk usage data.
* Processes image data to compute totals, active count, sizes, and reclaimable space.
*
* @param images - Array of image info from Docker df
* @returns Statistics with total, active, size, and reclaimable bytes
*/
export function calculateImageStats(
images: Array<{ Size?: number; SharedSize?: number; Containers?: number }>
): {
total: number;
active: number;
size: number;
reclaimable: number;
} {
const total = images.length;
const size = images.reduce((sum: number, i) => sum + (i.Size || 0), 0);
const shared = images.reduce((sum: number, i) => sum + (i.SharedSize || 0), 0);
const active = images.filter((i) => i.Containers && i.Containers > 0).length;
const reclaimable = size - shared;
return { total, active, size, reclaimable };
}
/**
* Calculate container statistics from Docker disk usage data.
* Processes container data to compute totals, running count, and sizes.
*
* @param containers - Array of container info from Docker df
* @returns Statistics with total, running, size, and rootfsSize in bytes
*/
export function calculateContainerStats(
containers: Array<{ SizeRw?: number; SizeRootFs?: number; State?: string }>
): {
total: number;
running: number;
size: number;
rootfsSize: number;
} {
const total = containers.length;
const size = containers.reduce((sum: number, c) => sum + (c.SizeRw || 0), 0);
const rootfsSize = containers.reduce((sum: number, c) => sum + (c.SizeRootFs || 0), 0);
const running = containers.filter((c) => c.State === "running").length;
return { total, running, size, rootfsSize };
}
/**
* Calculate volume statistics from Docker disk usage data.
* Processes volume data to compute totals, active count, sizes, and reclaimable space.
*
* @param volumes - Array of volume info from Docker df
* @returns Statistics with total, active, size, and reclaimable bytes
*/
export function calculateVolumeStats(
volumes: Array<{ UsageData?: { Size?: number; RefCount?: number } }>
): {
total: number;
active: number;
size: number;
reclaimable: number;
} {
const total = volumes.length;
const size = volumes.reduce((sum: number, v) => sum + (v.UsageData?.Size || 0), 0);
const active = volumes.filter((v) => v.UsageData?.RefCount && v.UsageData.RefCount > 0).length;
const reclaimable = volumes
.filter((v) => !v.UsageData?.RefCount)
.reduce((sum: number, v) => sum + (v.UsageData?.Size || 0), 0);
return { total, active, size, reclaimable };
}
/**
* Calculate build cache statistics from Docker disk usage data.
* Processes build cache data to compute totals, sizes, and reclaimable space.
*
* @param buildCache - Array of build cache info from Docker df
* @returns Statistics with total, size, and reclaimable bytes
*/
export function calculateBuildCacheStats(buildCache: Array<{ Size?: number; InUse?: boolean }>): {
total: number;
size: number;
reclaimable: number;
} {
const total = buildCache.length;
const size = buildCache.reduce((sum: number, b) => sum + (b.Size || 0), 0);
const reclaimable = buildCache
.filter((b) => !b.InUse)
.reduce((sum: number, b) => sum + (b.Size || 0), 0);
return { total, size, reclaimable };
}