"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var McpController_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.McpController = void 0;
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const mcp_service_1 = require("./mcp.service");
const create_mcp_config_dto_1 = require("./dto/create-mcp-config.dto");
const update_mcp_config_dto_1 = require("./dto/update-mcp-config.dto");
const batch_update_mcp_tools_dto_1 = require("./dto/batch-update-mcp-tools.dto");
let McpController = McpController_1 = class McpController {
    constructor(mcpService) {
        this.mcpService = mcpService;
        this.logger = new common_1.Logger(McpController_1.name);
    }
    getMcpServers() {
        this.logger.log('Request received for GET /mcp/servers');
        return this.mcpService.getMcpServers();
    }
    createMcpConfig(createMcpConfigDto) {
        this.logger.log('Request received for POST /mcp/configs');
        return this.mcpService.createMcpConfig(createMcpConfigDto.configJson);
    }
    updateMcpConfigStatus(serverName, updateMcpConfigDto) {
        this.logger.log(`Request received for PATCH /mcp/configs/${serverName}`);
        return this.mcpService.updateMcpConfigStatus(serverName, updateMcpConfigDto.is_active);
    }
    deleteMcpConfig(serverName) {
        this.logger.log(`Request received for DELETE /mcp/configs/${serverName}`);
        return this.mcpService.deleteMcpConfig(serverName);
    }
    batchUpdateToolStatus(batchUpdateDto) {
        this.logger.log('Request received for PATCH /mcp/tools');
        return this.mcpService.batchUpdateToolStatus(batchUpdateDto.toolIds, batchUpdateDto.is_active);
    }
};
exports.McpController = McpController;
__decorate([
    (0, common_1.Get)('servers'),
    (0, swagger_1.ApiOperation)({ summary: 'Get all MCP server configurations and status' }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'List of MCP servers with their tools and status',
    }),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], McpController.prototype, "getMcpServers", null);
__decorate([
    (0, common_1.Post)('configs'),
    (0, common_1.HttpCode)(201),
    (0, swagger_1.ApiOperation)({ summary: 'Create a new MCP server config' }),
    (0, swagger_1.ApiResponse)({ status: 201, description: 'MCP server config created' }),
    (0, swagger_1.ApiResponse)({ status: 400, description: 'Invalid JSON configuration' }),
    __param(0, (0, common_1.Body)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [create_mcp_config_dto_1.CreateMcpConfigDto]),
    __metadata("design:returntype", void 0)
], McpController.prototype, "createMcpConfig", null);
__decorate([
    (0, common_1.Patch)('configs/:serverName'),
    (0, common_1.HttpCode)(200),
    (0, swagger_1.ApiOperation)({ summary: 'Update MCP server active status' }),
    (0, swagger_1.ApiParam)({ name: 'serverName', description: 'Name of the MCP server' }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'MCP server status updated' }),
    (0, swagger_1.ApiResponse)({ status: 404, description: 'MCP server not found' }),
    __param(0, (0, common_1.Param)('serverName')),
    __param(1, (0, common_1.Body)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, update_mcp_config_dto_1.UpdateMcpConfigDto]),
    __metadata("design:returntype", void 0)
], McpController.prototype, "updateMcpConfigStatus", null);
__decorate([
    (0, common_1.Delete)('configs/:serverName'),
    (0, common_1.HttpCode)(204),
    (0, swagger_1.ApiOperation)({ summary: 'Delete an MCP server config' }),
    (0, swagger_1.ApiParam)({ name: 'serverName', description: 'Name of the MCP server' }),
    (0, swagger_1.ApiResponse)({ status: 204, description: 'MCP server config deleted' }),
    (0, swagger_1.ApiResponse)({ status: 404, description: 'MCP server not found' }),
    __param(0, (0, common_1.Param)('serverName')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", void 0)
], McpController.prototype, "deleteMcpConfig", null);
__decorate([
    (0, common_1.Patch)('tools'),
    (0, common_1.HttpCode)(200),
    (0, swagger_1.ApiOperation)({ summary: 'Batch update tool activation status' }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Tools updated' }),
    __param(0, (0, common_1.Body)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [batch_update_mcp_tools_dto_1.BatchUpdateMcpToolsDto]),
    __metadata("design:returntype", void 0)
], McpController.prototype, "batchUpdateToolStatus", null);
exports.McpController = McpController = McpController_1 = __decorate([
    (0, swagger_1.ApiTags)('mcp'),
    (0, common_1.Controller)('mcp'),
    __metadata("design:paramtypes", [mcp_service_1.McpService])
], McpController);
//# sourceMappingURL=mcp.controller.js.map