@integsec/mcp-pentester-cli 1.0.5 → 1.0.6
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 +35 -3
- package/dist/index.js +16 -5
- package/dist/index.js.map +1 -1
- package/dist/mcp-client.d.ts.map +1 -1
- package/dist/mcp-client.js +50 -11
- package/dist/mcp-client.js.map +1 -1
- package/dist/transport/http.d.ts +1 -0
- package/dist/transport/http.d.ts.map +1 -1
- package/dist/transport/http.js +82 -2
- package/dist/transport/http.js.map +1 -1
- package/dist/transport/sse.d.ts +25 -0
- package/dist/transport/sse.d.ts.map +1 -0
- package/dist/transport/sse.js +346 -0
- package/dist/transport/sse.js.map +1 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/tui.d.ts.map +1 -1
- package/dist/ui/tui.js +123 -20
- package/dist/ui/tui.js.map +1 -1
- package/examples/sse-basic-config.json +8 -0
- package/examples/sse-docker-gateway-config.json +8 -0
- package/examples/sse-proxy-config.json +17 -0
- package/package.json +1 -1
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.SSETransport = void 0;
|
|
37
|
+
const http = __importStar(require("http"));
|
|
38
|
+
const https = __importStar(require("https"));
|
|
39
|
+
const fs = __importStar(require("fs"));
|
|
40
|
+
const http_proxy_agent_1 = require("http-proxy-agent");
|
|
41
|
+
const https_proxy_agent_1 = require("https-proxy-agent");
|
|
42
|
+
const socks_proxy_agent_1 = require("socks-proxy-agent");
|
|
43
|
+
const base_1 = require("./base");
|
|
44
|
+
class SSETransport extends base_1.Transport {
|
|
45
|
+
constructor(url, proxyConfig, authConfig, certificateConfig, customHeaders) {
|
|
46
|
+
super();
|
|
47
|
+
this.url = url;
|
|
48
|
+
this.proxyConfig = proxyConfig;
|
|
49
|
+
this.authConfig = authConfig;
|
|
50
|
+
this.certificateConfig = certificateConfig;
|
|
51
|
+
this.authHeaders = {};
|
|
52
|
+
this.customHeaders = {};
|
|
53
|
+
this.reconnecting = false;
|
|
54
|
+
this.isHttps = url.startsWith('https://');
|
|
55
|
+
this.customHeaders = customHeaders || {};
|
|
56
|
+
// Extract endpoint path from URL
|
|
57
|
+
const urlObj = new URL(this.url);
|
|
58
|
+
this.endpoint = urlObj.pathname + urlObj.search;
|
|
59
|
+
this.setupAuthHeaders();
|
|
60
|
+
this.setupAgent();
|
|
61
|
+
}
|
|
62
|
+
setupAuthHeaders() {
|
|
63
|
+
if (!this.authConfig) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
switch (this.authConfig.type) {
|
|
67
|
+
case 'bearer':
|
|
68
|
+
if (this.authConfig.token) {
|
|
69
|
+
this.authHeaders['Authorization'] = `Bearer ${this.authConfig.token}`;
|
|
70
|
+
}
|
|
71
|
+
break;
|
|
72
|
+
case 'basic':
|
|
73
|
+
if (this.authConfig.username && this.authConfig.password) {
|
|
74
|
+
const credentials = Buffer.from(`${this.authConfig.username}:${this.authConfig.password}`).toString('base64');
|
|
75
|
+
this.authHeaders['Authorization'] = `Basic ${credentials}`;
|
|
76
|
+
}
|
|
77
|
+
break;
|
|
78
|
+
case 'custom':
|
|
79
|
+
if (this.authConfig.headers) {
|
|
80
|
+
this.authHeaders = { ...this.authHeaders, ...this.authConfig.headers };
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
setupAgent() {
|
|
86
|
+
const agentOptions = {};
|
|
87
|
+
if (this.certificateConfig) {
|
|
88
|
+
if (this.certificateConfig.cert) {
|
|
89
|
+
agentOptions.cert = fs.readFileSync(this.certificateConfig.cert);
|
|
90
|
+
}
|
|
91
|
+
if (this.certificateConfig.key) {
|
|
92
|
+
agentOptions.key = fs.readFileSync(this.certificateConfig.key);
|
|
93
|
+
}
|
|
94
|
+
if (this.certificateConfig.ca) {
|
|
95
|
+
agentOptions.ca = fs.readFileSync(this.certificateConfig.ca);
|
|
96
|
+
}
|
|
97
|
+
if (this.certificateConfig.passphrase) {
|
|
98
|
+
agentOptions.passphrase = this.certificateConfig.passphrase;
|
|
99
|
+
}
|
|
100
|
+
if (this.certificateConfig.rejectUnauthorized !== undefined) {
|
|
101
|
+
agentOptions.rejectUnauthorized = this.certificateConfig.rejectUnauthorized;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (!this.proxyConfig) {
|
|
105
|
+
if (Object.keys(agentOptions).length > 0 && this.isHttps) {
|
|
106
|
+
this.agent = new https.Agent(agentOptions);
|
|
107
|
+
}
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const proxyAuth = this.proxyConfig.auth
|
|
111
|
+
? `${this.proxyConfig.auth.username}:${this.proxyConfig.auth.password}@`
|
|
112
|
+
: '';
|
|
113
|
+
const proxyProtocol = this.proxyConfig.protocol || 'http';
|
|
114
|
+
if (proxyProtocol === 'socks' || proxyProtocol === 'socks5') {
|
|
115
|
+
const proxyUrl = `socks5://${proxyAuth}${this.proxyConfig.host}:${this.proxyConfig.port}`;
|
|
116
|
+
this.agent = new socks_proxy_agent_1.SocksProxyAgent(proxyUrl, agentOptions);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
const proxyUrl = `${proxyProtocol}://${proxyAuth}${this.proxyConfig.host}:${this.proxyConfig.port}`;
|
|
120
|
+
if (this.isHttps) {
|
|
121
|
+
this.agent = new https_proxy_agent_1.HttpsProxyAgent(proxyUrl, agentOptions);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
this.agent = new http_proxy_agent_1.HttpProxyAgent(proxyUrl, agentOptions);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async connect() {
|
|
129
|
+
// Open SSE stream with GET request
|
|
130
|
+
await this.openSSEStream();
|
|
131
|
+
this.emit('connected');
|
|
132
|
+
}
|
|
133
|
+
async openSSEStream() {
|
|
134
|
+
return new Promise((resolve, reject) => {
|
|
135
|
+
const urlObj = new URL(this.url);
|
|
136
|
+
const httpModule = this.isHttps ? https : http;
|
|
137
|
+
const headers = {
|
|
138
|
+
'Accept': 'text/event-stream',
|
|
139
|
+
'Cache-Control': 'no-cache',
|
|
140
|
+
...this.customHeaders,
|
|
141
|
+
...this.authHeaders,
|
|
142
|
+
};
|
|
143
|
+
// Include Last-Event-ID for session resumption
|
|
144
|
+
if (this.lastEventId) {
|
|
145
|
+
headers['Last-Event-ID'] = this.lastEventId;
|
|
146
|
+
}
|
|
147
|
+
const options = {
|
|
148
|
+
hostname: urlObj.hostname,
|
|
149
|
+
port: urlObj.port || (this.isHttps ? 443 : 80),
|
|
150
|
+
path: this.endpoint,
|
|
151
|
+
method: 'GET',
|
|
152
|
+
headers,
|
|
153
|
+
agent: this.agent,
|
|
154
|
+
};
|
|
155
|
+
const req = httpModule.request(options, (res) => {
|
|
156
|
+
if (res.statusCode !== 200) {
|
|
157
|
+
const error = new Error(`SSE connection failed: HTTP ${res.statusCode} ${res.statusMessage}`);
|
|
158
|
+
reject(error);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
this.sseStream = res;
|
|
162
|
+
let buffer = '';
|
|
163
|
+
res.on('data', (chunk) => {
|
|
164
|
+
buffer += chunk.toString();
|
|
165
|
+
// Process complete SSE events (separated by double newline)
|
|
166
|
+
const lines = buffer.split('\n\n');
|
|
167
|
+
buffer = lines.pop() || ''; // Keep incomplete event in buffer
|
|
168
|
+
for (const eventText of lines) {
|
|
169
|
+
if (eventText.trim()) {
|
|
170
|
+
this.handleSSEEvent(eventText);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
res.on('end', () => {
|
|
175
|
+
this.emit('disconnected');
|
|
176
|
+
// Auto-reconnect if not intentionally disconnected
|
|
177
|
+
if (!this.reconnecting) {
|
|
178
|
+
this.reconnecting = true;
|
|
179
|
+
setTimeout(() => {
|
|
180
|
+
this.reconnecting = false;
|
|
181
|
+
this.openSSEStream().catch((error) => {
|
|
182
|
+
this.emit('error', error);
|
|
183
|
+
});
|
|
184
|
+
}, 1000);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
res.on('error', (error) => {
|
|
188
|
+
this.emit('error', error);
|
|
189
|
+
reject(error);
|
|
190
|
+
});
|
|
191
|
+
resolve();
|
|
192
|
+
});
|
|
193
|
+
req.on('error', (error) => {
|
|
194
|
+
this.emit('error', error);
|
|
195
|
+
reject(error);
|
|
196
|
+
});
|
|
197
|
+
req.end();
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
handleSSEEvent(eventText) {
|
|
201
|
+
const event = { data: '' };
|
|
202
|
+
const lines = eventText.split('\n');
|
|
203
|
+
for (const line of lines) {
|
|
204
|
+
if (line.startsWith('id:')) {
|
|
205
|
+
event.id = line.substring(3).trim();
|
|
206
|
+
}
|
|
207
|
+
else if (line.startsWith('event:')) {
|
|
208
|
+
event.event = line.substring(6).trim();
|
|
209
|
+
}
|
|
210
|
+
else if (line.startsWith('data:')) {
|
|
211
|
+
event.data += line.substring(5).trim();
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
// Store last event ID for reconnection
|
|
215
|
+
if (event.id) {
|
|
216
|
+
this.lastEventId = event.id;
|
|
217
|
+
}
|
|
218
|
+
// Parse JSON data
|
|
219
|
+
if (event.data) {
|
|
220
|
+
try {
|
|
221
|
+
const message = JSON.parse(event.data);
|
|
222
|
+
this.emit('receive', message);
|
|
223
|
+
// Handle different message types
|
|
224
|
+
if ('result' in message || 'error' in message) {
|
|
225
|
+
this.handleResponse(message);
|
|
226
|
+
}
|
|
227
|
+
else if ('method' in message && !('id' in message)) {
|
|
228
|
+
this.handleNotification(message);
|
|
229
|
+
}
|
|
230
|
+
else if ('method' in message && 'id' in message) {
|
|
231
|
+
// Server request
|
|
232
|
+
this.emit('request', message);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
catch (error) {
|
|
236
|
+
// Silently ignore non-JSON SSE data (comments, heartbeats, etc.)
|
|
237
|
+
// Only log if debugging is enabled
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
async disconnect() {
|
|
242
|
+
this.reconnecting = true; // Prevent auto-reconnect
|
|
243
|
+
if (this.sseStream) {
|
|
244
|
+
this.sseStream.destroy();
|
|
245
|
+
this.sseStream = undefined;
|
|
246
|
+
}
|
|
247
|
+
if (this.agent) {
|
|
248
|
+
this.agent.destroy();
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
async send(data) {
|
|
252
|
+
const payload = JSON.stringify(data);
|
|
253
|
+
this.emit('send', data);
|
|
254
|
+
return new Promise((resolve, reject) => {
|
|
255
|
+
const urlObj = new URL(this.url);
|
|
256
|
+
const httpModule = this.isHttps ? https : http;
|
|
257
|
+
const headers = {
|
|
258
|
+
'Content-Type': 'application/json',
|
|
259
|
+
'Content-Length': Buffer.byteLength(payload).toString(),
|
|
260
|
+
'Accept': 'application/json, text/event-stream',
|
|
261
|
+
...this.customHeaders,
|
|
262
|
+
...this.authHeaders,
|
|
263
|
+
};
|
|
264
|
+
const options = {
|
|
265
|
+
hostname: urlObj.hostname,
|
|
266
|
+
port: urlObj.port || (this.isHttps ? 443 : 80),
|
|
267
|
+
path: this.endpoint,
|
|
268
|
+
method: 'POST',
|
|
269
|
+
headers,
|
|
270
|
+
agent: this.agent,
|
|
271
|
+
};
|
|
272
|
+
const req = httpModule.request(options, (res) => {
|
|
273
|
+
const contentType = res.headers['content-type'] || '';
|
|
274
|
+
let responseData = '';
|
|
275
|
+
res.on('data', (chunk) => {
|
|
276
|
+
responseData += chunk;
|
|
277
|
+
});
|
|
278
|
+
res.on('end', () => {
|
|
279
|
+
try {
|
|
280
|
+
// Handle SSE response
|
|
281
|
+
if (contentType.includes('text/event-stream')) {
|
|
282
|
+
// SSE response - events will be handled by the stream
|
|
283
|
+
// Just resolve the promise
|
|
284
|
+
resolve();
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
// Handle JSON response
|
|
288
|
+
if (contentType.includes('application/json')) {
|
|
289
|
+
if (!responseData.trim()) {
|
|
290
|
+
resolve();
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
const response = JSON.parse(responseData);
|
|
294
|
+
this.emit('receive', response);
|
|
295
|
+
if ('result' in response || 'error' in response) {
|
|
296
|
+
this.handleResponse(response);
|
|
297
|
+
}
|
|
298
|
+
else if ('method' in response && !('id' in response)) {
|
|
299
|
+
this.handleNotification(response);
|
|
300
|
+
}
|
|
301
|
+
resolve();
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
// No response or empty response
|
|
305
|
+
if (!responseData.trim()) {
|
|
306
|
+
resolve();
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
// Handle text/plain - try to parse as JSON first, otherwise accept as-is
|
|
310
|
+
if (contentType.includes('text/plain')) {
|
|
311
|
+
try {
|
|
312
|
+
const response = JSON.parse(responseData);
|
|
313
|
+
this.emit('receive', response);
|
|
314
|
+
if ('result' in response || 'error' in response) {
|
|
315
|
+
this.handleResponse(response);
|
|
316
|
+
}
|
|
317
|
+
else if ('method' in response && !('id' in response)) {
|
|
318
|
+
this.handleNotification(response);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
catch {
|
|
322
|
+
// Plain text response, not JSON - just accept it
|
|
323
|
+
}
|
|
324
|
+
resolve();
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
// Unexpected response type
|
|
328
|
+
reject(new Error(`Unexpected content type: ${contentType}`));
|
|
329
|
+
}
|
|
330
|
+
catch (error) {
|
|
331
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
332
|
+
reject(new Error(`Failed to process SSE response: ${errorMessage}`));
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
req.on('error', (error) => {
|
|
337
|
+
this.emit('error', error);
|
|
338
|
+
reject(error);
|
|
339
|
+
});
|
|
340
|
+
req.write(payload);
|
|
341
|
+
req.end();
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
exports.SSETransport = SSETransport;
|
|
346
|
+
//# sourceMappingURL=sse.js.map
|
|
@@ -0,0 +1 @@
|
|
|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I,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;gBAC1B,MAAM,CAAC,KAAK,CAAC,CAAC;YAChB,CAAC,CAAC,CAAC;YAEH,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACnB,GAAG,CAAC,GAAG,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA3VD,oCA2VC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ export interface MCPInitializeResult {
|
|
|
66
66
|
capabilities: MCPServerCapabilities;
|
|
67
67
|
serverInfo: MCPImplementation;
|
|
68
68
|
}
|
|
69
|
-
export type TransportType = 'stdio' | 'http' | 'https' | 'ws' | 'wss';
|
|
69
|
+
export type TransportType = 'stdio' | 'http' | 'https' | 'ws' | 'wss' | 'sse';
|
|
70
70
|
export type AuthType = 'bearer' | 'basic' | 'custom';
|
|
71
71
|
export interface AuthConfig {
|
|
72
72
|
type: AuthType;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EA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,EAAE,OAAO,EAAE,CAAC;IACjB,SAAS,EAAE,WAAW,EAAE,CAAC;IACzB,OAAO,EAAE,SAAS,EAAE,CAAC;IACrB,UAAU,EAAE,UAAU,EAAE,CAAC;CAC1B"}
|
package/dist/ui/tui.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../../src/ui/tui.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAmC,eAAe,EAAE,MAAM,UAAU,CAAC;AAI5E,qBAAa,GAAG;IACd,OAAO,CAAC,MAAM,CAAyB;IACvC,OAAO,CAAC,MAAM,CAMZ;IAEF,OAAO,CAAC,WAAW,CAA0D;IAC7E,OAAO,CAAC,MAAM,CAAC,CAAY;IAC3B,OAAO,CAAC,aAAa,CAAC,CAAkB;IACxC,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,YAAY,CAAoE;IACxF,OAAO,CAAC,WAAW,CAA6C;IAChE,OAAO,CAAC,eAAe,CAAmC;IAC1D,OAAO,CAAC,mBAAmB,CAAgF;IAC3G,OAAO,CAAC,cAAc,CAAS;;IAY/B,OAAO,CAAC,gBAAgB;IA6CxB,OAAO,CAAC,YAAY;IAkIpB,OAAO,CAAC,gBAAgB;IAkFxB,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,eAAe;
|
|
1
|
+
{"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../../src/ui/tui.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAmC,eAAe,EAAE,MAAM,UAAU,CAAC;AAI5E,qBAAa,GAAG;IACd,OAAO,CAAC,MAAM,CAAyB;IACvC,OAAO,CAAC,MAAM,CAMZ;IAEF,OAAO,CAAC,WAAW,CAA0D;IAC7E,OAAO,CAAC,MAAM,CAAC,CAAY;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js
CHANGED
|
@@ -294,6 +294,10 @@ class TUI {
|
|
|
294
294
|
});
|
|
295
295
|
}
|
|
296
296
|
setClient(client, config) {
|
|
297
|
+
// Remove all listeners from old client if it exists
|
|
298
|
+
if (this.client) {
|
|
299
|
+
this.client.removeAllListeners();
|
|
300
|
+
}
|
|
297
301
|
this.client = client;
|
|
298
302
|
if (config) {
|
|
299
303
|
this.currentConfig = config;
|
|
@@ -357,6 +361,22 @@ class TUI {
|
|
|
357
361
|
let responseLine = '';
|
|
358
362
|
if ('error' in data && data.error) {
|
|
359
363
|
const errorMsg = this.escapeBlessedTags(String(data.error.message || 'Unknown error'));
|
|
364
|
+
// Suppress "method not found" errors for list methods (expected when server doesn't support them)
|
|
365
|
+
if (responseId !== null && this.pendingRequests.has(responseId)) {
|
|
366
|
+
const requestData = this.pendingRequests.get(responseId).data;
|
|
367
|
+
if (requestData && 'method' in requestData) {
|
|
368
|
+
const method = requestData.method;
|
|
369
|
+
const isListMethod = ['tools/list', 'resources/list', 'prompts/list'].includes(method);
|
|
370
|
+
const isMethodNotFoundError = errorMsg.includes('not a function') ||
|
|
371
|
+
errorMsg.includes('not found') ||
|
|
372
|
+
data.error?.code === -32601;
|
|
373
|
+
if (isListMethod && isMethodNotFoundError) {
|
|
374
|
+
// Don't log expected "method not supported" errors for list methods
|
|
375
|
+
this.pendingRequests.delete(responseId);
|
|
376
|
+
return; // Skip logging this error
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
360
380
|
responseLine = `{cyan-fg}[${timestamp}]{/cyan-fg} {red-fg}<<<{/red-fg} ERROR: ${errorMsg}`;
|
|
361
381
|
}
|
|
362
382
|
else {
|
|
@@ -422,7 +442,13 @@ class TUI {
|
|
|
422
442
|
updateCurrentView() {
|
|
423
443
|
if (!this.client)
|
|
424
444
|
return;
|
|
445
|
+
// Check if client is connected before trying to get state
|
|
425
446
|
const state = this.client.getState();
|
|
447
|
+
if (!state.connected) {
|
|
448
|
+
// Client not connected yet, show loading message
|
|
449
|
+
this.layout.main.setItems(['{yellow-fg}Connecting... Please wait.{/yellow-fg}']);
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
426
452
|
switch (this.currentView) {
|
|
427
453
|
case 'tools':
|
|
428
454
|
this.displayTools(state.tools);
|
|
@@ -602,20 +628,44 @@ class TUI {
|
|
|
602
628
|
}
|
|
603
629
|
async prompt(label) {
|
|
604
630
|
return new Promise((resolve) => {
|
|
631
|
+
// Remember which panel was active before prompting
|
|
632
|
+
const previousPanel = this.activePanel;
|
|
605
633
|
this.layout.input.setLabel(` ${label} `);
|
|
606
634
|
this.layout.input.show();
|
|
607
635
|
this.layout.input.focus();
|
|
608
636
|
this.layout.input.on('submit', (value) => {
|
|
609
637
|
this.layout.input.hide();
|
|
610
638
|
this.layout.input.clearValue();
|
|
611
|
-
|
|
639
|
+
// Restore focus to the previously active panel
|
|
640
|
+
switch (previousPanel) {
|
|
641
|
+
case 'sidebar':
|
|
642
|
+
this.layout.sidebar.focus();
|
|
643
|
+
break;
|
|
644
|
+
case 'main':
|
|
645
|
+
this.layout.main.focus();
|
|
646
|
+
break;
|
|
647
|
+
case 'traffic':
|
|
648
|
+
this.layout.traffic.focus();
|
|
649
|
+
break;
|
|
650
|
+
}
|
|
612
651
|
this.screen.render();
|
|
613
652
|
resolve(value || '');
|
|
614
653
|
});
|
|
615
654
|
this.layout.input.on('cancel', () => {
|
|
616
655
|
this.layout.input.hide();
|
|
617
656
|
this.layout.input.clearValue();
|
|
618
|
-
|
|
657
|
+
// Restore focus to the previously active panel
|
|
658
|
+
switch (previousPanel) {
|
|
659
|
+
case 'sidebar':
|
|
660
|
+
this.layout.sidebar.focus();
|
|
661
|
+
break;
|
|
662
|
+
case 'main':
|
|
663
|
+
this.layout.main.focus();
|
|
664
|
+
break;
|
|
665
|
+
case 'traffic':
|
|
666
|
+
this.layout.traffic.focus();
|
|
667
|
+
break;
|
|
668
|
+
}
|
|
619
669
|
this.screen.render();
|
|
620
670
|
resolve('');
|
|
621
671
|
});
|
|
@@ -973,17 +1023,64 @@ class TUI {
|
|
|
973
1023
|
if (filename.length > 100) {
|
|
974
1024
|
filename = filename.substring(0, 100);
|
|
975
1025
|
}
|
|
976
|
-
return `${filename}.
|
|
1026
|
+
return `${filename}.mcpconn`;
|
|
977
1027
|
}
|
|
978
1028
|
configsAreEqual(config1, config2) {
|
|
979
|
-
// Deep comparison of configs (excluding _saved metadata)
|
|
1029
|
+
// Deep comparison of configs (excluding _saved metadata and undefined values)
|
|
980
1030
|
const normalize = (config) => {
|
|
981
|
-
const normalized = {
|
|
982
|
-
//
|
|
983
|
-
if (
|
|
984
|
-
normalized.
|
|
1031
|
+
const normalized = {};
|
|
1032
|
+
// Copy only defined properties
|
|
1033
|
+
if (config.type !== undefined)
|
|
1034
|
+
normalized.type = config.type;
|
|
1035
|
+
if (config.url !== undefined)
|
|
1036
|
+
normalized.url = config.url;
|
|
1037
|
+
if (config.command !== undefined)
|
|
1038
|
+
normalized.command = config.command;
|
|
1039
|
+
if (config.args !== undefined) {
|
|
1040
|
+
// Sort arrays for comparison
|
|
1041
|
+
normalized.args = Array.isArray(config.args) ? [...config.args].sort() : config.args;
|
|
1042
|
+
}
|
|
1043
|
+
if (config.env !== undefined) {
|
|
1044
|
+
// Sort env object keys for comparison
|
|
1045
|
+
const envKeys = Object.keys(config.env).sort();
|
|
1046
|
+
normalized.env = {};
|
|
1047
|
+
for (const key of envKeys) {
|
|
1048
|
+
normalized.env[key] = config.env[key];
|
|
1049
|
+
}
|
|
985
1050
|
}
|
|
986
|
-
|
|
1051
|
+
if (config.proxy !== undefined) {
|
|
1052
|
+
normalized.proxy = { ...config.proxy };
|
|
1053
|
+
if (config.proxy.auth !== undefined) {
|
|
1054
|
+
normalized.proxy.auth = { ...config.proxy.auth };
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
if (config.auth !== undefined) {
|
|
1058
|
+
normalized.auth = { ...config.auth };
|
|
1059
|
+
if (config.auth.headers !== undefined) {
|
|
1060
|
+
const headerKeys = Object.keys(config.auth.headers).sort();
|
|
1061
|
+
normalized.auth.headers = {};
|
|
1062
|
+
for (const key of headerKeys) {
|
|
1063
|
+
normalized.auth.headers[key] = config.auth.headers[key];
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
if (config.certificate !== undefined) {
|
|
1068
|
+
normalized.certificate = { ...config.certificate };
|
|
1069
|
+
}
|
|
1070
|
+
if (config.headers !== undefined) {
|
|
1071
|
+
const headerKeys = Object.keys(config.headers).sort();
|
|
1072
|
+
normalized.headers = {};
|
|
1073
|
+
for (const key of headerKeys) {
|
|
1074
|
+
normalized.headers[key] = config.headers[key];
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
// Sort top-level keys for consistent comparison
|
|
1078
|
+
const sortedKeys = Object.keys(normalized).sort();
|
|
1079
|
+
const sorted = {};
|
|
1080
|
+
for (const key of sortedKeys) {
|
|
1081
|
+
sorted[key] = normalized[key];
|
|
1082
|
+
}
|
|
1083
|
+
return JSON.stringify(sorted);
|
|
987
1084
|
};
|
|
988
1085
|
return normalize(config1) === normalize(config2);
|
|
989
1086
|
}
|
|
@@ -992,7 +1089,7 @@ class TUI {
|
|
|
992
1089
|
const cwd = process.cwd();
|
|
993
1090
|
const files = fs.readdirSync(cwd);
|
|
994
1091
|
for (const file of files) {
|
|
995
|
-
if (file.endsWith('.
|
|
1092
|
+
if (file.endsWith('.mcpconn')) {
|
|
996
1093
|
try {
|
|
997
1094
|
const filepath = path.join(cwd, file);
|
|
998
1095
|
const content = fs.readFileSync(filepath, 'utf-8');
|
|
@@ -1040,8 +1137,8 @@ class TUI {
|
|
|
1040
1137
|
let finalFilepath = filepath;
|
|
1041
1138
|
if (fs.existsSync(filepath)) {
|
|
1042
1139
|
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
|
|
1043
|
-
const baseName = filename.replace('.
|
|
1044
|
-
finalFilepath = path.join(cwd, `${baseName}-${timestamp}.
|
|
1140
|
+
const baseName = filename.replace('.mcpconn', '');
|
|
1141
|
+
finalFilepath = path.join(cwd, `${baseName}-${timestamp}.mcpconn`);
|
|
1045
1142
|
}
|
|
1046
1143
|
const configToSave = {
|
|
1047
1144
|
...config,
|
|
@@ -1065,7 +1162,7 @@ class TUI {
|
|
|
1065
1162
|
const cwd = process.cwd();
|
|
1066
1163
|
const files = fs.readdirSync(cwd);
|
|
1067
1164
|
for (const file of files) {
|
|
1068
|
-
if (file.endsWith('.
|
|
1165
|
+
if (file.endsWith('.mcpconn')) {
|
|
1069
1166
|
try {
|
|
1070
1167
|
const filepath = path.join(cwd, file);
|
|
1071
1168
|
const content = fs.readFileSync(filepath, 'utf-8');
|
|
@@ -1115,13 +1212,13 @@ class TUI {
|
|
|
1115
1212
|
if (connections.length === 0) {
|
|
1116
1213
|
this.showMessage('No Saved Connections', '{yellow-fg}No saved connections found in current directory.{/yellow-fg}\n\n' +
|
|
1117
1214
|
'Connections are automatically saved when you successfully connect to a server.\n' +
|
|
1118
|
-
'Saved files use the extension: {cyan-fg}.
|
|
1215
|
+
'Saved files use the extension: {cyan-fg}.mcpconn{/cyan-fg}', 'yellow');
|
|
1119
1216
|
return;
|
|
1120
1217
|
}
|
|
1121
1218
|
const items = connections.map((conn, index) => {
|
|
1122
1219
|
const date = new Date(conn.timestamp);
|
|
1123
1220
|
const dateStr = date.toLocaleString();
|
|
1124
|
-
const filename = path.basename(conn.filepath, '.
|
|
1221
|
+
const filename = path.basename(conn.filepath, '.mcpconn');
|
|
1125
1222
|
// Show filename details if it contains useful info
|
|
1126
1223
|
let displayName = conn.serverName;
|
|
1127
1224
|
if (filename.length > 0 && filename !== conn.serverName.replace(/[^a-zA-Z0-9-_]/g, '_').toLowerCase()) {
|
|
@@ -1170,26 +1267,32 @@ class TUI {
|
|
|
1170
1267
|
// Show loading message
|
|
1171
1268
|
this.layout.status.setContent('{yellow-fg}Switching connection...{/yellow-fg}');
|
|
1172
1269
|
this.screen.render();
|
|
1173
|
-
// Disconnect
|
|
1270
|
+
// Disconnect and remove old client if exists
|
|
1174
1271
|
if (this.client) {
|
|
1175
1272
|
try {
|
|
1273
|
+
// Remove all event listeners first
|
|
1274
|
+
this.client.removeAllListeners();
|
|
1176
1275
|
await this.client.disconnect();
|
|
1177
1276
|
}
|
|
1178
1277
|
catch {
|
|
1179
1278
|
// Ignore disconnect errors
|
|
1180
1279
|
}
|
|
1280
|
+
this.client = undefined;
|
|
1181
1281
|
}
|
|
1182
|
-
// Create new client with the saved config
|
|
1183
|
-
const newClient = new mcp_client_1.MCPClient(config);
|
|
1184
|
-
this.setClient(newClient, config);
|
|
1185
1282
|
// Clear current state
|
|
1186
1283
|
this.trafficLines = [];
|
|
1187
1284
|
this.trafficPairs = [];
|
|
1188
1285
|
this.layout.traffic.setContent('');
|
|
1189
1286
|
this.layout.main.setItems([]);
|
|
1190
1287
|
this.currentView = 'tools';
|
|
1191
|
-
//
|
|
1288
|
+
// Create new client with the saved config
|
|
1289
|
+
const newClient = new mcp_client_1.MCPClient(config);
|
|
1290
|
+
// Set up client and event handlers BEFORE connecting
|
|
1291
|
+
this.setClient(newClient, config);
|
|
1292
|
+
// Connect and wait for it to complete
|
|
1192
1293
|
await newClient.connect();
|
|
1294
|
+
// Wait a moment for the UI to update from the 'connected' event
|
|
1295
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
1193
1296
|
this.addTrafficLine(`{green-fg}Switched to connection:{/green-fg} ${path.basename(filepath)}`);
|
|
1194
1297
|
this.screen.render();
|
|
1195
1298
|
}
|