@lanonasis/cli 2.0.2 → 2.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/dist/utils/api.js +5 -1
- package/dist/utils/config.js +5 -5
- package/dist/utils/mcp-client.js +11 -2
- package/package.json +1 -1
package/dist/utils/api.js
CHANGED
|
@@ -13,7 +13,11 @@ export class APIClient {
|
|
|
13
13
|
await this.config.init();
|
|
14
14
|
// Service Discovery
|
|
15
15
|
await this.config.discoverServices();
|
|
16
|
-
|
|
16
|
+
// Use appropriate base URL based on endpoint
|
|
17
|
+
const isAuthEndpoint = config.url?.includes('/auth/') || config.url?.includes('/login') || config.url?.includes('/register');
|
|
18
|
+
config.baseURL = isAuthEndpoint ?
|
|
19
|
+
(this.config.get('discoveredServices')?.auth_base || 'https://api.lanonasis.com/auth') :
|
|
20
|
+
this.config.getApiUrl();
|
|
17
21
|
// Enhanced Authentication Support
|
|
18
22
|
const token = this.config.getToken();
|
|
19
23
|
const vendorKey = this.config.getVendorKey();
|
package/dist/utils/config.js
CHANGED
|
@@ -57,12 +57,12 @@ export class CLIConfig {
|
|
|
57
57
|
console.log('Service discovery failed, using fallback defaults');
|
|
58
58
|
}
|
|
59
59
|
// Set fallback service endpoints to prevent double slash issues
|
|
60
|
-
//
|
|
60
|
+
// CORRECTED: CLI auth routes through central auth system (api.lanonasis.com)
|
|
61
61
|
this.config.discoveredServices = {
|
|
62
|
-
auth_base: 'https://api.lanonasis.com
|
|
63
|
-
memory_base: 'https://api.lanonasis.com/api/v1',
|
|
64
|
-
mcp_ws_base: 'wss://mcp.lanonasis.com/ws',
|
|
65
|
-
project_scope: 'lanonasis'
|
|
62
|
+
auth_base: 'https://api.lanonasis.com', // CLI auth goes to central auth system
|
|
63
|
+
memory_base: 'https://api.lanonasis.com/api/v1', // Memory via onasis-core
|
|
64
|
+
mcp_ws_base: 'wss://mcp.lanonasis.com/ws', // MCP WebSocket separate
|
|
65
|
+
project_scope: 'lanonasis-maas' // Correct project scope
|
|
66
66
|
};
|
|
67
67
|
await this.save();
|
|
68
68
|
}
|
package/dist/utils/mcp-client.js
CHANGED
|
@@ -3,6 +3,7 @@ import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js'
|
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import { CLIConfig } from './config.js';
|
|
5
5
|
import * as path from 'path';
|
|
6
|
+
import * as fs from 'fs';
|
|
6
7
|
import { EventSource } from 'eventsource';
|
|
7
8
|
import { fileURLToPath } from 'url';
|
|
8
9
|
import WebSocket from 'ws';
|
|
@@ -23,11 +24,12 @@ export class MCPClient {
|
|
|
23
24
|
async connect(options = {}) {
|
|
24
25
|
try {
|
|
25
26
|
// Determine connection mode with priority to explicit mode option
|
|
27
|
+
// Default to 'remote' for better user experience
|
|
26
28
|
const connectionMode = options.connectionMode ??
|
|
27
29
|
(options.useWebSocket ? 'websocket' :
|
|
28
30
|
options.useRemote ? 'remote' :
|
|
29
31
|
this.config.get('mcpConnectionMode') ??
|
|
30
|
-
this.config.get('mcpUseRemote') ? 'remote' : '
|
|
32
|
+
this.config.get('mcpUseRemote') ? 'remote' : 'remote');
|
|
31
33
|
let wsUrl;
|
|
32
34
|
let serverUrl;
|
|
33
35
|
let serverPath;
|
|
@@ -55,10 +57,17 @@ export class MCPClient {
|
|
|
55
57
|
case 'local':
|
|
56
58
|
default:
|
|
57
59
|
{
|
|
58
|
-
// Local MCP server connection
|
|
60
|
+
// Local MCP server connection - check if server exists
|
|
59
61
|
serverPath = options.serverPath ??
|
|
60
62
|
this.config.get('mcpServerPath') ??
|
|
61
63
|
path.join(__dirname, '../../../../onasis-gateway/mcp-server/server.js');
|
|
64
|
+
// Check if the server file exists
|
|
65
|
+
if (!fs.existsSync(serverPath)) {
|
|
66
|
+
console.log(chalk.yellow(`⚠️ Local MCP server not found at ${serverPath}`));
|
|
67
|
+
console.log(chalk.cyan('💡 For remote connection, use: onasis mcp connect --url wss://mcp.lanonasis.com/ws'));
|
|
68
|
+
console.log(chalk.cyan('💡 Or install local server: npm install -g @lanonasis/mcp-server'));
|
|
69
|
+
throw new Error(`MCP server not found at ${serverPath}`);
|
|
70
|
+
}
|
|
62
71
|
console.log(chalk.cyan(`Connecting to local MCP server at ${serverPath}...`));
|
|
63
72
|
const localTransport = new StdioClientTransport({
|
|
64
73
|
command: 'node',
|
package/package.json
CHANGED