@juspay/neurolink 7.13.0 → 7.14.0
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 +6 -0
- package/README.md +89 -25
- 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 +16 -1
- package/dist/core/baseProvider.js +208 -9
- package/dist/core/conversationMemoryManager.js +3 -2
- package/dist/core/factory.js +13 -2
- package/dist/factories/providerFactory.js +5 -11
- package/dist/factories/providerRegistry.js +2 -2
- 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 +16 -1
- package/dist/lib/core/baseProvider.js +208 -9
- package/dist/lib/core/conversationMemoryManager.js +3 -2
- package/dist/lib/core/factory.js +13 -2
- package/dist/lib/factories/providerFactory.js +5 -11
- package/dist/lib/factories/providerRegistry.js +2 -2
- package/dist/lib/mcp/externalServerManager.d.ts +115 -0
- package/dist/lib/mcp/externalServerManager.js +677 -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 +104 -0
- package/dist/lib/mcp/mcpClientFactory.js +416 -0
- package/dist/lib/mcp/toolDiscoveryService.d.ts +192 -0
- package/dist/lib/mcp/toolDiscoveryService.js +578 -0
- package/dist/lib/neurolink.d.ts +111 -16
- package/dist/lib/neurolink.js +517 -50
- package/dist/lib/providers/googleVertex.d.ts +1 -1
- package/dist/lib/providers/googleVertex.js +23 -7
- package/dist/lib/types/externalMcp.d.ts +282 -0
- package/dist/lib/types/externalMcp.js +6 -0
- package/dist/lib/types/generateTypes.d.ts +0 -1
- package/dist/lib/types/index.d.ts +1 -0
- package/dist/mcp/externalServerManager.d.ts +115 -0
- package/dist/mcp/externalServerManager.js +677 -0
- package/dist/mcp/mcpCircuitBreaker.d.ts +184 -0
- package/dist/mcp/mcpCircuitBreaker.js +338 -0
- package/dist/mcp/mcpClientFactory.d.ts +104 -0
- package/dist/mcp/mcpClientFactory.js +416 -0
- package/dist/mcp/toolDiscoveryService.d.ts +192 -0
- package/dist/mcp/toolDiscoveryService.js +578 -0
- package/dist/neurolink.d.ts +111 -16
- package/dist/neurolink.js +517 -50
- package/dist/providers/googleVertex.d.ts +1 -1
- package/dist/providers/googleVertex.js +23 -7
- package/dist/types/externalMcp.d.ts +282 -0
- package/dist/types/externalMcp.js +6 -0
- package/dist/types/generateTypes.d.ts +0 -1
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -25,7 +25,7 @@ export declare class GoogleVertexProvider extends BaseProvider {
|
|
|
25
25
|
private static readonly MAX_CACHE_SIZE;
|
|
26
26
|
private static maxTokensCache;
|
|
27
27
|
private static maxTokensCacheTime;
|
|
28
|
-
constructor(modelName?: string, sdk?: unknown);
|
|
28
|
+
constructor(modelName?: string, providerName?: string, sdk?: unknown);
|
|
29
29
|
protected getProviderName(): AIProviderName;
|
|
30
30
|
protected getDefaultModel(): string;
|
|
31
31
|
/**
|
|
@@ -125,7 +125,7 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
125
125
|
// Memory-managed cache for maxTokens handling decisions to optimize streaming performance
|
|
126
126
|
static maxTokensCache = new Map();
|
|
127
127
|
static maxTokensCacheTime = 0;
|
|
128
|
-
constructor(modelName, sdk) {
|
|
128
|
+
constructor(modelName, providerName, sdk) {
|
|
129
129
|
super(modelName, "vertex", sdk);
|
|
130
130
|
// Validate Google Cloud credentials - now using consolidated utility
|
|
131
131
|
if (!hasGoogleCredentials()) {
|
|
@@ -198,6 +198,14 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
198
198
|
hasSchema: !!analysisSchema,
|
|
199
199
|
});
|
|
200
200
|
const model = await this.getModel();
|
|
201
|
+
// Get all available tools (direct + MCP + external) for streaming
|
|
202
|
+
const shouldUseTools = !options.disableTools && this.supportsTools();
|
|
203
|
+
const tools = shouldUseTools ? await this.getAllTools() : {};
|
|
204
|
+
logger.debug(`${functionTag}: Tools for streaming`, {
|
|
205
|
+
shouldUseTools,
|
|
206
|
+
toolCount: Object.keys(tools).length,
|
|
207
|
+
toolNames: Object.keys(tools),
|
|
208
|
+
});
|
|
201
209
|
// Model-specific maxTokens handling
|
|
202
210
|
const modelName = this.modelName || getDefaultVertexModel();
|
|
203
211
|
// Use cached model configuration to determine maxTokens handling for streaming performance
|
|
@@ -206,18 +214,19 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
206
214
|
const maxTokens = shouldSetMaxTokens
|
|
207
215
|
? options.maxTokens || DEFAULT_MAX_TOKENS
|
|
208
216
|
: undefined;
|
|
209
|
-
// Get tools consistently with generate method (using BaseProvider pattern)
|
|
210
|
-
const shouldUseTools = !options.disableTools && this.supportsTools();
|
|
211
|
-
const tools = shouldUseTools ? await this.getAllTools() : {};
|
|
212
217
|
// Build complete stream options with proper typing
|
|
213
218
|
let streamOptions = {
|
|
214
219
|
model: model,
|
|
215
220
|
messages: messages,
|
|
216
221
|
temperature: options.temperature,
|
|
217
222
|
...(maxTokens && { maxTokens }),
|
|
218
|
-
tools
|
|
219
|
-
|
|
220
|
-
|
|
223
|
+
// Add tools support for streaming
|
|
224
|
+
...(shouldUseTools &&
|
|
225
|
+
Object.keys(tools).length > 0 && {
|
|
226
|
+
tools,
|
|
227
|
+
toolChoice: "auto",
|
|
228
|
+
maxSteps: options.maxSteps || DEFAULT_MAX_STEPS,
|
|
229
|
+
}),
|
|
221
230
|
abortSignal: timeoutController?.controller.signal,
|
|
222
231
|
onError: (event) => {
|
|
223
232
|
const error = event.error;
|
|
@@ -258,10 +267,17 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
258
267
|
timeoutController?.cleanup();
|
|
259
268
|
// Transform string stream to content object stream using BaseProvider method
|
|
260
269
|
const transformedStream = this.createTextStream(result);
|
|
270
|
+
// Track tool calls and results for streaming
|
|
271
|
+
const toolCalls = [];
|
|
272
|
+
const toolResults = [];
|
|
261
273
|
return {
|
|
262
274
|
stream: transformedStream,
|
|
263
275
|
provider: this.providerName,
|
|
264
276
|
model: this.modelName,
|
|
277
|
+
...(shouldUseTools && {
|
|
278
|
+
toolCalls,
|
|
279
|
+
toolResults,
|
|
280
|
+
}),
|
|
265
281
|
};
|
|
266
282
|
}
|
|
267
283
|
catch (error) {
|
|
@@ -0,0 +1,282 @@
|
|
|
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
|
+
/** Server capabilities reported by MCP */
|
|
70
|
+
capabilities?: Record<string, JsonValue>;
|
|
71
|
+
/** Health monitoring timer */
|
|
72
|
+
healthTimer?: NodeJS.Timeout;
|
|
73
|
+
/** Restart backoff timer */
|
|
74
|
+
restartTimer?: NodeJS.Timeout;
|
|
75
|
+
/** Performance metrics */
|
|
76
|
+
metrics: {
|
|
77
|
+
totalConnections: number;
|
|
78
|
+
totalDisconnections: number;
|
|
79
|
+
totalErrors: number;
|
|
80
|
+
totalToolCalls: number;
|
|
81
|
+
averageResponseTime: number;
|
|
82
|
+
lastResponseTime: number;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* External MCP server status states
|
|
87
|
+
*/
|
|
88
|
+
export type ExternalMCPServerStatus = "initializing" | "connecting" | "connected" | "disconnected" | "failed" | "restarting" | "stopping" | "stopped";
|
|
89
|
+
/**
|
|
90
|
+
* Tool information from external MCP server
|
|
91
|
+
*/
|
|
92
|
+
export interface ExternalMCPToolInfo {
|
|
93
|
+
/** Tool name */
|
|
94
|
+
name: string;
|
|
95
|
+
/** Tool description */
|
|
96
|
+
description: string;
|
|
97
|
+
/** Server ID that provides this tool */
|
|
98
|
+
serverId: string;
|
|
99
|
+
/** Input schema (JSON Schema) */
|
|
100
|
+
inputSchema?: JsonObject;
|
|
101
|
+
/** Whether the tool is currently available */
|
|
102
|
+
isAvailable: boolean;
|
|
103
|
+
/** Tool metadata */
|
|
104
|
+
metadata?: Record<string, JsonValue>;
|
|
105
|
+
/** When the tool was last successfully called */
|
|
106
|
+
lastCalled?: Date;
|
|
107
|
+
/** Tool execution statistics */
|
|
108
|
+
stats: {
|
|
109
|
+
totalCalls: number;
|
|
110
|
+
successfulCalls: number;
|
|
111
|
+
failedCalls: number;
|
|
112
|
+
averageExecutionTime: number;
|
|
113
|
+
lastExecutionTime: number;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* External MCP server health status
|
|
118
|
+
*/
|
|
119
|
+
export interface ExternalMCPServerHealth {
|
|
120
|
+
/** Server ID */
|
|
121
|
+
serverId: string;
|
|
122
|
+
/** Whether the server is healthy */
|
|
123
|
+
isHealthy: boolean;
|
|
124
|
+
/** Current status */
|
|
125
|
+
status: ExternalMCPServerStatus;
|
|
126
|
+
/** When the health check was performed */
|
|
127
|
+
checkedAt: Date;
|
|
128
|
+
/** Response time for health check */
|
|
129
|
+
responseTime?: number;
|
|
130
|
+
/** Number of available tools */
|
|
131
|
+
toolCount: number;
|
|
132
|
+
/** Any health issues detected */
|
|
133
|
+
issues: string[];
|
|
134
|
+
/** Performance metrics */
|
|
135
|
+
performance: {
|
|
136
|
+
uptime: number;
|
|
137
|
+
memoryUsage?: number;
|
|
138
|
+
cpuUsage?: number;
|
|
139
|
+
averageResponseTime: number;
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* External MCP server configuration validation result
|
|
144
|
+
*/
|
|
145
|
+
export interface ExternalMCPConfigValidation {
|
|
146
|
+
/** Whether the configuration is valid */
|
|
147
|
+
isValid: boolean;
|
|
148
|
+
/** Validation errors */
|
|
149
|
+
errors: string[];
|
|
150
|
+
/** Validation warnings */
|
|
151
|
+
warnings: string[];
|
|
152
|
+
/** Suggestions for improvement */
|
|
153
|
+
suggestions: string[];
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* External MCP server operation result
|
|
157
|
+
*/
|
|
158
|
+
export interface ExternalMCPOperationResult<T = unknown> {
|
|
159
|
+
/** Whether the operation was successful */
|
|
160
|
+
success: boolean;
|
|
161
|
+
/** Result data if successful */
|
|
162
|
+
data?: T;
|
|
163
|
+
/** Error message if failed */
|
|
164
|
+
error?: string;
|
|
165
|
+
/** Server ID */
|
|
166
|
+
serverId?: string;
|
|
167
|
+
/** Operation duration in milliseconds */
|
|
168
|
+
duration?: number;
|
|
169
|
+
/** Additional metadata */
|
|
170
|
+
metadata?: {
|
|
171
|
+
timestamp: number;
|
|
172
|
+
operation: string;
|
|
173
|
+
[key: string]: JsonValue;
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* External MCP tool execution context
|
|
178
|
+
*/
|
|
179
|
+
export interface ExternalMCPToolContext {
|
|
180
|
+
/** Execution session ID */
|
|
181
|
+
sessionId: string;
|
|
182
|
+
/** User ID if available */
|
|
183
|
+
userId?: string;
|
|
184
|
+
/** Server ID executing the tool */
|
|
185
|
+
serverId: string;
|
|
186
|
+
/** Tool name being executed */
|
|
187
|
+
toolName: string;
|
|
188
|
+
/** Execution timeout in milliseconds */
|
|
189
|
+
timeout?: number;
|
|
190
|
+
/** Additional context data */
|
|
191
|
+
metadata?: Record<string, JsonValue>;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* External MCP tool execution result
|
|
195
|
+
*/
|
|
196
|
+
export interface ExternalMCPToolResult {
|
|
197
|
+
/** Whether the execution was successful */
|
|
198
|
+
success: boolean;
|
|
199
|
+
/** Result data if successful */
|
|
200
|
+
data?: unknown;
|
|
201
|
+
/** Error message if failed */
|
|
202
|
+
error?: string;
|
|
203
|
+
/** Execution duration in milliseconds */
|
|
204
|
+
duration: number;
|
|
205
|
+
/** Tool execution metadata */
|
|
206
|
+
metadata?: {
|
|
207
|
+
toolName: string;
|
|
208
|
+
serverId: string;
|
|
209
|
+
timestamp: number;
|
|
210
|
+
[key: string]: JsonValue;
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* External MCP server events
|
|
215
|
+
*/
|
|
216
|
+
export interface ExternalMCPServerEvents {
|
|
217
|
+
/** Server status changed */
|
|
218
|
+
statusChanged: {
|
|
219
|
+
serverId: string;
|
|
220
|
+
oldStatus: ExternalMCPServerStatus;
|
|
221
|
+
newStatus: ExternalMCPServerStatus;
|
|
222
|
+
timestamp: Date;
|
|
223
|
+
};
|
|
224
|
+
/** Server connected successfully */
|
|
225
|
+
connected: {
|
|
226
|
+
serverId: string;
|
|
227
|
+
toolCount: number;
|
|
228
|
+
timestamp: Date;
|
|
229
|
+
};
|
|
230
|
+
/** Server disconnected */
|
|
231
|
+
disconnected: {
|
|
232
|
+
serverId: string;
|
|
233
|
+
reason?: string;
|
|
234
|
+
timestamp: Date;
|
|
235
|
+
};
|
|
236
|
+
/** Server failed */
|
|
237
|
+
failed: {
|
|
238
|
+
serverId: string;
|
|
239
|
+
error: string;
|
|
240
|
+
timestamp: Date;
|
|
241
|
+
};
|
|
242
|
+
/** Tool discovered */
|
|
243
|
+
toolDiscovered: {
|
|
244
|
+
serverId: string;
|
|
245
|
+
toolName: string;
|
|
246
|
+
toolInfo: ExternalMCPToolInfo;
|
|
247
|
+
timestamp: Date;
|
|
248
|
+
};
|
|
249
|
+
/** Tool removed */
|
|
250
|
+
toolRemoved: {
|
|
251
|
+
serverId: string;
|
|
252
|
+
toolName: string;
|
|
253
|
+
timestamp: Date;
|
|
254
|
+
};
|
|
255
|
+
/** Health check completed */
|
|
256
|
+
healthCheck: {
|
|
257
|
+
serverId: string;
|
|
258
|
+
health: ExternalMCPServerHealth;
|
|
259
|
+
timestamp: Date;
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* External MCP manager configuration
|
|
264
|
+
*/
|
|
265
|
+
export interface ExternalMCPManagerConfig {
|
|
266
|
+
/** Maximum number of concurrent servers */
|
|
267
|
+
maxServers?: number;
|
|
268
|
+
/** Default timeout for operations */
|
|
269
|
+
defaultTimeout?: number;
|
|
270
|
+
/** Default health check interval */
|
|
271
|
+
defaultHealthCheckInterval?: number;
|
|
272
|
+
/** Whether to enable automatic restart */
|
|
273
|
+
enableAutoRestart?: boolean;
|
|
274
|
+
/** Maximum restart attempts per server */
|
|
275
|
+
maxRestartAttempts?: number;
|
|
276
|
+
/** Restart backoff multiplier */
|
|
277
|
+
restartBackoffMultiplier?: number;
|
|
278
|
+
/** Whether to enable performance monitoring */
|
|
279
|
+
enablePerformanceMonitoring?: boolean;
|
|
280
|
+
/** Log level for external MCP operations */
|
|
281
|
+
logLevel?: "debug" | "info" | "warn" | "error";
|
|
282
|
+
}
|
|
@@ -11,6 +11,7 @@ export type { ToolArgs, ToolContext, ToolResult, ToolDefinition, SimpleTool, Ava
|
|
|
11
11
|
export type { AISDKModel, ProviderError, TokenUsage, AnalyticsData, EvaluationData, ProviderConfig, } from "./providers.js";
|
|
12
12
|
export type { BaseCommandArgs, GenerateCommandArgs, MCPCommandArgs, ModelsCommandArgs, CommandResult, GenerateResult, StreamChunk, } from "./cli.js";
|
|
13
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";
|
|
14
15
|
export type { ModelCapability, ModelUseCase, ModelFilter, ModelResolutionContext, ModelStats, ModelPricing, } from "./providers.js";
|
|
15
16
|
export type { ToolCallResults, ToolCalls, StreamAnalyticsData, } from "./streamTypes.js";
|
|
16
17
|
export type { DomainType, DomainConfig, DomainTemplate, DomainConfigOptions, DomainEvaluationCriteria, DomainValidationRule, } from "./domainTypes.js";
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External MCP Server Manager
|
|
3
|
+
* Handles lifecycle management of external MCP servers including:
|
|
4
|
+
* - Process spawning and management
|
|
5
|
+
* - Health monitoring and automatic restart
|
|
6
|
+
* - Connection management and cleanup
|
|
7
|
+
* - Tool discovery and registration
|
|
8
|
+
*/
|
|
9
|
+
import { EventEmitter } from "events";
|
|
10
|
+
import { ToolDiscoveryService } from "./toolDiscoveryService.js";
|
|
11
|
+
import type { ExternalMCPServerConfig, ExternalMCPServerInstance, ExternalMCPServerHealth, ExternalMCPConfigValidation, ExternalMCPOperationResult, ExternalMCPManagerConfig, ExternalMCPToolInfo } from "../types/externalMcp.js";
|
|
12
|
+
/**
|
|
13
|
+
* ExternalServerManager
|
|
14
|
+
* Core class for managing external MCP servers
|
|
15
|
+
*/
|
|
16
|
+
export declare class ExternalServerManager extends EventEmitter {
|
|
17
|
+
private servers;
|
|
18
|
+
private config;
|
|
19
|
+
private isShuttingDown;
|
|
20
|
+
private toolDiscovery;
|
|
21
|
+
constructor(config?: ExternalMCPManagerConfig);
|
|
22
|
+
/**
|
|
23
|
+
* Validate external MCP server configuration
|
|
24
|
+
*/
|
|
25
|
+
validateConfig(config: ExternalMCPServerConfig): ExternalMCPConfigValidation;
|
|
26
|
+
/**
|
|
27
|
+
* Add a new external MCP server
|
|
28
|
+
*/
|
|
29
|
+
addServer(serverId: string, config: ExternalMCPServerConfig): Promise<ExternalMCPOperationResult<ExternalMCPServerInstance>>;
|
|
30
|
+
/**
|
|
31
|
+
* Remove an external MCP server
|
|
32
|
+
*/
|
|
33
|
+
removeServer(serverId: string): Promise<ExternalMCPOperationResult<void>>;
|
|
34
|
+
/**
|
|
35
|
+
* Start an external MCP server
|
|
36
|
+
*/
|
|
37
|
+
private startServer;
|
|
38
|
+
/**
|
|
39
|
+
* Stop an external MCP server
|
|
40
|
+
*/
|
|
41
|
+
private stopServer;
|
|
42
|
+
/**
|
|
43
|
+
* Update server status and emit events
|
|
44
|
+
*/
|
|
45
|
+
private updateServerStatus;
|
|
46
|
+
/**
|
|
47
|
+
* Handle server errors
|
|
48
|
+
*/
|
|
49
|
+
private handleServerError;
|
|
50
|
+
/**
|
|
51
|
+
* Handle server disconnection
|
|
52
|
+
*/
|
|
53
|
+
private handleServerDisconnection;
|
|
54
|
+
/**
|
|
55
|
+
* Schedule server restart with exponential backoff
|
|
56
|
+
*/
|
|
57
|
+
private scheduleRestart;
|
|
58
|
+
/**
|
|
59
|
+
* Start health monitoring for a server
|
|
60
|
+
*/
|
|
61
|
+
private startHealthMonitoring;
|
|
62
|
+
/**
|
|
63
|
+
* Perform health check on a server
|
|
64
|
+
*/
|
|
65
|
+
private performHealthCheck;
|
|
66
|
+
/**
|
|
67
|
+
* Get server instance
|
|
68
|
+
*/
|
|
69
|
+
getServer(serverId: string): ExternalMCPServerInstance | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Get all servers
|
|
72
|
+
*/
|
|
73
|
+
getAllServers(): Map<string, ExternalMCPServerInstance>;
|
|
74
|
+
/**
|
|
75
|
+
* Get server statuses
|
|
76
|
+
*/
|
|
77
|
+
getServerStatuses(): ExternalMCPServerHealth[];
|
|
78
|
+
/**
|
|
79
|
+
* Shutdown all servers
|
|
80
|
+
*/
|
|
81
|
+
shutdown(): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Get manager statistics
|
|
84
|
+
*/
|
|
85
|
+
getStatistics(): {
|
|
86
|
+
totalServers: number;
|
|
87
|
+
connectedServers: number;
|
|
88
|
+
failedServers: number;
|
|
89
|
+
totalTools: number;
|
|
90
|
+
totalConnections: number;
|
|
91
|
+
totalErrors: number;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Discover tools from a server
|
|
95
|
+
*/
|
|
96
|
+
private discoverServerTools;
|
|
97
|
+
/**
|
|
98
|
+
* Execute a tool on a specific server
|
|
99
|
+
*/
|
|
100
|
+
executeTool(serverId: string, toolName: string, parameters: Record<string, any>, options?: {
|
|
101
|
+
timeout?: number;
|
|
102
|
+
}): Promise<any>;
|
|
103
|
+
/**
|
|
104
|
+
* Get all tools from all servers
|
|
105
|
+
*/
|
|
106
|
+
getAllTools(): ExternalMCPToolInfo[];
|
|
107
|
+
/**
|
|
108
|
+
* Get tools for a specific server
|
|
109
|
+
*/
|
|
110
|
+
getServerTools(serverId: string): ExternalMCPToolInfo[];
|
|
111
|
+
/**
|
|
112
|
+
* Get tool discovery service
|
|
113
|
+
*/
|
|
114
|
+
getToolDiscovery(): ToolDiscoveryService;
|
|
115
|
+
}
|