@lanonasis/cli 3.0.7 → 3.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/dist/commands/mcp.js
CHANGED
|
@@ -2,6 +2,7 @@ import chalk from 'chalk';
|
|
|
2
2
|
import ora from 'ora';
|
|
3
3
|
import { table } from 'table';
|
|
4
4
|
import { getMCPClient } from '../utils/mcp-client.js';
|
|
5
|
+
import { EnhancedMCPClient } from '../mcp/client/enhanced-client.js';
|
|
5
6
|
import { CLIConfig } from '../utils/config.js';
|
|
6
7
|
export function mcpCommands(program) {
|
|
7
8
|
const mcp = program
|
|
@@ -92,12 +93,32 @@ export function mcpCommands(program) {
|
|
|
92
93
|
config.set('mcpServerUrl', options.url);
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
let connected = false;
|
|
97
|
+
// Use Enhanced MCP Client for better connection handling
|
|
98
|
+
const enhancedClient = new EnhancedMCPClient();
|
|
99
|
+
if (options.url) {
|
|
100
|
+
// Connect to specific URL (WebSocket or remote)
|
|
101
|
+
const serverConfig = {
|
|
102
|
+
name: 'user-specified',
|
|
103
|
+
type: (options.url.startsWith('wss://') ? 'websocket' : 'stdio'),
|
|
104
|
+
url: options.url,
|
|
105
|
+
priority: 1
|
|
106
|
+
};
|
|
107
|
+
connected = await enhancedClient.connectSingle(serverConfig);
|
|
108
|
+
if (connected) {
|
|
109
|
+
spinner.succeed(chalk.green(`Connected to MCP server at ${options.url}`));
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
// Fall back to old client for local connections
|
|
115
|
+
const client = getMCPClient();
|
|
116
|
+
connected = await client.connect({
|
|
117
|
+
connectionMode,
|
|
118
|
+
serverPath: options.server,
|
|
119
|
+
serverUrl: options.url
|
|
120
|
+
});
|
|
121
|
+
}
|
|
101
122
|
if (connected) {
|
|
102
123
|
spinner.succeed(chalk.green(`Connected to MCP server in ${connectionMode} mode`));
|
|
103
124
|
if (connectionMode === 'remote') {
|
package/dist/index.js
CHANGED
|
File without changes
|
|
@@ -217,13 +217,13 @@ export declare const BulkOperationSchema: z.ZodObject<{
|
|
|
217
217
|
transaction: z.ZodDefault<z.ZodBoolean>;
|
|
218
218
|
}, "strip", z.ZodTypeAny, {
|
|
219
219
|
operation?: "create" | "delete" | "update";
|
|
220
|
-
items?: Record<string, any>[];
|
|
221
220
|
entity_type?: "topic" | "memory" | "apikey";
|
|
221
|
+
items?: Record<string, any>[];
|
|
222
222
|
transaction?: boolean;
|
|
223
223
|
}, {
|
|
224
224
|
operation?: "create" | "delete" | "update";
|
|
225
|
-
items?: Record<string, any>[];
|
|
226
225
|
entity_type?: "topic" | "memory" | "apikey";
|
|
226
|
+
items?: Record<string, any>[];
|
|
227
227
|
transaction?: boolean;
|
|
228
228
|
}>;
|
|
229
229
|
export declare const ImportExportSchema: z.ZodObject<{
|
|
@@ -597,13 +597,13 @@ export declare const MCPSchemas: {
|
|
|
597
597
|
transaction: z.ZodDefault<z.ZodBoolean>;
|
|
598
598
|
}, "strip", z.ZodTypeAny, {
|
|
599
599
|
operation?: "create" | "delete" | "update";
|
|
600
|
-
items?: Record<string, any>[];
|
|
601
600
|
entity_type?: "topic" | "memory" | "apikey";
|
|
601
|
+
items?: Record<string, any>[];
|
|
602
602
|
transaction?: boolean;
|
|
603
603
|
}, {
|
|
604
604
|
operation?: "create" | "delete" | "update";
|
|
605
|
-
items?: Record<string, any>[];
|
|
606
605
|
entity_type?: "topic" | "memory" | "apikey";
|
|
606
|
+
items?: Record<string, any>[];
|
|
607
607
|
transaction?: boolean;
|
|
608
608
|
}>;
|
|
609
609
|
importExport: z.ZodObject<{
|
|
@@ -29,10 +29,7 @@ export class LanonasisMCPServer {
|
|
|
29
29
|
// Initialize config and API client
|
|
30
30
|
this.config = new CLIConfig();
|
|
31
31
|
this.apiClient = new APIClient();
|
|
32
|
-
//
|
|
33
|
-
this.registerTools();
|
|
34
|
-
this.registerResources();
|
|
35
|
-
this.registerPrompts();
|
|
32
|
+
// Note: registerTools is now async and called in initialize()
|
|
36
33
|
// Setup error handling
|
|
37
34
|
this.setupErrorHandling();
|
|
38
35
|
}
|
|
@@ -56,6 +53,10 @@ export class LanonasisMCPServer {
|
|
|
56
53
|
this.apiClient = new APIClient();
|
|
57
54
|
// APIClient will use the config internally
|
|
58
55
|
}
|
|
56
|
+
// Register tools, resources, and prompts after config is loaded
|
|
57
|
+
await this.registerTools();
|
|
58
|
+
this.registerResources();
|
|
59
|
+
this.registerPrompts();
|
|
59
60
|
if (this.options.verbose) {
|
|
60
61
|
console.log(chalk.cyan('🚀 Lanonasis MCP Server initialized'));
|
|
61
62
|
console.log(chalk.gray(`API URL: ${apiUrl}`));
|
|
@@ -65,9 +66,11 @@ export class LanonasisMCPServer {
|
|
|
65
66
|
/**
|
|
66
67
|
* Register MCP tools
|
|
67
68
|
*/
|
|
68
|
-
registerTools() {
|
|
69
|
-
//
|
|
70
|
-
|
|
69
|
+
async registerTools() {
|
|
70
|
+
// Import request schemas dynamically for ES modules
|
|
71
|
+
const { ListToolsRequestSchema, CallToolRequestSchema } = await import('@modelcontextprotocol/sdk/types.js');
|
|
72
|
+
// List available tools
|
|
73
|
+
this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
71
74
|
tools: [
|
|
72
75
|
// Memory tools
|
|
73
76
|
{
|
|
@@ -305,8 +308,8 @@ export class LanonasisMCPServer {
|
|
|
305
308
|
}
|
|
306
309
|
]
|
|
307
310
|
}));
|
|
308
|
-
// Tool call handler
|
|
309
|
-
this.server.setRequestHandler(
|
|
311
|
+
// Tool call handler (CallToolRequestSchema already imported above)
|
|
312
|
+
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
310
313
|
const { name, arguments: args } = request.params;
|
|
311
314
|
try {
|
|
312
315
|
const result = await this.handleToolCall(name, args);
|
package/package.json
CHANGED