From 466bede7deb04807f7bde2cf7db6da0e051263e7 Mon Sep 17 00:00:00 2001 From: Hongfei Yang Date: Sun, 6 Apr 2025 13:04:31 +1000 Subject: [PATCH] fix: move MCP server creation logic to mcp-server.ts to resolve circular dependency issue --- src/index.ts | 22 ---------------------- src/mcp/mcp-server.ts | 22 +++++++++++++++++++++- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/index.ts b/src/index.ts index 8484cf0..65f24dc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -27,11 +27,6 @@ import mcpServer from './mcp/mcp-server.js'; * It also serves as the entry point for starting the MCP server. */ -// Local imports for internal use -import { IDBManager } from './idb/IDBManager.js'; -import { NLParser } from './parser/NLParser.js'; -import { MCPOrchestrator } from './orchestrator/MCPOrchestrator.js'; - // Export interfaces export { IIDBManager, SimulatorInfo, AppInfo, SessionConfig } from './idb/interfaces/IIDBManager.js'; export { IParser, ParseResult, ValidationResult } from './parser/interfaces/IParser.js'; @@ -54,23 +49,6 @@ export { MCPOrchestrator } from './orchestrator/MCPOrchestrator.js'; export { ParserToOrchestrator } from './adapters/ParserToOrchestrator.js'; export { OrchestratorToIDB } from './adapters/OrchestratorToIDB.js'; -/** - * Create a complete MCP Server instance - * @returns Object with all necessary instances - */ -export function createMCPServer() { - // Create instances - const idbManager = new IDBManager(); - const parser = new NLParser(); - const orchestrator = new MCPOrchestrator(parser, idbManager); - - return { - idbManager, - parser, - orchestrator - }; -} - /** * Main entry point for the MCP server * diff --git a/src/mcp/mcp-server.ts b/src/mcp/mcp-server.ts index f4dcd06..1b75585 100644 --- a/src/mcp/mcp-server.ts +++ b/src/mcp/mcp-server.ts @@ -12,7 +12,10 @@ import fs from 'fs'; import path from 'path'; import { fileURLToPath } from 'url'; -import { createMCPServer } from '../index.js'; +// Export implementations +import { IDBManager } from '../idb/IDBManager.js'; +import { NLParser } from '../parser/NLParser.js'; +import { MCPOrchestrator } from '../orchestrator/MCPOrchestrator.js'; // Log configuration // Get the directory name using ESM approach @@ -35,6 +38,23 @@ const logToFile = (message: string, level: string = 'info') => { } }; +/** + * Create a complete MCP Server instance + * @returns Object with all necessary instances + */ +export function createMCPServer() { + // Create instances + const idbManager = new IDBManager(); + const parser = new NLParser(); + const orchestrator = new MCPOrchestrator(parser, idbManager); + + return { + idbManager, + parser, + orchestrator + }; +} + /** * MCP Server implementation for iOS simulator */