@lanonasis/cli 3.6.3 ā 3.6.5
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/dist/commands/api-keys.d.ts +1 -2
- package/dist/commands/api-keys.js +78 -73
- package/dist/commands/auth.js +167 -160
- package/dist/commands/completion.js +39 -31
- package/dist/commands/config.js +201 -162
- package/dist/commands/enhanced-memory.js +17 -11
- package/dist/commands/guide.js +88 -79
- package/dist/commands/init.js +20 -14
- package/dist/commands/mcp.js +173 -142
- package/dist/commands/memory.js +83 -77
- package/dist/commands/organization.js +21 -15
- package/dist/commands/topics.js +58 -52
- package/dist/core/achievements.js +26 -19
- package/dist/core/architecture.js +59 -42
- package/dist/core/dashboard.js +81 -71
- package/dist/core/error-handler.js +39 -30
- package/dist/core/power-mode.js +53 -46
- package/dist/core/progress.js +44 -35
- package/dist/core/welcome.js +64 -56
- package/dist/enhanced-cli.js +58 -49
- package/dist/index-simple.js +112 -74
- package/dist/index.js +68 -63
- package/dist/mcp/access-control.js +17 -13
- package/dist/mcp/client/enhanced-client.js +23 -16
- package/dist/mcp/enhanced-server.js +14 -10
- package/dist/mcp/logger.js +6 -2
- package/dist/mcp/memory-state.js +17 -13
- package/dist/mcp/schemas/tool-schemas.d.ts +28 -28
- package/dist/mcp/schemas/tool-schemas.js +126 -122
- package/dist/mcp/server/lanonasis-server.js +51 -44
- package/dist/mcp/transports/transport-manager.js +25 -18
- package/dist/mcp/vector-store.js +10 -6
- package/dist/mcp-server.js +21 -17
- package/dist/utils/api.js +30 -21
- package/dist/utils/config.js +61 -15
- package/dist/utils/formatting.js +14 -6
- package/dist/utils/mcp-client.js +132 -77
- package/package.json +17 -92
- package/dist/completions/bash-completion.sh +0 -88
- package/dist/completions/fish-completion.fish +0 -132
- package/dist/completions/zsh-completion.zsh +0 -196
package/dist/commands/mcp.js
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.mcpCommands = mcpCommands;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const ora_1 = __importDefault(require("ora"));
|
|
9
|
+
const table_1 = require("table");
|
|
10
|
+
const mcp_client_js_1 = require("../utils/mcp-client.js");
|
|
11
|
+
const enhanced_client_js_1 = require("../mcp/client/enhanced-client.js");
|
|
12
|
+
const config_js_1 = require("../utils/config.js");
|
|
13
|
+
const ws_1 = __importDefault(require("ws"));
|
|
14
|
+
function mcpCommands(program) {
|
|
9
15
|
const mcp = program
|
|
10
16
|
.command('mcp')
|
|
11
17
|
.description('MCP (Model Context Protocol) server operations');
|
|
@@ -16,35 +22,35 @@ export function mcpCommands(program) {
|
|
|
16
22
|
mcpServer.command('init')
|
|
17
23
|
.description('Initialize MCP server configuration')
|
|
18
24
|
.action(async () => {
|
|
19
|
-
console.log(
|
|
25
|
+
console.log(chalk_1.default.cyan('š Initializing MCP Server Configuration'));
|
|
20
26
|
console.log('');
|
|
21
|
-
const config = new CLIConfig();
|
|
27
|
+
const config = new config_js_1.CLIConfig();
|
|
22
28
|
const isAuthenticated = !!config.get('token');
|
|
23
29
|
if (isAuthenticated) {
|
|
24
|
-
console.log(
|
|
30
|
+
console.log(chalk_1.default.green('ā Authenticated - Using remote MCP mode'));
|
|
25
31
|
console.log(' Your memory operations will use mcp.lanonasis.com');
|
|
26
32
|
console.log(' with real-time SSE updates enabled');
|
|
27
33
|
}
|
|
28
34
|
else {
|
|
29
|
-
console.log(
|
|
35
|
+
console.log(chalk_1.default.yellow('ā ļø Not authenticated - Using local MCP mode'));
|
|
30
36
|
console.log(' Run "lanonasis auth login" to enable remote mode');
|
|
31
37
|
}
|
|
32
38
|
console.log('');
|
|
33
|
-
console.log(
|
|
39
|
+
console.log(chalk_1.default.cyan('Available MCP Commands:'));
|
|
34
40
|
console.log(' lanonasis mcp connect # Auto-connect to best mode');
|
|
35
41
|
console.log(' lanonasis mcp connect -r # Force remote mode');
|
|
36
42
|
console.log(' lanonasis mcp connect -l # Force local mode');
|
|
37
43
|
console.log(' lanonasis mcp status # Check connection status');
|
|
38
44
|
console.log(' lanonasis mcp tools # List available tools');
|
|
39
45
|
console.log('');
|
|
40
|
-
console.log(
|
|
46
|
+
console.log(chalk_1.default.cyan('Memory operations are MCP-powered by default!'));
|
|
41
47
|
// Auto-connect to MCP
|
|
42
|
-
const spinner =
|
|
48
|
+
const spinner = (0, ora_1.default)('Auto-connecting to MCP...').start();
|
|
43
49
|
try {
|
|
44
|
-
const client = getMCPClient();
|
|
50
|
+
const client = (0, mcp_client_js_1.getMCPClient)();
|
|
45
51
|
const connected = await client.connect({ useRemote: isAuthenticated });
|
|
46
52
|
if (connected) {
|
|
47
|
-
spinner.succeed(
|
|
53
|
+
spinner.succeed(chalk_1.default.green(`Connected to ${isAuthenticated ? 'remote' : 'local'} MCP server`));
|
|
48
54
|
process.exit(0);
|
|
49
55
|
}
|
|
50
56
|
else {
|
|
@@ -67,8 +73,8 @@ export function mcpCommands(program) {
|
|
|
67
73
|
.option('-u, --url <url>', 'Remote/WebSocket server URL')
|
|
68
74
|
.option('--local-args <args>', 'Extra args for local server (e.g., "--stdio --port 3001")')
|
|
69
75
|
.action(async (options) => {
|
|
70
|
-
const spinner =
|
|
71
|
-
const config = new CLIConfig();
|
|
76
|
+
const spinner = (0, ora_1.default)('Connecting to MCP server...').start();
|
|
77
|
+
const config = new config_js_1.CLIConfig();
|
|
72
78
|
try {
|
|
73
79
|
let connectionMode;
|
|
74
80
|
// Determine connection mode - WebSocket takes precedence over remote and local
|
|
@@ -100,7 +106,7 @@ export function mcpCommands(program) {
|
|
|
100
106
|
}
|
|
101
107
|
let connected = false;
|
|
102
108
|
// Use Enhanced MCP Client for better connection handling
|
|
103
|
-
const enhancedClient = new EnhancedMCPClient();
|
|
109
|
+
const enhancedClient = new enhanced_client_js_1.EnhancedMCPClient();
|
|
104
110
|
if (options.url) {
|
|
105
111
|
// Connect to specific URL (WebSocket or remote)
|
|
106
112
|
const serverConfig = {
|
|
@@ -111,14 +117,14 @@ export function mcpCommands(program) {
|
|
|
111
117
|
};
|
|
112
118
|
connected = await enhancedClient.connectSingle(serverConfig);
|
|
113
119
|
if (connected) {
|
|
114
|
-
spinner.succeed(
|
|
120
|
+
spinner.succeed(chalk_1.default.green(`Connected to MCP server at ${options.url}`));
|
|
115
121
|
process.exit(0);
|
|
116
122
|
return;
|
|
117
123
|
}
|
|
118
124
|
}
|
|
119
125
|
else {
|
|
120
126
|
// Fall back to old client for local connections
|
|
121
|
-
const client = getMCPClient();
|
|
127
|
+
const client = (0, mcp_client_js_1.getMCPClient)();
|
|
122
128
|
const localArgs = typeof options.localArgs === 'string' && options.localArgs.trim().length > 0
|
|
123
129
|
? options.localArgs.split(' ').map((s) => s.trim()).filter(Boolean)
|
|
124
130
|
: undefined;
|
|
@@ -130,15 +136,15 @@ export function mcpCommands(program) {
|
|
|
130
136
|
});
|
|
131
137
|
}
|
|
132
138
|
if (connected) {
|
|
133
|
-
spinner.succeed(
|
|
139
|
+
spinner.succeed(chalk_1.default.green(`Connected to MCP server in ${connectionMode} mode`));
|
|
134
140
|
process.exit(0);
|
|
135
141
|
if (connectionMode === 'remote') {
|
|
136
|
-
console.log(
|
|
137
|
-
console.log(
|
|
142
|
+
console.log(chalk_1.default.cyan('ā¹ļø Using remote MCP via mcp.lanonasis.com'));
|
|
143
|
+
console.log(chalk_1.default.cyan('š” SSE endpoint active for real-time updates'));
|
|
138
144
|
}
|
|
139
145
|
else if (connectionMode === 'websocket') {
|
|
140
|
-
console.log(
|
|
141
|
-
console.log(
|
|
146
|
+
console.log(chalk_1.default.cyan('ā¹ļø Using enterprise WebSocket MCP server'));
|
|
147
|
+
console.log(chalk_1.default.cyan('š” WebSocket connection active with auto-reconnect'));
|
|
142
148
|
}
|
|
143
149
|
}
|
|
144
150
|
else {
|
|
@@ -155,55 +161,80 @@ export function mcpCommands(program) {
|
|
|
155
161
|
mcp.command('disconnect')
|
|
156
162
|
.description('Disconnect from MCP server')
|
|
157
163
|
.action(async () => {
|
|
158
|
-
const client = getMCPClient();
|
|
164
|
+
const client = (0, mcp_client_js_1.getMCPClient)();
|
|
159
165
|
await client.disconnect();
|
|
160
|
-
console.log(
|
|
166
|
+
console.log(chalk_1.default.green('ā Disconnected from MCP server'));
|
|
161
167
|
});
|
|
162
168
|
// Status command
|
|
163
169
|
mcp.command('status')
|
|
164
170
|
.description('Show MCP connection status')
|
|
165
171
|
.action(async () => {
|
|
166
|
-
const client = getMCPClient();
|
|
172
|
+
const client = (0, mcp_client_js_1.getMCPClient)();
|
|
173
|
+
// Reload config from disk to get latest preference
|
|
174
|
+
await client.init();
|
|
167
175
|
const status = client.getConnectionStatus();
|
|
168
|
-
console.log(
|
|
169
|
-
console.log(
|
|
170
|
-
console.log(`Status: ${status.connected ?
|
|
171
|
-
|
|
176
|
+
console.log(chalk_1.default.cyan('\nš MCP Connection Status'));
|
|
177
|
+
console.log(chalk_1.default.cyan('========================'));
|
|
178
|
+
console.log(`Status: ${status.connected ? chalk_1.default.green('Connected') : chalk_1.default.red('Disconnected')}`);
|
|
179
|
+
// Display mode with proper labels
|
|
180
|
+
let modeDisplay;
|
|
181
|
+
switch (status.mode) {
|
|
182
|
+
case 'websocket':
|
|
183
|
+
modeDisplay = chalk_1.default.blue('WebSocket');
|
|
184
|
+
break;
|
|
185
|
+
case 'remote':
|
|
186
|
+
modeDisplay = chalk_1.default.blue('Remote (HTTP/SSE)');
|
|
187
|
+
break;
|
|
188
|
+
case 'local':
|
|
189
|
+
modeDisplay = chalk_1.default.yellow('Local (stdio)');
|
|
190
|
+
break;
|
|
191
|
+
default:
|
|
192
|
+
modeDisplay = chalk_1.default.gray(status.mode);
|
|
193
|
+
}
|
|
194
|
+
console.log(`Mode: ${modeDisplay}`);
|
|
172
195
|
console.log(`Server: ${status.server}`);
|
|
173
|
-
if (status.connected
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
196
|
+
if (status.connected) {
|
|
197
|
+
if (status.mode === 'remote') {
|
|
198
|
+
console.log(`\n${chalk_1.default.cyan('Features:')}`);
|
|
199
|
+
console.log('⢠Real-time updates via SSE');
|
|
200
|
+
console.log('⢠Authenticated API access');
|
|
201
|
+
console.log('⢠MCP-compatible tool interface');
|
|
202
|
+
}
|
|
203
|
+
else if (status.mode === 'websocket') {
|
|
204
|
+
console.log(`\n${chalk_1.default.cyan('Features:')}`);
|
|
205
|
+
console.log('⢠Bi-directional real-time communication');
|
|
206
|
+
console.log('⢠Authenticated WebSocket connection');
|
|
207
|
+
console.log('⢠Production-ready MCP server');
|
|
208
|
+
}
|
|
178
209
|
}
|
|
179
210
|
});
|
|
180
211
|
// List tools command
|
|
181
212
|
mcp.command('tools')
|
|
182
213
|
.description('List available MCP tools')
|
|
183
214
|
.action(async () => {
|
|
184
|
-
const spinner =
|
|
215
|
+
const spinner = (0, ora_1.default)('Fetching available tools...').start();
|
|
185
216
|
try {
|
|
186
|
-
const client = getMCPClient();
|
|
217
|
+
const client = (0, mcp_client_js_1.getMCPClient)();
|
|
187
218
|
if (!client.isConnectedToServer()) {
|
|
188
219
|
spinner.info('Not connected. Attempting auto-connect...');
|
|
189
|
-
const config = new CLIConfig();
|
|
220
|
+
const config = new config_js_1.CLIConfig();
|
|
190
221
|
const useRemote = !!config.get('token');
|
|
191
222
|
await client.connect({ useRemote });
|
|
192
223
|
}
|
|
193
224
|
const tools = await client.listTools();
|
|
194
225
|
spinner.succeed('Tools fetched successfully');
|
|
195
|
-
console.log(
|
|
196
|
-
console.log(
|
|
226
|
+
console.log(chalk_1.default.cyan('\nš§ Available MCP Tools'));
|
|
227
|
+
console.log(chalk_1.default.cyan('====================='));
|
|
197
228
|
const tableData = [
|
|
198
|
-
[
|
|
229
|
+
[chalk_1.default.bold('Tool Name'), chalk_1.default.bold('Description')]
|
|
199
230
|
];
|
|
200
231
|
tools.forEach(tool => {
|
|
201
232
|
tableData.push([
|
|
202
|
-
|
|
233
|
+
chalk_1.default.green(tool.name),
|
|
203
234
|
tool.description
|
|
204
235
|
]);
|
|
205
236
|
});
|
|
206
|
-
console.log(table(tableData, {
|
|
237
|
+
console.log((0, table_1.table)(tableData, {
|
|
207
238
|
border: {
|
|
208
239
|
topBody: 'ā',
|
|
209
240
|
topJoin: 'ā¬',
|
|
@@ -234,12 +265,12 @@ export function mcpCommands(program) {
|
|
|
234
265
|
.argument('<tool>', 'Tool name to call')
|
|
235
266
|
.option('-a, --args <json>', 'Tool arguments as JSON')
|
|
236
267
|
.action(async (toolName, options) => {
|
|
237
|
-
const spinner =
|
|
268
|
+
const spinner = (0, ora_1.default)(`Calling tool: ${toolName}...`).start();
|
|
238
269
|
try {
|
|
239
|
-
const client = getMCPClient();
|
|
270
|
+
const client = (0, mcp_client_js_1.getMCPClient)();
|
|
240
271
|
if (!client.isConnectedToServer()) {
|
|
241
272
|
spinner.info('Not connected. Attempting auto-connect...');
|
|
242
|
-
const config = new CLIConfig();
|
|
273
|
+
const config = new config_js_1.CLIConfig();
|
|
243
274
|
const useRemote = !!config.get('token');
|
|
244
275
|
await client.connect({ useRemote });
|
|
245
276
|
}
|
|
@@ -255,7 +286,7 @@ export function mcpCommands(program) {
|
|
|
255
286
|
}
|
|
256
287
|
const result = await client.callTool(toolName, args);
|
|
257
288
|
spinner.succeed(`Tool ${toolName} executed successfully`);
|
|
258
|
-
console.log(
|
|
289
|
+
console.log(chalk_1.default.cyan('\nš¤ Tool Result:'));
|
|
259
290
|
console.log(JSON.stringify(result, null, 2));
|
|
260
291
|
}
|
|
261
292
|
catch (error) {
|
|
@@ -273,12 +304,12 @@ export function mcpCommands(program) {
|
|
|
273
304
|
.option('-T, --type <type>', 'Memory type', 'context')
|
|
274
305
|
.option('--tags <tags>', 'Comma-separated tags')
|
|
275
306
|
.action(async (options) => {
|
|
276
|
-
const spinner =
|
|
307
|
+
const spinner = (0, ora_1.default)('Creating memory via MCP...').start();
|
|
277
308
|
try {
|
|
278
|
-
const client = getMCPClient();
|
|
309
|
+
const client = (0, mcp_client_js_1.getMCPClient)();
|
|
279
310
|
if (!client.isConnectedToServer()) {
|
|
280
311
|
spinner.info('Not connected. Attempting auto-connect...');
|
|
281
|
-
const config = new CLIConfig();
|
|
312
|
+
const config = new config_js_1.CLIConfig();
|
|
282
313
|
const useRemote = !!config.get('token');
|
|
283
314
|
await client.connect({ useRemote });
|
|
284
315
|
}
|
|
@@ -289,8 +320,8 @@ export function mcpCommands(program) {
|
|
|
289
320
|
tags: options.tags ? options.tags.split(',').map((t) => t.trim()) : []
|
|
290
321
|
});
|
|
291
322
|
spinner.succeed('Memory created successfully');
|
|
292
|
-
console.log(
|
|
293
|
-
console.log(`ID: ${
|
|
323
|
+
console.log(chalk_1.default.green('\nā Memory created'));
|
|
324
|
+
console.log(`ID: ${chalk_1.default.cyan(result.id)}`);
|
|
294
325
|
console.log(`Title: ${result.title}`);
|
|
295
326
|
console.log(`Type: ${result.memory_type}`);
|
|
296
327
|
}
|
|
@@ -305,12 +336,12 @@ export function mcpCommands(program) {
|
|
|
305
336
|
.option('-l, --limit <number>', 'Maximum results', '10')
|
|
306
337
|
.option('-t, --threshold <number>', 'Similarity threshold (0-1)', '0.7')
|
|
307
338
|
.action(async (query, options) => {
|
|
308
|
-
const spinner =
|
|
339
|
+
const spinner = (0, ora_1.default)('Searching memories via MCP...').start();
|
|
309
340
|
try {
|
|
310
|
-
const client = getMCPClient();
|
|
341
|
+
const client = (0, mcp_client_js_1.getMCPClient)();
|
|
311
342
|
if (!client.isConnectedToServer()) {
|
|
312
343
|
spinner.info('Not connected. Attempting auto-connect...');
|
|
313
|
-
const config = new CLIConfig();
|
|
344
|
+
const config = new config_js_1.CLIConfig();
|
|
314
345
|
const useRemote = !!config.get('token');
|
|
315
346
|
await client.connect({ useRemote });
|
|
316
347
|
}
|
|
@@ -321,15 +352,15 @@ export function mcpCommands(program) {
|
|
|
321
352
|
});
|
|
322
353
|
spinner.succeed(`Found ${results.length} memories`);
|
|
323
354
|
if (results.length === 0) {
|
|
324
|
-
console.log(
|
|
355
|
+
console.log(chalk_1.default.yellow('\nNo memories found matching your query'));
|
|
325
356
|
return;
|
|
326
357
|
}
|
|
327
|
-
console.log(
|
|
358
|
+
console.log(chalk_1.default.cyan('\nš Search Results:'));
|
|
328
359
|
results.forEach((memory, index) => {
|
|
329
|
-
console.log(`\n${
|
|
330
|
-
console.log(` ID: ${
|
|
331
|
-
console.log(` Type: ${
|
|
332
|
-
console.log(` Score: ${
|
|
360
|
+
console.log(`\n${chalk_1.default.bold(`${index + 1}. ${memory.title}`)}`);
|
|
361
|
+
console.log(` ID: ${chalk_1.default.gray(memory.id)}`);
|
|
362
|
+
console.log(` Type: ${chalk_1.default.blue(memory.memory_type)}`);
|
|
363
|
+
console.log(` Score: ${chalk_1.default.green((memory.relevance_score * 100).toFixed(1) + '%')}`);
|
|
333
364
|
console.log(` Content: ${memory.content.substring(0, 100)}...`);
|
|
334
365
|
});
|
|
335
366
|
}
|
|
@@ -345,22 +376,22 @@ export function mcpCommands(program) {
|
|
|
345
376
|
.option('--prefer-local', 'Prefer local MCP server')
|
|
346
377
|
.option('--auto', 'Auto-detect best connection mode')
|
|
347
378
|
.action(async (options) => {
|
|
348
|
-
const config = new CLIConfig();
|
|
379
|
+
const config = new config_js_1.CLIConfig();
|
|
349
380
|
if (options.preferRemote) {
|
|
350
381
|
await config.setAndSave('mcpPreference', 'remote');
|
|
351
|
-
console.log(
|
|
382
|
+
console.log(chalk_1.default.green('ā Set MCP preference to remote'));
|
|
352
383
|
}
|
|
353
384
|
else if (options.preferLocal) {
|
|
354
385
|
await config.setAndSave('mcpPreference', 'local');
|
|
355
|
-
console.log(
|
|
386
|
+
console.log(chalk_1.default.green('ā Set MCP preference to local'));
|
|
356
387
|
}
|
|
357
388
|
else if (options.auto) {
|
|
358
389
|
await config.setAndSave('mcpPreference', 'auto');
|
|
359
|
-
console.log(
|
|
390
|
+
console.log(chalk_1.default.green('ā Set MCP preference to auto-detect'));
|
|
360
391
|
}
|
|
361
392
|
else {
|
|
362
393
|
const current = config.get('mcpPreference') || 'auto';
|
|
363
|
-
console.log(`Current MCP preference: ${
|
|
394
|
+
console.log(`Current MCP preference: ${chalk_1.default.cyan(current)}`);
|
|
364
395
|
console.log('\nOptions:');
|
|
365
396
|
console.log(' --prefer-remote : Use remote MCP server (mcp.lanonasis.com)');
|
|
366
397
|
console.log(' --prefer-local : Use local MCP server');
|
|
@@ -372,10 +403,10 @@ export function mcpCommands(program) {
|
|
|
372
403
|
.description('Diagnose MCP connection issues')
|
|
373
404
|
.option('-v, --verbose', 'show detailed diagnostic information')
|
|
374
405
|
.action(async (options) => {
|
|
375
|
-
const config = new CLIConfig();
|
|
406
|
+
const config = new config_js_1.CLIConfig();
|
|
376
407
|
await config.init();
|
|
377
|
-
console.log(
|
|
378
|
-
console.log(
|
|
408
|
+
console.log(chalk_1.default.blue.bold('š MCP Connection Diagnostic'));
|
|
409
|
+
console.log(chalk_1.default.cyan('ā'.repeat(50)));
|
|
379
410
|
console.log();
|
|
380
411
|
const diagnostics = {
|
|
381
412
|
authenticationValid: false,
|
|
@@ -391,64 +422,64 @@ export function mcpCommands(program) {
|
|
|
391
422
|
healthCheckPassing: false
|
|
392
423
|
};
|
|
393
424
|
// Step 1: Check authentication status
|
|
394
|
-
console.log(
|
|
425
|
+
console.log(chalk_1.default.cyan('1. Authentication Status'));
|
|
395
426
|
const token = config.getToken();
|
|
396
427
|
const vendorKey = config.getVendorKey();
|
|
397
428
|
if (!token && !vendorKey) {
|
|
398
|
-
console.log(
|
|
399
|
-
console.log(
|
|
400
|
-
console.log(
|
|
429
|
+
console.log(chalk_1.default.red(' ā No authentication credentials found'));
|
|
430
|
+
console.log(chalk_1.default.gray(' ā Run: lanonasis auth login'));
|
|
431
|
+
console.log(chalk_1.default.gray(' ā MCP requires authentication for remote access'));
|
|
401
432
|
}
|
|
402
433
|
else {
|
|
403
434
|
try {
|
|
404
435
|
const isValid = await config.validateStoredCredentials();
|
|
405
436
|
diagnostics.authenticationValid = isValid;
|
|
406
437
|
if (isValid) {
|
|
407
|
-
console.log(
|
|
438
|
+
console.log(chalk_1.default.green(' ā Authentication credentials are valid'));
|
|
408
439
|
}
|
|
409
440
|
else {
|
|
410
|
-
console.log(
|
|
411
|
-
console.log(
|
|
441
|
+
console.log(chalk_1.default.red(' ā Authentication credentials are invalid'));
|
|
442
|
+
console.log(chalk_1.default.gray(' ā Run: lanonasis auth login'));
|
|
412
443
|
}
|
|
413
444
|
}
|
|
414
445
|
catch (error) {
|
|
415
|
-
console.log(
|
|
416
|
-
console.log(
|
|
446
|
+
console.log(chalk_1.default.yellow(' ā Could not validate authentication'));
|
|
447
|
+
console.log(chalk_1.default.gray(` ${error instanceof Error ? error.message : 'Unknown error'}`));
|
|
417
448
|
}
|
|
418
449
|
}
|
|
419
450
|
// Step 2: Test endpoint availability
|
|
420
|
-
console.log(
|
|
421
|
-
const spinner1 =
|
|
451
|
+
console.log(chalk_1.default.cyan('\n2. Endpoint Availability'));
|
|
452
|
+
const spinner1 = (0, ora_1.default)('Testing MCP endpoints...').start();
|
|
422
453
|
try {
|
|
423
454
|
await config.discoverServices(options.verbose);
|
|
424
455
|
const services = config.get('discoveredServices');
|
|
425
456
|
if (services) {
|
|
426
457
|
spinner1.succeed('MCP endpoints discovered');
|
|
427
458
|
diagnostics.endpointsReachable = true;
|
|
428
|
-
console.log(
|
|
459
|
+
console.log(chalk_1.default.green(' ā Service discovery successful'));
|
|
429
460
|
if (options.verbose) {
|
|
430
461
|
const svc = services;
|
|
431
|
-
console.log(
|
|
432
|
-
console.log(
|
|
433
|
-
console.log(
|
|
462
|
+
console.log(chalk_1.default.gray(` HTTP: ${svc.mcp_base}`));
|
|
463
|
+
console.log(chalk_1.default.gray(` WebSocket: ${svc.mcp_ws_base}`));
|
|
464
|
+
console.log(chalk_1.default.gray(` SSE: ${svc.mcp_sse_base}`));
|
|
434
465
|
}
|
|
435
466
|
}
|
|
436
467
|
else {
|
|
437
468
|
spinner1.warn('Using fallback endpoints');
|
|
438
|
-
console.log(
|
|
469
|
+
console.log(chalk_1.default.yellow(' ā Service discovery failed, using fallbacks'));
|
|
439
470
|
diagnostics.endpointsReachable = true; // Fallbacks still work
|
|
440
471
|
}
|
|
441
472
|
}
|
|
442
473
|
catch (error) {
|
|
443
474
|
spinner1.fail('Endpoint discovery failed');
|
|
444
|
-
console.log(
|
|
445
|
-
console.log(
|
|
475
|
+
console.log(chalk_1.default.red(' ā Cannot discover MCP endpoints'));
|
|
476
|
+
console.log(chalk_1.default.gray(` ${error instanceof Error ? error.message : 'Unknown error'}`));
|
|
446
477
|
}
|
|
447
478
|
// Step 3: Test transport protocols
|
|
448
|
-
console.log(
|
|
479
|
+
console.log(chalk_1.default.cyan('\n3. Transport Protocol Tests'));
|
|
449
480
|
// Test HTTP/REST endpoint
|
|
450
481
|
if (diagnostics.authenticationValid) {
|
|
451
|
-
const httpSpinner =
|
|
482
|
+
const httpSpinner = (0, ora_1.default)('Testing HTTP transport...').start();
|
|
452
483
|
try {
|
|
453
484
|
const startTime = Date.now();
|
|
454
485
|
const axios = (await import('axios')).default;
|
|
@@ -464,22 +495,22 @@ export function mcpCommands(program) {
|
|
|
464
495
|
diagnostics.connectionLatency.http = latency;
|
|
465
496
|
diagnostics.transportTests.http = true;
|
|
466
497
|
httpSpinner.succeed(`HTTP transport working (${latency}ms)`);
|
|
467
|
-
console.log(
|
|
498
|
+
console.log(chalk_1.default.green(` ā HTTP/REST endpoint reachable`));
|
|
468
499
|
}
|
|
469
500
|
catch (error) {
|
|
470
501
|
httpSpinner.fail('HTTP transport failed');
|
|
471
|
-
console.log(
|
|
502
|
+
console.log(chalk_1.default.red(' ā HTTP/REST endpoint failed'));
|
|
472
503
|
if (options.verbose) {
|
|
473
|
-
console.log(
|
|
504
|
+
console.log(chalk_1.default.gray(` Error: ${error instanceof Error ? error.message : String(error)}`));
|
|
474
505
|
}
|
|
475
506
|
}
|
|
476
507
|
// Test WebSocket endpoint
|
|
477
|
-
const wsSpinner =
|
|
508
|
+
const wsSpinner = (0, ora_1.default)('Testing WebSocket transport...').start();
|
|
478
509
|
try {
|
|
479
510
|
const startTime = Date.now();
|
|
480
511
|
const wsUrl = config.getMCPServerUrl();
|
|
481
512
|
// Create a test WebSocket connection
|
|
482
|
-
const ws = new
|
|
513
|
+
const ws = new ws_1.default(wsUrl, [], {
|
|
483
514
|
headers: {
|
|
484
515
|
'Authorization': `Bearer ${token}`,
|
|
485
516
|
'X-API-Key': String(token || vendorKey)
|
|
@@ -504,17 +535,17 @@ export function mcpCommands(program) {
|
|
|
504
535
|
});
|
|
505
536
|
});
|
|
506
537
|
wsSpinner.succeed(`WebSocket transport working (${diagnostics.connectionLatency.websocket}ms)`);
|
|
507
|
-
console.log(
|
|
538
|
+
console.log(chalk_1.default.green(' ā WebSocket endpoint reachable'));
|
|
508
539
|
}
|
|
509
540
|
catch (error) {
|
|
510
541
|
wsSpinner.fail('WebSocket transport failed');
|
|
511
|
-
console.log(
|
|
542
|
+
console.log(chalk_1.default.red(' ā WebSocket endpoint failed'));
|
|
512
543
|
if (options.verbose) {
|
|
513
|
-
console.log(
|
|
544
|
+
console.log(chalk_1.default.gray(` Error: ${error instanceof Error ? error.message : String(error)}`));
|
|
514
545
|
}
|
|
515
546
|
}
|
|
516
547
|
// Test SSE endpoint
|
|
517
|
-
const sseSpinner =
|
|
548
|
+
const sseSpinner = (0, ora_1.default)('Testing SSE transport...').start();
|
|
518
549
|
try {
|
|
519
550
|
const startTime = Date.now();
|
|
520
551
|
const sseUrl = config.getMCPSSEUrl();
|
|
@@ -531,86 +562,86 @@ export function mcpCommands(program) {
|
|
|
531
562
|
diagnostics.connectionLatency.sse = latency;
|
|
532
563
|
diagnostics.transportTests.sse = true;
|
|
533
564
|
sseSpinner.succeed(`SSE transport working (${latency}ms)`);
|
|
534
|
-
console.log(
|
|
565
|
+
console.log(chalk_1.default.green(' ā SSE endpoint reachable'));
|
|
535
566
|
}
|
|
536
567
|
catch (error) {
|
|
537
568
|
sseSpinner.fail('SSE transport failed');
|
|
538
|
-
console.log(
|
|
569
|
+
console.log(chalk_1.default.red(' ā SSE endpoint failed'));
|
|
539
570
|
if (options.verbose) {
|
|
540
|
-
console.log(
|
|
571
|
+
console.log(chalk_1.default.gray(` Error: ${error instanceof Error ? error.message : String(error)}`));
|
|
541
572
|
}
|
|
542
573
|
}
|
|
543
574
|
}
|
|
544
575
|
else {
|
|
545
|
-
console.log(
|
|
576
|
+
console.log(chalk_1.default.gray(' - Skipped transport tests (authentication required)'));
|
|
546
577
|
}
|
|
547
578
|
// Step 4: Test current MCP connection
|
|
548
|
-
console.log(
|
|
549
|
-
const client = getMCPClient();
|
|
579
|
+
console.log(chalk_1.default.cyan('\n4. Current MCP Connection'));
|
|
580
|
+
const client = (0, mcp_client_js_1.getMCPClient)();
|
|
550
581
|
diagnostics.currentConnection = client.getConnectionStatus();
|
|
551
582
|
if (diagnostics.currentConnection.connected) {
|
|
552
|
-
console.log(
|
|
553
|
-
console.log(
|
|
554
|
-
console.log(
|
|
583
|
+
console.log(chalk_1.default.green(' ā MCP client is connected'));
|
|
584
|
+
console.log(chalk_1.default.gray(` Mode: ${diagnostics.currentConnection.mode}`));
|
|
585
|
+
console.log(chalk_1.default.gray(` Server: ${diagnostics.currentConnection.server}`));
|
|
555
586
|
if (diagnostics.currentConnection.connectionUptime) {
|
|
556
587
|
const uptimeSeconds = Math.floor(diagnostics.currentConnection.connectionUptime / 1000);
|
|
557
|
-
console.log(
|
|
588
|
+
console.log(chalk_1.default.gray(` Uptime: ${uptimeSeconds}s`));
|
|
558
589
|
}
|
|
559
590
|
if (diagnostics.currentConnection.lastHealthCheck) {
|
|
560
591
|
const healthCheckAge = Date.now() - diagnostics.currentConnection.lastHealthCheck.getTime();
|
|
561
|
-
console.log(
|
|
592
|
+
console.log(chalk_1.default.gray(` Last health check: ${Math.floor(healthCheckAge / 1000)}s ago`));
|
|
562
593
|
}
|
|
563
594
|
}
|
|
564
595
|
else {
|
|
565
|
-
console.log(
|
|
566
|
-
console.log(
|
|
596
|
+
console.log(chalk_1.default.red(' ā MCP client is not connected'));
|
|
597
|
+
console.log(chalk_1.default.gray(' ā Try: lanonasis mcp connect'));
|
|
567
598
|
}
|
|
568
599
|
// Step 5: Test tool availability
|
|
569
|
-
console.log(
|
|
600
|
+
console.log(chalk_1.default.cyan('\n5. Tool Availability'));
|
|
570
601
|
if (diagnostics.currentConnection.connected) {
|
|
571
|
-
const toolSpinner =
|
|
602
|
+
const toolSpinner = (0, ora_1.default)('Testing MCP tools...').start();
|
|
572
603
|
try {
|
|
573
604
|
const tools = await client.listTools();
|
|
574
605
|
diagnostics.toolsAvailable = tools.length > 0;
|
|
575
606
|
toolSpinner.succeed(`Found ${tools.length} available tools`);
|
|
576
|
-
console.log(
|
|
607
|
+
console.log(chalk_1.default.green(` ā ${tools.length} MCP tools available`));
|
|
577
608
|
if (options.verbose && tools.length > 0) {
|
|
578
|
-
console.log(
|
|
609
|
+
console.log(chalk_1.default.gray(' Available tools:'));
|
|
579
610
|
tools.slice(0, 5).forEach(tool => {
|
|
580
|
-
console.log(
|
|
611
|
+
console.log(chalk_1.default.gray(` ⢠${tool.name}`));
|
|
581
612
|
});
|
|
582
613
|
if (tools.length > 5) {
|
|
583
|
-
console.log(
|
|
614
|
+
console.log(chalk_1.default.gray(` ... and ${tools.length - 5} more`));
|
|
584
615
|
}
|
|
585
616
|
}
|
|
586
617
|
}
|
|
587
618
|
catch (error) {
|
|
588
619
|
toolSpinner.fail('Tool listing failed');
|
|
589
|
-
console.log(
|
|
620
|
+
console.log(chalk_1.default.red(' ā Cannot list MCP tools'));
|
|
590
621
|
if (options.verbose) {
|
|
591
|
-
console.log(
|
|
622
|
+
console.log(chalk_1.default.gray(` Error: ${error instanceof Error ? error.message : 'Unknown error'}`));
|
|
592
623
|
}
|
|
593
624
|
}
|
|
594
625
|
}
|
|
595
626
|
else {
|
|
596
|
-
console.log(
|
|
627
|
+
console.log(chalk_1.default.gray(' - Skipped (not connected to MCP server)'));
|
|
597
628
|
}
|
|
598
629
|
// Step 6: Connection quality measurement
|
|
599
|
-
console.log(
|
|
630
|
+
console.log(chalk_1.default.cyan('\n6. Connection Quality'));
|
|
600
631
|
if (Object.keys(diagnostics.connectionLatency).length > 0) {
|
|
601
|
-
console.log(
|
|
632
|
+
console.log(chalk_1.default.green(' ā Latency measurements:'));
|
|
602
633
|
Object.entries(diagnostics.connectionLatency).forEach(([transport, latency]) => {
|
|
603
634
|
const quality = latency < 100 ? 'Excellent' : latency < 300 ? 'Good' : latency < 1000 ? 'Fair' : 'Poor';
|
|
604
|
-
const color = latency < 100 ?
|
|
635
|
+
const color = latency < 100 ? chalk_1.default.green : latency < 300 ? chalk_1.default.yellow : chalk_1.default.red;
|
|
605
636
|
console.log(color(` ${transport.toUpperCase()}: ${latency}ms (${quality})`));
|
|
606
637
|
});
|
|
607
638
|
}
|
|
608
639
|
else {
|
|
609
|
-
console.log(
|
|
640
|
+
console.log(chalk_1.default.gray(' - No latency measurements available'));
|
|
610
641
|
}
|
|
611
642
|
// Summary and recommendations
|
|
612
|
-
console.log(
|
|
613
|
-
console.log(
|
|
643
|
+
console.log(chalk_1.default.blue.bold('\nš MCP Diagnostic Summary'));
|
|
644
|
+
console.log(chalk_1.default.cyan('ā'.repeat(50)));
|
|
614
645
|
const issues = [];
|
|
615
646
|
const recommendations = [];
|
|
616
647
|
if (!diagnostics.authenticationValid) {
|
|
@@ -640,30 +671,30 @@ export function mcpCommands(program) {
|
|
|
640
671
|
}
|
|
641
672
|
// Show results
|
|
642
673
|
if (issues.length === 0) {
|
|
643
|
-
console.log(
|
|
644
|
-
console.log(
|
|
674
|
+
console.log(chalk_1.default.green('ā
All MCP connection checks passed!'));
|
|
675
|
+
console.log(chalk_1.default.cyan(' Your MCP connection is working correctly.'));
|
|
645
676
|
if (Object.keys(diagnostics.connectionLatency).length > 0) {
|
|
646
677
|
const avgLatency = Object.values(diagnostics.connectionLatency).reduce((a, b) => a + b, 0) / Object.values(diagnostics.connectionLatency).length;
|
|
647
|
-
console.log(
|
|
678
|
+
console.log(chalk_1.default.cyan(` Average latency: ${Math.round(avgLatency)}ms`));
|
|
648
679
|
}
|
|
649
680
|
}
|
|
650
681
|
else {
|
|
651
|
-
console.log(
|
|
682
|
+
console.log(chalk_1.default.red(`ā Found ${issues.length} issue(s):`));
|
|
652
683
|
issues.forEach(issue => {
|
|
653
|
-
console.log(
|
|
684
|
+
console.log(chalk_1.default.red(` ⢠${issue}`));
|
|
654
685
|
});
|
|
655
|
-
console.log(
|
|
686
|
+
console.log(chalk_1.default.yellow('\nš” Recommended actions:'));
|
|
656
687
|
recommendations.forEach(rec => {
|
|
657
|
-
console.log(
|
|
688
|
+
console.log(chalk_1.default.cyan(` ⢠${rec}`));
|
|
658
689
|
});
|
|
659
690
|
}
|
|
660
691
|
// Additional troubleshooting info
|
|
661
692
|
if (issues.length > 0) {
|
|
662
|
-
console.log(
|
|
663
|
-
console.log(
|
|
664
|
-
console.log(
|
|
665
|
-
console.log(
|
|
666
|
-
console.log(
|
|
693
|
+
console.log(chalk_1.default.gray('\nš§ Additional troubleshooting:'));
|
|
694
|
+
console.log(chalk_1.default.gray(' ⢠Try different connection modes: --mode websocket|remote|local'));
|
|
695
|
+
console.log(chalk_1.default.gray(' ⢠Check firewall settings for ports 80, 443, and WebSocket'));
|
|
696
|
+
console.log(chalk_1.default.gray(' ⢠Verify your network allows outbound HTTPS connections'));
|
|
697
|
+
console.log(chalk_1.default.gray(' ⢠Contact support if issues persist'));
|
|
667
698
|
}
|
|
668
699
|
});
|
|
669
700
|
}
|