@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.
- package/CHANGELOG.md +12 -0
- package/README.md +89 -25
- 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/config/conversationMemoryConfig.js +2 -1
- package/dist/context/ContextManager.js +15 -4
- package/dist/context/config.js +5 -1
- package/dist/context/utils.js +1 -1
- package/dist/core/baseProvider.d.ts +11 -30
- package/dist/core/baseProvider.js +268 -42
- package/dist/core/conversationMemoryManager.js +3 -2
- 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 -1
- package/dist/factories/providerFactory.js +5 -11
- package/dist/factories/providerRegistry.js +2 -2
- package/dist/index.d.ts +5 -4
- package/dist/index.js +1 -1
- package/dist/lib/agent/directTools.js +1 -1
- package/dist/lib/config/conversationMemoryConfig.js +2 -1
- package/dist/lib/context/ContextManager.js +15 -4
- package/dist/lib/context/config.js +5 -1
- package/dist/lib/context/utils.js +1 -1
- package/dist/lib/core/baseProvider.d.ts +11 -30
- package/dist/lib/core/baseProvider.js +268 -42
- package/dist/lib/core/conversationMemoryManager.js +3 -2
- package/dist/lib/core/dynamicModels.js +1 -1
- package/dist/lib/core/evaluation.js +1 -1
- package/dist/lib/core/factory.js +1 -1
- package/dist/lib/factories/providerFactory.js +5 -11
- package/dist/lib/factories/providerRegistry.js +2 -2
- package/dist/lib/index.d.ts +5 -4
- package/dist/lib/index.js +1 -1
- package/dist/lib/mcp/externalServerManager.d.ts +148 -0
- package/dist/lib/mcp/externalServerManager.js +1038 -0
- package/dist/lib/mcp/mcpCircuitBreaker.d.ts +184 -0
- package/dist/lib/mcp/mcpCircuitBreaker.js +338 -0
- package/dist/lib/mcp/mcpClientFactory.d.ts +105 -0
- package/dist/lib/mcp/mcpClientFactory.js +421 -0
- package/dist/lib/mcp/toolDiscoveryService.d.ts +193 -0
- package/dist/lib/mcp/toolDiscoveryService.js +646 -0
- 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 +139 -43
- package/dist/lib/neurolink.js +604 -174
- package/dist/lib/providers/googleVertex.d.ts +7 -1
- package/dist/lib/providers/googleVertex.js +34 -7
- 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 +288 -0
- package/dist/lib/types/externalMcp.js +7 -0
- package/dist/lib/types/generateTypes.d.ts +0 -1
- package/dist/lib/types/index.d.ts +2 -2
- 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 +148 -0
- package/dist/mcp/externalServerManager.js +1038 -0
- package/dist/mcp/mcpCircuitBreaker.d.ts +184 -0
- package/dist/mcp/mcpCircuitBreaker.js +338 -0
- package/dist/mcp/mcpClientFactory.d.ts +105 -0
- package/dist/mcp/mcpClientFactory.js +421 -0
- package/dist/mcp/toolDiscoveryService.d.ts +193 -0
- package/dist/mcp/toolDiscoveryService.js +646 -0
- 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 +139 -43
- package/dist/neurolink.js +604 -174
- package/dist/providers/googleVertex.d.ts +7 -1
- package/dist/providers/googleVertex.js +34 -7
- 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 +288 -0
- package/dist/types/externalMcp.js +7 -0
- package/dist/types/generateTypes.d.ts +0 -1
- package/dist/types/index.d.ts +2 -2
- 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
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External MCP Server Types
|
|
3
|
+
* Comprehensive type system for external MCP server integration
|
|
4
|
+
* Following MCP 2024-11-05 specification
|
|
5
|
+
*/
|
|
6
|
+
import type { JsonValue, JsonObject } from "./common.js";
|
|
7
|
+
import type { ChildProcess } from "child_process";
|
|
8
|
+
import type { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
9
|
+
import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
10
|
+
/**
|
|
11
|
+
* Supported MCP transport protocols
|
|
12
|
+
*/
|
|
13
|
+
export type MCPTransportType = "stdio" | "sse" | "websocket";
|
|
14
|
+
/**
|
|
15
|
+
* External MCP server configuration for process spawning
|
|
16
|
+
*/
|
|
17
|
+
export interface ExternalMCPServerConfig {
|
|
18
|
+
/** Unique identifier for the server */
|
|
19
|
+
id: string;
|
|
20
|
+
/** Command to execute (e.g., 'npx', 'node', 'python') */
|
|
21
|
+
command: string;
|
|
22
|
+
/** Arguments to pass to the command */
|
|
23
|
+
args: string[];
|
|
24
|
+
/** Environment variables for the process */
|
|
25
|
+
env?: Record<string, string>;
|
|
26
|
+
/** Transport protocol to use */
|
|
27
|
+
transport: MCPTransportType;
|
|
28
|
+
/** Connection timeout in milliseconds (default: 10000) */
|
|
29
|
+
timeout?: number;
|
|
30
|
+
/** Maximum retry attempts for connection (default: 3) */
|
|
31
|
+
retries?: number;
|
|
32
|
+
/** Health check interval in milliseconds (default: 30000) */
|
|
33
|
+
healthCheckInterval?: number;
|
|
34
|
+
/** Whether to automatically restart on failure (default: true) */
|
|
35
|
+
autoRestart?: boolean;
|
|
36
|
+
/** Working directory for the process */
|
|
37
|
+
cwd?: string;
|
|
38
|
+
/** URL for SSE/WebSocket transports */
|
|
39
|
+
url?: string;
|
|
40
|
+
/** Additional metadata */
|
|
41
|
+
metadata?: Record<string, JsonValue>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Runtime state of an external MCP server instance
|
|
45
|
+
*/
|
|
46
|
+
export interface ExternalMCPServerInstance {
|
|
47
|
+
/** Server configuration */
|
|
48
|
+
config: ExternalMCPServerConfig;
|
|
49
|
+
/** Child process (for stdio transport) */
|
|
50
|
+
process: ChildProcess | null;
|
|
51
|
+
/** MCP client instance */
|
|
52
|
+
client: Client | null;
|
|
53
|
+
/** Transport instance */
|
|
54
|
+
transport: Transport | null;
|
|
55
|
+
/** Current server status */
|
|
56
|
+
status: ExternalMCPServerStatus;
|
|
57
|
+
/** Last error message if any */
|
|
58
|
+
lastError?: string;
|
|
59
|
+
/** When the server was started */
|
|
60
|
+
startTime?: Date;
|
|
61
|
+
/** When the server was last seen healthy */
|
|
62
|
+
lastHealthCheck?: Date;
|
|
63
|
+
/** Number of reconnection attempts */
|
|
64
|
+
reconnectAttempts: number;
|
|
65
|
+
/** Maximum reconnection attempts before giving up */
|
|
66
|
+
maxReconnectAttempts: number;
|
|
67
|
+
/** Available tools from this server */
|
|
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
|
+
}>;
|
|
75
|
+
/** Server capabilities reported by MCP */
|
|
76
|
+
capabilities?: Record<string, JsonValue>;
|
|
77
|
+
/** Health monitoring timer */
|
|
78
|
+
healthTimer?: NodeJS.Timeout;
|
|
79
|
+
/** Restart backoff timer */
|
|
80
|
+
restartTimer?: NodeJS.Timeout;
|
|
81
|
+
/** Performance metrics */
|
|
82
|
+
metrics: {
|
|
83
|
+
totalConnections: number;
|
|
84
|
+
totalDisconnections: number;
|
|
85
|
+
totalErrors: number;
|
|
86
|
+
totalToolCalls: number;
|
|
87
|
+
averageResponseTime: number;
|
|
88
|
+
lastResponseTime: number;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* External MCP server status states
|
|
93
|
+
*/
|
|
94
|
+
export type ExternalMCPServerStatus = "initializing" | "connecting" | "connected" | "disconnected" | "failed" | "restarting" | "stopping" | "stopped";
|
|
95
|
+
/**
|
|
96
|
+
* Tool information from external MCP server
|
|
97
|
+
*/
|
|
98
|
+
export interface ExternalMCPToolInfo {
|
|
99
|
+
/** Tool name */
|
|
100
|
+
name: string;
|
|
101
|
+
/** Tool description */
|
|
102
|
+
description: string;
|
|
103
|
+
/** Server ID that provides this tool */
|
|
104
|
+
serverId: string;
|
|
105
|
+
/** Input schema (JSON Schema) */
|
|
106
|
+
inputSchema?: JsonObject;
|
|
107
|
+
/** Whether the tool is currently available */
|
|
108
|
+
isAvailable: boolean;
|
|
109
|
+
/** Tool metadata */
|
|
110
|
+
metadata?: Record<string, JsonValue>;
|
|
111
|
+
/** When the tool was last successfully called */
|
|
112
|
+
lastCalled?: Date;
|
|
113
|
+
/** Tool execution statistics */
|
|
114
|
+
stats: {
|
|
115
|
+
totalCalls: number;
|
|
116
|
+
successfulCalls: number;
|
|
117
|
+
failedCalls: number;
|
|
118
|
+
averageExecutionTime: number;
|
|
119
|
+
lastExecutionTime: number;
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* External MCP server health status
|
|
124
|
+
*/
|
|
125
|
+
export interface ExternalMCPServerHealth {
|
|
126
|
+
/** Server ID */
|
|
127
|
+
serverId: string;
|
|
128
|
+
/** Whether the server is healthy */
|
|
129
|
+
isHealthy: boolean;
|
|
130
|
+
/** Current status */
|
|
131
|
+
status: ExternalMCPServerStatus;
|
|
132
|
+
/** When the health check was performed */
|
|
133
|
+
checkedAt: Date;
|
|
134
|
+
/** Response time for health check */
|
|
135
|
+
responseTime?: number;
|
|
136
|
+
/** Number of available tools */
|
|
137
|
+
toolCount: number;
|
|
138
|
+
/** Any health issues detected */
|
|
139
|
+
issues: string[];
|
|
140
|
+
/** Performance metrics */
|
|
141
|
+
performance: {
|
|
142
|
+
uptime: number;
|
|
143
|
+
memoryUsage?: number;
|
|
144
|
+
cpuUsage?: number;
|
|
145
|
+
averageResponseTime: number;
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* External MCP server configuration validation result
|
|
150
|
+
*/
|
|
151
|
+
export interface ExternalMCPConfigValidation {
|
|
152
|
+
/** Whether the configuration is valid */
|
|
153
|
+
isValid: boolean;
|
|
154
|
+
/** Validation errors */
|
|
155
|
+
errors: string[];
|
|
156
|
+
/** Validation warnings */
|
|
157
|
+
warnings: string[];
|
|
158
|
+
/** Suggestions for improvement */
|
|
159
|
+
suggestions: string[];
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* External MCP server operation result
|
|
163
|
+
*/
|
|
164
|
+
export interface ExternalMCPOperationResult<T = unknown> {
|
|
165
|
+
/** Whether the operation was successful */
|
|
166
|
+
success: boolean;
|
|
167
|
+
/** Result data if successful */
|
|
168
|
+
data?: T;
|
|
169
|
+
/** Error message if failed */
|
|
170
|
+
error?: string;
|
|
171
|
+
/** Server ID */
|
|
172
|
+
serverId?: string;
|
|
173
|
+
/** Operation duration in milliseconds */
|
|
174
|
+
duration?: number;
|
|
175
|
+
/** Additional metadata */
|
|
176
|
+
metadata?: {
|
|
177
|
+
timestamp: number;
|
|
178
|
+
operation: string;
|
|
179
|
+
[key: string]: JsonValue;
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* External MCP tool execution context
|
|
184
|
+
*/
|
|
185
|
+
export interface ExternalMCPToolContext {
|
|
186
|
+
/** Execution session ID */
|
|
187
|
+
sessionId: string;
|
|
188
|
+
/** User ID if available */
|
|
189
|
+
userId?: string;
|
|
190
|
+
/** Server ID executing the tool */
|
|
191
|
+
serverId: string;
|
|
192
|
+
/** Tool name being executed */
|
|
193
|
+
toolName: string;
|
|
194
|
+
/** Execution timeout in milliseconds */
|
|
195
|
+
timeout?: number;
|
|
196
|
+
/** Additional context data */
|
|
197
|
+
metadata?: Record<string, JsonValue>;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* External MCP tool execution result
|
|
201
|
+
*/
|
|
202
|
+
export interface ExternalMCPToolResult {
|
|
203
|
+
/** Whether the execution was successful */
|
|
204
|
+
success: boolean;
|
|
205
|
+
/** Result data if successful */
|
|
206
|
+
data?: unknown;
|
|
207
|
+
/** Error message if failed */
|
|
208
|
+
error?: string;
|
|
209
|
+
/** Execution duration in milliseconds */
|
|
210
|
+
duration: number;
|
|
211
|
+
/** Tool execution metadata */
|
|
212
|
+
metadata?: {
|
|
213
|
+
toolName: string;
|
|
214
|
+
serverId: string;
|
|
215
|
+
timestamp: number;
|
|
216
|
+
[key: string]: JsonValue;
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* External MCP server events
|
|
221
|
+
*/
|
|
222
|
+
export interface ExternalMCPServerEvents {
|
|
223
|
+
/** Server status changed */
|
|
224
|
+
statusChanged: {
|
|
225
|
+
serverId: string;
|
|
226
|
+
oldStatus: ExternalMCPServerStatus;
|
|
227
|
+
newStatus: ExternalMCPServerStatus;
|
|
228
|
+
timestamp: Date;
|
|
229
|
+
};
|
|
230
|
+
/** Server connected successfully */
|
|
231
|
+
connected: {
|
|
232
|
+
serverId: string;
|
|
233
|
+
toolCount: number;
|
|
234
|
+
timestamp: Date;
|
|
235
|
+
};
|
|
236
|
+
/** Server disconnected */
|
|
237
|
+
disconnected: {
|
|
238
|
+
serverId: string;
|
|
239
|
+
reason?: string;
|
|
240
|
+
timestamp: Date;
|
|
241
|
+
};
|
|
242
|
+
/** Server failed */
|
|
243
|
+
failed: {
|
|
244
|
+
serverId: string;
|
|
245
|
+
error: string;
|
|
246
|
+
timestamp: Date;
|
|
247
|
+
};
|
|
248
|
+
/** Tool discovered */
|
|
249
|
+
toolDiscovered: {
|
|
250
|
+
serverId: string;
|
|
251
|
+
toolName: string;
|
|
252
|
+
toolInfo: ExternalMCPToolInfo;
|
|
253
|
+
timestamp: Date;
|
|
254
|
+
};
|
|
255
|
+
/** Tool removed */
|
|
256
|
+
toolRemoved: {
|
|
257
|
+
serverId: string;
|
|
258
|
+
toolName: string;
|
|
259
|
+
timestamp: Date;
|
|
260
|
+
};
|
|
261
|
+
/** Health check completed */
|
|
262
|
+
healthCheck: {
|
|
263
|
+
serverId: string;
|
|
264
|
+
health: ExternalMCPServerHealth;
|
|
265
|
+
timestamp: Date;
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* External MCP manager configuration
|
|
270
|
+
*/
|
|
271
|
+
export interface ExternalMCPManagerConfig {
|
|
272
|
+
/** Maximum number of concurrent servers */
|
|
273
|
+
maxServers?: number;
|
|
274
|
+
/** Default timeout for operations */
|
|
275
|
+
defaultTimeout?: number;
|
|
276
|
+
/** Default health check interval */
|
|
277
|
+
defaultHealthCheckInterval?: number;
|
|
278
|
+
/** Whether to enable automatic restart */
|
|
279
|
+
enableAutoRestart?: boolean;
|
|
280
|
+
/** Maximum restart attempts per server */
|
|
281
|
+
maxRestartAttempts?: number;
|
|
282
|
+
/** Restart backoff multiplier */
|
|
283
|
+
restartBackoffMultiplier?: number;
|
|
284
|
+
/** Whether to enable performance monitoring */
|
|
285
|
+
enablePerformanceMonitoring?: boolean;
|
|
286
|
+
/** Log level for external MCP operations */
|
|
287
|
+
logLevel?: "debug" | "info" | "warn" | "error";
|
|
288
|
+
}
|
|
@@ -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,7 +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,
|
|
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";
|
|
14
14
|
export type { ModelCapability, ModelUseCase, ModelFilter, ModelResolutionContext, ModelStats, ModelPricing, } from "./providers.js";
|
|
15
15
|
export type { ToolCallResults, ToolCalls, StreamAnalyticsData, } from "./streamTypes.js";
|
|
16
16
|
export type { DomainType, DomainConfig, DomainTemplate, DomainConfigOptions, DomainEvaluationCriteria, DomainValidationRule, } from "./domainTypes.js";
|
package/dist/lib/types/index.js
CHANGED
|
@@ -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
|
-
*
|
|
10
|
+
* MCP Transport Types - Maximally Reusable
|
|
43
11
|
*/
|
|
44
|
-
export
|
|
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
|
-
*
|
|
14
|
+
* MCP Server Connection Status - Individual server status
|
|
68
15
|
*/
|
|
69
|
-
export
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
84
|
-
|
|
45
|
+
installed?: boolean;
|
|
46
|
+
cwd?: string;
|
|
47
|
+
autoRestart?: boolean;
|
|
48
|
+
healthCheckInterval?: number;
|
|
85
49
|
metadata?: {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
|
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,
|
|
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:
|
|
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,
|
|
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,
|
|
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<
|
|
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,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
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";
|
package/dist/lib/types/tools.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
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
|
|
@@ -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;
|