mcp-prune 0.1.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/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # mcp-prune
2
+
3
+ Audit MCP server usage from Claude Code transcripts. Find idle servers so you
4
+ can prune them and stop loading their tool schemas into every conversation.
5
+
6
+ This npm package wraps the Rust binary distributed via GitHub Releases.
7
+
8
+ ## Install
9
+
10
+ ```sh
11
+ npm install -g mcp-prune
12
+ # or run without installing
13
+ npx mcp-prune report
14
+ ```
15
+
16
+ On install, a small postinstall script downloads the prebuilt binary for your
17
+ platform (`darwin-arm64`, `darwin-x64`, `linux-x64`, `linux-arm64`) from the
18
+ matching GitHub Release. No Rust toolchain required.
19
+
20
+ ## Usage
21
+
22
+ ```sh
23
+ mcp-prune install # add SessionStart hook to ~/.claude/settings.json
24
+ mcp-prune report # grouped usage report
25
+ mcp-prune idle # only idle servers
26
+ mcp-prune apply # interactive prune
27
+ ```
28
+
29
+ See the full README at https://github.com/mstuart/mcp-prune for details.
30
+
31
+ ## Troubleshooting
32
+
33
+ If the binary fails to download during install (corp proxy, offline, etc.):
34
+
35
+ ```sh
36
+ npm rebuild mcp-prune # retry the download
37
+ ```
38
+
39
+ Or build from source:
40
+
41
+ ```sh
42
+ cargo install --git https://github.com/mstuart/mcp-prune
43
+ ```
44
+
45
+ ## License
46
+
47
+ MIT
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env node
2
+ // Thin shim that exec's the platform-native binary that postinstall placed
3
+ // next to this file. Keeping this as JS (not the binary itself) means npm can
4
+ // always link a stable `bin/mcp-prune.js` regardless of host arch.
5
+
6
+ 'use strict';
7
+
8
+ const { spawnSync } = require('child_process');
9
+ const fs = require('fs');
10
+ const path = require('path');
11
+
12
+ const ext = process.platform === 'win32' ? '.exe' : '';
13
+ const binPath = path.join(__dirname, `mcp-prune-bin${ext}`);
14
+
15
+ if (!fs.existsSync(binPath)) {
16
+ console.error('mcp-prune: native binary not found at', binPath);
17
+ console.error('mcp-prune: re-run install with `npm rebuild mcp-prune` (postinstall fetches it from GitHub Releases).');
18
+ console.error('mcp-prune: if this keeps failing, report at https://github.com/mstuart/mcp-prune/issues');
19
+ process.exit(1);
20
+ }
21
+
22
+ const result = spawnSync(binPath, process.argv.slice(2), { stdio: 'inherit' });
23
+ if (result.error) {
24
+ console.error('mcp-prune:', result.error.message);
25
+ process.exit(1);
26
+ }
27
+ process.exit(result.status ?? 1);
package/install.js ADDED
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env node
2
+ // Downloads the prebuilt mcp-prune binary for this platform from the matching
3
+ // GitHub Release and writes it next to the Node shim in ./bin/.
4
+ //
5
+ // Fails loudly with a clear message on unsupported platforms or network errors.
6
+ // The shim in bin/mcp-prune.js is the npm entry point and will report a
7
+ // friendlier error if the binary is missing at run time, so a postinstall
8
+ // failure here doesn't break the install — it just defers the error.
9
+
10
+ 'use strict';
11
+
12
+ const fs = require('fs');
13
+ const path = require('path');
14
+ const https = require('https');
15
+ const zlib = require('zlib');
16
+ const { pipeline } = require('stream/promises');
17
+
18
+ const REPO = 'mstuart/mcp-prune';
19
+ const VERSION = require('./package.json').version;
20
+
21
+ const TARGETS = {
22
+ 'darwin-arm64': 'aarch64-apple-darwin',
23
+ 'darwin-x64': 'x86_64-apple-darwin',
24
+ 'linux-x64': 'x86_64-unknown-linux-gnu',
25
+ 'linux-arm64': 'aarch64-unknown-linux-gnu',
26
+ };
27
+
28
+ function targetTriple() {
29
+ const key = `${process.platform}-${process.arch}`;
30
+ const triple = TARGETS[key];
31
+ if (!triple) {
32
+ const supported = Object.keys(TARGETS).join(', ');
33
+ throw new Error(
34
+ `unsupported platform: ${key}. Supported: ${supported}. ` +
35
+ `Build from source with \`cargo install --git https://github.com/${REPO}\`.`
36
+ );
37
+ }
38
+ return triple;
39
+ }
40
+
41
+ function get(url, redirects = 5) {
42
+ return new Promise((resolve, reject) => {
43
+ https
44
+ .get(url, { headers: { 'user-agent': `mcp-prune-npm/${VERSION}` } }, (res) => {
45
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
46
+ if (redirects === 0) {
47
+ reject(new Error('too many redirects'));
48
+ return;
49
+ }
50
+ res.resume();
51
+ resolve(get(res.headers.location, redirects - 1));
52
+ return;
53
+ }
54
+ if (res.statusCode !== 200) {
55
+ reject(new Error(`GET ${url} returned ${res.statusCode}`));
56
+ return;
57
+ }
58
+ resolve(res);
59
+ })
60
+ .on('error', reject);
61
+ });
62
+ }
63
+
64
+ async function main() {
65
+ const triple = targetTriple();
66
+ const url = `https://github.com/${REPO}/releases/download/v${VERSION}/mcp-prune-${triple}.gz`;
67
+ const outDir = path.join(__dirname, 'bin');
68
+ const outPath = path.join(outDir, process.platform === 'win32' ? 'mcp-prune-bin.exe' : 'mcp-prune-bin');
69
+
70
+ fs.mkdirSync(outDir, { recursive: true });
71
+
72
+ process.stdout.write(`mcp-prune: downloading ${triple} binary... `);
73
+ const res = await get(url);
74
+ await pipeline(res, zlib.createGunzip(), fs.createWriteStream(outPath, { mode: 0o755 }));
75
+ process.stdout.write('done\n');
76
+ }
77
+
78
+ main().catch((err) => {
79
+ console.error(`mcp-prune: postinstall failed: ${err.message}`);
80
+ console.error(`mcp-prune: the binary will be downloaded on first run, or you can re-run \`npm rebuild mcp-prune\`.`);
81
+ process.exit(0);
82
+ });
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "mcp-prune",
3
+ "version": "0.1.0",
4
+ "description": "Audit MCP server usage from Claude Code transcripts. Find idle servers to prune.",
5
+ "keywords": [
6
+ "mcp",
7
+ "claude-code",
8
+ "anthropic",
9
+ "audit"
10
+ ],
11
+ "homepage": "https://github.com/mstuart/mcp-prune#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/mstuart/mcp-prune/issues"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/mstuart/mcp-prune.git"
18
+ },
19
+ "license": "MIT",
20
+ "author": "Mark Stuart <mstuart@users.noreply.github.com>",
21
+ "bin": {
22
+ "mcp-prune": "bin/mcp-prune.js"
23
+ },
24
+ "files": [
25
+ "bin/mcp-prune.js",
26
+ "install.js",
27
+ "README.md"
28
+ ],
29
+ "scripts": {
30
+ "postinstall": "node install.js"
31
+ },
32
+ "engines": {
33
+ "node": ">=16"
34
+ },
35
+ "os": [
36
+ "darwin",
37
+ "linux"
38
+ ],
39
+ "cpu": [
40
+ "x64",
41
+ "arm64"
42
+ ]
43
+ }