UNPKG

@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

126 lines (125 loc) 3.81 kB
/** * Smart Defaults for MCPServerInfo Creation * Eliminates boilerplate manual object creation */ /** * Smart category detection based on context */ export function detectCategory(context) { // If category is already provided, validate and use it if (context.existingCategory) { const validCategories = [ "external", "in-memory", "built-in", "user-defined", ]; if (validCategories.includes(context.existingCategory)) { return context.existingCategory; } } // Smart detection based on context if (context.isCustomTool) { return "user-defined"; } if (context.isBuiltIn) { return "built-in"; } if (context.isExternal) { return "external"; } if (context.serverId?.startsWith("custom-tool-")) { return "user-defined"; } if (context.serverId?.includes("external")) { return "external"; } if (context.serverId === "direct") { return "built-in"; } // Default to in-memory for most cases return "in-memory"; } /** * Generate smart description based on name and category */ function generateDescription(name, category) { // Generate descriptions based on category for better context switch (category) { case "external": return `External MCP server: ${name}`; case "built-in": return `Built-in tool server: ${name}`; case "custom": case "user-defined": return `Custom tool server: ${name}`; case "in-memory": return `In-memory MCP server: ${name}`; default: return name; } } /** * Create MCPServerInfo with smart defaults * Eliminates manual boilerplate object creation */ export function createMCPServerInfo(options) { const id = options.id || `server-${options.name}`; const category = options.category || detectCategory({ isCustomTool: options.isCustomTool, isExternal: options.isExternal, isBuiltIn: options.isBuiltIn, serverId: id, }); const tools = options.tools || (options.tool ? [options.tool] : []); return { id, name: options.name, transport: options.transport || "stdio", status: options.status || "connected", tools, description: options.description || generateDescription(options.name, category), ...(options.command && { command: options.command }), ...(options.args && { args: options.args }), ...(options.env && { env: options.env }), metadata: { category: category, toolCount: tools.length, }, }; } /** * Create MCPServerInfo for custom tool registration * Specialized version with smart defaults for registerTool usage */ export function createCustomToolServerInfo(toolName, tool) { return createMCPServerInfo({ id: `custom-tool-${toolName}`, name: toolName, tool: { name: toolName, description: tool.description || toolName, inputSchema: tool.inputSchema || {}, execute: tool.execute, }, isCustomTool: true, }); } /** * Create MCPServerInfo for external servers * Specialized version with smart defaults for external server usage */ export function createExternalServerInfo(options) { return createMCPServerInfo({ id: options.id, name: options.name || options.id, tools: options.tools || [], transport: options.transport || "stdio", description: options.description || options.name || options.id, isExternal: true, command: options.command, args: options.args, env: options.env, }); }