Skip to main content
Glama
lkb2k

Gradle Tomcat MCP Server

by lkb2k

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
NameRequiredDescriptionDefault
gradle_commandNoGradle command to run (default: appRun)appRun
working_directoryNoWorking directory for the Gradle command

Implementation Reference

  • 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); } }); }
  • 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" } } } },
  • 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 );

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lkb2k/mcp-gradle'

If you have feedback or need assistance with the MCP directory API, please join our Discord server