start_tomcat
Launch and manage Tomcat server processes using Gradle commands in a specified working directory for Gradle-based applications within the Gradle Tomcat MCP Server.
Instructions
Launch Tomcat via Gradle
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| gradle_command | No | Gradle command to run (default: appRun) | appRun |
| working_directory | No | Working directory for the Gradle command |
Implementation Reference
- src/process-manager.js:12-67 (handler)The startTomcat method in ProcessManager class that spawns a Gradle process to launch Tomcat, sets up event handlers for stdout/stderr/error/exit, and resolves with process status after a short delay.async startTomcat(gradleCommand = 'appRun', workingDirectory = null) { if (this.process) { throw new Error('Tomcat is already running'); } const workDir = workingDirectory || this.config.workingDirectory || process.cwd(); const command = gradleCommand || this.config.gradleCommand || 'appRun'; return new Promise((resolve, reject) => { try { this.process = spawn('./gradlew', [command], { cwd: workDir, stdio: ['pipe', 'pipe', 'pipe'], detached: false }); this.startTime = new Date(); this.process.stdout.on('data', (data) => { this.emit('stdout', data.toString()); }); this.process.stderr.on('data', (data) => { this.emit('stderr', data.toString()); }); this.process.on('error', (error) => { this.emit('error', error); this.cleanup(); reject(error); }); this.process.on('exit', (code, signal) => { this.emit('exit', { code, signal }); this.cleanup(); }); setTimeout(() => { if (this.process && this.process.pid) { resolve({ running: true, pid: this.process.pid, uptime: this.getUptime(), port: this.config.port || null, gradle_command: command }); } else { reject(new Error('Failed to start Tomcat process')); } }, 1000); } catch (error) { reject(error); } }); }
- src/tools/index.js:2-19 (schema)Input schema definition for the start_tomcat tool, specifying gradle_command and working_directory parameters.{ name: "start_tomcat", description: "Launch Tomcat via Gradle", inputSchema: { type: "object", properties: { gradle_command: { type: "string", description: "Gradle command to run (default: appRun)", default: "appRun" }, working_directory: { type: "string", description: "Working directory for the Gradle command" } } } },
- src/tools/index.js:108-112 (registration)Registration and dispatching of the start_tomcat tool call to processManager.startTomcat in the handleToolCall switch statement.case "start_tomcat": return await processManager.startTomcat( args.gradle_command, args.working_directory );