@markmayandi/bridge 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +123 -2
- package/bridge-icon.svg +130 -0
- package/bridge.bat +8 -0
- package/bridge.js +897 -0
- package/bridge_icon.jpg +0 -0
- package/bridge_icon.png +0 -0
- package/bridge_icon_chatgpt_under10kb.png +0 -0
- package/bridge_logo.jpg +0 -0
- package/package.json +36 -4
- package/secure-folder-mcp/README.md +142 -0
- package/secure-folder-mcp/configure_tunnel.bat +6 -0
- package/secure-folder-mcp/configure_tunnel.ps1 +61 -0
- package/secure-folder-mcp/package.json +26 -0
- package/secure-folder-mcp/server.js +1519 -0
- package/secure-folder-mcp/start-web-bridge.bat +19 -0
- package/secure-folder-mcp/test_client.js +209 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
setlocal
|
|
3
|
+
set "PROJECT_DIR=%~1"
|
|
4
|
+
if "%PROJECT_DIR%"=="" set "PROJECT_DIR=%CD%"
|
|
5
|
+
|
|
6
|
+
echo ========================================================
|
|
7
|
+
echo Starting Secure Folder MCP (Web Bridge Mode)
|
|
8
|
+
echo ========================================================
|
|
9
|
+
echo Sandboxed Directory: %PROJECT_DIR%
|
|
10
|
+
echo HTTP Endpoint: http://localhost:3000
|
|
11
|
+
echo OpenAPI Schema: http://localhost:3000/openapi.json
|
|
12
|
+
echo.
|
|
13
|
+
echo Ready for Web Chatbots (ChatGPT, Claude, DeepSeek, Gemini)!
|
|
14
|
+
echo Press Ctrl+C to stop.
|
|
15
|
+
echo ========================================================
|
|
16
|
+
echo.
|
|
17
|
+
|
|
18
|
+
node "%~dp0server.js" "%PROJECT_DIR%" --http 3000
|
|
19
|
+
pause
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Automated Test Suite for Secure Folder MCP Server
|
|
3
|
+
* Validates protocol compliance, file operations, and strict security isolation.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const { spawn } = require('child_process');
|
|
7
|
+
const path = require('path');
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
|
|
10
|
+
const SANDBOX_DIR = path.join(__dirname, 'test_sandbox');
|
|
11
|
+
|
|
12
|
+
// Ensure clean test sandbox
|
|
13
|
+
if (fs.existsSync(SANDBOX_DIR)) {
|
|
14
|
+
fs.rmSync(SANDBOX_DIR, { recursive: true, force: true });
|
|
15
|
+
}
|
|
16
|
+
fs.mkdirSync(SANDBOX_DIR, { recursive: true });
|
|
17
|
+
|
|
18
|
+
console.log(`[TEST] Setting up test sandbox at: ${SANDBOX_DIR}`);
|
|
19
|
+
|
|
20
|
+
// Start server child process
|
|
21
|
+
const serverProcess = spawn('node', [path.join(__dirname, 'server.js'), SANDBOX_DIR], {
|
|
22
|
+
stdio: ['pipe', 'pipe', 'pipe']
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
let messageId = 1;
|
|
26
|
+
const pendingRequests = new Map();
|
|
27
|
+
let buffer = '';
|
|
28
|
+
|
|
29
|
+
serverProcess.stdout.on('data', (chunk) => {
|
|
30
|
+
buffer += chunk.toString();
|
|
31
|
+
const lines = buffer.split('\n');
|
|
32
|
+
buffer = lines.pop(); // Keep partial line in buffer
|
|
33
|
+
|
|
34
|
+
for (const line of lines) {
|
|
35
|
+
if (!line.trim()) continue;
|
|
36
|
+
try {
|
|
37
|
+
const msg = JSON.parse(line.trim());
|
|
38
|
+
if (msg.id && pendingRequests.has(msg.id)) {
|
|
39
|
+
const { resolve, reject } = pendingRequests.get(msg.id);
|
|
40
|
+
pendingRequests.delete(msg.id);
|
|
41
|
+
resolve(msg);
|
|
42
|
+
}
|
|
43
|
+
} catch (e) {
|
|
44
|
+
console.error('[TEST] Could not parse JSON from server:', line);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
serverProcess.stderr.on('data', (chunk) => {
|
|
50
|
+
// Stderr is for server diagnostic logs
|
|
51
|
+
// console.log('[SERVER-STDERR]', chunk.toString().trim());
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
function sendRequest(method, params = {}) {
|
|
55
|
+
const id = messageId++;
|
|
56
|
+
const payload = {
|
|
57
|
+
jsonrpc: '2.0',
|
|
58
|
+
id,
|
|
59
|
+
method,
|
|
60
|
+
params
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
return new Promise((resolve, reject) => {
|
|
64
|
+
pendingRequests.set(id, { resolve, reject });
|
|
65
|
+
serverProcess.stdin.write(JSON.stringify(payload) + '\n');
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function sendNotification(method, params = {}) {
|
|
70
|
+
const payload = {
|
|
71
|
+
jsonrpc: '2.0',
|
|
72
|
+
method,
|
|
73
|
+
params
|
|
74
|
+
};
|
|
75
|
+
serverProcess.stdin.write(JSON.stringify(payload) + '\n');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function runTests() {
|
|
79
|
+
console.log('[TEST] Starting MCP Protocol Verification...\n');
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
// 1. Initialize
|
|
83
|
+
console.log('1. Testing "initialize"...');
|
|
84
|
+
const initRes = await sendRequest('initialize', {
|
|
85
|
+
protocolVersion: '2024-11-05',
|
|
86
|
+
capabilities: {},
|
|
87
|
+
clientInfo: { name: 'test-client', version: '1.0.0' }
|
|
88
|
+
});
|
|
89
|
+
console.assert(initRes.result.serverInfo.name === 'secure-folder-fs', 'Server name match');
|
|
90
|
+
console.log(' ✓ Initialize succeeded:', initRes.result.serverInfo);
|
|
91
|
+
|
|
92
|
+
// 2. Notification initialized
|
|
93
|
+
sendNotification('notifications/initialized');
|
|
94
|
+
|
|
95
|
+
// 3. Tools list
|
|
96
|
+
console.log('2. Testing "tools/list"...');
|
|
97
|
+
const toolsRes = await sendRequest('tools/list', {});
|
|
98
|
+
const tools = toolsRes.result.tools;
|
|
99
|
+
console.assert(tools.length >= 7, 'Has at least 7 tools');
|
|
100
|
+
console.log(` ✓ Found ${tools.length} available tools:`, tools.map(t => t.name).join(', '));
|
|
101
|
+
|
|
102
|
+
// 4. Write file
|
|
103
|
+
console.log('3. Testing "write_file"...');
|
|
104
|
+
const writeRes = await sendRequest('tools/call', {
|
|
105
|
+
name: 'write_file',
|
|
106
|
+
arguments: {
|
|
107
|
+
path: 'src/main.py',
|
|
108
|
+
content: 'def hello():\n print("Hello from Chatbot MCP!")\n\nif __name__ == "__main__":\n hello()\n'
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
console.assert(writeRes.result.isError === false, 'Write file succeeded');
|
|
112
|
+
console.log(' ✓ Write succeeded:', writeRes.result.content[0].text);
|
|
113
|
+
|
|
114
|
+
// 5. Read file (full & range)
|
|
115
|
+
console.log('4. Testing "read_file"...');
|
|
116
|
+
const readRes = await sendRequest('tools/call', {
|
|
117
|
+
name: 'read_file',
|
|
118
|
+
arguments: {
|
|
119
|
+
path: 'src/main.py',
|
|
120
|
+
start_line: 1,
|
|
121
|
+
end_line: 2
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
console.assert(readRes.result.isError === false, 'Read range succeeded');
|
|
125
|
+
console.log(' ✓ Read line range succeeded:\n' + readRes.result.content[0].text);
|
|
126
|
+
|
|
127
|
+
// 6. Edit file (Search & Replace)
|
|
128
|
+
console.log('5. Testing "edit_file" (surgical token-saving replacement)...');
|
|
129
|
+
const editRes = await sendRequest('tools/call', {
|
|
130
|
+
name: 'edit_file',
|
|
131
|
+
arguments: {
|
|
132
|
+
path: 'src/main.py',
|
|
133
|
+
target: 'print("Hello from Chatbot MCP!")',
|
|
134
|
+
replacement: 'print("Hello from Claude/Gemini/DeepSeek Secure MCP!")'
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
console.assert(editRes.result.isError === false, 'Edit succeeded');
|
|
138
|
+
console.log(' ✓ Edit succeeded:', editRes.result.content[0].text);
|
|
139
|
+
|
|
140
|
+
// Verify edit persisted
|
|
141
|
+
const verifyEdit = await sendRequest('tools/call', {
|
|
142
|
+
name: 'read_file',
|
|
143
|
+
arguments: { path: 'src/main.py' }
|
|
144
|
+
});
|
|
145
|
+
console.assert(verifyEdit.result.content[0].text.includes('Claude/Gemini/DeepSeek'), 'Replacement verified');
|
|
146
|
+
|
|
147
|
+
// 7. Search files
|
|
148
|
+
console.log('6. Testing "search_files"...');
|
|
149
|
+
const searchRes = await sendRequest('tools/call', {
|
|
150
|
+
name: 'search_files',
|
|
151
|
+
arguments: { query: 'DeepSeek' }
|
|
152
|
+
});
|
|
153
|
+
console.assert(searchRes.result.content[0].text.includes('src/main.py'), 'Search found file');
|
|
154
|
+
console.log(' ✓ Search succeeded:\n' + searchRes.result.content[0].text);
|
|
155
|
+
|
|
156
|
+
// 8. List directory
|
|
157
|
+
console.log('7. Testing "list_directory"...');
|
|
158
|
+
const listRes = await sendRequest('tools/call', {
|
|
159
|
+
name: 'list_directory',
|
|
160
|
+
arguments: { path: '.' }
|
|
161
|
+
});
|
|
162
|
+
console.assert(listRes.result.content[0].text.includes('src/main.py'), 'List contains created file');
|
|
163
|
+
console.log(' ✓ Directory listing:\n' + listRes.result.content[0].text);
|
|
164
|
+
|
|
165
|
+
// 9. SECURITY VERIFICATION: Path Traversal Tests
|
|
166
|
+
console.log('8. Testing SECURITY SANDBOX (Attempting Traversal Outside Folder)...');
|
|
167
|
+
|
|
168
|
+
// Attack A: Read parent file
|
|
169
|
+
const attackA = await sendRequest('tools/call', {
|
|
170
|
+
name: 'read_file',
|
|
171
|
+
arguments: { path: '../../build_compiled_dossier.py' }
|
|
172
|
+
});
|
|
173
|
+
console.assert(attackA.result.isError === true, 'Attack A blocked');
|
|
174
|
+
console.log(' ✓ Attack A (relative traversal) BLOCKED successfully:', attackA.result.content[0].text);
|
|
175
|
+
|
|
176
|
+
// Attack B: Write outside folder
|
|
177
|
+
const attackB = await sendRequest('tools/call', {
|
|
178
|
+
name: 'write_file',
|
|
179
|
+
arguments: { path: '../malicious_hack.txt', content: 'pwned' }
|
|
180
|
+
});
|
|
181
|
+
console.assert(attackB.result.isError === true, 'Attack B blocked');
|
|
182
|
+
console.log(' ✓ Attack B (write outside root) BLOCKED successfully:', attackB.result.content[0].text);
|
|
183
|
+
|
|
184
|
+
// Attack C: Read sensitive .env file
|
|
185
|
+
fs.writeFileSync(path.join(SANDBOX_DIR, '.env'), 'SECRET_API_KEY=12345');
|
|
186
|
+
const attackC = await sendRequest('tools/call', {
|
|
187
|
+
name: 'read_file',
|
|
188
|
+
arguments: { path: '.env' }
|
|
189
|
+
});
|
|
190
|
+
console.assert(attackC.result.isError === true, 'Attack C blocked');
|
|
191
|
+
console.log(' ✓ Attack C (.env secret file protection) BLOCKED successfully:', attackC.result.content[0].text);
|
|
192
|
+
|
|
193
|
+
console.log('\n========================================');
|
|
194
|
+
console.log('[PASS] ALL TESTS PASSED! 100% SECURE & FUNCTIONAL.');
|
|
195
|
+
console.log('========================================\n');
|
|
196
|
+
|
|
197
|
+
} catch (err) {
|
|
198
|
+
console.error('Test failed:', err);
|
|
199
|
+
} finally {
|
|
200
|
+
serverProcess.kill();
|
|
201
|
+
// Clean up test sandbox
|
|
202
|
+
try {
|
|
203
|
+
fs.rmSync(SANDBOX_DIR, { recursive: true, force: true });
|
|
204
|
+
} catch (e) {}
|
|
205
|
+
process.exit(0);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
runTests();
|