@lanonasis/cli 2.0.6 → 2.0.9
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 +27 -4
- package/dist/commands/auth.js +13 -0
- package/dist/index-simple.js +6 -3
- package/dist/index.js +4 -1
- package/dist/mcp/client/enhanced-client.d.ts +116 -0
- package/dist/mcp/client/enhanced-client.js +379 -0
- package/dist/mcp/schemas/tool-schemas.d.ts +740 -0
- package/dist/mcp/schemas/tool-schemas.js +378 -0
- package/dist/mcp/server/lanonasis-server.d.ts +68 -0
- package/dist/mcp/server/lanonasis-server.js +696 -0
- package/dist/mcp/transports/transport-manager.d.ts +82 -0
- package/dist/mcp/transports/transport-manager.js +434 -0
- package/dist/utils/api.js +9 -4
- package/dist/utils/config.d.ts +3 -3
- package/dist/utils/config.js +16 -0
- package/dist/utils/mcp-client.d.ts +4 -0
- package/dist/utils/mcp-client.js +46 -35
- package/package.json +10 -2
package/dist/utils/mcp-client.js
CHANGED
|
@@ -18,11 +18,19 @@ export class MCPClient {
|
|
|
18
18
|
constructor() {
|
|
19
19
|
this.config = new CLIConfig();
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Initialize the MCP client configuration
|
|
23
|
+
*/
|
|
24
|
+
async init() {
|
|
25
|
+
await this.config.init();
|
|
26
|
+
}
|
|
21
27
|
/**
|
|
22
28
|
* Connect to MCP server (local or remote)
|
|
23
29
|
*/
|
|
24
30
|
async connect(options = {}) {
|
|
25
31
|
try {
|
|
32
|
+
// Initialize config if not already done
|
|
33
|
+
await this.init();
|
|
26
34
|
// Determine connection mode with priority to explicit mode option
|
|
27
35
|
// Default to 'remote' for better user experience
|
|
28
36
|
const connectionMode = options.connectionMode ??
|
|
@@ -34,54 +42,57 @@ export class MCPClient {
|
|
|
34
42
|
let serverUrl;
|
|
35
43
|
let serverPath;
|
|
36
44
|
switch (connectionMode) {
|
|
37
|
-
case 'websocket':
|
|
45
|
+
case 'websocket': {
|
|
38
46
|
// WebSocket connection mode for enterprise users
|
|
39
|
-
|
|
47
|
+
const wsUrlValue = options.serverUrl ??
|
|
40
48
|
this.config.get('mcpWebSocketUrl') ??
|
|
41
49
|
'ws://localhost:8081/mcp/ws';
|
|
50
|
+
wsUrl = wsUrlValue;
|
|
42
51
|
console.log(chalk.cyan(`Connecting to WebSocket MCP server at ${wsUrl}...`));
|
|
43
52
|
// Initialize WebSocket connection
|
|
44
53
|
await this.initializeWebSocket(wsUrl);
|
|
45
54
|
this.isConnected = true;
|
|
46
55
|
return true;
|
|
47
|
-
|
|
56
|
+
}
|
|
57
|
+
case 'remote': {
|
|
48
58
|
// For remote MCP, we'll use the REST API with MCP-style interface
|
|
49
|
-
|
|
59
|
+
const serverUrlValue = options.serverUrl ??
|
|
50
60
|
this.config.get('mcpServerUrl') ??
|
|
51
61
|
'https://api.lanonasis.com';
|
|
62
|
+
serverUrl = serverUrlValue;
|
|
52
63
|
console.log(chalk.cyan(`Connecting to remote MCP server at ${serverUrl}...`));
|
|
53
64
|
// Initialize SSE connection for real-time updates
|
|
54
65
|
await this.initializeSSE(serverUrl);
|
|
55
66
|
this.isConnected = true;
|
|
56
67
|
return true;
|
|
57
|
-
|
|
58
|
-
default:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
console.log(chalk.cyan(`Connecting to local MCP server at ${serverPath}...`));
|
|
72
|
-
const localTransport = new StdioClientTransport({
|
|
73
|
-
command: 'node',
|
|
74
|
-
args: [serverPath]
|
|
75
|
-
});
|
|
76
|
-
this.client = new Client({
|
|
77
|
-
name: '@lanonasis/cli',
|
|
78
|
-
version: '2.0.0'
|
|
79
|
-
});
|
|
80
|
-
await this.client.connect(localTransport);
|
|
68
|
+
}
|
|
69
|
+
default: {
|
|
70
|
+
// Local MCP server connection (default)
|
|
71
|
+
const serverPathValue = options.serverPath ??
|
|
72
|
+
this.config.get('mcpServerPath') ??
|
|
73
|
+
path.join(__dirname, '../../../../onasis-gateway/mcp-server/server.js');
|
|
74
|
+
serverPath = serverPathValue;
|
|
75
|
+
// Check if the server file exists
|
|
76
|
+
if (!fs.existsSync(serverPath)) {
|
|
77
|
+
console.log(chalk.yellow(`⚠️ Local MCP server not found at ${serverPath}`));
|
|
78
|
+
console.log(chalk.cyan('💡 For remote connection, use: onasis mcp connect --url wss://mcp.lanonasis.com/ws'));
|
|
79
|
+
console.log(chalk.cyan('💡 Or install local server: npm install -g @lanonasis/mcp-server'));
|
|
80
|
+
throw new Error(`MCP server not found at ${serverPath}`);
|
|
81
81
|
}
|
|
82
|
+
console.log(chalk.cyan(`Connecting to local MCP server at ${serverPath}...`));
|
|
83
|
+
const localTransport = new StdioClientTransport({
|
|
84
|
+
command: 'node',
|
|
85
|
+
args: [serverPath]
|
|
86
|
+
});
|
|
87
|
+
this.client = new Client({
|
|
88
|
+
name: '@lanonasis/cli',
|
|
89
|
+
version: '2.0.0'
|
|
90
|
+
});
|
|
91
|
+
await this.client.connect(localTransport);
|
|
82
92
|
this.isConnected = true;
|
|
83
93
|
console.log(chalk.green('✓ Connected to MCP server'));
|
|
84
94
|
return true;
|
|
95
|
+
}
|
|
85
96
|
}
|
|
86
97
|
}
|
|
87
98
|
catch (error) {
|
|
@@ -129,7 +140,7 @@ export class MCPClient {
|
|
|
129
140
|
this.wsConnection = null;
|
|
130
141
|
}
|
|
131
142
|
// Create new WebSocket connection with authentication
|
|
132
|
-
this.wsConnection = new WebSocket(wsUrl, {
|
|
143
|
+
this.wsConnection = new WebSocket(wsUrl, [], {
|
|
133
144
|
headers: {
|
|
134
145
|
'Authorization': `Bearer ${token}`,
|
|
135
146
|
'X-API-Key': token
|
|
@@ -255,22 +266,22 @@ export class MCPClient {
|
|
|
255
266
|
const toolMappings = {
|
|
256
267
|
'memory_create_memory': {
|
|
257
268
|
method: 'POST',
|
|
258
|
-
endpoint: '/
|
|
269
|
+
endpoint: '/memory',
|
|
259
270
|
transform: (args) => args
|
|
260
271
|
},
|
|
261
272
|
'memory_search_memories': {
|
|
262
273
|
method: 'POST',
|
|
263
|
-
endpoint: '/
|
|
274
|
+
endpoint: '/memory/search',
|
|
264
275
|
transform: (args) => args
|
|
265
276
|
},
|
|
266
277
|
'memory_get_memory': {
|
|
267
278
|
method: 'GET',
|
|
268
|
-
endpoint: '/
|
|
279
|
+
endpoint: '/memory/{id}',
|
|
269
280
|
transform: () => undefined
|
|
270
281
|
},
|
|
271
282
|
'memory_update_memory': {
|
|
272
283
|
method: 'PUT',
|
|
273
|
-
endpoint: '/
|
|
284
|
+
endpoint: '/memory/{id}',
|
|
274
285
|
transform: (args) => {
|
|
275
286
|
const data = { ...args };
|
|
276
287
|
delete data.memory_id;
|
|
@@ -279,12 +290,12 @@ export class MCPClient {
|
|
|
279
290
|
},
|
|
280
291
|
'memory_delete_memory': {
|
|
281
292
|
method: 'DELETE',
|
|
282
|
-
endpoint: '/
|
|
293
|
+
endpoint: '/memory/{id}',
|
|
283
294
|
transform: () => undefined
|
|
284
295
|
},
|
|
285
296
|
'memory_list_memories': {
|
|
286
297
|
method: 'GET',
|
|
287
|
-
endpoint: '/
|
|
298
|
+
endpoint: '/memory',
|
|
288
299
|
transform: (args) => args
|
|
289
300
|
}
|
|
290
301
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lanonasis/cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.9",
|
|
4
4
|
"description": "LanOnasis Enterprise CLI - Memory as a Service, API Key Management, and Infrastructure Orchestration",
|
|
5
5
|
"main": "dist/index-simple.js",
|
|
6
6
|
"bin": {
|
|
@@ -14,12 +14,20 @@
|
|
|
14
14
|
"type": "module",
|
|
15
15
|
"scripts": {
|
|
16
16
|
"dev": "tsx src/index.ts",
|
|
17
|
+
"dev:mcp": "tsx src/mcp/server/lanonasis-server.ts --verbose",
|
|
17
18
|
"build": "tsc && chmod +x dist/index-simple.js && chmod +x dist/mcp-server.js && cp -r src/completions dist/",
|
|
19
|
+
"build:mcp": "tsc && npm run build:mcp-server && npm run build:mcp-client",
|
|
20
|
+
"build:mcp-server": "tsc src/mcp/server/lanonasis-server.ts --outDir dist/mcp/server && chmod +x dist/mcp/server/lanonasis-server.js",
|
|
21
|
+
"build:mcp-client": "tsc src/mcp/client/enhanced-client.ts --outDir dist/mcp/client",
|
|
18
22
|
"start": "node dist/index.js",
|
|
23
|
+
"start:mcp-server": "node dist/mcp/server/lanonasis-server.js",
|
|
19
24
|
"test": "jest",
|
|
25
|
+
"test:mcp": "jest --testPathPattern=mcp",
|
|
26
|
+
"test:integration": "npm run build:mcp && npm run test:mcp",
|
|
20
27
|
"lint": "eslint src/**/*.ts",
|
|
21
28
|
"type-check": "tsc --noEmit",
|
|
22
|
-
"prepare": "npm run build"
|
|
29
|
+
"prepare": "npm run build",
|
|
30
|
+
"publish:with-mcp": "npm run build:mcp && npm publish"
|
|
23
31
|
},
|
|
24
32
|
"keywords": [
|
|
25
33
|
"lanonasis",
|