UNPKG

@gork-labs/secondbrain-mcp

Version:

Second Brain MCP Server - Agent team orchestration with dynamic tool discovery

65 lines (64 loc) 1.84 kB
import { ChildProcess } from 'child_process'; export interface ToolCall { name: string; arguments: Record<string, any>; } export interface ToolResult { content: string; isError: boolean; } export interface McpServerConfig { command: string; args: string[]; env?: Record<string, string>; type: string; } export interface McpConnection { process: ChildProcess; requestId: number; pendingRequests: Map<number, { resolve: Function; reject: Function; }>; } /** * Simplified Tool Proxy - Routes tool calls to appropriate MCP servers * Uses simple heuristics and lets MCP servers handle validation */ export declare class ToolProxy { private static instance; private mcpConnections; private serverConfigs; private successfulRoutes; private vsCodeToolProxy; private constructor(); static getInstance(): ToolProxy; private initializeFromConfig; private initializeFallbackConfig; /** * Simple heuristic to guess which server might have a tool */ private guessServerForTool; private connectToServer; private setupJsonRpcCommunication; private handleJsonRpcMessage; private sendJsonRpcRequest; private initializeServer; /** * Execute a tool call - tries servers until one succeeds * Alias for backward compatibility */ callTool(toolName: string, args: Record<string, any>): Promise<ToolResult>; /** * Execute a tool call - tries servers until one succeeds */ executeTool(toolCall: ToolCall): Promise<ToolResult>; /** * Get available tools for a specific chatmode (simplified - just tool names) */ getAvailableToolsForChatmode(chatmodeName: string): string[]; /** * Cleanup connections when shutting down */ disconnect(): Promise<void>; }