@juspay/neurolink 7.13.0 โ†’ 7.14.1

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.
Files changed (132) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +89 -25
  3. package/dist/agent/directTools.d.ts +3 -3
  4. package/dist/agent/directTools.js +1 -1
  5. package/dist/cli/commands/mcp.js +67 -207
  6. package/dist/cli/factories/commandFactory.js +7 -1
  7. package/dist/cli/utils/interactiveSetup.js +1 -1
  8. package/dist/config/conversationMemoryConfig.js +2 -1
  9. package/dist/context/ContextManager.js +15 -4
  10. package/dist/context/config.js +5 -1
  11. package/dist/context/utils.js +1 -1
  12. package/dist/core/baseProvider.d.ts +11 -30
  13. package/dist/core/baseProvider.js +268 -42
  14. package/dist/core/conversationMemoryManager.js +3 -2
  15. package/dist/core/dynamicModels.d.ts +14 -14
  16. package/dist/core/dynamicModels.js +1 -1
  17. package/dist/core/evaluation.js +1 -1
  18. package/dist/core/factory.js +1 -1
  19. package/dist/factories/providerFactory.js +5 -11
  20. package/dist/factories/providerRegistry.js +2 -2
  21. package/dist/index.d.ts +5 -4
  22. package/dist/index.js +1 -1
  23. package/dist/lib/agent/directTools.js +1 -1
  24. package/dist/lib/config/conversationMemoryConfig.js +2 -1
  25. package/dist/lib/context/ContextManager.js +15 -4
  26. package/dist/lib/context/config.js +5 -1
  27. package/dist/lib/context/utils.js +1 -1
  28. package/dist/lib/core/baseProvider.d.ts +11 -30
  29. package/dist/lib/core/baseProvider.js +268 -42
  30. package/dist/lib/core/conversationMemoryManager.js +3 -2
  31. package/dist/lib/core/dynamicModels.js +1 -1
  32. package/dist/lib/core/evaluation.js +1 -1
  33. package/dist/lib/core/factory.js +1 -1
  34. package/dist/lib/factories/providerFactory.js +5 -11
  35. package/dist/lib/factories/providerRegistry.js +2 -2
  36. package/dist/lib/index.d.ts +5 -4
  37. package/dist/lib/index.js +1 -1
  38. package/dist/lib/mcp/externalServerManager.d.ts +148 -0
  39. package/dist/lib/mcp/externalServerManager.js +1038 -0
  40. package/dist/lib/mcp/mcpCircuitBreaker.d.ts +184 -0
  41. package/dist/lib/mcp/mcpCircuitBreaker.js +338 -0
  42. package/dist/lib/mcp/mcpClientFactory.d.ts +105 -0
  43. package/dist/lib/mcp/mcpClientFactory.js +421 -0
  44. package/dist/lib/mcp/toolDiscoveryService.d.ts +193 -0
  45. package/dist/lib/mcp/toolDiscoveryService.js +646 -0
  46. package/dist/lib/mcp/toolRegistry.d.ts +15 -11
  47. package/dist/lib/mcp/toolRegistry.js +118 -55
  48. package/dist/lib/models/modelResolver.js +1 -1
  49. package/dist/lib/neurolink.d.ts +139 -43
  50. package/dist/lib/neurolink.js +604 -174
  51. package/dist/lib/providers/googleVertex.d.ts +7 -1
  52. package/dist/lib/providers/googleVertex.js +34 -7
  53. package/dist/lib/providers/huggingFace.js +1 -1
  54. package/dist/lib/providers/mistral.js +3 -3
  55. package/dist/lib/providers/ollama.js +1 -1
  56. package/dist/lib/providers/openAI.d.ts +3 -2
  57. package/dist/lib/providers/openAI.js +2 -2
  58. package/dist/lib/providers/openaiCompatible.d.ts +1 -1
  59. package/dist/lib/providers/openaiCompatible.js +2 -2
  60. package/dist/lib/providers/sagemaker/config.js +1 -1
  61. package/dist/lib/sdk/toolRegistration.d.ts +4 -13
  62. package/dist/lib/sdk/toolRegistration.js +19 -66
  63. package/dist/lib/types/cli.d.ts +0 -1
  64. package/dist/lib/types/cli.js +0 -1
  65. package/dist/lib/types/common.d.ts +1 -2
  66. package/dist/lib/types/common.js +0 -1
  67. package/dist/lib/types/contextTypes.d.ts +1 -1
  68. package/dist/lib/types/contextTypes.js +3 -3
  69. package/dist/lib/types/externalMcp.d.ts +288 -0
  70. package/dist/lib/types/externalMcp.js +7 -0
  71. package/dist/lib/types/generateTypes.d.ts +0 -1
  72. package/dist/lib/types/index.d.ts +2 -2
  73. package/dist/lib/types/index.js +0 -1
  74. package/dist/lib/types/mcpTypes.d.ts +53 -99
  75. package/dist/lib/types/providers.d.ts +0 -1
  76. package/dist/lib/types/providers.js +0 -1
  77. package/dist/lib/types/tools.d.ts +2 -2
  78. package/dist/lib/types/tools.js +2 -2
  79. package/dist/lib/utils/factoryProcessing.js +1 -1
  80. package/dist/lib/utils/mcpDefaults.d.ts +54 -0
  81. package/dist/lib/utils/mcpDefaults.js +125 -0
  82. package/dist/lib/utils/providerConfig.d.ts +1 -1
  83. package/dist/lib/utils/providerConfig.js +2 -2
  84. package/dist/lib/utils/providerHealth.js +6 -6
  85. package/dist/mcp/externalServerManager.d.ts +148 -0
  86. package/dist/mcp/externalServerManager.js +1038 -0
  87. package/dist/mcp/mcpCircuitBreaker.d.ts +184 -0
  88. package/dist/mcp/mcpCircuitBreaker.js +338 -0
  89. package/dist/mcp/mcpClientFactory.d.ts +105 -0
  90. package/dist/mcp/mcpClientFactory.js +421 -0
  91. package/dist/mcp/toolDiscoveryService.d.ts +193 -0
  92. package/dist/mcp/toolDiscoveryService.js +646 -0
  93. package/dist/mcp/toolRegistry.d.ts +15 -11
  94. package/dist/mcp/toolRegistry.js +118 -55
  95. package/dist/models/modelResolver.js +1 -1
  96. package/dist/neurolink.d.ts +139 -43
  97. package/dist/neurolink.js +604 -174
  98. package/dist/providers/googleVertex.d.ts +7 -1
  99. package/dist/providers/googleVertex.js +34 -7
  100. package/dist/providers/huggingFace.js +1 -1
  101. package/dist/providers/mistral.js +3 -3
  102. package/dist/providers/ollama.js +1 -1
  103. package/dist/providers/openAI.d.ts +3 -2
  104. package/dist/providers/openAI.js +2 -2
  105. package/dist/providers/openaiCompatible.d.ts +1 -1
  106. package/dist/providers/openaiCompatible.js +2 -2
  107. package/dist/providers/sagemaker/config.js +1 -1
  108. package/dist/sdk/toolRegistration.d.ts +4 -13
  109. package/dist/sdk/toolRegistration.js +19 -66
  110. package/dist/types/cli.d.ts +0 -1
  111. package/dist/types/cli.js +0 -1
  112. package/dist/types/common.d.ts +1 -2
  113. package/dist/types/common.js +0 -1
  114. package/dist/types/contextTypes.d.ts +1 -1
  115. package/dist/types/contextTypes.js +3 -3
  116. package/dist/types/externalMcp.d.ts +288 -0
  117. package/dist/types/externalMcp.js +7 -0
  118. package/dist/types/generateTypes.d.ts +0 -1
  119. package/dist/types/index.d.ts +2 -2
  120. package/dist/types/index.js +0 -1
  121. package/dist/types/mcpTypes.d.ts +53 -99
  122. package/dist/types/providers.d.ts +0 -1
  123. package/dist/types/providers.js +0 -1
  124. package/dist/types/tools.d.ts +2 -2
  125. package/dist/types/tools.js +2 -2
  126. package/dist/utils/factoryProcessing.js +1 -1
  127. package/dist/utils/mcpDefaults.d.ts +54 -0
  128. package/dist/utils/mcpDefaults.js +125 -0
  129. package/dist/utils/providerConfig.d.ts +1 -1
  130. package/dist/utils/providerConfig.js +2 -2
  131. package/dist/utils/providerHealth.js +6 -6
  132. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## [7.14.1](https://github.com/juspay/neurolink/compare/v7.14.0...v7.14.1) (2025-08-15)
