@juspay/neurolink 7.14.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 (111) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/agent/directTools.d.ts +3 -3
  3. package/dist/agent/directTools.js +1 -1
  4. package/dist/cli/commands/mcp.js +67 -207
  5. package/dist/cli/factories/commandFactory.js +7 -1
  6. package/dist/cli/utils/interactiveSetup.js +1 -1
  7. package/dist/core/baseProvider.d.ts +6 -40
  8. package/dist/core/baseProvider.js +102 -75
  9. package/dist/core/dynamicModels.d.ts +14 -14
  10. package/dist/core/dynamicModels.js +1 -1
  11. package/dist/core/evaluation.js +1 -1
  12. package/dist/core/factory.js +1 -12
  13. package/dist/index.d.ts +5 -4
  14. package/dist/index.js +1 -1
  15. package/dist/lib/agent/directTools.js +1 -1
  16. package/dist/lib/core/baseProvider.d.ts +6 -40
  17. package/dist/lib/core/baseProvider.js +102 -75
  18. package/dist/lib/core/dynamicModels.js +1 -1
  19. package/dist/lib/core/evaluation.js +1 -1
  20. package/dist/lib/core/factory.js +1 -12
  21. package/dist/lib/index.d.ts +5 -4
  22. package/dist/lib/index.js +1 -1
  23. package/dist/lib/mcp/externalServerManager.d.ts +46 -13
  24. package/dist/lib/mcp/externalServerManager.js +393 -32
  25. package/dist/lib/mcp/mcpClientFactory.d.ts +5 -4
  26. package/dist/lib/mcp/mcpClientFactory.js +8 -3
  27. package/dist/lib/mcp/toolDiscoveryService.d.ts +1 -0
  28. package/dist/lib/mcp/toolDiscoveryService.js +76 -8
  29. package/dist/lib/mcp/toolRegistry.d.ts +15 -11
  30. package/dist/lib/mcp/toolRegistry.js +118 -55
  31. package/dist/lib/models/modelResolver.js +1 -1
  32. package/dist/lib/neurolink.d.ts +32 -31
  33. package/dist/lib/neurolink.js +173 -210
  34. package/dist/lib/providers/googleVertex.d.ts +6 -0
  35. package/dist/lib/providers/googleVertex.js +11 -0
  36. package/dist/lib/providers/huggingFace.js +1 -1
  37. package/dist/lib/providers/mistral.js +3 -3
  38. package/dist/lib/providers/ollama.js +1 -1
  39. package/dist/lib/providers/openAI.d.ts +3 -2
  40. package/dist/lib/providers/openAI.js +2 -2
  41. package/dist/lib/providers/openaiCompatible.d.ts +1 -1
  42. package/dist/lib/providers/openaiCompatible.js +2 -2
  43. package/dist/lib/providers/sagemaker/config.js +1 -1
  44. package/dist/lib/sdk/toolRegistration.d.ts +4 -13
  45. package/dist/lib/sdk/toolRegistration.js +19 -66
  46. package/dist/lib/types/cli.d.ts +0 -1
  47. package/dist/lib/types/cli.js +0 -1
  48. package/dist/lib/types/common.d.ts +1 -2
  49. package/dist/lib/types/common.js +0 -1
  50. package/dist/lib/types/contextTypes.d.ts +1 -1
  51. package/dist/lib/types/contextTypes.js +3 -3
  52. package/dist/lib/types/externalMcp.d.ts +6 -0
  53. package/dist/lib/types/externalMcp.js +1 -0
  54. package/dist/lib/types/index.d.ts +2 -3
  55. package/dist/lib/types/index.js +0 -1
  56. package/dist/lib/types/mcpTypes.d.ts +53 -99
  57. package/dist/lib/types/providers.d.ts +0 -1
  58. package/dist/lib/types/providers.js +0 -1
  59. package/dist/lib/types/tools.d.ts +2 -2
  60. package/dist/lib/types/tools.js +2 -2
  61. package/dist/lib/utils/factoryProcessing.js +1 -1
  62. package/dist/lib/utils/mcpDefaults.d.ts +54 -0
  63. package/dist/lib/utils/mcpDefaults.js +125 -0
  64. package/dist/lib/utils/providerConfig.d.ts +1 -1
  65. package/dist/lib/utils/providerConfig.js +2 -2
  66. package/dist/lib/utils/providerHealth.js +6 -6
  67. package/dist/mcp/externalServerManager.d.ts +46 -13
  68. package/dist/mcp/externalServerManager.js +393 -32
  69. package/dist/mcp/mcpClientFactory.d.ts +5 -4
  70. package/dist/mcp/mcpClientFactory.js +8 -3
  71. package/dist/mcp/toolDiscoveryService.d.ts +1 -0
  72. package/dist/mcp/toolDiscoveryService.js +76 -8
  73. package/dist/mcp/toolRegistry.d.ts +15 -11
  74. package/dist/mcp/toolRegistry.js +118 -55
  75. package/dist/models/modelResolver.js +1 -1
  76. package/dist/neurolink.d.ts +32 -31
  77. package/dist/neurolink.js +173 -210
  78. package/dist/providers/googleVertex.d.ts +6 -0
  79. package/dist/providers/googleVertex.js +11 -0
  80. package/dist/providers/huggingFace.js +1 -1
  81. package/dist/providers/mistral.js +3 -3
  82. package/dist/providers/ollama.js +1 -1
  83. package/dist/providers/openAI.d.ts +3 -2
  84. package/dist/providers/openAI.js +2 -2
  85. package/dist/providers/openaiCompatible.d.ts +1 -1
  86. package/dist/providers/openaiCompatible.js +2 -2
  87. package/dist/providers/sagemaker/config.js +1 -1
  88. package/dist/sdk/toolRegistration.d.ts +4 -13
  89. package/dist/sdk/toolRegistration.js +19 -66
  90. package/dist/types/cli.d.ts +0 -1
  91. package/dist/types/cli.js +0 -1
  92. package/dist/types/common.d.ts +1 -2
  93. package/dist/types/common.js +0 -1
  94. package/dist/types/contextTypes.d.ts +1 -1
  95. package/dist/types/contextTypes.js +3 -3
  96. package/dist/types/externalMcp.d.ts +6 -0
  97. package/dist/types/externalMcp.js +1 -0
  98. package/dist/types/index.d.ts +2 -3
  99. package/dist/types/index.js +0 -1
  100. package/dist/types/mcpTypes.d.ts +53 -99
  101. package/dist/types/providers.d.ts +0 -1
  102. package/dist/types/providers.js +0 -1
  103. package/dist/types/tools.d.ts +2 -2
  104. package/dist/types/tools.js +2 -2
  105. package/dist/utils/factoryProcessing.js +1 -1
  106. package/dist/utils/mcpDefaults.d.ts +54 -0
  107. package/dist/utils/mcpDefaults.js +125 -0
  108. package/dist/utils/providerConfig.d.ts +1 -1
  109. package/dist/utils/providerConfig.js +2 -2
  110. package/dist/utils/providerHealth.js +6 -6
  111. package/package.json +1 -1
