@juspay/neurolink 7.14.0 ā 7.14.2
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/CHANGELOG.md +12 -0
- package/dist/agent/directTools.d.ts +3 -3
- package/dist/agent/directTools.js +1 -1
- package/dist/cli/commands/mcp.js +67 -207
- package/dist/cli/factories/commandFactory.js +7 -1
- package/dist/cli/utils/interactiveSetup.js +1 -1
- package/dist/core/baseProvider.d.ts +6 -40
- package/dist/core/baseProvider.js +102 -75
- package/dist/core/dynamicModels.d.ts +14 -14
- package/dist/core/dynamicModels.js +1 -1
- package/dist/core/evaluation.js +1 -1
- package/dist/core/factory.js +1 -12
- package/dist/index.d.ts +23 -4
- package/dist/index.js +22 -1
- package/dist/lib/agent/directTools.js +1 -1
- package/dist/lib/core/baseProvider.d.ts +6 -40
- package/dist/lib/core/baseProvider.js +102 -75
- package/dist/lib/core/dynamicModels.js +1 -1
- package/dist/lib/core/evaluation.js +1 -1
- package/dist/lib/core/factory.js +1 -12
- package/dist/lib/index.d.ts +23 -4
- package/dist/lib/index.js +22 -1
- package/dist/lib/mcp/externalServerManager.d.ts +46 -13
- package/dist/lib/mcp/externalServerManager.js +393 -32
- package/dist/lib/mcp/mcpClientFactory.d.ts +5 -4
- package/dist/lib/mcp/mcpClientFactory.js +8 -3
- package/dist/lib/mcp/toolDiscoveryService.d.ts +1 -0
- package/dist/lib/mcp/toolDiscoveryService.js +76 -8
- package/dist/lib/mcp/toolRegistry.d.ts +15 -11
- package/dist/lib/mcp/toolRegistry.js +118 -55
- package/dist/lib/models/modelResolver.js +1 -1
- package/dist/lib/neurolink.d.ts +32 -31
- package/dist/lib/neurolink.js +173 -210
- package/dist/lib/providers/googleVertex.d.ts +6 -0
- package/dist/lib/providers/googleVertex.js +11 -0
- package/dist/lib/providers/huggingFace.js +1 -1
- package/dist/lib/providers/mistral.js +3 -3
- package/dist/lib/providers/ollama.js +1 -1
- package/dist/lib/providers/openAI.d.ts +3 -2
- package/dist/lib/providers/openAI.js +2 -2
- package/dist/lib/providers/openaiCompatible.d.ts +1 -1
- package/dist/lib/providers/openaiCompatible.js +2 -2
- package/dist/lib/providers/sagemaker/config.js +1 -1
- package/dist/lib/sdk/toolRegistration.d.ts +4 -13
- package/dist/lib/sdk/toolRegistration.js +19 -66
- package/dist/lib/types/cli.d.ts +0 -1
- package/dist/lib/types/cli.js +0 -1
- package/dist/lib/types/common.d.ts +1 -2
- package/dist/lib/types/common.js +0 -1
- package/dist/lib/types/contextTypes.d.ts +1 -1
- package/dist/lib/types/contextTypes.js +3 -3
- package/dist/lib/types/externalMcp.d.ts +6 -0
- package/dist/lib/types/externalMcp.js +1 -0
- package/dist/lib/types/index.d.ts +2 -3
- package/dist/lib/types/index.js +0 -1
- package/dist/lib/types/mcpTypes.d.ts +53 -99
- package/dist/lib/types/providers.d.ts +0 -1
- package/dist/lib/types/providers.js +0 -1
- package/dist/lib/types/tools.d.ts +2 -2
- package/dist/lib/types/tools.js +2 -2
- package/dist/lib/utils/factoryProcessing.js +1 -1
- package/dist/lib/utils/mcpDefaults.d.ts +54 -0
- package/dist/lib/utils/mcpDefaults.js +125 -0
- package/dist/lib/utils/providerConfig.d.ts +1 -1
- package/dist/lib/utils/providerConfig.js +2 -2
- package/dist/lib/utils/providerHealth.js +6 -6
- package/dist/mcp/externalServerManager.d.ts +46 -13
- package/dist/mcp/externalServerManager.js +393 -32
- package/dist/mcp/mcpClientFactory.d.ts +5 -4
- package/dist/mcp/mcpClientFactory.js +8 -3
- package/dist/mcp/toolDiscoveryService.d.ts +1 -0
- package/dist/mcp/toolDiscoveryService.js +76 -8
- package/dist/mcp/toolRegistry.d.ts +15 -11
- package/dist/mcp/toolRegistry.js +118 -55
- package/dist/models/modelResolver.js +1 -1
- package/dist/neurolink.d.ts +32 -31
- package/dist/neurolink.js +173 -210
- package/dist/providers/googleVertex.d.ts +6 -0
- package/dist/providers/googleVertex.js +11 -0
- package/dist/providers/huggingFace.js +1 -1
- package/dist/providers/mistral.js +3 -3
- package/dist/providers/ollama.js +1 -1
- package/dist/providers/openAI.d.ts +3 -2
- package/dist/providers/openAI.js +2 -2
- package/dist/providers/openaiCompatible.d.ts +1 -1
- package/dist/providers/openaiCompatible.js +2 -2
- package/dist/providers/sagemaker/config.js +1 -1
- package/dist/sdk/toolRegistration.d.ts +4 -13
- package/dist/sdk/toolRegistration.js +19 -66
- package/dist/types/cli.d.ts +0 -1
- package/dist/types/cli.js +0 -1
- package/dist/types/common.d.ts +1 -2
- package/dist/types/common.js +0 -1
- package/dist/types/contextTypes.d.ts +1 -1
- package/dist/types/contextTypes.js +3 -3
- package/dist/types/externalMcp.d.ts +6 -0
- package/dist/types/externalMcp.js +1 -0
- package/dist/types/index.d.ts +2 -3
- package/dist/types/index.js +0 -1
- package/dist/types/mcpTypes.d.ts +53 -99
- package/dist/types/providers.d.ts +0 -1
- package/dist/types/providers.js +0 -1
- package/dist/types/tools.d.ts +2 -2
- package/dist/types/tools.js +2 -2
- package/dist/utils/factoryProcessing.js +1 -1
- package/dist/utils/mcpDefaults.d.ts +54 -0
- package/dist/utils/mcpDefaults.js +125 -0
- package/dist/utils/providerConfig.d.ts +1 -1
- package/dist/utils/providerConfig.js +2 -2
- package/dist/utils/providerHealth.js +6 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## [7.14.2](https://github.com/juspay/neurolink/compare/v7.14.1...v7.14.2) (2025-08-16)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- **(sdk):** add generateText backward compatibility and fix formatting consistency ([93ff23c](https://github.com/juspay/neurolink/commit/93ff23c766ca71cbe7f77821b35cf5156bbe9d1f))
|
|
6
|
+
|
|
7
|
+
## [7.14.1](https://github.com/juspay/neurolink/compare/v7.14.0...v7.14.1) (2025-08-15)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
- **(mcp):** implement external MCP server integration with real tool execution ([9427a95](https://github.com/juspay/neurolink/commit/9427a95599a829f82e697eaf30388a8f3c899d4f))
|
|
12
|
+
|
|
1
13
|
## [7.14.0](https://github.com/juspay/neurolink/compare/v7.13.0...v7.14.0) (2025-08-14)
|
|
2
14
|
|
|
3
15
|
### Features
|
|
@@ -219,12 +219,12 @@ export declare const directAgentTools: {
|
|
|
219
219
|
content: z.ZodString;
|
|
220
220
|
mode: z.ZodDefault<z.ZodEnum<["create", "overwrite", "append"]>>;
|
|
221
221
|
}, "strip", z.ZodTypeAny, {
|
|
222
|
-
path: string;
|
|
223
222
|
content: string;
|
|
223
|
+
path: string;
|
|
224
224
|
mode: "create" | "overwrite" | "append";
|
|
225
225
|
}, {
|
|
226
|
-
path: string;
|
|
227
226
|
content: string;
|
|
227
|
+
path: string;
|
|
228
228
|
mode?: "create" | "overwrite" | "append" | undefined;
|
|
229
229
|
}>, {
|
|
230
230
|
success: boolean;
|
|
@@ -249,8 +249,8 @@ export declare const directAgentTools: {
|
|
|
249
249
|
written?: undefined;
|
|
250
250
|
}> & {
|
|
251
251
|
execute: (args: {
|
|
252
|
-
path: string;
|
|
253
252
|
content: string;
|
|
253
|
+
path: string;
|
|
254
254
|
mode: "create" | "overwrite" | "append";
|
|
255
255
|
}, options: import("ai").ToolExecutionOptions) => PromiseLike<{
|
|
256
256
|
success: boolean;
|
|
@@ -163,7 +163,7 @@ export const directAgentTools = {
|
|
|
163
163
|
for (const func of allowedMathFunctions) {
|
|
164
164
|
safeExpression = safeExpression.replace(new RegExp(func, "g"), func);
|
|
165
165
|
}
|
|
166
|
-
// Remove
|
|
166
|
+
// Remove remaining non-safe characters except Math functions
|
|
167
167
|
const mathSafe = /^[0-9+\-*/().\s]|Math\.(abs|ceil|floor|round|sqrt|pow|sin|cos|tan|log|exp|PI|E)/g;
|
|
168
168
|
if (!safeExpression
|
|
169
169
|
.split("")
|
package/dist/cli/commands/mcp.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Implements comprehensive MCP server management commands
|
|
4
4
|
* Part of Phase 4.2 - MCP CLI Commands
|
|
5
5
|
*/
|
|
6
|
+
import { createExternalServerInfo } from "../../lib/utils/mcpDefaults.js";
|
|
6
7
|
import { NeuroLink } from "../../lib/neurolink.js";
|
|
7
8
|
import { logger } from "../../lib/utils/logger.js";
|
|
8
9
|
import chalk from "chalk";
|
|
@@ -80,91 +81,6 @@ const POPULAR_MCP_SERVERS = {
|
|
|
80
81
|
description: "Bitbucket repository management and development workflows",
|
|
81
82
|
},
|
|
82
83
|
};
|
|
83
|
-
/**
|
|
84
|
-
* Type guard to check if an object conforms to MCPStatusResponse interface
|
|
85
|
-
*/
|
|
86
|
-
function isMCPStatusResponse(obj) {
|
|
87
|
-
if (!obj || typeof obj !== "object") {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
const record = obj;
|
|
91
|
-
// Check if autoDiscoveredServers is either undefined or an array
|
|
92
|
-
if (record.autoDiscoveredServers !== undefined) {
|
|
93
|
-
if (!Array.isArray(record.autoDiscoveredServers)) {
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
// Check each server object in the array
|
|
97
|
-
for (const server of record.autoDiscoveredServers) {
|
|
98
|
-
if (!server || typeof server !== "object") {
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
const serverRecord = server;
|
|
102
|
-
// Optional properties should be correct type if present
|
|
103
|
-
if (serverRecord.name !== undefined &&
|
|
104
|
-
typeof serverRecord.name !== "string") {
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
if (serverRecord.id !== undefined &&
|
|
108
|
-
typeof serverRecord.id !== "string") {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
if (serverRecord.status !== undefined &&
|
|
112
|
-
typeof serverRecord.status !== "string") {
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
if (serverRecord.source !== undefined &&
|
|
116
|
-
typeof serverRecord.source !== "string") {
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return true;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Convert SDK MCPStatus to CLI format with server list
|
|
125
|
-
*/
|
|
126
|
-
function convertMCPStatusForCLI(status, // Use flexible object type
|
|
127
|
-
sdk) {
|
|
128
|
-
// Create server list from in-memory servers and discovered servers
|
|
129
|
-
const servers = [];
|
|
130
|
-
// Add in-memory servers
|
|
131
|
-
const inMemoryServers = sdk.getInMemoryServers();
|
|
132
|
-
inMemoryServers.forEach((config, name) => {
|
|
133
|
-
servers.push({
|
|
134
|
-
name,
|
|
135
|
-
connected: true, // In-memory servers are always "connected"
|
|
136
|
-
description: config.server?.title || "In-memory MCP server",
|
|
137
|
-
tools: [], // Could extract from config.server.tools if needed
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
// Add auto-discovered servers
|
|
141
|
-
// Cache the type guard result to avoid repeated validation
|
|
142
|
-
const isValidStatusResponse = isMCPStatusResponse(status);
|
|
143
|
-
if (isValidStatusResponse && status.autoDiscoveredServers) {
|
|
144
|
-
status.autoDiscoveredServers.forEach((server) => {
|
|
145
|
-
servers.push({
|
|
146
|
-
name: server.name || server.id || "Unknown",
|
|
147
|
-
connected: server.status === "connected",
|
|
148
|
-
description: server.source
|
|
149
|
-
? `Auto-discovered from ${server.source}`
|
|
150
|
-
: `Auto-discovered server`,
|
|
151
|
-
tools: [],
|
|
152
|
-
error: server.status === "failed" ? "Connection failed" : undefined,
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
return {
|
|
157
|
-
mcpInitialized: status.mcpInitialized,
|
|
158
|
-
totalServers: status.totalServers,
|
|
159
|
-
availableServers: status.availableServers,
|
|
160
|
-
autoDiscoveredCount: status.autoDiscoveredCount,
|
|
161
|
-
totalTools: status.totalTools,
|
|
162
|
-
customToolsCount: status.customToolsCount,
|
|
163
|
-
inMemoryServersCount: status.inMemoryServersCount,
|
|
164
|
-
error: status.error,
|
|
165
|
-
servers,
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
84
|
/**
|
|
169
85
|
* MCP CLI command factory
|
|
170
86
|
*/
|
|
@@ -280,7 +196,7 @@ export class MCPCommandFactory {
|
|
|
280
196
|
demandOption: true,
|
|
281
197
|
})
|
|
282
198
|
.option("transport", {
|
|
283
|
-
choices: ["stdio", "sse", "
|
|
199
|
+
choices: ["stdio", "sse", "websocket"],
|
|
284
200
|
default: "stdio",
|
|
285
201
|
description: "Transport type for MCP communication",
|
|
286
202
|
})
|
|
@@ -312,7 +228,7 @@ export class MCPCommandFactory {
|
|
|
312
228
|
demandOption: true,
|
|
313
229
|
})
|
|
314
230
|
.option("transport", {
|
|
315
|
-
choices: ["stdio", "sse", "
|
|
231
|
+
choices: ["stdio", "sse", "websocket"],
|
|
316
232
|
default: "stdio",
|
|
317
233
|
description: "Transport type for MCP communication",
|
|
318
234
|
})
|
|
@@ -393,12 +309,12 @@ export class MCPCommandFactory {
|
|
|
393
309
|
const spinner = argv.quiet ? null : ora("Loading MCP servers...").start();
|
|
394
310
|
// Get configured servers from NeuroLink
|
|
395
311
|
const sdk = new NeuroLink();
|
|
396
|
-
const
|
|
397
|
-
const
|
|
312
|
+
const mcpStatus = await sdk.getMCPStatus();
|
|
313
|
+
const allServers = await sdk.listMCPServers();
|
|
398
314
|
if (spinner) {
|
|
399
|
-
spinner.succeed(`Found ${
|
|
315
|
+
spinner.succeed(`Found ${allServers.length} MCP servers`);
|
|
400
316
|
}
|
|
401
|
-
if (
|
|
317
|
+
if (allServers.length === 0) {
|
|
402
318
|
logger.always(chalk.yellow("No MCP servers configured."));
|
|
403
319
|
logger.always(chalk.blue("š” Use 'neurolink mcp install <server>' to install popular servers"));
|
|
404
320
|
logger.always(chalk.blue("š” Use 'neurolink discover' to find existing servers"));
|
|
@@ -408,17 +324,19 @@ export class MCPCommandFactory {
|
|
|
408
324
|
if (argv.format === "json") {
|
|
409
325
|
logger.always(JSON.stringify(mcpStatus, null, 2));
|
|
410
326
|
}
|
|
411
|
-
else if (argv.format
|
|
412
|
-
|
|
413
|
-
|
|
327
|
+
else if (argv.format === "compact") {
|
|
328
|
+
const allServers = await sdk.listMCPServers();
|
|
329
|
+
allServers.forEach((server) => {
|
|
330
|
+
const status = server.status === "connected" ? chalk.green("ā") : chalk.red("ā");
|
|
414
331
|
logger.always(`${status} ${server.name} - ${server.description || "No description"}`);
|
|
415
332
|
});
|
|
416
333
|
}
|
|
417
334
|
else {
|
|
418
335
|
// Table format
|
|
419
336
|
logger.always(chalk.bold("\nš§ MCP Servers:\n"));
|
|
420
|
-
|
|
421
|
-
|
|
337
|
+
const allServers = await sdk.listMCPServers();
|
|
338
|
+
for (const server of allServers) {
|
|
339
|
+
const status = server.status === "connected"
|
|
422
340
|
? chalk.green("CONNECTED")
|
|
423
341
|
: chalk.red("DISCONNECTED");
|
|
424
342
|
logger.always(`${chalk.cyan(server.name)} ${status}`);
|
|
@@ -474,58 +392,36 @@ export class MCPCommandFactory {
|
|
|
474
392
|
process.exit(1);
|
|
475
393
|
}
|
|
476
394
|
}
|
|
477
|
-
|
|
478
|
-
|
|
395
|
+
const serverInfo = createExternalServerInfo({
|
|
396
|
+
...serverConfig,
|
|
397
|
+
id: serverName,
|
|
479
398
|
name: serverName,
|
|
480
|
-
command: serverConfig.command,
|
|
481
|
-
args: argv.args || serverConfig.args,
|
|
482
|
-
env,
|
|
483
|
-
transport: (argv.transport &&
|
|
484
|
-
(argv.transport === "websocket"
|
|
485
|
-
? "ws"
|
|
486
|
-
: argv.transport)) ||
|
|
487
|
-
serverConfig.transport,
|
|
488
|
-
description: serverConfig.description,
|
|
489
|
-
installed: true,
|
|
490
|
-
status: "unknown",
|
|
491
|
-
};
|
|
492
|
-
// Add server to NeuroLink (using in-memory MCP server for now)
|
|
493
|
-
const sdk = new NeuroLink();
|
|
494
|
-
await sdk.addInMemoryMCPServer(serverName, {
|
|
495
|
-
server: {
|
|
496
|
-
title: serverConfig.description,
|
|
497
|
-
tools: {}, // Empty tools for external servers
|
|
498
|
-
description: serverConfig.description,
|
|
499
|
-
},
|
|
500
|
-
metadata: {
|
|
501
|
-
command: config.command,
|
|
502
|
-
args: config.args,
|
|
503
|
-
env: config.env,
|
|
504
|
-
transport: config.transport,
|
|
505
|
-
},
|
|
506
399
|
});
|
|
400
|
+
// Add server to NeuroLink - direct usage, zero transformations!
|
|
401
|
+
const sdk = new NeuroLink();
|
|
402
|
+
await sdk.addInMemoryMCPServer(serverName, serverInfo);
|
|
507
403
|
if (spinner) {
|
|
508
404
|
spinner.succeed(chalk.green(`ā
Successfully installed ${serverName} MCP server`));
|
|
509
405
|
}
|
|
510
406
|
// Display configuration info
|
|
511
407
|
logger.always(chalk.bold("\nš Server Configuration:"));
|
|
512
|
-
logger.always(`Name: ${
|
|
513
|
-
logger.always(`Command: ${
|
|
514
|
-
if (
|
|
515
|
-
logger.always(`Args: ${
|
|
408
|
+
logger.always(`Name: ${serverInfo.name}`);
|
|
409
|
+
logger.always(`Command: ${serverInfo.command}`);
|
|
410
|
+
if (serverInfo.args?.length) {
|
|
411
|
+
logger.always(`Args: ${serverInfo.args.join(" ")}`);
|
|
516
412
|
}
|
|
517
|
-
if (
|
|
518
|
-
logger.always(`Environment: ${Object.keys(
|
|
413
|
+
if (serverInfo.env) {
|
|
414
|
+
logger.always(`Environment: ${Object.keys(serverInfo.env).length} variables`);
|
|
519
415
|
}
|
|
520
|
-
logger.always(`Transport: ${
|
|
521
|
-
logger.always(`Description: ${
|
|
416
|
+
logger.always(`Transport: ${serverInfo.transport}`);
|
|
417
|
+
logger.always(`Description: ${serverInfo.description}`);
|
|
522
418
|
// Test connection
|
|
523
419
|
logger.always(chalk.blue("\nš Testing connection..."));
|
|
524
420
|
try {
|
|
525
421
|
const rawStatus = await sdk.getMCPStatus();
|
|
526
|
-
const status =
|
|
527
|
-
const installedServer = status.
|
|
528
|
-
if (installedServer?.connected) {
|
|
422
|
+
const status = rawStatus;
|
|
423
|
+
const installedServer = status.externalMCPServers?.find((s) => s.name === serverName);
|
|
424
|
+
if (installedServer?.status === "connected") {
|
|
529
425
|
logger.always(chalk.green("ā
Server connected successfully"));
|
|
530
426
|
if (installedServer.tools?.length) {
|
|
531
427
|
logger.always(`š ļø Available tools: ${installedServer.tools.length}`);
|
|
@@ -571,47 +467,32 @@ export class MCPCommandFactory {
|
|
|
571
467
|
process.exit(1);
|
|
572
468
|
}
|
|
573
469
|
}
|
|
574
|
-
|
|
575
|
-
|
|
470
|
+
const serverInfo = createExternalServerInfo({
|
|
471
|
+
id: name,
|
|
576
472
|
name,
|
|
577
473
|
command,
|
|
578
474
|
args: argv.args,
|
|
579
475
|
env,
|
|
580
|
-
transport:
|
|
581
|
-
|
|
582
|
-
: argv.transport) || "stdio",
|
|
583
|
-
installed: true,
|
|
584
|
-
status: "unknown",
|
|
585
|
-
};
|
|
586
|
-
// Add server to NeuroLink
|
|
587
|
-
const sdk = new NeuroLink();
|
|
588
|
-
await sdk.addInMemoryMCPServer(name, {
|
|
589
|
-
server: {
|
|
590
|
-
title: name,
|
|
591
|
-
tools: {}, // Empty tools for external servers
|
|
592
|
-
description: `Custom MCP server: ${command}`,
|
|
593
|
-
},
|
|
594
|
-
metadata: {
|
|
595
|
-
command: config.command,
|
|
596
|
-
args: config.args,
|
|
597
|
-
env: config.env,
|
|
598
|
-
transport: config.transport,
|
|
599
|
-
},
|
|
476
|
+
transport: argv.transport || "stdio",
|
|
477
|
+
description: command,
|
|
600
478
|
});
|
|
479
|
+
// Add server to NeuroLink using MCPServerInfo directly
|
|
480
|
+
const sdk = new NeuroLink();
|
|
481
|
+
await sdk.addInMemoryMCPServer(name, serverInfo);
|
|
601
482
|
if (spinner) {
|
|
602
483
|
spinner.succeed(chalk.green(`ā
Successfully added ${name} MCP server`));
|
|
603
484
|
}
|
|
604
485
|
// Display configuration
|
|
605
486
|
logger.always(chalk.bold("\nš Server Configuration:"));
|
|
606
|
-
logger.always(`Name: ${
|
|
607
|
-
logger.always(`Command: ${
|
|
608
|
-
if (
|
|
609
|
-
logger.always(`Args: ${
|
|
487
|
+
logger.always(`Name: ${serverInfo.name}`);
|
|
488
|
+
logger.always(`Command: ${serverInfo.command}`);
|
|
489
|
+
if (serverInfo.args?.length) {
|
|
490
|
+
logger.always(`Args: ${serverInfo.args.join(" ")}`);
|
|
610
491
|
}
|
|
611
|
-
if (
|
|
612
|
-
logger.always(`Environment: ${Object.keys(
|
|
492
|
+
if (serverInfo.env) {
|
|
493
|
+
logger.always(`Environment: ${Object.keys(serverInfo.env).length} variables`);
|
|
613
494
|
}
|
|
614
|
-
logger.always(`Transport: ${
|
|
495
|
+
logger.always(`Transport: ${serverInfo.transport}`);
|
|
615
496
|
}
|
|
616
497
|
catch (_error) {
|
|
617
498
|
logger.error(chalk.red(`ā Add command failed: ${_error.message}`));
|
|
@@ -629,10 +510,9 @@ export class MCPCommandFactory {
|
|
|
629
510
|
: ora("Testing MCP server connections...").start();
|
|
630
511
|
const sdk = new NeuroLink();
|
|
631
512
|
const rawMcpStatus = await sdk.getMCPStatus();
|
|
632
|
-
|
|
633
|
-
let serversToTest = mcpStatus.servers;
|
|
513
|
+
let serversToTest = await sdk.listMCPServers();
|
|
634
514
|
if (targetServer) {
|
|
635
|
-
serversToTest =
|
|
515
|
+
serversToTest = serversToTest.filter((s) => s.name === targetServer);
|
|
636
516
|
if (serversToTest.length === 0) {
|
|
637
517
|
if (spinner) {
|
|
638
518
|
spinner.fail();
|
|
@@ -647,11 +527,11 @@ export class MCPCommandFactory {
|
|
|
647
527
|
// Display test results
|
|
648
528
|
logger.always(chalk.bold("\nš§Ŗ MCP Server Test Results:\n"));
|
|
649
529
|
for (const server of serversToTest) {
|
|
650
|
-
const status = server.connected
|
|
530
|
+
const status = server.status === "connected"
|
|
651
531
|
? chalk.green("ā
CONNECTED")
|
|
652
532
|
: chalk.red("ā DISCONNECTED");
|
|
653
533
|
logger.always(`${server.name}: ${status}`);
|
|
654
|
-
if (server.connected) {
|
|
534
|
+
if (server.status === "connected") {
|
|
655
535
|
logger.always(` Tools: ${server.tools?.length || 0} available`);
|
|
656
536
|
if (server.tools?.length) {
|
|
657
537
|
server.tools.slice(0, 3).forEach((tool) => {
|
|
@@ -671,7 +551,7 @@ export class MCPCommandFactory {
|
|
|
671
551
|
logger.always();
|
|
672
552
|
}
|
|
673
553
|
// Summary
|
|
674
|
-
const connected = serversToTest.filter((s) => s.connected).length;
|
|
554
|
+
const connected = serversToTest.filter((s) => s.status === "connected").length;
|
|
675
555
|
const total = serversToTest.length;
|
|
676
556
|
if (connected === total) {
|
|
677
557
|
logger.always(chalk.green(`š All ${total} servers connected successfully`));
|
|
@@ -711,9 +591,8 @@ export class MCPCommandFactory {
|
|
|
711
591
|
}
|
|
712
592
|
const sdk = new NeuroLink();
|
|
713
593
|
// Check if server exists and is connected
|
|
714
|
-
const
|
|
715
|
-
const
|
|
716
|
-
const server = mcpStatus.servers.find((s) => s.name === serverName);
|
|
594
|
+
const allServers = await sdk.listMCPServers();
|
|
595
|
+
const server = allServers.find((s) => s.name === serverName);
|
|
717
596
|
if (!server) {
|
|
718
597
|
if (spinner) {
|
|
719
598
|
spinner.fail();
|
|
@@ -721,7 +600,7 @@ export class MCPCommandFactory {
|
|
|
721
600
|
logger.error(chalk.red(`ā Server not found: ${serverName}`));
|
|
722
601
|
process.exit(1);
|
|
723
602
|
}
|
|
724
|
-
if (
|
|
603
|
+
if (server.status !== "connected") {
|
|
725
604
|
if (spinner) {
|
|
726
605
|
spinner.fail();
|
|
727
606
|
}
|
|
@@ -815,9 +694,8 @@ export class MCPCommandFactory {
|
|
|
815
694
|
try {
|
|
816
695
|
const serverName = argv.server;
|
|
817
696
|
const sdk = new NeuroLink();
|
|
818
|
-
const
|
|
819
|
-
const
|
|
820
|
-
const server = mcpStatus.servers.find((s) => s.name === serverName);
|
|
697
|
+
const allServers = await sdk.listMCPServers();
|
|
698
|
+
const server = allServers.find((s) => s.name === serverName);
|
|
821
699
|
if (!server) {
|
|
822
700
|
logger.error(chalk.red(`ā Server not found: ${serverName}`));
|
|
823
701
|
process.exit(1);
|
|
@@ -907,19 +785,8 @@ export class MCPCommandFactory {
|
|
|
907
785
|
const sdk = new NeuroLink();
|
|
908
786
|
for (const server of discovered) {
|
|
909
787
|
try {
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
title: server.name,
|
|
913
|
-
tools: {},
|
|
914
|
-
description: server.description,
|
|
915
|
-
},
|
|
916
|
-
metadata: {
|
|
917
|
-
command: server.command,
|
|
918
|
-
args: server.args,
|
|
919
|
-
env: server.env,
|
|
920
|
-
transport: server.transport,
|
|
921
|
-
},
|
|
922
|
-
});
|
|
788
|
+
// Use discovered MCPServerInfo directly - zero conversions!
|
|
789
|
+
await sdk.addInMemoryMCPServer(server.name, server);
|
|
923
790
|
logger.always(chalk.green(`ā
Installed ${server.name}`));
|
|
924
791
|
}
|
|
925
792
|
catch (_error) {
|
|
@@ -950,17 +817,14 @@ export class MCPCommandFactory {
|
|
|
950
817
|
const config = JSON.parse(fs.readFileSync(configPath, "utf8"));
|
|
951
818
|
if (config.mcpServers) {
|
|
952
819
|
Object.entries(config.mcpServers).forEach(([name, serverConfig]) => {
|
|
953
|
-
const
|
|
954
|
-
|
|
820
|
+
const typedConfig = serverConfig;
|
|
821
|
+
// SMART DEFAULTS: Use utility to eliminate manual MCPServerInfo creation
|
|
822
|
+
servers.push(createExternalServerInfo({
|
|
823
|
+
...typedConfig,
|
|
824
|
+
id: name,
|
|
955
825
|
name,
|
|
956
|
-
command: config.command,
|
|
957
|
-
args: config.args,
|
|
958
|
-
env: config.env,
|
|
959
|
-
transport: "stdio",
|
|
960
826
|
description: "Discovered from Claude Desktop",
|
|
961
|
-
|
|
962
|
-
status: "unknown",
|
|
963
|
-
});
|
|
827
|
+
}));
|
|
964
828
|
});
|
|
965
829
|
}
|
|
966
830
|
break; // Found config file, stop searching
|
|
@@ -991,16 +855,12 @@ export class MCPCommandFactory {
|
|
|
991
855
|
if (settings["mcp.servers"]) {
|
|
992
856
|
Object.entries(settings["mcp.servers"]).forEach(([name, serverConfig]) => {
|
|
993
857
|
const config = serverConfig;
|
|
994
|
-
servers.push({
|
|
858
|
+
servers.push(createExternalServerInfo({
|
|
859
|
+
...config,
|
|
860
|
+
id: name,
|
|
995
861
|
name,
|
|
996
|
-
command: config.command || "unknown",
|
|
997
|
-
args: config.args,
|
|
998
|
-
env: config.env,
|
|
999
|
-
transport: "stdio",
|
|
1000
862
|
description: "Discovered from VS Code",
|
|
1001
|
-
|
|
1002
|
-
status: "unknown",
|
|
1003
|
-
});
|
|
863
|
+
}));
|
|
1004
864
|
});
|
|
1005
865
|
}
|
|
1006
866
|
break;
|
|
@@ -288,7 +288,7 @@ export class CLICommandFactory {
|
|
|
288
288
|
let analyticsText = "\n\nš Analytics:\n";
|
|
289
289
|
// Provider and model info
|
|
290
290
|
analyticsText += ` Provider: ${analytics.provider}`;
|
|
291
|
-
// Check for model in multiple locations: result.model, analytics.model, or
|
|
291
|
+
// Check for model in multiple locations: result.model, analytics.model, or available model property
|
|
292
292
|
const modelName = result.model ||
|
|
293
293
|
analytics.model ||
|
|
294
294
|
analytics.modelName;
|
|
@@ -703,6 +703,12 @@ export class CLICommandFactory {
|
|
|
703
703
|
return;
|
|
704
704
|
}
|
|
705
705
|
const sdk = new NeuroLink();
|
|
706
|
+
if (options.debug) {
|
|
707
|
+
logger.debug("CLI Tools configuration:", {
|
|
708
|
+
disableTools: options.disableTools,
|
|
709
|
+
toolsEnabled: !options.disableTools,
|
|
710
|
+
});
|
|
711
|
+
}
|
|
706
712
|
const result = await sdk.generate({
|
|
707
713
|
input: { text: inputText },
|
|
708
714
|
provider: options.provider,
|
|
@@ -3,43 +3,8 @@ import type { Schema } from "ai";
|
|
|
3
3
|
import type { Tool, LanguageModelV1 } from "ai";
|
|
4
4
|
import type { AIProvider, TextGenerationOptions, EnhancedGenerateResult, AnalyticsData, AIProviderName, EvaluationData } from "../core/types.js";
|
|
5
5
|
import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
8
|
-
/**
|
|
9
|
-
* Interface for SDK with in-memory MCP servers and external MCP support
|
|
10
|
-
*/
|
|
11
|
-
export interface NeuroLinkSDK {
|
|
12
|
-
getInMemoryServers?: () => Map<string, {
|
|
13
|
-
server: {
|
|
14
|
-
title?: string;
|
|
15
|
-
description?: string;
|
|
16
|
-
tools?: Map<string, ToolInfo> | Record<string, ToolInfo>;
|
|
17
|
-
};
|
|
18
|
-
category?: string;
|
|
19
|
-
metadata?: UnknownRecord;
|
|
20
|
-
}>;
|
|
21
|
-
externalServerManager?: {
|
|
22
|
-
getAllTools: () => Array<{
|
|
23
|
-
name: string;
|
|
24
|
-
description: string;
|
|
25
|
-
serverId: string;
|
|
26
|
-
isAvailable: boolean;
|
|
27
|
-
inputSchema?: Record<string, unknown>;
|
|
28
|
-
}>;
|
|
29
|
-
executeTool: (serverId: string, toolName: string, params: any) => Promise<any>;
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Interface for tool information in MCP servers
|
|
34
|
-
*/
|
|
35
|
-
interface ToolInfo {
|
|
36
|
-
description?: string;
|
|
37
|
-
inputSchema?: ZodType<JsonValue>;
|
|
38
|
-
parameters?: ZodType<JsonValue>;
|
|
39
|
-
execute: (args: JsonValue) => Promise<JsonValue | ToolResult> | JsonValue | ToolResult;
|
|
40
|
-
isImplemented?: boolean;
|
|
41
|
-
metadata?: UnknownRecord;
|
|
42
|
-
}
|
|
6
|
+
import type { UnknownRecord } from "../types/common.js";
|
|
7
|
+
import type { NeuroLink } from "../neurolink.js";
|
|
43
8
|
/**
|
|
44
9
|
* Abstract base class for all AI providers
|
|
45
10
|
* Tools are integrated as first-class citizens - always available by default
|
|
@@ -50,10 +15,12 @@ export declare abstract class BaseProvider implements AIProvider {
|
|
|
50
15
|
protected readonly defaultTimeout: number;
|
|
51
16
|
protected readonly directTools: {};
|
|
52
17
|
protected mcpTools?: Record<string, Tool>;
|
|
18
|
+
protected customTools?: Map<string, unknown>;
|
|
19
|
+
protected toolExecutor?: (toolName: string, params: unknown) => Promise<unknown>;
|
|
53
20
|
protected sessionId?: string;
|
|
54
21
|
protected userId?: string;
|
|
55
|
-
protected
|
|
56
|
-
constructor(modelName?: string, providerName?: AIProviderName,
|
|
22
|
+
protected neurolink?: NeuroLink;
|
|
23
|
+
constructor(modelName?: string, providerName?: AIProviderName, neurolink?: NeuroLink);
|
|
57
24
|
/**
|
|
58
25
|
* Check if this provider supports tool/function calling
|
|
59
26
|
* Override in subclasses to disable tools for specific providers or models
|
|
@@ -176,4 +143,3 @@ export declare abstract class BaseProvider implements AIProvider {
|
|
|
176
143
|
*/
|
|
177
144
|
static chunkPrompt(prompt: string, maxChunkSize?: number, overlap?: number): string[];
|
|
178
145
|
}
|
|
179
|
-
export {};
|