@juspay/neurolink
Version:
Universal AI Development Platform with working MCP integration, multi-provider support, and professional CLI. Built-in tools operational, 58+ external MCP servers discoverable. Connect to filesystem, GitHub, database operations, and more. Build, test, and
162 lines (161 loc) • 4.78 kB
TypeScript
/**
* NeuroLink MCP Server Factory
* Factory-First Architecture: MCP servers create tools for internal orchestration
* Compatible with Lighthouse MCP patterns for seamless migration
*/
import { z } from "zod";
import type { ExecutionContext } from "./contracts/mcpContract.js";
/**
* MCP Server Categories for organization and discovery
*/
export type MCPServerCategory = "aiProviders" | "frameworks" | "development" | "business" | "content" | "data" | "integrations" | "automation" | "analysis" | "custom";
/**
* Tool execution context - Rich context passed to every tool execution
* Following Lighthouse's pattern for rich tool context
* Extends ExecutionContext for compatibility
*/
export interface NeuroLinkExecutionContext extends ExecutionContext {
aiProvider?: string;
modelId?: string;
temperature?: number;
maxTokens?: number;
appId?: string;
clientId?: string;
clientVersion?: string;
organizationId?: string;
projectId?: string;
environment?: string;
environmentType?: "development" | "staging" | "production";
platform?: string;
device?: string;
browser?: string;
userAgent?: string;
frameworkType?: "react" | "vue" | "svelte" | "next" | "nuxt" | "sveltekit";
toolChain?: string[];
parentToolId?: string;
locale?: string;
timezone?: string;
ipAddress?: string;
requestId?: string;
timestamp?: number;
permissions?: string[];
features?: string[];
enableDemoMode?: boolean;
securityLevel?: "public" | "private" | "organization";
metadata?: Record<string, unknown>;
[key: string]: unknown;
}
/**
* Tool execution result - Standardized result format
*/
export interface ToolResult {
success: boolean;
data?: unknown;
error?: string | Error;
usage?: {
tokens?: number;
cost?: number;
provider?: string;
model?: string;
executionTime?: number;
};
metadata?: {
toolName?: string;
serverId?: string;
serverTitle?: string;
sessionId?: string;
timestamp?: number;
executionTime?: number;
executionId?: string;
[key: string]: unknown;
};
}
/**
* MCP Tool Interface - Lighthouse compatible with NeuroLink enhancements
*/
export interface NeuroLinkMCPTool {
name: string;
description: string;
execute: (params: unknown, context: NeuroLinkExecutionContext) => Promise<ToolResult>;
inputSchema?: z.ZodSchema;
outputSchema?: z.ZodSchema;
isImplemented?: boolean;
category?: string;
permissions?: string[];
version?: string;
metadata?: Record<string, unknown>;
}
/**
* MCP Server Interface - Lighthouse compatible
*/
export interface NeuroLinkMCPServer {
id: string;
title: string;
description?: string;
version?: string;
category?: MCPServerCategory;
visibility?: "public" | "private" | "organization";
tools: Record<string, NeuroLinkMCPTool>;
registerTool(tool: NeuroLinkMCPTool): NeuroLinkMCPServer;
metadata?: Record<string, unknown>;
dependencies?: string[];
capabilities?: string[];
}
/**
* MCP Server Configuration for creation
*/
export interface MCPServerConfig {
id: string;
title: string;
description?: string;
version?: string;
category?: MCPServerCategory;
visibility?: "public" | "private" | "organization";
metadata?: Record<string, unknown>;
dependencies?: string[];
capabilities?: string[];
}
/**
* Create MCP Server Factory Function
*
* Core factory function for creating Lighthouse-compatible MCP servers.
* Follows Factory-First architecture where tools are internal implementation.
*
* @param config Server configuration with minimal required fields
* @returns Fully configured MCP server ready for tool registration
*
* @example
* ```typescript
* const aiCoreServer = createMCPServer({
* id: 'neurolink-ai-core',
* title: 'NeuroLink AI Core',
* description: 'Core AI provider tools',
* category: 'aiProviders'
* });
*
* aiCoreServer.registerTool({
* name: 'generate',
* description: 'Generate text using AI providers',
* execute: async (params, context) => {
* // Tool implementation
* return { success: true, data: result };
* }
* });
* ```
*/
export declare function createMCPServer(config: MCPServerConfig): NeuroLinkMCPServer;
/**
* Utility function to validate tool interface
*/
export declare function validateTool(tool: NeuroLinkMCPTool): boolean;
/**
* Utility function to get server info
*/
export declare function getServerInfo(server: NeuroLinkMCPServer): {
id: string;
title: string;
description?: string;
category?: MCPServerCategory;
toolCount: number;
capabilities: string[];
};