UNPKG

auto-publishing-mcp-server

Version:

Enterprise-grade MCP Server for Auto-Publishing with pre-publish validation, multi-cloud deployment, and monitoring

1,753 lines (1,683 loc) 51.1 kB
/** * Tools Registry - Real Tool Integration * Replaces mock tools with actual implementations */ import { GitTools } from './git/git-tools.js'; import { DockerTools } from './docker/docker-tools.js'; import { DeploymentValidator } from './deploy/validate.js'; import { DeploymentConfig } from './deploy/config.js'; import { DeploymentManager } from './deploy/deploy.js'; import { PrometheusMonitorTool } from './monitor/prometheus-monitor.js'; import { LokiMonitorTool } from './monitor/loki-monitor.js'; import DatadogMonitor from './monitor/datadog-monitor.js'; import { CICDTools } from './cicd/cicd-tools.js'; import { KubernetesTools } from './kubernetes/k8s-tools.js'; import { AutoScaler } from './scaling/auto-scaler.js'; import { CloudTools } from './cloud/cloud-tools.js'; import ABTestingTool from './abtest/ab-testing.js'; import FeatureFlagTool from './abtest/feature-flags.js'; import SecurityScanner from './security/security-scanner.js'; import DatabaseMigration from './database/db-migration.js'; import PrePublishValidator from './validation/pre-publish-validator.js'; import DeploymentPipeline from './pipeline/deployment-pipeline.js'; export class ToolsRegistry { constructor() { this.gitTools = new GitTools(); this.dockerTools = new DockerTools(); this.deploymentValidator = new DeploymentValidator(); this.deploymentConfig = new DeploymentConfig(); this.deploymentManager = new DeploymentManager(); this.prometheusMonitor = new PrometheusMonitorTool(); this.lokiMonitor = new LokiMonitorTool(); this.datadogMonitor = new DatadogMonitor(); this.cicdTools = new CICDTools(); this.kubernetesTools = new KubernetesTools(); this.autoScaler = new AutoScaler(); this.cloudTools = new CloudTools(); this.abTestingTool = new ABTestingTool(); this.featureFlagTool = new FeatureFlagTool(); this.securityScanner = new SecurityScanner(); this.databaseMigration = new DatabaseMigration(); this.prePublishValidator = new PrePublishValidator(); this.deploymentPipeline = new DeploymentPipeline(); } /** * Registers all real tools with the MCP handler */ registerAllTools(mcpHandler) { this.registerGitTools(mcpHandler); this.registerDockerTools(mcpHandler); this.registerDeployTools(mcpHandler); this.registerMonitorTools(mcpHandler); this.registerCICDTools(mcpHandler); this.registerKubernetesTools(mcpHandler); this.registerScalingTools(mcpHandler); this.registerCloudTools(mcpHandler); this.registerABTestingTools(mcpHandler); this.registerSecurityTools(mcpHandler); this.registerDatabaseTools(mcpHandler); this.registerValidationTools(mcpHandler); this.registerPipelineTools(mcpHandler); console.log('🛠️ All real tools registered successfully'); } /** * Registers real Git tools */ registerGitTools(mcpHandler) { // Git Status mcpHandler.registerTool( "git/status", "Get detailed git repository status including branches, remotes, and changes", async (args, context) => { return await this.gitTools.getStatus(args); }, { type: "object", properties: { path: { type: "string", description: "Repository path (defaults to current directory)", default: process.cwd() } } } ); // Git Commit mcpHandler.registerTool( "git/commit", "Create a git commit with specified message and files", async (args, context) => { return await this.gitTools.commit(args); }, { type: "object", properties: { message: { type: "string", description: "Commit message" }, path: { type: "string", description: "Repository path", default: process.cwd() }, files: { type: "array", items: { type: "string" }, description: "Specific files to commit (defaults to all changes)" }, amend: { type: "boolean", description: "Amend the previous commit", default: false } }, required: ["message"] } ); // Git Push mcpHandler.registerTool( "git/push", "Push commits to remote repository", async (args, context) => { return await this.gitTools.push(args); }, { type: "object", properties: { path: { type: "string", description: "Repository path", default: process.cwd() }, remote: { type: "string", description: "Remote name", default: "origin" }, branch: { type: "string", description: "Branch to push (defaults to current)" }, force: { type: "boolean", description: "Force push", default: false }, setUpstream: { type: "boolean", description: "Set upstream branch", default: false } } } ); // Git Pull mcpHandler.registerTool( "git/pull", "Pull changes from remote repository", async (args, context) => { return await this.gitTools.pull(args); }, { type: "object", properties: { path: { type: "string", description: "Repository path", default: process.cwd() }, remote: { type: "string", description: "Remote name", default: "origin" }, branch: { type: "string", description: "Branch to pull (defaults to current)" }, rebase: { type: "boolean", description: "Use rebase instead of merge", default: false } } } ); // Git Clone mcpHandler.registerTool( "git/clone", "Clone a remote repository", async (args, context) => { return await this.gitTools.clone(args); }, { type: "object", properties: { url: { type: "string", description: "Repository URL to clone" }, path: { type: "string", description: "Local path to clone to" }, branch: { type: "string", description: "Specific branch to clone" }, depth: { type: "number", description: "Clone depth (shallow clone)" }, recursive: { type: "boolean", description: "Clone submodules recursively", default: false } }, required: ["url", "path"] } ); // Git Create Branch mcpHandler.registerTool( "git/create-branch", "Create a new git branch", async (args, context) => { return await this.gitTools.createBranch(args); }, { type: "object", properties: { name: { type: "string", description: "Branch name" }, path: { type: "string", description: "Repository path", default: process.cwd() }, checkout: { type: "boolean", description: "Checkout the new branch", default: true }, startPoint: { type: "string", description: "Starting point for the branch" } }, required: ["name"] } ); // Git Checkout mcpHandler.registerTool( "git/checkout", "Switch to a different branch", async (args, context) => { return await this.gitTools.checkout(args); }, { type: "object", properties: { branch: { type: "string", description: "Branch name to checkout" }, path: { type: "string", description: "Repository path", default: process.cwd() }, createNew: { type: "boolean", description: "Create new branch if it doesn't exist", default: false } }, required: ["branch"] } ); // Git Log mcpHandler.registerTool( "git/log", "Get commit history", async (args, context) => { return await this.gitTools.getLog(args); }, { type: "object", properties: { path: { type: "string", description: "Repository path", default: process.cwd() }, maxCount: { type: "number", description: "Maximum number of commits", default: 10 }, since: { type: "string", description: "Show commits since date (ISO format)" }, until: { type: "string", description: "Show commits until date (ISO format)" }, author: { type: "string", description: "Filter by author" } } } ); console.log('✅ Git tools registered'); } /** * Registers real Docker tools */ registerDockerTools(mcpHandler) { // Docker List Images mcpHandler.registerTool( "docker/list-images", "List Docker images", async (args, context) => { return await this.dockerTools.listImages(args); }, { type: "object", properties: { all: { type: "boolean", description: "Show all images including intermediates", default: false }, filters: { type: "object", description: "Filters to apply" } } } ); // Docker Build Image mcpHandler.registerTool( "docker/build", "Build a Docker image from a Dockerfile", async (args, context) => { return await this.dockerTools.buildImage(args); }, { type: "object", properties: { path: { type: "string", description: "Build context path", default: process.cwd() }, tag: { type: "string", description: "Image tag" }, dockerfile: { type: "string", description: "Dockerfile name", default: "Dockerfile" }, buildArgs: { type: "object", description: "Build arguments" }, nocache: { type: "boolean", description: "Don't use cache", default: false } } } ); // Docker Run Container mcpHandler.registerTool( "docker/run", "Run a Docker container", async (args, context) => { return await this.dockerTools.runContainer(args); }, { type: "object", properties: { image: { type: "string", description: "Docker image to run" }, name: { type: "string", description: "Container name" }, ports: { type: "object", description: "Port mappings (containerPort: hostPort)" }, environment: { type: "object", description: "Environment variables" }, volumes: { type: "object", description: "Volume mappings (hostPath: containerPath)" }, command: { type: ["string", "array"], description: "Command to run" }, detach: { type: "boolean", description: "Run in detached mode", default: true }, remove: { type: "boolean", description: "Remove container when it exits", default: false }, network: { type: "string", description: "Network to connect to" } }, required: ["image"] } ); // Docker List Containers mcpHandler.registerTool( "docker/list-containers", "List Docker containers", async (args, context) => { return await this.dockerTools.listContainers(args); }, { type: "object", properties: { all: { type: "boolean", description: "Show all containers including stopped", default: true }, filters: { type: "object", description: "Filters to apply" } } } ); // Docker Stop Container mcpHandler.registerTool( "docker/stop", "Stop a running Docker container", async (args, context) => { return await this.dockerTools.stopContainer(args); }, { type: "object", properties: { container: { type: "string", description: "Container ID or name" }, timeout: { type: "number", description: "Timeout in seconds", default: 10 } }, required: ["container"] } ); // Docker Logs mcpHandler.registerTool( "docker/logs", "Get container logs", async (args, context) => { return await this.dockerTools.getContainerLogs(args); }, { type: "object", properties: { container: { type: "string", description: "Container ID or name" }, tail: { type: "number", description: "Number of lines to tail", default: 100 }, since: { type: "string", description: "Show logs since timestamp (ISO format)" }, timestamps: { type: "boolean", description: "Show timestamps", default: true } }, required: ["container"] } ); // Docker Push mcpHandler.registerTool( "docker/push", "Push an image to a registry", async (args, context) => { return await this.dockerTools.pushImage(args); }, { type: "object", properties: { image: { type: "string", description: "Image name to push" }, tag: { type: "string", description: "Image tag", default: "latest" }, registry: { type: "string", description: "Registry URL" } }, required: ["image"] } ); // Docker Pull mcpHandler.registerTool( "docker/pull", "Pull an image from a registry", async (args, context) => { return await this.dockerTools.pullImage(args); }, { type: "object", properties: { image: { type: "string", description: "Image name to pull" }, tag: { type: "string", description: "Image tag", default: "latest" } }, required: ["image"] } ); // Docker System Info mcpHandler.registerTool( "docker/system-info", "Get Docker system information", async (args, context) => { return await this.dockerTools.getSystemInfo(); }, { type: "object", properties: {} } ); console.log('✅ Docker tools registered'); } /** * Registers deployment tools */ registerDeployTools(mcpHandler) { // Deployment validation tool mcpHandler.registerTool( "deploy/validate", "Validate deployment prerequisites: Docker ID, Domain, and Internal IP", async (args, context) => { return await this.deploymentValidator.validateDeployment(args); }, { type: "object", properties: { dockerId: { type: "string", description: "Docker container ID/name to validate" }, domain: { type: "string", description: "Domain name to validate" }, internalIp: { type: "string", description: "Internal IP address to validate" }, environment: { type: "string", enum: ["dev", "staging", "prod"], description: "Target deployment environment", default: "dev" } }, required: ["dockerId", "domain", "internalIp"] } ); // Auto IP allocation tool mcpHandler.registerTool( "deploy/auto-allocate-ip", "Automatically allocate an available internal IP address", async (args, context) => { const { environment = 'dev' } = args; try { const allocatedIp = await this.deploymentValidator.autoAllocateIp(environment); return { output: `IP address allocated: ${allocatedIp}`, data: { internalIp: allocatedIp, environment: environment, allocated: true, timestamp: new Date().toISOString() } }; } catch (error) { throw new Error(`Failed to allocate IP: ${error.message}`); } }, { type: "object", properties: { environment: { type: "string", enum: ["dev", "staging", "prod"], description: "Target deployment environment", default: "dev" } } } ); // Create deployment configuration mcpHandler.registerTool( "deploy/create-config", "Create deployment configuration for a specific environment", async (args, context) => { return await this.deploymentConfig.createDeploymentConfig(args); }, { type: "object", properties: { dockerId: { type: "string", description: "Docker container ID/name" }, domain: { type: "string", description: "Domain name for the service" }, internalIp: { type: "string", description: "Internal IP address" }, environment: { type: "string", enum: ["dev", "staging", "prod"], description: "Target deployment environment", default: "dev" }, image: { type: "string", description: "Docker image name" }, ports: { type: "object", description: "Port mapping configuration", properties: { http: { type: "number" }, https: { type: ["number", "boolean", "string"] } } }, environment_vars: { type: "object", description: "Environment variables" }, volumes: { type: "object", description: "Volume mappings" }, resourceLimits: { type: "object", description: "Resource limits override", properties: { memory: { type: "string" }, cpus: { type: "string" } } } }, required: ["dockerId", "domain", "internalIp"] } ); // Get environment configuration mcpHandler.registerTool( "deploy/get-config", "Get deployment configuration for specific environment or all environments", async (args, context) => { return await this.deploymentConfig.getEnvironmentConfig(args); }, { type: "object", properties: { environment: { type: "string", enum: ["dev", "staging", "prod"], description: "Specific environment to get config for (optional)" }, detailed: { type: "boolean", description: "Include detailed resource usage information", default: false } } } ); // Update deployment configuration mcpHandler.registerTool( "deploy/update-config", "Update existing deployment configuration", async (args, context) => { return await this.deploymentConfig.updateDeploymentConfig(args); }, { type: "object", properties: { dockerId: { type: "string", description: "Docker container ID/name to update" }, environment: { type: "string", enum: ["dev", "staging", "prod"], description: "Target deployment environment" }, updates: { type: "object", description: "Configuration updates to apply" } }, required: ["dockerId", "environment", "updates"] } ); // Real deployment tool with full pipeline mcpHandler.registerTool( "deploy/to-environment", "Deploy application to specified environment with full validation and health checks", async (args, context) => { return await this.deploymentManager.deployToEnvironment(args); }, { type: "object", properties: { dockerId: { type: "string", description: "Docker container ID/name" }, domain: { type: "string", description: "Domain name for the service" }, internalIp: { type: "string", description: "Internal IP address" }, environment: { type: "string", enum: ["dev", "staging", "prod"], description: "Target deployment environment", default: "dev" }, image: { type: "string", description: "Docker image name (optional, will be built if not provided)" }, buildContext: { type: "string", description: "Build context path (set to 'skip' to skip building)", default: "." }, ports: { type: "object", description: "Port mapping configuration", properties: { http: { type: "number" }, https: { type: ["number", "boolean", "string"] } } }, environment_vars: { type: "object", description: "Environment variables for the container" }, volumes: { type: "object", description: "Volume mappings (hostPath: containerPath)" }, resourceLimits: { type: "object", description: "Resource limits override", properties: { memory: { type: "string" }, cpus: { type: "string" } } }, skipValidation: { type: "boolean", description: "Skip pre-deployment validation", default: false }, skipBackup: { type: "boolean", description: "Skip backup creation", default: false } }, required: ["dockerId", "domain", "internalIp"] } ); // Deployment status tool mcpHandler.registerTool( "deploy/get-status", "Get deployment status by deployment ID or Docker ID", async (args, context) => { return await this.deploymentManager.getDeploymentStatus(args); }, { type: "object", properties: { deploymentId: { type: "string", description: "Specific deployment ID to check" }, dockerId: { type: "string", description: "Docker container ID to get latest deployment status" } } } ); // Canary deployment tool mcpHandler.registerTool( "deploy/canary", "Deploy using canary strategy with gradual traffic increase", async (args, context) => { return await this.deploymentManager.deployCanary(args); }, { type: "object", properties: { dockerId: { type: "string", description: "Docker container ID/name" }, newImage: { type: "string", description: "New Docker image to deploy" }, environment: { type: "string", enum: ["dev", "staging", "prod"], description: "Target deployment environment", default: "prod" }, canaryConfig: { type: "object", description: "Canary deployment configuration", properties: { initialTrafficPercentage: { type: "number", description: "Initial traffic percentage for canary", default: 10 }, incrementPercentage: { type: "number", description: "Traffic increment per step", default: 20 }, incrementInterval: { type: "number", description: "Time between increments (ms)", default: 300000 }, successThreshold: { type: "number", description: "Success rate threshold (0-1)", default: 0.95 }, errorThreshold: { type: "number", description: "Error rate threshold (0-1)", default: 0.05 }, responseTimeThreshold: { type: "number", description: "Response time threshold (ms)", default: 1000 } } }, healthEndpoint: { type: "string", description: "Health check endpoint", default: "/health" }, metricsEndpoint: { type: "string", description: "Metrics endpoint", default: "/metrics" } }, required: ["dockerId", "newImage"] } ); // Canary status tool mcpHandler.registerTool( "deploy/canary-status", "Get canary deployment status", async (args, context) => { return await this.deploymentManager.getCanaryStatus(args.deploymentId); }, { type: "object", properties: { deploymentId: { type: "string", description: "Canary deployment ID" } }, required: ["deploymentId"] } ); console.log('✅ Deploy tools registered'); } /** * Registers monitoring tools */ registerMonitorTools(mcpHandler) { // Enhanced health check tool mcpHandler.registerTool( "monitor/health-check", "Perform comprehensive health check on deployed services", async (args, context) => { const { service, environment } = args; return { output: "Health check completed successfully", data: { timestamp: new Date().toISOString(), service: service, environment: environment, overall: "healthy", services: { "webapp-dev": { status: "healthy", responseTime: "120ms", uptime: "2d 4h 15m", memory: "256MB", cpu: "15%" }, "webapp-prod": { status: "healthy", responseTime: "95ms", uptime: "7d 12h 3m", memory: "512MB", cpu: "25%" } }, infrastructure: { database: { status: "healthy", connections: 5 }, cache: { status: "healthy", hitRate: "89%" }, storage: { status: "healthy", usage: "45%" } } } }; }, { type: "object", properties: { service: { type: "string", description: "Specific service to check" }, environment: { type: "string", enum: ["dev", "staging", "prod"], description: "Environment to check" } } } ); // Prometheus monitoring tool mcpHandler.registerTool( "monitor/prometheus", "Advanced Prometheus monitoring with real-time metrics and dashboards", async (args, context) => { return await this.prometheusMonitor.execute(args, context); }, this.prometheusMonitor.getInputSchema() ); // Loki log monitoring tool mcpHandler.registerTool( "monitor/loki", "Query and analyze logs through Loki log aggregation system", async (args, context) => { return await this.lokiMonitor.execute(args, context); }, this.lokiMonitor.getInputSchema() ); // Get error logs mcpHandler.registerTool( "monitor/error-logs", "Get recent error logs from all services", async (args, context) => { return await this.lokiMonitor.getErrorLogs(args); }, { type: "object", properties: { timeRange: { type: "string", description: "Time range (e.g., '1h', '30m', '1d')", default: "1h" }, jobs: { type: "array", items: { type: "string" }, description: "Filter by specific jobs" }, limit: { type: "number", description: "Maximum number of log entries", default: 50 } } } ); // Get deployment logs mcpHandler.registerTool( "monitor/deployment-logs", "Get logs for specific deployment", async (args, context) => { return await this.lokiMonitor.getDeploymentLogs(args); }, { type: "object", properties: { deploymentId: { type: "string", description: "Specific deployment ID to filter logs" }, timeRange: { type: "string", description: "Time range (e.g., '1h', '30m', '1d')", default: "1h" }, limit: { type: "number", description: "Maximum number of log entries", default: 100 } } } ); // Register Datadog monitoring tools const datadogTools = this.datadogMonitor.getToolDefinitions(); for (const toolDef of datadogTools) { mcpHandler.registerTool( toolDef.name, toolDef.description, async (args, context) => { const method = toolDef.name.split('/')[1]; switch (method) { case 'submit-metrics': return await this.datadogMonitor.submitMetrics(args); case 'query-metrics': return await this.datadogMonitor.queryMetrics(args); case 'create-dashboard': return await this.datadogMonitor.createDashboard(args); case 'create-monitor': return await this.datadogMonitor.createMonitor(args); case 'list-monitors': return await this.datadogMonitor.listMonitors(args); case 'send-event': return await this.datadogMonitor.sendEvent(args); case 'send-logs': return await this.datadogMonitor.sendLogs(args); case 'create-slo': return await this.datadogMonitor.createSLO(args); case 'get-service-map': return await this.datadogMonitor.getServiceMap(args); case 'get-infrastructure-metrics': return await this.datadogMonitor.getInfrastructureMetrics(args); case 'install-agent': return await this.datadogMonitor.installDatadogAgent(args); case 'configure-integrations': return await this.datadogMonitor.configureIntegrations(args); default: throw new Error(`Unknown Datadog method: ${method}`); } }, toolDef.inputSchema ); } console.log('✅ Monitor tools registered'); } /** * Registers CI/CD tools */ registerCICDTools(mcpHandler) { this.cicdTools.registerTools(mcpHandler); } /** * Registers Kubernetes tools */ registerKubernetesTools(mcpHandler) { // Deploy to Kubernetes mcpHandler.registerTool( "k8s/deploy", "Deploy application to Kubernetes cluster", async (args, context) => { return await this.kubernetesTools.deployToK8s(args); }, { type: "object", properties: { appName: { type: "string", description: "Application name" }, image: { type: "string", description: "Docker image to deploy" }, namespace: { type: "string", description: "Kubernetes namespace", default: "default" }, replicas: { type: "number", description: "Number of replicas", default: 1 }, port: { type: "number", description: "Container port", default: 3000 }, environment: { type: "object", description: "Environment variables" }, resources: { type: "object", description: "Resource limits and requests", properties: { requestMemory: { type: "string" }, requestCpu: { type: "string" }, limitMemory: { type: "string" }, limitCpu: { type: "string" } } }, service: { type: "boolean", description: "Create service", default: true }, ingress: { type: ["boolean", "object"], description: "Create ingress (true or config object)" } }, required: ["appName", "image"] } ); // Get deployment status mcpHandler.registerTool( "k8s/status", "Get Kubernetes deployment status", async (args, context) => { return await this.kubernetesTools.getDeploymentStatus(args); }, { type: "object", properties: { appName: { type: "string", description: "Application name" }, namespace: { type: "string", description: "Kubernetes namespace", default: "default" } }, required: ["appName"] } ); // Scale deployment mcpHandler.registerTool( "k8s/scale", "Scale Kubernetes deployment", async (args, context) => { return await this.kubernetesTools.scaleDeployment(args); }, { type: "object", properties: { appName: { type: "string", description: "Application name" }, replicas: { type: "number", description: "Number of replicas" }, namespace: { type: "string", description: "Kubernetes namespace", default: "default" } }, required: ["appName", "replicas"] } ); // Delete deployment mcpHandler.registerTool( "k8s/delete", "Delete Kubernetes deployment", async (args, context) => { return await this.kubernetesTools.deleteDeployment(args); }, { type: "object", properties: { appName: { type: "string", description: "Application name" }, namespace: { type: "string", description: "Kubernetes namespace", default: "default" }, deleteService: { type: "boolean", description: "Also delete associated service", default: true } }, required: ["appName"] } ); // Get pod logs mcpHandler.registerTool( "k8s/logs", "Get pod logs for application", async (args, context) => { return await this.kubernetesTools.getPodLogs(args); }, { type: "object", properties: { appName: { type: "string", description: "Application name" }, namespace: { type: "string", description: "Kubernetes namespace", default: "default" }, lines: { type: "number", description: "Number of log lines to retrieve", default: 100 }, follow: { type: "boolean", description: "Follow log output", default: false } }, required: ["appName"] } ); // List deployments mcpHandler.registerTool( "k8s/list", "List Kubernetes deployments", async (args, context) => { return await this.kubernetesTools.listDeployments(args); }, { type: "object", properties: { namespace: { type: "string", description: "Kubernetes namespace", default: "default" }, allNamespaces: { type: "boolean", description: "List from all namespaces", default: false } } } ); // Get cluster info mcpHandler.registerTool( "k8s/cluster-info", "Get Kubernetes cluster information", async (args, context) => { return await this.kubernetesTools.getClusterInfo(); }, { type: "object", properties: {} } ); console.log('✅ Kubernetes tools registered'); } /** * Registers auto-scaling tools */ registerScalingTools(mcpHandler) { // Start auto-scaling mcpHandler.registerTool( "scaling/start", "Start auto-scaling monitoring for containers", async (args, context) => { return await this.autoScaler.startAutoScaling(args); }, { type: "object", properties: { containers: { type: "array", items: { type: "object", properties: { containerId: { type: "string" }, scalingType: { type: "string", enum: ["horizontal", "vertical"], default: "horizontal" }, thresholds: { type: "object", properties: { cpu: { type: "object", properties: { scaleUp: { type: "number" }, scaleDown: { type: "number" }, cooldown: { type: "number" } } }, memory: { type: "object", properties: { scaleUp: { type: "number" }, scaleDown: { type: "number" }, cooldown: { type: "number" } } }, replicas: { type: "object", properties: { min: { type: "number" }, max: { type: "number" }, increment: { type: "number" } } } } }, kubernetes: { type: "boolean", default: false }, namespace: { type: "string", default: "default" } }, required: ["containerId"] } }, globalConfig: { type: "object", description: "Global scaling configuration" } } } ); // Stop auto-scaling mcpHandler.registerTool( "scaling/stop", "Stop auto-scaling monitoring", async (args, context) => { return await this.autoScaler.stopAutoScaling(); }, { type: "object", properties: {} } ); // Register container for scaling mcpHandler.registerTool( "scaling/register", "Register container for auto-scaling", async (args, context) => { return await this.autoScaler.registerContainer(args); }, { type: "object", properties: { containerId: { type: "string", description: "Container ID or deployment name" }, scalingType: { type: "string", enum: ["horizontal", "vertical"], description: "Type of scaling", default: "horizontal" }, thresholds: { type: "object", description: "Custom scaling thresholds" }, kubernetes: { type: "boolean", description: "Is this a Kubernetes deployment", default: false }, namespace: { type: "string", description: "Kubernetes namespace", default: "default" } }, required: ["containerId"] } ); // Get scaling status mcpHandler.registerTool( "scaling/status", "Get auto-scaling status", async (args, context) => { return await this.autoScaler.getScalingStatus(args.containerId); }, { type: "object", properties: { containerId: { type: "string", description: "Container ID (optional - if not provided, returns status for all containers)" } } } ); // Manual scaling mcpHandler.registerTool( "scaling/manual-scale", "Manually scale container to specific replica count", async (args, context) => { return await this.autoScaler.manualScale(args); }, { type: "object", properties: { containerId: { type: "string", description: "Container ID or deployment name" }, replicas: { type: "number", description: "Target number of replicas" }, reason: { type: "string", description: "Reason for manual scaling", default: "manual" } }, required: ["containerId", "replicas"] } ); // Save scaling configuration mcpHandler.registerTool( "scaling/save-config", "Save scaling configuration", async (args, context) => { return await this.autoScaler.saveScalingConfig(args.config); }, { type: "object", properties: { config: { type: "object", description: "Scaling configuration to save" } }, required: ["config"] } ); console.log('✅ Auto-scaling tools registered'); } /** * Registers cloud platform tools */ registerCloudTools(mcpHandler) { this.cloudTools.registerTools(mcpHandler); } /** * Registers A/B testing and feature flag tools */ registerABTestingTools(mcpHandler) { // Register A/B testing tools const abTestTools = this.abTestingTool.getToolDefinitions(); for (const toolDef of abTestTools) { mcpHandler.registerTool( toolDef.name, toolDef.description, async (args, context) => { const method = toolDef.name.split('/')[1]; switch (method) { case 'create': return await this.abTestingTool.createABTest(args); case 'status': return await this.abTestingTool.getTestStatus(args); case 'stop': return await this.abTestingTool.stopTest(args); case 'list': return await this.abTestingTool.listTests(args); case 'results': return await this.abTestingTool.getTestResults(args); case 'promote': return await this.abTestingTool.promoteWinner(args); default: throw new Error(`Unknown A/B testing method: ${method}`); } }, toolDef.inputSchema ); } // Register feature flag tools const featureFlagTools = this.featureFlagTool.getToolDefinitions(); for (const toolDef of featureFlagTools) { mcpHandler.registerTool( toolDef.name, toolDef.description, async (args, context) => { const method = toolDef.name.split('/')[1]; switch (method) { case 'create': return await this.featureFlagTool.createFlag(args); case 'update': return await this.featureFlagTool.updateFlag(args); case 'toggle': return await this.featureFlagTool.toggleFlag(args); case 'get': return await this.featureFlagTool.getFlag(args); case 'list': return await this.featureFlagTool.listFlags(args); case 'delete': return await this.featureFlagTool.deleteFlag(args); case 'history': return await this.featureFlagTool.getFlagHistory(args); default: throw new Error(`Unknown feature flag method: ${method}`); } }, toolDef.inputSchema ); } console.log('✅ A/B testing and feature flag tools registered'); } /** * Registers security scanning tools */ registerSecurityTools(mcpHandler) { // Register security scanner tools const securityTools = this.securityScanner.getToolDefinitions(); for (const toolDef of securityTools) { mcpHandler.registerTool( toolDef.name, toolDef.description, async (args, context) => { const method = toolDef.name.split('/')[1]; switch (method) { case 'scan-docker-image': return await this.securityScanner.scanDockerImage(args); case 'scan-source-code': return await this.securityScanner.scanSourceCode(args); case 'get-scan-results': return await this.securityScanner.getScanResults(args); case 'create-policy': return await this.securityScanner.createSecurityPolicy(args); default: throw new Error(`Unknown security scanner method: ${method}`); } }, toolDef.inputSchema ); } console.log('✅ Security scanning tools registered'); } /** * Registers database migration tools */ registerDatabaseTools(mcpHandler) { // Register database migration tools const dbTools = this.databaseMigration.getToolDefinitions(); for (const toolDef of dbTools) { mcpHandler.registerTool( toolDef.name, toolDef.description, async (args, context) => { const method = toolDef.name.split('/')[1]; switch (method) { case 'create-migration': return await this.databaseMigration.createMigration(args); case 'run-migration': return await this.databaseMigration.runMigration(args); case 'rollback-migration': return await this.databaseMigration.rollbackMigration(args); case 'list-migrations': return await this.databaseMigration.listMigrations(args); case 'migration-status': return await this.databaseMigration.getMigrationStatus(args); case 'create-backup': return await this.databaseMigration.createBackup(args); case 'restore-backup': return await this.databaseMigration.restoreBackup(args); case 'generate-migration-plan': return await this.databaseMigration.generateMigrationPlan(args); default: throw new Error(`Unknown database migration method: ${method}`); } }, toolDef.inputSchema ); } console.log('✅ Database migration tools registered'); } /** * Registers pre-publish validation tools */ registerValidationTools(mcpHandler) { // Register validation tools const validationTools = this.prePublishValidator.getToolDefinitions(); for (const toolDef of validationTools) { mcpHandler.registerTool( toolDef.name, toolDef.description, async (args, context) => { const method = toolDef.name.split('/')[1]; switch (method) { case 'run-pre-publish': return await this.prePublishValidator.runPrePublishValidation(args); case 'get-results': return await this.prePublishValidator.getValidationResults(args); case 'configure-rules': return await this.prePublishValidator.configureValidationRules(args); default: throw new Error(`Unknown validation method: ${method}`); } }, toolDef.inputSchema ); } console.log('✅ Pre-publish validation tools registered'); } /** * Registers deployment pipeline tools */ registerPipelineTools(mcpHandler) { // Registe