@juspay/neurolink 7.14.0 → 7.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/agent/directTools.d.ts +3 -3
- package/dist/agent/directTools.js +1 -1
- package/dist/cli/commands/mcp.js +67 -207
- package/dist/cli/factories/commandFactory.js +7 -1
- package/dist/cli/utils/interactiveSetup.js +1 -1
- package/dist/core/baseProvider.d.ts +6 -40
- package/dist/core/baseProvider.js +102 -75
- package/dist/core/dynamicModels.d.ts +14 -14
- package/dist/core/dynamicModels.js +1 -1
- package/dist/core/evaluation.js +1 -1
- package/dist/core/factory.js +1 -12
- package/dist/index.d.ts +23 -4
- package/dist/index.js +22 -1
- package/dist/lib/agent/directTools.js +1 -1
- package/dist/lib/core/baseProvider.d.ts +6 -40
- package/dist/lib/core/baseProvider.js +102 -75
- package/dist/lib/core/dynamicModels.js +1 -1
- package/dist/lib/core/evaluation.js +1 -1
- package/dist/lib/core/factory.js +1 -12
- package/dist/lib/index.d.ts +23 -4
- package/dist/lib/index.js +22 -1
- package/dist/lib/mcp/externalServerManager.d.ts +46 -13
- package/dist/lib/mcp/externalServerManager.js +393 -32
- package/dist/lib/mcp/mcpClientFactory.d.ts +5 -4
- package/dist/lib/mcp/mcpClientFactory.js +8 -3
- package/dist/lib/mcp/toolDiscoveryService.d.ts +1 -0
- package/dist/lib/mcp/toolDiscoveryService.js +76 -8
- package/dist/lib/mcp/toolRegistry.d.ts +15 -11
- package/dist/lib/mcp/toolRegistry.js +118 -55
- package/dist/lib/models/modelResolver.js +1 -1
- package/dist/lib/neurolink.d.ts +32 -31
- package/dist/lib/neurolink.js +173 -210
- package/dist/lib/providers/googleVertex.d.ts +6 -0
- package/dist/lib/providers/googleVertex.js +11 -0
- package/dist/lib/providers/huggingFace.js +1 -1
- package/dist/lib/providers/mistral.js +3 -3
- package/dist/lib/providers/ollama.js +1 -1
- package/dist/lib/providers/openAI.d.ts +3 -2
- package/dist/lib/providers/openAI.js +2 -2
- package/dist/lib/providers/openaiCompatible.d.ts +1 -1
- package/dist/lib/providers/openaiCompatible.js +2 -2
- package/dist/lib/providers/sagemaker/config.js +1 -1
- package/dist/lib/sdk/toolRegistration.d.ts +4 -13
- package/dist/lib/sdk/toolRegistration.js +19 -66
- package/dist/lib/types/cli.d.ts +0 -1
- package/dist/lib/types/cli.js +0 -1
- package/dist/lib/types/common.d.ts +1 -2
- package/dist/lib/types/common.js +0 -1
- package/dist/lib/types/contextTypes.d.ts +1 -1
- package/dist/lib/types/contextTypes.js +3 -3
- package/dist/lib/types/externalMcp.d.ts +6 -0
- package/dist/lib/types/externalMcp.js +1 -0
- package/dist/lib/types/index.d.ts +2 -3
- package/dist/lib/types/index.js +0 -1
- package/dist/lib/types/mcpTypes.d.ts +53 -99
- package/dist/lib/types/providers.d.ts +0 -1
- package/dist/lib/types/providers.js +0 -1
- package/dist/lib/types/tools.d.ts +2 -2
- package/dist/lib/types/tools.js +2 -2
- package/dist/lib/utils/factoryProcessing.js +1 -1
- package/dist/lib/utils/mcpDefaults.d.ts +54 -0
- package/dist/lib/utils/mcpDefaults.js +125 -0
- package/dist/lib/utils/providerConfig.d.ts +1 -1
- package/dist/lib/utils/providerConfig.js +2 -2
- package/dist/lib/utils/providerHealth.js +6 -6
- package/dist/mcp/externalServerManager.d.ts +46 -13
- package/dist/mcp/externalServerManager.js +393 -32
- package/dist/mcp/mcpClientFactory.d.ts +5 -4
- package/dist/mcp/mcpClientFactory.js +8 -3
- package/dist/mcp/toolDiscoveryService.d.ts +1 -0
- package/dist/mcp/toolDiscoveryService.js +76 -8
- package/dist/mcp/toolRegistry.d.ts +15 -11
- package/dist/mcp/toolRegistry.js +118 -55
- package/dist/models/modelResolver.js +1 -1
- package/dist/neurolink.d.ts +32 -31
- package/dist/neurolink.js +173 -210
- package/dist/providers/googleVertex.d.ts +6 -0
- package/dist/providers/googleVertex.js +11 -0
- package/dist/providers/huggingFace.js +1 -1
- package/dist/providers/mistral.js +3 -3
- package/dist/providers/ollama.js +1 -1
- package/dist/providers/openAI.d.ts +3 -2
- package/dist/providers/openAI.js +2 -2
- package/dist/providers/openaiCompatible.d.ts +1 -1
- package/dist/providers/openaiCompatible.js +2 -2
- package/dist/providers/sagemaker/config.js +1 -1
- package/dist/sdk/toolRegistration.d.ts +4 -13
- package/dist/sdk/toolRegistration.js +19 -66
- package/dist/types/cli.d.ts +0 -1
- package/dist/types/cli.js +0 -1
- package/dist/types/common.d.ts +1 -2
- package/dist/types/common.js +0 -1
- package/dist/types/contextTypes.d.ts +1 -1
- package/dist/types/contextTypes.js +3 -3
- package/dist/types/externalMcp.d.ts +6 -0
- package/dist/types/externalMcp.js +1 -0
- package/dist/types/index.d.ts +2 -3
- package/dist/types/index.js +0 -1
- package/dist/types/mcpTypes.d.ts +53 -99
- package/dist/types/providers.d.ts +0 -1
- package/dist/types/providers.js +0 -1
- package/dist/types/tools.d.ts +2 -2
- package/dist/types/tools.js +2 -2
- package/dist/utils/factoryProcessing.js +1 -1
- package/dist/utils/mcpDefaults.d.ts +54 -0
- package/dist/utils/mcpDefaults.js +125 -0
- package/dist/utils/providerConfig.d.ts +1 -1
- package/dist/utils/providerConfig.js +2 -2
- package/dist/utils/providerHealth.js +6 -6
- package/package.json +1 -1
|
@@ -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
|
|
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,
|
|
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,
|
|
25
|
-
super(modelName || getOpenAIModel(), AIProviderName.OPENAI,
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 {
|
|
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
|
-
*
|
|
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?:
|
|
83
|
+
category?: MCPServerCategory;
|
|
93
84
|
version?: string;
|
|
94
85
|
author?: string;
|
|
95
86
|
[key: string]: JsonValue | undefined;
|
|
96
|
-
}):
|
|
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
|
-
*
|
|
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
|
|
72
|
+
mcpTools.push({
|
|
73
|
+
name,
|
|
74
|
+
description: tool.description || name,
|
|
75
|
+
inputSchema: {},
|
|
76
|
+
});
|
|
127
77
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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
|
-
|
|
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
|
package/dist/lib/types/cli.d.ts
CHANGED
package/dist/lib/types/cli.js
CHANGED
|
@@ -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
|
|
5
|
+
* Type-safe unknown value - use when type is truly unknown
|
|
7
6
|
*/
|
|
8
7
|
export type Unknown = unknown;
|
|
9
8
|
/**
|
package/dist/lib/types/common.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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 */
|
|
@@ -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,
|
|
14
|
-
export type {
|
|
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";
|
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;
|