unix-disk-mcp 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tools/exploration.js +62 -39
- package/package.json +1 -1
|
@@ -71,48 +71,71 @@ export function registerExplorationTools(server, config) {
|
|
|
71
71
|
try {
|
|
72
72
|
let disk;
|
|
73
73
|
if (process.platform === 'darwin') {
|
|
74
|
-
// macOS: Use diskutil for
|
|
75
|
-
const
|
|
76
|
-
|
|
74
|
+
// macOS: Use df to get relevant volumes, plus diskutil for container info
|
|
75
|
+
const dfOutput = execSync("df -k | awk '$9==\"/\" || $9==\"/System/Volumes/Data\" || $9~/^\\/Volumes\\// {print}'", { encoding: "utf-8" });
|
|
76
|
+
const dfLines = dfOutput.trim().split("\n");
|
|
77
|
+
const disks = dfLines.map((line) => {
|
|
78
|
+
const parts = line.trim().split(/\s+/);
|
|
79
|
+
const totalBytes = parseInt(parts[1]) * 1024 || 0;
|
|
80
|
+
const usedBytes = parseInt(parts[2]) * 1024 || 0;
|
|
81
|
+
const availableBytes = parseInt(parts[3]) * 1024 || 0;
|
|
82
|
+
const percentUsed = Math.round((usedBytes / totalBytes) * 100) || 0;
|
|
83
|
+
return {
|
|
84
|
+
filesystem: parts[0],
|
|
85
|
+
total_bytes: totalBytes,
|
|
86
|
+
used_bytes: usedBytes,
|
|
87
|
+
available_bytes: availableBytes,
|
|
88
|
+
percent_used: percentUsed,
|
|
89
|
+
mounted_on: parts[8],
|
|
90
|
+
};
|
|
77
91
|
});
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
92
|
+
// Add container summary for context
|
|
93
|
+
try {
|
|
94
|
+
const diskutilOutput = execSync("diskutil info / | grep -E 'Container Total Space|Container Free Space'", { encoding: "utf-8" });
|
|
95
|
+
const lines = diskutilOutput.trim().split("\n");
|
|
96
|
+
const totalLine = lines[0]?.split(":")[1]?.trim() || "";
|
|
97
|
+
const freeLine = lines[1]?.split(":")[1]?.trim() || "";
|
|
98
|
+
const totalBytesMatch = totalLine.match(/\((\d+) Bytes\)/);
|
|
99
|
+
const freeBytesMatch = freeLine.match(/\((\d+) Bytes\)/);
|
|
100
|
+
const containerTotal = totalBytesMatch ? parseInt(totalBytesMatch[1]) : 0;
|
|
101
|
+
const containerFree = freeBytesMatch ? parseInt(freeBytesMatch[1]) : 0;
|
|
102
|
+
const containerUsed = containerTotal - containerFree;
|
|
103
|
+
disk = {
|
|
104
|
+
volumes: disks,
|
|
105
|
+
apfs_container: {
|
|
106
|
+
total_bytes: containerTotal,
|
|
107
|
+
used_bytes: containerUsed,
|
|
108
|
+
available_bytes: containerFree,
|
|
109
|
+
percent_used: Math.round((containerUsed / containerTotal) * 100),
|
|
110
|
+
note: "Shared APFS container space - volumes dynamically allocate from this",
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
// If diskutil fails, just return volumes
|
|
116
|
+
disk = disks;
|
|
117
|
+
}
|
|
103
118
|
}
|
|
104
119
|
else {
|
|
105
|
-
// Linux: Use df
|
|
106
|
-
const dfOutput = execSync("df -
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
120
|
+
// Linux: Use df to get all relevant filesystems
|
|
121
|
+
const dfOutput = execSync("df -B1 | awk 'NR==1 || $6==\"/\" || $6==\"/home\" || $6~/^\\/mnt\\// || $6~/^\\/media\\//'", { encoding: "utf-8" });
|
|
122
|
+
const lines = dfOutput.trim().split("\n");
|
|
123
|
+
const disks = lines.slice(1).map((line) => {
|
|
124
|
+
const parts = line.trim().split(/\s+/);
|
|
125
|
+
const totalBytes = parseInt(parts[1]) || 0;
|
|
126
|
+
const usedBytes = parseInt(parts[2]) || 0;
|
|
127
|
+
const availableBytes = parseInt(parts[3]) || 0;
|
|
128
|
+
const percentUsed = Math.round((usedBytes / totalBytes) * 100) || 0;
|
|
129
|
+
return {
|
|
130
|
+
filesystem: parts[0],
|
|
131
|
+
total_bytes: totalBytes,
|
|
132
|
+
used_bytes: usedBytes,
|
|
133
|
+
available_bytes: availableBytes,
|
|
134
|
+
percent_used: percentUsed,
|
|
135
|
+
mounted_on: parts[5],
|
|
136
|
+
};
|
|
137
|
+
});
|
|
138
|
+
disk = disks;
|
|
116
139
|
}
|
|
117
140
|
// Get home directory breakdown
|
|
118
141
|
const home = homedir();
|