"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.connectMcpServer = connectMcpServer;
const services_1 = require("../../../services");
const Tools_1 = require("../../../services/Tools");
async function connectMcpServer(serverName, timeout = 30000) {
    const toolService = (this instanceof Tools_1.ToolsService ? this : (0, services_1.services)().Tools);
    const context = toolService.getContext();
    const Mcp = context.Mcp;
    if (!Mcp) {
        return {
            success: false,
            error: "MCP service not available in context",
            toolsAdded: [],
        };
    }
    if (!serverName) {
        return {
            success: false,
            error: "serverName parameter is required",
            toolsAdded: [],
        };
    }
    const result = await Mcp.connectSingle(serverName, timeout);
    if (result.success && result.toolsAdded.length > 0) {
        await Mcp.addTools(toolService);
    }
    return result;
}
//# sourceMappingURL=connectMcpServer.js.map