@@ -2,14 +2,15 @@ import type { ZodType, ZodTypeDef } from "zod";
2
2
  import { type Schema, type LanguageModelV1 } from "ai";
3
3
  import { AIProviderName } from "../core/types.js";
4
4
  import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
5
- import { BaseProvider, type NeuroLinkSDK } from "../core/baseProvider.js";
5
+ import { BaseProvider } from "../core/baseProvider.js";
6
+ import type { NeuroLink } from "../neurolink.js";
6
7
  /**
7
8
  * OpenAI Provider v2 - BaseProvider Implementation
8
9
  * Migrated to use factory pattern with exact Google AI provider pattern
9
10
  */
10
11
  export declare class OpenAIProvider extends BaseProvider {
11
12
  private model;
12
- constructor(modelName?: string, sdk?: NeuroLinkSDK);
13
+ constructor(modelName?: string, neurolink?: NeuroLink);
13
14
  protected getProviderName(): AIProviderName;
14
15
  protected getDefaultModel(): string;
15
16
  /**
@@ -21,8 +21,8 @@ const getOpenAIModel = () => {
21
21
  */
22
22
  export class OpenAIProvider extends BaseProvider {
23
23
  model;
24
- constructor(modelName, sdk) {
25
- super(modelName || getOpenAIModel(), AIProviderName.OPENAI, sdk);
24
+ constructor(modelName, neurolink) {
25
+ super(modelName || getOpenAIModel(), AIProviderName.OPENAI, neurolink);
26
26
  // Set OpenAI API key as environment variable (required by @ai-sdk/openai)
27
27
  process.env.OPENAI_API_KEY = getOpenAIApiKey();
28
28
  // Initialize model
@@ -5,7 +5,7 @@ import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
5
5
  import { BaseProvider } from "../core/baseProvider.js";
6
6
  /**
7
7
  * OpenAI Compatible Provider - BaseProvider Implementation
8
- * Provides access to any OpenAI-compatible endpoint (OpenRouter, vLLM, LiteLLM, etc.)
8
+ * Provides access to one of the OpenAI-compatible endpoint (OpenRouter, vLLM, LiteLLM, etc.)
9
9
  */
10
10
  export declare class OpenAICompatibleProvider extends BaseProvider {
11
11
  private model?;
@@ -35,7 +35,7 @@ const getDefaultOpenAICompatibleModel = () => {
35
35
  };
36
36
  /**
37
37
  * OpenAI Compatible Provider - BaseProvider Implementation
38
- * Provides access to any OpenAI-compatible endpoint (OpenRouter, vLLM, LiteLLM, etc.)
38
+ * Provides access to one of the OpenAI-compatible endpoint (OpenRouter, vLLM, LiteLLM, etc.)
39
39
  */
40
40
  export class OpenAICompatibleProvider extends BaseProvider {
41
41
  model;
@@ -47,7 +47,7 @@ export class OpenAICompatibleProvider extends BaseProvider {
47
47
  // Initialize OpenAI Compatible configuration
48
48
  this.config = getOpenAICompatibleConfig();
49
49
  // Create OpenAI SDK instance configured for custom endpoint
50
- // This allows us to use any OpenAI-compatible API by simply changing the baseURL
50
+ // This allows us to use OpenAI-compatible API by simply changing the baseURL
51
51
  this.customOpenAI = createOpenAI({
52
52
  baseURL: this.config.baseURL,
53
53
  apiKey: this.config.apiKey,
@@ -168,7 +168,7 @@ function checkAccessKeyPresence(accessKeyId) {
168
168
  if (!accessKeyId || accessKeyId.trim() === "") {
169
169
  return { isValid: false };
170
170
  }
171
- // Accept any non-empty string - let AWS handle validation
171
+ // Accept non-empty string - let AWS handle validation
172
172
  // This prevents attackers from learning about valid formats
173
173
  return { isValid: true };
174
174
  }
@@ -3,9 +3,8 @@
3
3
  * Simple interface for developers to register custom tools
4
4
  */
5
5
  import { z } from "zod";
6
- import type { Tool } from "ai";
7
6
  import { logger } from "../utils/logger.js";
8
- import type { InMemoryMCPServerConfig, InMemoryToolInfo } from "../types/mcpTypes.js";
7
+ import type { MCPServerInfo, MCPServerCategory } from "../types/mcpTypes.js";
9
8
  import type { ToolArgs, ToolContext as CoreToolContext, ToolResult, SimpleTool as CoreSimpleTool } from "../types/tools.js";
10
9
  import type { JsonValue } from "../types/common.js";
11
10
  /**
@@ -76,24 +75,16 @@ export interface SimpleTool<TArgs = ToolArgs, TResult = JsonValue> extends Omit<
76
75
  };
77
76
  }
78
77
  /**
79
- * Converts a SimpleTool to Vercel AI SDK format
80
- */
81
- export declare function convertToAISDKTool(name: string, simpleTool: SimpleTool): Tool;
82
- /**
83
- * Converts a SimpleTool to MCP tool format
84
- */
85
- export declare function convertToMCPTool(simpleTool: SimpleTool): InMemoryToolInfo;
86
- /**
87
- * Creates an in-memory MCP server configuration from a set of tools
78
+ * Creates a MCPServerInfo from a set of tools
88
79
  */
89
80
  export declare function createMCPServerFromTools(serverId: string, tools: Record<string, SimpleTool>, metadata?: {
90
81
  title?: string;
91
82
  description?: string;
92
- category?: string;
83
+ category?: MCPServerCategory;
93
84
  version?: string;
94
85
  author?: string;
95
86
  [key: string]: JsonValue | undefined;
96
- }): InMemoryMCPServerConfig;
87
+ }): MCPServerInfo;
97
88
  /**
98
89
  * Helper to create a tool with type safety
99
90
  */
@@ -2,9 +2,8 @@
2
2
  * NeuroLink SDK Tool Registration API
3
3
  * Simple interface for developers to register custom tools
4
4
  */
5
- import { z } from "zod";
6
- import { tool as createAISDKTool } from "ai";
7
5
  import { logger } from "../utils/logger.js";
6
+ import { createMCPServerInfo } from "../utils/mcpDefaults.js";
8
7
  /**
9
8
  * Configuration constants for tool validation
10
9
  */
@@ -65,75 +64,29 @@ const VALIDATION_CONFIG = {
65
64
  ].map((pattern) => new RegExp(pattern.replace(/_/g, "[_-]"), "i")),
66
65
  };
67
66
  /**
68
- * Converts a SimpleTool to Vercel AI SDK format
69
- */
70
- export function convertToAISDKTool(name, simpleTool) {
71
- return createAISDKTool({
72
- description: simpleTool.description,
73
- parameters: simpleTool.parameters || z.object({}),
74
- execute: async (args) => {
75
- try {
76
- // Create a minimal context for standalone execution
77
- const context = {
78
- sessionId: `tool-${name}-${Date.now()}`,
79
- logger,
80
- };
81
- const result = await simpleTool.execute(args, context);
82
- return result;
83
- }
84
- catch (error) {
85
- logger.error(`Tool ${name} execution failed:`, error);
86
- throw error;
87
- }
88
- },
89
- });
90
- }
91
- /**
92
- * Converts a SimpleTool to MCP tool format
93
- */
94
- export function convertToMCPTool(simpleTool) {
95
- return {
96
- description: simpleTool.description,
97
- execute: async (params) => {
98
- const typedParams = params;
99
- try {
100
- const result = await simpleTool.execute(typedParams);
101
- return {
102
- success: true,
103
- data: result,
104
- };
105
- }
106
- catch (error) {
107
- const errorMessage = error instanceof Error ? error.message : String(error);
108
- logger.error("MCP tool execution failed:", error);
109
- return {
110
- success: false,
111
- error: errorMessage,
112
- };
113
- }
114
- },
115
- inputSchema: simpleTool.parameters,
116
- isImplemented: true,
117
- metadata: simpleTool.metadata,
118
- };
119
- }
120
- /**
121
- * Creates an in-memory MCP server configuration from a set of tools
67
+ * Creates a MCPServerInfo from a set of tools
122
68
  */
123
69
  export function createMCPServerFromTools(serverId, tools, metadata) {
124
- const mcpTools = {};
70
+ const mcpTools = [];
125
71
  for (const [name, tool] of Object.entries(tools)) {
126
- mcpTools[name] = convertToMCPTool(tool);
72
+ mcpTools.push({
73
+ name,
74
+ description: tool.description || name,
75
+ inputSchema: {},
76
+ });
127
77
  }
128
- return {
129
- server: {
130
- title: metadata?.title || serverId,
131
- description: metadata?.description,
132
- tools: mcpTools,
133
- },
78
+ // SMART DEFAULTS: Use utility to eliminate manual MCPServerInfo creation
79
+ return createMCPServerInfo({
80
+ id: serverId,
81
+ name: metadata?.title || serverId,
82
+ tools: mcpTools,
83
+ description: metadata?.description || serverId,
134
84
  category: metadata?.category,
135
- metadata: metadata || {},
136
- };
85
+ // Detect category based on context if not provided
86
+ isExternal: metadata?.category === "external",
87
+ isBuiltIn: metadata?.category === "built-in",
88
+ isCustomTool: false,
89
+ });
137
90
  }
138
91
  /**
139
92
  * Helper to create a tool with type safety
@@ -1,6 +1,5 @@
1
1
  /**
2
2
  * CLI-specific type definitions for NeuroLink
3
- * Replaces 'any' types in CLI commands and arguments
4
3
  */
5
4
  import type { UnknownRecord, JsonValue } from "./common.js";
6
5
  import type { AnalyticsData, EvaluationData, TokenUsage } from "./providers.js";
package/dist/types/cli.js CHANGED
@@ -1,6 +1,5 @@
1
1
  /**
2
2
  * CLI-specific type definitions for NeuroLink
3
- * Replaces 'any' types in CLI commands and arguments
4
3
  */
5
4
  /**
6
5
  * Type guard for generate result
@@ -1,9 +1,8 @@
1
1
  /**
2
2
  * Common utility types for NeuroLink
3
- * These types provide type-safe alternatives to 'any' usage
4
3
  */
5
4
  /**
6
- * Type-safe unknown value - use instead of 'any' when type is truly unknown
5
+ * Type-safe unknown value - use when type is truly unknown
7
6
  */
8
7
  export type Unknown = unknown;
9
8
  /**
@@ -1,6 +1,5 @@
1
1
  /**
2
2
  * Common utility types for NeuroLink
3
- * These types provide type-safe alternatives to 'any' usage
4
3
  */
5
4
  /**
6
5
  * Type guard to check if value is Error
@@ -162,7 +162,7 @@ export declare class ContextConverter {
162
162
  */
163
163
  static convertBusinessContext(legacyContext: Record<string, unknown>, domainType: string, options?: ContextConversionOptions): ExecutionContext;
164
164
  /**
165
- * Create execution context for any domain
165
+ * Create execution context for required domain
166
166
  */
167
167
  static createDomainContext(domainType: string, domainData: Record<string, unknown>, sessionInfo?: {
168
168
  sessionId?: string;
@@ -327,7 +327,7 @@ export class ContextConverter {
327
327
  projectId: legacyContext.projectId,
328
328
  }
329
329
  : {}),
330
- // Include any additional custom data
330
+ // Include all additional custom data
331
331
  ...this.extractCustomData(legacyContext),
332
332
  },
333
333
  },
@@ -342,7 +342,7 @@ export class ContextConverter {
342
342
  };
343
343
  }
344
344
  /**
345
- * Create execution context for any domain
345
+ * Create execution context for required domain
346
346
  */
347
347
  static createDomainContext(domainType, domainData, sessionInfo = {}) {
348
348
  return {
@@ -385,7 +385,7 @@ export class ContextConverter {
385
385
  ...(config.additionalFields || []),
386
386
  ]);
387
387
  }
388
- // Remove any fields that should be included despite being in the exclude list
388
+ // Remove filtered fields that should be included despite being in the exclude list
389
389
  if (config.includeFields) {
390
390
  config.includeFields.forEach((field) => fieldsToExclude.delete(field));
391
391
  }
@@ -66,6 +66,12 @@ export interface ExternalMCPServerInstance {
66
66
  maxReconnectAttempts: number;
67
67
  /** Available tools from this server */
68
68
  tools: Map<string, ExternalMCPToolInfo>;
69
+ /** Cached tools array for ZERO conversion - MCP format */
70
+ toolsArray?: Array<{
71
+ name: string;
72
+ description: string;
73
+ inputSchema?: object;
74
+ }>;
69
75
  /** Server capabilities reported by MCP */
70
76
  capabilities?: Record<string, JsonValue>;
71
77
  /** Health monitoring timer */
@@ -4,3 +4,4 @@
4
4
  * Following MCP 2024-11-05 specification
5
5
  */
6
6
  export {};
7
+ // Note: In Phase 2, these interfaces will be consolidated into MCPServerInfo
@@ -1,6 +1,5 @@
1
1
  /**
2
2
  * Centralized type exports for NeuroLink
3
- * Provides type-safe alternatives to 'any' usage throughout the codebase
4
3
  */
5
4
  export * from "./common.js";
6
5
  export * from "./tools.js";
@@ -10,8 +9,8 @@ export type { Unknown, UnknownRecord, UnknownArray, JsonValue, JsonObject, JsonA
10
9
  export type { ToolArgs, ToolContext, ToolResult, ToolDefinition, SimpleTool, AvailableTool, ToolExecution, } from "./tools.js";
11
10
  export type { AISDKModel, ProviderError, TokenUsage, AnalyticsData, EvaluationData, ProviderConfig, } from "./providers.js";
12
11
  export type { BaseCommandArgs, GenerateCommandArgs, MCPCommandArgs, ModelsCommandArgs, CommandResult, GenerateResult, StreamChunk, } from "./cli.js";
13
- export type { MCPTransportType, MCPServerStatus, MCPDiscoveredServer, MCPConnectedServer, MCPServerConfig, MCPToolInfo, MCPServerMetadata, MCPToolMetadata, MCPServerRegistryEntry, } from "./mcpTypes.js";
14
- export type { ExternalMCPServerConfig, ExternalMCPServerInstance, ExternalMCPServerStatus, ExternalMCPToolInfo, ExternalMCPServerHealth, ExternalMCPConfigValidation, ExternalMCPOperationResult, ExternalMCPToolContext, ExternalMCPToolResult, ExternalMCPServerEvents, ExternalMCPManagerConfig, } from "./externalMcp.js";
12
+ export type { MCPTransportType, MCPServerConnectionStatus, MCPServerCategory, MCPServerStatus, MCPDiscoveredServer, MCPConnectedServer, MCPToolInfo, MCPExecutableTool, MCPServerMetadata, MCPToolMetadata, MCPServerRegistryEntry, } from "./mcpTypes.js";
13
+ export type { ExternalMCPServerInstance, ExternalMCPServerStatus, ExternalMCPToolInfo, ExternalMCPServerHealth, ExternalMCPConfigValidation, ExternalMCPOperationResult, ExternalMCPToolContext, ExternalMCPToolResult, ExternalMCPServerEvents, ExternalMCPManagerConfig, } from "./externalMcp.js";
15
14
  export type { ModelCapability, ModelUseCase, ModelFilter, ModelResolutionContext, ModelStats, ModelPricing, } from "./providers.js";
16
15
  export type { ToolCallResults, ToolCalls, StreamAnalyticsData, } from "./streamTypes.js";
17
16
  export type { DomainType, DomainConfig, DomainTemplate, DomainConfigOptions, DomainEvaluationCriteria, DomainValidationRule, } from "./domainTypes.js";
@@ -1,6 +1,5 @@
1
1
  /**
2
2
  * Centralized type exports for NeuroLink
3
- * Provides type-safe alternatives to 'any' usage throughout the codebase
4
3
  */
5
4
  // Common utility types
6
5
  export * from "./common.js";
@@ -6,93 +6,57 @@ import type { JsonValue, JsonObject } from "./common.js";
6
6
  /**
7
7
  * In-memory MCP server configuration
8
8
  */
9
- export interface InMemoryMCPServerConfig {
10
- /**
11
- * The actual server instance with tools
12
- */
13
- server: {
14
- /**
15
- * Server title for display
16
- */
17
- title?: string;
18
- /**
19
- * Map of tool name to tool implementation
20
- */
21
- tools: Map<string, InMemoryToolInfo> | Record<string, InMemoryToolInfo>;
22
- /**
23
- * Optional server description
24
- */
25
- description?: string;
26
- };
27
- /**
28
- * Category for grouping tools
29
- */
30
- category?: string;
31
- /**
32
- * Metadata about the server
33
- */
34
- metadata?: {
35
- provider?: string;
36
- version?: string;
37
- author?: string;
38
- [key: string]: unknown;
39
- };
40
- }
41
9
  /**
42
- * In-memory tool information
10
+ * MCP Transport Types - Maximally Reusable
43
11
  */
44
- export interface InMemoryToolInfo {
45
- /**
46
- * Tool description
47
- */
48
- description: string;
49
- /**
50
- * Tool execution function
51
- */
52
- execute: (params: unknown) => Promise<InMemoryToolResult> | InMemoryToolResult;
53
- /**
54
- * Input parameter schema (Zod or JSON Schema)
55
- */
56
- inputSchema?: unknown;
57
- /**
58
- * Whether the tool is implemented (default: true)
59
- */
60
- isImplemented?: boolean;
61
- /**
62
- * Optional metadata
63
- */
64
- metadata?: Record<string, unknown>;
65
- }
12
+ export type MCPTransportType = "stdio" | "sse" | "websocket" | "ws" | "tcp" | "unix";
66
13
  /**
67
- * Result from in-memory tool execution
14
+ * MCP Server Connection Status - Individual server status
68
15
  */
69
- export interface InMemoryToolResult {
70
- /**
71
- * Whether execution was successful
72
- */
73
- success: boolean;
74
- /**
75
- * Result data if successful
76
- */
77
- data?: unknown;
78
- /**
79
- * Error message if failed
80
- */
16
+ export type MCPServerConnectionStatus = "initializing" | "connecting" | "connected" | "disconnected" | "failed" | "restarting" | "stopping" | "stopped";
17
+ /**
18
+ * MCP Server Category Types - Organizational classification
19
+ */
20
+ export type MCPServerCategory = "external" | "in-memory" | "built-in" | "user-defined" | "custom" | "uncategorized";
21
+ /**
22
+ * Universal MCP Server - Unified configuration and runtime state
23
+ * MCP 2024-11-05 specification compliant
24
+ * Replaces both MCPServerInfo and MCPServerConfig
25
+ */
26
+ export interface MCPServerInfo {
27
+ id: string;
28
+ name: string;
29
+ description: string;
30
+ transport: MCPTransportType;
31
+ status: MCPServerConnectionStatus;
32
+ tools: Array<{
33
+ name: string;
34
+ description: string;
35
+ inputSchema?: object;
36
+ execute?: (params: unknown, context?: unknown) => Promise<unknown> | unknown;
37
+ }>;
38
+ command?: string;
39
+ args?: string[];
40
+ env?: Record<string, string>;
41
+ url?: string;
42
+ timeout?: number;
43
+ retries?: number;
81
44
  error?: string;
82
- /**
83
- * Optional metadata about execution
84
- */
45
+ installed?: boolean;
46
+ cwd?: string;
47
+ autoRestart?: boolean;
48
+ healthCheckInterval?: number;
85
49
  metadata?: {
86
- executionTime?: number;
87
- toolName?: string;
88
- serverId?: string;
50
+ uptime?: number;
51
+ toolCount?: number;
52
+ category?: MCPServerCategory;
53
+ provider?: string;
54
+ version?: string;
55
+ author?: string;
56
+ tags?: string[];
89
57
  [key: string]: unknown;
90
58
  };
91
59
  }
92
- /**
93
- * MCP Transport Types - Maximally Reusable
94
- */
95
- export type MCPTransportType = "stdio" | "websocket" | "tcp" | "unix";
96
60
  /**
97
61
  * MCP Server Status for CLI Operations - High Reusability
98
62
  */
@@ -111,7 +75,7 @@ export interface MCPServerStatus {
111
75
  customToolsCount: number;
112
76
  /** Number of in-memory servers */
113
77
  inMemoryServersCount: number;
114
- /** Error message if any */
78
+ /** Error message */
115
79
  error?: string;
116
80
  /** Auto-discovered servers from various sources */
117
81
  autoDiscoveredServers?: MCPDiscoveredServer[];
@@ -120,14 +84,14 @@ export interface MCPServerStatus {
120
84
  /** Available tools across all servers */
121
85
  availableTools: MCPToolInfo[];
122
86
  /** Server registry entries */
123
- serverRegistry?: Record<string, MCPServerConfig>;
87
+ serverRegistry?: Record<string, MCPServerInfo>;
124
88
  }
125
89
  /**
126
90
  * Auto-discovered MCP Server - High Reusability
127
91
  */
128
92
  export interface MCPDiscoveredServer {
129
93
  name: string;
130
- status: "connected" | "disconnected" | "error" | "pending" | "failed";
94
+ status: MCPServerConnectionStatus;
131
95
  source: string;
132
96
  transport: MCPTransportType;
133
97
  description?: string;
@@ -149,21 +113,6 @@ export interface MCPConnectedServer {
149
113
  connectionTime?: Date;
150
114
  metadata?: MCPServerMetadata;
151
115
  }
152
- /**
153
- * MCP Server Configuration - Maximally Reusable
154
- */
155
- export interface MCPServerConfig {
156
- name: string;
157
- transport: MCPTransportType;
158
- description?: string;
159
- command?: string;
160
- args?: string[];
161
- env?: Record<string, string>;
162
- url?: string;
163
- timeout?: number;
164
- retries?: number;
165
- metadata?: MCPServerMetadata;
166
- }
167
116
  /**
168
117
  * MCP Tool Information - High Reusability
169
118
  */
@@ -177,6 +126,11 @@ export interface MCPToolInfo {
177
126
  outputSchema?: JsonObject;
178
127
  metadata?: MCPToolMetadata;
179
128
  }
129
+ /**
130
+ * MCP Executable Tool - Tool with execution capability
131
+ * Extracted from MCPServerInfo.tools array for better readability
132
+ */
133
+ export type MCPExecutableTool = MCPServerInfo["tools"][0];
180
134
  /**
181
135
  * MCP Server Metadata - Extensible
182
136
  */
@@ -203,7 +157,7 @@ export type MCPToolMetadata = {
203
157
  /**
204
158
  * MCP Server Registry Entry - For Object.entries() usage
205
159
  */
206
- export type MCPServerRegistryEntry = [string, MCPServerConfig];
160
+ export type MCPServerRegistryEntry = [string, MCPServerInfo];
207
161
  /**
208
162
  * Unified MCP Registry interface
209
163
  */
@@ -211,7 +165,7 @@ export interface UnifiedMCPRegistry {
211
165
  /**
212
166
  * Register an in-memory server
213
167
  */
214
- registerInMemoryServer(serverId: string, config: InMemoryMCPServerConfig): Promise<void>;
168
+ registerInMemoryServer(serverId: string, serverInfo: MCPServerInfo): Promise<void>;
215
169
  /**
216
170
  * Get all available tools
217
171
  */
@@ -219,7 +173,7 @@ export interface UnifiedMCPRegistry {
219
173
  /**
220
174
  * Execute a tool
221
175
  */
222
- executeTool(toolName: string, params: JsonObject, context: JsonObject): Promise<InMemoryToolResult>;
176
+ executeTool(toolName: string, params: JsonObject, context: JsonObject): Promise<unknown>;
223
177
  /**
224
178
  * Check if connected to a server
225
179
  */
@@ -1,6 +1,5 @@
1
1
  /**
2
2
  * Provider-specific type definitions for NeuroLink
3
- * Replaces 'any' types in provider implementations
4
3
  */
5
4
  import type { UnknownRecord, JsonValue } from "./common.js";
6
5
  /**
@@ -1,6 +1,5 @@
1
1
  /**
2
2
  * Provider-specific type definitions for NeuroLink
3
- * Replaces 'any' types in provider implementations
4
3
  */
5
4
  /**
6
5
  * Type guard for provider error
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Tool system type definitions for NeuroLink
3
- * Replaces 'any' types in tool registration and execution
2
+ * Type definitions for NeuroLink tool system, including parameter schemas,
3
+ * argument patterns, execution metadata, context, and result types.
4
4
  */
5
5
  import { z } from "zod";
6
6
  import type { Result, JsonValue, ErrorInfo } from "./common.js";
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Tool system type definitions for NeuroLink
3
- * Replaces 'any' types in tool registration and execution
2
+ * Type definitions for NeuroLink tool system, including parameter schemas,
3
+ * argument patterns, execution metadata, context, and result types.
4
4
  */
5
5
  /**
6
6
  * Type guard for tool result
@@ -204,7 +204,7 @@ class FactoryProcessingCache {
204
204
  return hash >>> 0;
205
205
  }
206
206
  /**
207
- * Hash any value to a numeric hash
207
+ * Hash random value to a numeric hash
208
208
  * Optimized for different value types
209
209
  */
210
210
  hashValue(value) {
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Smart Defaults for MCPServerInfo Creation
3
+ * Eliminates boilerplate manual object creation
4
+ */
5
+ import type { MCPServerInfo, MCPExecutableTool, MCPServerCategory } from "../types/mcpTypes.js";
6
+ /**
7
+ * Smart category detection based on context
8
+ */
9
+ export declare function detectCategory(context: {
10
+ isCustomTool?: boolean;
11
+ isExternal?: boolean;
12
+ isBuiltIn?: boolean;
13
+ serverId?: string;
14
+ existingCategory?: string;
15
+ }): MCPServerCategory;
16
+ /**
17
+ * Create MCPServerInfo with smart defaults
18
+ * Eliminates manual boilerplate object creation
19
+ */
20
+ export declare function createMCPServerInfo(options: {
21
+ id?: string;
22
+ name: string;
23
+ tool?: MCPExecutableTool;
24
+ tools?: MCPServerInfo["tools"];
25
+ transport?: MCPServerInfo["transport"];
26
+ status?: MCPServerInfo["status"];
27
+ description?: string;
28
+ category?: string;
29
+ isCustomTool?: boolean;
30
+ isExternal?: boolean;
31
+ isBuiltIn?: boolean;
32
+ command?: string;
33
+ args?: string[];
34
+ env?: Record<string, string>;
35
+ }): MCPServerInfo;
36
+ /**
37
+ * Create MCPServerInfo for custom tool registration
38
+ * Specialized version with smart defaults for registerTool usage
39
+ */
40
+ export declare function createCustomToolServerInfo(toolName: string, tool: MCPExecutableTool): MCPServerInfo;
41
+ /**
42
+ * Create MCPServerInfo for external servers
43
+ * Specialized version with smart defaults for external server usage
44
+ */
45
+ export declare function createExternalServerInfo(options: {
46
+ id: string;
47
+ name?: string;
48
+ command?: string;
49
+ args?: string[];
50
+ env?: Record<string, string>;
51
+ transport?: MCPServerInfo["transport"];
52
+ description?: string;
53
+ tools?: MCPServerInfo["tools"];
54
+ }): MCPServerInfo;