2
+
3
+ ### Bug Fixes
4
+
5
+ - **(mcp):** implement external MCP server integration with real tool execution ([9427a95](https://github.com/juspay/neurolink/commit/9427a95599a829f82e697eaf30388a8f3c899d4f))
6
+
7
+ ## [7.14.0](https://github.com/juspay/neurolink/compare/v7.13.0...v7.14.0) (2025-08-14)
8
+
9
+ ### Features
10
+
11
+ - **(external-mcp):** add external MCP server integration support ([c03dee8](https://github.com/juspay/neurolink/commit/c03dee8dd7a2e06e78bc743d7b3a5cff858395de))
12
+
1
13
  ## [7.13.0](https://github.com/juspay/neurolink/compare/v7.12.0...v7.13.0) (2025-08-14)
2
14
 
3
15
  ### Features
package/README.md CHANGED
@@ -69,7 +69,7 @@ npx @juspay/neurolink sagemaker benchmark my-endpoint # Performance testing
69
69
  - **๐Ÿ›ก๏ธ Error Recovery** - Graceful failures with provider fallback and retry logic
70
70
  - **๐Ÿ“Š Analytics & Evaluation** - Built-in usage tracking and AI-powered quality assessment
71
71
  - **๐ŸŽฏ Real-time Event Monitoring** - EventEmitter integration for progress tracking and debugging
72
- - **๐Ÿ”ง MCP Integration** - Model Context Protocol with 6 built-in tools and 58+ discoverable servers
72
+ - **๐Ÿ”ง External MCP Integration** - Model Context Protocol with 6 built-in tools + full external MCP server support
73
73
  - **๐Ÿš€ Lighthouse Integration** - Unified tool registration API supporting both object and array formats for seamless Lighthouse tool import
74
74
 
75
75
  ---
@@ -118,6 +118,28 @@ npx @juspay/neurolink status # Check all providers
118
118
  ```bash
119
119
  # SDK Installation for using in your typescript projects
120
120
  npm install @juspay/neurolink
121
+
122
+ # ๐Ÿ†• NEW: External MCP Server Integration Quick Test
123
+ node -e "
124
+ const { NeuroLink } = require('@juspay/neurolink');
125
+ (async () => {
126
+ const neurolink = new NeuroLink();
127
+
128
+ // Add external filesystem MCP server
129
+ await neurolink.addExternalMCPServer('filesystem', {
130
+ command: 'npx',
131
+ args: ['-y', '@modelcontextprotocol/server-filesystem', '/tmp'],
132
+ transport: 'stdio'
133
+ });
134
+
135
+ // External tools automatically available in generate()
136
+ const result = await neurolink.generate({
137
+ input: { text: 'List files in the current directory' }
138
+ });
139
+ console.log('๐ŸŽ‰ External MCP integration working!');
140
+ console.log(result.content);
141
+ })();
142
+ "
121
143
  ```
122
144
 
123
145
  ### Basic Usage
@@ -327,41 +349,56 @@ console.log(productData.name, productData.price, productData.features);
327
349
  - โšก **Automatic Fallback** - Never fail when providers are down, intelligent provider switching
328
350
  - ๐Ÿ–ฅ๏ธ **CLI + SDK** - Use from command line or integrate programmatically with TypeScript support
329
351
  - ๐Ÿ›ก๏ธ **Production Ready** - Enterprise-grade error handling, performance optimization, extracted from production
330
- - โœ… **MCP Integration** - Model Context Protocol with working built-in tools and 58+ discoverable external servers
352
+ - โœ… **External MCP Integration** - Model Context Protocol with built-in tools + full external MCP server support
331
353
  - ๐Ÿ” **Smart Model Resolution** - Fuzzy matching, aliases, and capability-based search across all providers
332
354
  - ๐Ÿ  **Local AI Support** - Run completely offline with Ollama or through LiteLLM proxy
333
355
  - ๐ŸŒ **Universal Model Access** - Direct providers + 100,000+ models via Hugging Face + 100+ models via LiteLLM
334
356
  - ๐Ÿง  **Automatic Context Summarization** - Stateful, long-running conversations with automatic history summarization.
335
357
  - ๐Ÿ“Š **Analytics & Evaluation** - Built-in usage tracking and AI-powered quality assessment
336
358
 
337
- ## ๐Ÿ› ๏ธ MCP Integration Status โœ… **BUILT-IN TOOLS WORKING**
359
+ ## ๐Ÿ› ๏ธ External MCP Integration Status โœ… **PRODUCTION READY**
338
360
 
339
- | Component | Status | Description |
340
- | ------------------- | ------------------ | -------------------------------------------------------- |
341
- | Built-in Tools | โœ… **Working** | 6 core tools fully functional across all providers |
342
- | SDK Custom Tools | โœ… **Working** | Register custom tools programmatically |
343
- | External Discovery | ๐Ÿ” **Discovery** | 58+ MCP servers discovered from AI tools ecosystem |
344
- | Tool Execution | โœ… **Working** | Real-time AI tool calling with built-in tools |
345
- | **External Tools** | ๐Ÿšง **Development** | Manual config needs one-line fix, activation in progress |
346
- | **CLI Integration** | โœ… **READY** | **Production-ready with built-in tools** |
347
- | External Activation | ๐Ÿ”ง **Development** | Discovery complete, activation protocol in progress |
361
+ | Component | Status | Description |
362
+ | ---------------------- | -------------- | ---------------------------------------------------------------- |
363
+ | Built-in Tools | โœ… **Working** | 6 core tools fully functional across all providers |
364
+ | SDK Custom Tools | โœ… **Working** | Register custom tools programmatically |
365
+ | **External MCP Tools** | โœ… **Working** | **Full external MCP server support with dynamic tool discovery** |
366
+ | Tool Execution | โœ… **Working** | Real-time AI tool calling with all tool types |
367
+ | **Streaming Support** | โœ… **Working** | **External MCP tools work with streaming generation** |
368
+ | **Multi-Provider** | โœ… **Working** | **External tools work across all AI providers** |
369
+ | **CLI Integration** | โœ… **READY** | **Production-ready with external MCP support** |
348
370
 
349
- ### โœ… Quick MCP Test (v1.7.1)
371
+ ### โœ… External MCP Integration Demo
350
372
 
351
373
  ```bash
352
374
  # Test built-in tools (works immediately)
353
375
  npx @juspay/neurolink generate "What time is it?" --debug
354
376
 
355
- # Disable tools for pure text generation
356
- npx @juspay/neurolink generate "Write a poem" --disable-tools
377
+ # ๐Ÿ†• NEW: External MCP server integration (SDK)
378
+ import { NeuroLink } from '@juspay/neurolink';
379
+
380
+ const neurolink = new NeuroLink();
381
+
382
+ // Add external MCP server (e.g., Bitbucket)
383
+ await neurolink.addExternalMCPServer('bitbucket', {
384
+ command: 'npx',
385
+ args: ['-y', '@nexus2520/bitbucket-mcp-server'],
386
+ transport: 'stdio',
387
+ env: {
388
+ BITBUCKET_USERNAME: process.env.BITBUCKET_USERNAME,
389
+ BITBUCKET_TOKEN: process.env.BITBUCKET_TOKEN,
390
+ BITBUCKET_BASE_URL: 'https://bitbucket.example.com'
391
+ }
392
+ });
393
+
394
+ // Use external MCP tools in generation
395
+ const result = await neurolink.generate({
396
+ input: { text: 'Get pull request #123 details from the main repository' },
397
+ disableTools: false // External MCP tools automatically available
398
+ });
357
399
 
358
400
  # Discover available MCP servers
359
401
  npx @juspay/neurolink mcp discover --format table
360
-
361
- # Install popular MCP servers (NEW: Bitbucket support added!)
362
- npx @juspay/neurolink mcp install filesystem
363
- npx @juspay/neurolink mcp install github
364
- npx @juspay/neurolink mcp install bitbucket # ๐Ÿ†• NEW
365
402
  ```
366
403
 
367
404
  ### ๐Ÿ”ง SDK Custom Tool Registration (NEW!)
@@ -663,16 +700,43 @@ npx @juspay/neurolink generate "Hello!" --provider openai-compatible
663
700
  - **Extensibility**: Connect external tools and services via MCP protocol
664
701
  - **๐Ÿ†• Dynamic Server Management**: Programmatically add MCP servers at runtime
665
702
 
666
- ### ๐Ÿ”ง Programmatic MCP Server Management [Coming Soon]
703
+ ### ๐Ÿ”ง External MCP Server Management โœ… **AVAILABLE NOW**
667
704
 
668
- **Note**: External MCP server activation is in development. Currently available:
705
+ **External MCP integration is now production-ready:**
669
706
 
670
707
  - โœ… 6 built-in tools working across all providers
671
708
  - โœ… SDK custom tool registration
672
- - ๐Ÿ” MCP server discovery (58+ servers found)
673
- - ๐Ÿšง External server activation (one-line fix pending)
709
+ - โœ… **External MCP server management** (add, remove, list, test servers)
710
+ - โœ… **Dynamic tool discovery** (automatic tool registration from external servers)
711
+ - โœ… **Multi-provider support** (external tools work with all AI providers)
712
+ - โœ… **Streaming integration** (external tools work with real-time streaming)
713
+ - โœ… **Enhanced tool tracking** (proper parameter extraction and execution logging)
674
714
 
675
- Manual MCP configuration (`.mcp-config.json`) support coming soon.
715
+ ```typescript
716
+ // Complete external MCP server API
717
+ const neurolink = new NeuroLink();
718
+
719
+ // Server management
720
+ await neurolink.addExternalMCPServer(serverId, config);
721
+ await neurolink.removeExternalMCPServer(serverId);
722
+ const servers = neurolink.listExternalMCPServers();
723
+ const server = neurolink.getExternalMCPServer(serverId);
724
+
725
+ // Tool management
726
+ const tools = neurolink.getExternalMCPTools();
727
+ const serverTools = neurolink.getExternalMCPServerTools(serverId);
728
+
729
+ // Direct tool execution
730
+ const result = await neurolink.executeExternalMCPTool(
731
+ serverId,
732
+ toolName,
733
+ params,
734
+ );
735
+
736
+ // Statistics and monitoring
737
+ const stats = neurolink.getExternalMCPStatistics();
738
+ await neurolink.shutdownExternalMCPServers();
739
+ ```
676
740
 
677
741
  ## ๐Ÿค Contributing
678
742
 
@@ -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 any remaining non-safe characters except Math functions
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("")
@@ -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", "ws"],
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", "ws"],
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 rawMcpStatus = await sdk.getMCPStatus();
397
- const mcpStatus = convertMCPStatusForCLI(rawMcpStatus, sdk);
312
+ const mcpStatus = await sdk.getMCPStatus();
313
+ const allServers = await sdk.listMCPServers();
398
314
  if (spinner) {
399
- spinner.succeed(`Found ${mcpStatus.servers.length} MCP servers`);
315
+ spinner.succeed(`Found ${allServers.length} MCP servers`);
400
316
  }
401
- if (mcpStatus.servers.length === 0) {
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 && argv.format === "compact") {
412
- mcpStatus.servers.forEach((server) => {
413
- const status = server.connected ? chalk.green("โœ“") : chalk.red("โœ—");
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
- for (const server of mcpStatus.servers) {
421
- const status = server.connected
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
- // Create server configuration
478
- const config = {
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: ${config.name}`);
513
- logger.always(`Command: ${config.command}`);
514
- if (config.args?.length) {
515
- logger.always(`Args: ${config.args.join(" ")}`);
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 (config.env) {
518
- logger.always(`Environment: ${Object.keys(config.env).length} variables`);
413
+ if (serverInfo.env) {
414
+ logger.always(`Environment: ${Object.keys(serverInfo.env).length} variables`);
519
415
  }
520
- logger.always(`Transport: ${config.transport}`);
521
- logger.always(`Description: ${config.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 = convertMCPStatusForCLI(rawStatus, sdk);
527
- const installedServer = status.servers.find((s) => s.name === serverName);
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
- // Create server configuration
575
- const config = {
470
+ const serverInfo = createExternalServerInfo({
471
+ id: name,
576
472
  name,
577
473
  command,
578
474
  args: argv.args,
579
475
  env,
580
- transport: (argv.transport === "websocket"
581
- ? "ws"
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: ${config.name}`);
607
- logger.always(`Command: ${config.command}`);
608
- if (config.args?.length) {
609
- logger.always(`Args: ${config.args.join(" ")}`);
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 (config.env) {
612
- logger.always(`Environment: ${Object.keys(config.env).length} variables`);
492
+ if (serverInfo.env) {
493
+ logger.always(`Environment: ${Object.keys(serverInfo.env).length} variables`);
613
494
  }
614
- logger.always(`Transport: ${config.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
- const mcpStatus = convertMCPStatusForCLI(rawMcpStatus, sdk);
633
- let serversToTest = mcpStatus.servers;
513
+ let serversToTest = await sdk.listMCPServers();
634
514
  if (targetServer) {
635
- serversToTest = mcpStatus.servers.filter((s) => s.name === targetServer);
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 rawMcpStatus = await sdk.getMCPStatus();
715
- const mcpStatus = convertMCPStatusForCLI(rawMcpStatus, sdk);
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 (!server.connected) {
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 rawMcpStatus = await sdk.getMCPStatus();
819
- const mcpStatus = convertMCPStatusForCLI(rawMcpStatus, sdk);
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
- await sdk.addInMemoryMCPServer(server.name, {
911
- server: {
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 config = serverConfig;
954
- servers.push({
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
- installed: false,
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
- installed: false,
1002
- status: "unknown",
1003
- });
863
+ }));
1004
864
  });
1005
865
  }
1006
866
  break;