"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.disconnectMcpServer = disconnectMcpServer;
const services_1 = require("../../../services");
const Tools_1 = require("../../../services/Tools");
async function disconnectMcpServer(serverName) {
    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",
            toolsRemoved: [],
        };
    }
    if (!serverName) {
        return {
            success: false,
            error: "serverName parameter is required",
            toolsRemoved: [],
        };
    }
    const result = await Mcp.disconnectSingle(serverName);
    if (result.success && result.toolsRemoved.length > 0) {
        toolService.tools = toolService.tools.filter((tool) => !result.toolsRemoved.includes(tool.function.name));
    }
    return result;
}
//# sourceMappingURL=disconnectMcpServer.js.map