hacktricks-mcp-server 1.3.2 → 1.3.3

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 CHANGED
@@ -15,27 +15,26 @@ MCP (Model Context Protocol) server for searching and querying [HackTricks](http
15
15
 
16
16
  ## Setup
17
17
 
18
- ### 1. Clone and Initialize
18
+ ### Option 1: Install from npm (Recommended)
19
19
 
20
20
  ```bash
21
- git clone https://github.com/Xplo8E/hacktricks-mcp-server.git
22
- cd hacktricks-mcp-server
23
- git submodule update --init --recursive
24
- ```
25
-
26
- ### 2. Install Dependencies
21
+ # Install the package
22
+ npm install -g hacktricks-mcp-server
27
23
 
28
- ```bash
29
- bun install
24
+ # The postinstall script will automatically clone HackTricks repository
30
25
  ```
31
26
 
32
- ### 3. Build
27
+ ### Option 2: Install from source
33
28
 
34
29
  ```bash
35
- bun run build
30
+ git clone https://github.com/Xplo8E/hacktricks-mcp-server.git
31
+ cd hacktricks-mcp-server
32
+ git submodule update --init --recursive
33
+ npm install
34
+ npm run build
36
35
  ```
37
36
 
38
- ### 4. Configure Claude
37
+ ### Configure Claude
39
38
 
40
39
  Add to your Claude settings (`~/.claude/settings.json`):
41
40
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hacktricks-mcp-server",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "MCP server for searching HackTricks documentation",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -12,7 +12,8 @@
12
12
  "scripts": {
13
13
  "build": "tsc",
14
14
  "dev": "tsc --watch",
15
- "start": "node dist/index.js"
15
+ "start": "node dist/index.js",
16
+ "postinstall": "node scripts/postinstall.js"
16
17
  },
17
18
  "keywords": [
18
19
  "mcp",
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { existsSync, rmSync } from 'fs';
4
+ import { execSync } from 'child_process';
5
+ import { join, dirname } from 'path';
6
+ import { fileURLToPath } from 'url';
7
+
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = dirname(__filename);
10
+ const rootDir = join(__dirname, '..');
11
+ const hacktricksPath = join(rootDir, 'hacktricks');
12
+
13
+ console.log('đŸ“Ļ Setting up HackTricks MCP Server...');
14
+
15
+ // Check if hacktricks directory already exists and is valid
16
+ if (existsSync(hacktricksPath)) {
17
+ // Verify it's a valid git repo with content
18
+ const gitDir = join(hacktricksPath, '.git');
19
+ const srcDir = join(hacktricksPath, 'src');
20
+
21
+ if (existsSync(gitDir) && existsSync(srcDir)) {
22
+ console.log('✓ HackTricks repository already exists');
23
+ process.exit(0);
24
+ } else {
25
+ console.log('âš ī¸ Incomplete HackTricks directory found, removing...');
26
+ try {
27
+ rmSync(hacktricksPath, { recursive: true, force: true });
28
+ } catch (e) {
29
+ console.error('❌ Could not remove incomplete directory');
30
+ console.error(` Please remove manually: ${hacktricksPath}`);
31
+ process.exit(1);
32
+ }
33
+ }
34
+ }
35
+
36
+ // Check if git is installed
37
+ try {
38
+ execSync('git --version', { stdio: 'ignore' });
39
+ } catch (error) {
40
+ console.error('❌ Git is not installed');
41
+ console.error(' Please install git: https://git-scm.com/downloads');
42
+ console.error(' Then run: npm rebuild hacktricks-mcp-server');
43
+ process.exit(0); // Exit 0 to not fail npm install
44
+ }
45
+
46
+ // Check for SKIP_POSTINSTALL environment variable
47
+ if (process.env.SKIP_POSTINSTALL === 'true') {
48
+ console.log('â„šī¸ Skipping HackTricks clone (SKIP_POSTINSTALL=true)');
49
+ console.log(' Run manually: git clone https://github.com/carlospolop/hacktricks.git');
50
+ process.exit(0);
51
+ }
52
+
53
+ console.log('đŸ“Ĩ Cloning HackTricks repository (this may take a minute)...');
54
+
55
+ try {
56
+ execSync(
57
+ 'git clone --depth 1 --single-branch https://github.com/carlospolop/hacktricks.git',
58
+ {
59
+ cwd: rootDir,
60
+ stdio: ['ignore', 'pipe', 'pipe'],
61
+ timeout: 120000 // 2 minute timeout
62
+ }
63
+ );
64
+
65
+ // Verify clone was successful
66
+ if (existsSync(join(hacktricksPath, 'src'))) {
67
+ console.log('✓ HackTricks repository cloned successfully');
68
+ console.log('✓ Setup complete! You can now use the HackTricks MCP server.');
69
+ } else {
70
+ throw new Error('Clone incomplete - src directory not found');
71
+ }
72
+ } catch (error) {
73
+ console.error('❌ Failed to clone HackTricks repository');
74
+ console.error(` Error: ${error.message}`);
75
+ console.error('');
76
+ console.error(' Please run manually:');
77
+ console.error(` cd ${rootDir}`);
78
+ console.error(' git clone https://github.com/carlospolop/hacktricks.git');
79
+ console.error('');
80
+ console.error(' Or set SKIP_POSTINSTALL=true to skip this step');
81
+
82
+ // Clean up partial clone
83
+ if (existsSync(hacktricksPath)) {
84
+ try {
85
+ rmSync(hacktricksPath, { recursive: true, force: true });
86
+ } catch (e) {
87
+ // Ignore cleanup errors
88
+ }
89
+ }
90
+
91
+ process.exit(0); // Exit 0 to not fail npm install
92
+ }