hacktricks-mcp-server 1.3.1

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/test-mcp.js ADDED
@@ -0,0 +1,127 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Simple MCP server test script
5
+ * Tests the server by sending MCP protocol messages
6
+ */
7
+
8
+ import { spawn } from 'child_process';
9
+
10
+ const serverProcess = spawn('node', ['dist/index.js'], {
11
+ stdio: ['pipe', 'pipe', 'inherit'] // stdin, stdout, stderr
12
+ });
13
+
14
+ let responseBuffer = '';
15
+
16
+ serverProcess.stdout.on('data', (data) => {
17
+ responseBuffer += data.toString();
18
+
19
+ // Try to parse complete JSON messages
20
+ const lines = responseBuffer.split('\n');
21
+ responseBuffer = lines.pop() || ''; // Keep incomplete line
22
+
23
+ for (const line of lines) {
24
+ if (line.trim()) {
25
+ try {
26
+ const message = JSON.parse(line);
27
+ console.log('📨 Received:', JSON.stringify(message, null, 2));
28
+ } catch (e) {
29
+ console.log('📨 Raw:', line);
30
+ }
31
+ }
32
+ }
33
+ });
34
+
35
+ serverProcess.on('error', (error) => {
36
+ console.error('❌ Server error:', error);
37
+ process.exit(1);
38
+ });
39
+
40
+ serverProcess.on('exit', (code) => {
41
+ console.log(`Server exited with code ${code}`);
42
+ process.exit(code);
43
+ });
44
+
45
+ // Send test messages
46
+ function sendMessage(message) {
47
+ console.log('📤 Sending:', JSON.stringify(message, null, 2));
48
+ serverProcess.stdin.write(JSON.stringify(message) + '\n');
49
+ }
50
+
51
+ // Wait a bit for server to start
52
+ setTimeout(() => {
53
+ console.log('\n=== Test 1: Initialize ===');
54
+ sendMessage({
55
+ jsonrpc: '2.0',
56
+ id: 1,
57
+ method: 'initialize',
58
+ params: {
59
+ protocolVersion: '2024-11-05',
60
+ capabilities: {},
61
+ clientInfo: {
62
+ name: 'test-client',
63
+ version: '1.0.0'
64
+ }
65
+ }
66
+ });
67
+ }, 500);
68
+
69
+ setTimeout(() => {
70
+ console.log('\n=== Test 2: List Tools ===');
71
+ sendMessage({
72
+ jsonrpc: '2.0',
73
+ id: 2,
74
+ method: 'tools/list',
75
+ params: {}
76
+ });
77
+ }, 1500);
78
+
79
+ setTimeout(() => {
80
+ console.log('\n=== Test 3: Call search_hacktricks ===');
81
+ sendMessage({
82
+ jsonrpc: '2.0',
83
+ id: 3,
84
+ method: 'tools/call',
85
+ params: {
86
+ name: 'search_hacktricks',
87
+ arguments: {
88
+ query: 'SUID'
89
+ }
90
+ }
91
+ });
92
+ }, 2500);
93
+
94
+ setTimeout(() => {
95
+ console.log('\n=== Test 4: Call list_hacktricks_categories ===');
96
+ sendMessage({
97
+ jsonrpc: '2.0',
98
+ id: 4,
99
+ method: 'tools/call',
100
+ params: {
101
+ name: 'list_hacktricks_categories',
102
+ arguments: {}
103
+ }
104
+ });
105
+ }, 3500);
106
+
107
+ setTimeout(() => {
108
+ console.log('\n=== Test 5: Call get_hacktricks_page ===');
109
+ sendMessage({
110
+ jsonrpc: '2.0',
111
+ id: 5,
112
+ method: 'tools/call',
113
+ params: {
114
+ name: 'get_hacktricks_page',
115
+ arguments: {
116
+ path: 'src/README.md'
117
+ }
118
+ }
119
+ });
120
+ }, 4500);
121
+
122
+ // Exit after tests
123
+ setTimeout(() => {
124
+ console.log('\n=== All tests complete ===');
125
+ serverProcess.kill();
126
+ process.exit(0);
127
+ }, 6000);
package/tsconfig.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "Node16",
5
+ "moduleResolution": "Node16",
6
+ "outDir": "./dist",
7
+ "rootDir": "./src",
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "resolveJsonModule": true
13
+ },
14
+ "include": ["src/**/*"],
15
+ "exclude": ["node_modules", "dist"]
16
+ }