MCP Maven Server
The MCP Maven Server allows AI assistants like Claude to interact with Maven and Spring Boot projects, returning structured JSON output instead of raw build logs.
Build Operations
compileProject– Compile a project and get structured error output (file, line, column, message)getCompilationErrors– Run compile and return only the error listverifyProject– Runmvn verify(compile + test + integration checks)packageProject– Build a JAR/WAR artifact (skips tests by default)cleanProject– Clean build artifactsexecuteMavenCommand– Execute any arbitrary Maven command with custom arguments
Test Operations
runTests– Run all tests and get structured resultsrunSingleTest– Run a single test class by namerunSingleMethod– Run a single test method within a classgetFailedTests– Read existing test reports and return only failed/errored tests (no re-run)getTestReports– Read all existing test reports from disk without re-running tests
Spring Boot Lifecycle
springBootRun– Start the application, detecting port and capturing logsspringBootStop– Stop the app gracefully (actuator shutdown first, SIGTERM fallback)springBootRestart– Restart the applicationspringBootStatus– Check current status (port, PID, uptime, health endpoint)springBootLogs– Retrieve recent log lines from the running application
Project & Environment Info
getProjectInfo– Detect project structure, modules, and Java version frompom.xmlgetJavaInfo– Identify which JDK is in usegetMavenInfo– Get Maven version and installation pathping– Health check to verify the server is alive and responding
Provides tools to manage Spring Boot application lifecycle: start, stop, restart, check status, and view logs.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP Maven Server run all tests in the project"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP Maven Server
An MCP (Model Context Protocol) server that wraps Maven and Spring Boot operations for Claude Code. Provides structured JSON output instead of raw build logs — saving tokens and allowing Claude to focus on code fixes.
Prerequisites
Node.js 18+ (with npm)
Maven 3.6+ (in PATH or configured via
MCP_MAVEN_COMMAND)Java 8–21+ (detected automatically)
Related MCP server: Build Runner MCP Server
Installation
# Clone
cd C:\Java
git clone https://github.com/Christian-Carminati/mcp-maven-server.git
cd mcp-maven-server
# Install and build
npm install
npm run buildIntegration with Claude Code
1. MCP Server Configuration
Add to ~\.claude.json:
{
"mcpServers": {
"mcp-maven": {
"type": "stdio",
"command": "node",
"args": ["C:\\Java\\mcp-maven-server\\dist\\index.js"],
"env": {
"MCP_MAVEN_TIMEOUT_MS": "300000",
"MCP_MAVEN_MAX_LOG_LINES": "500",
"MCP_MAVEN_COMMAND": "C:\\Program Files\\JetBrains\\IntelliJ IDEA 2025.3.6\\plugins\\maven\\lib\\maven3\\bin\\mvn.cmd"
}
}
}
}
MCP_MAVEN_COMMANDis optional — set it ifmvnis not in your system PATH. Omitting it makes the server look formvnvia PATH.
2. Block Maven via Bash (Permissions)
Add to ~\.claude\settings.json:
{
"permissions": {
"deny": ["Bash(mvn *)", "Bash(./mvnw *)", "Bash(java -jar *)"]
}
}3. PreToolUse Hook (Bash Interception)
Add to ~\.claude\settings.json:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "C:\\Java\\mcp-maven-server\\hooks\\maven-intercept.bat"
}
]
}
]
}
}4. CLAUDE.md Instruction
Add to ~\.claude\CLAUDE.md:
## Maven MCP Server
For ALL Maven operations (compile, test, verify, package, clean, spring-boot)
use ONLY the `mcp-maven` MCP tools. Available:
compileProject, runTests, runSingleTest, runSingleMethod, getFailedTests,
verifyProject, packageProject, cleanProject, executeMavenCommand,
getCoverageReport,
springBootRun, springBootStop, springBootRestart, springBootStatus, springBootLogs,
getProjectInfo, getJavaInfo, getMavenInfo, ping,
getCacheInfo, clearCache.
The Bash tool is blocked for mvn/java commands by permission rules.
Do not attempt to run mvn via Bash — it will be denied.
### Example
- ❌ "Run `mvn test` in the terminal"
- ✅ "Run tests using mcp-maven's runTests tool"
- ❌ "Compile with `mvn compile` via Bash"
- ✅ "Compile using mcp-maven's compileProject tool"
- ❌ "Start Spring Boot with `mvn spring-boot:run`"
- ✅ "Start Spring Boot using mcp-maven's springBootRun tool"Available Tools
Build
Tool | Description | Key Parameters |
| Compile with structured error output (file, line, column, message) |
|
| Compile + test + integration-check |
|
| Build JAR/WAR artifact (skips tests by default) |
|
| Clean build artifacts |
|
| Run arbitrary Maven with parsed error output |
|
Test
Tool | Description | Key Parameters |
| Execute tests with build cache (second call is instant) |
|
| Run one test class |
|
| Run one test method |
|
| Read failed tests without re-running |
|
| Read existing reports from disk |
|
runTestscaching: By default, checks if any source/test files changed since the last run. If nothing changed, returns cached results instantly — no Maven execution. Useforce: trueto bypass cache and re-run all tests. Useparallel: true(default) for parallel execution (-T 2 -DforkCount=2). Response includes_cached: trueflag when served from cache.
Cache Management
Tool | Description |
| Show which modules are cached and how old |
| Invalidate cache for a module (or all) |
Coverage
Tool | Description | Key Parameters |
| Read JaCoCo coverage report (lines, branches, methods per package) |
|
Spring Boot
Tool | Description | Key Parameters |
| Start the application (detects port, captures logs) |
|
| Stop gracefully (actuator shutdown first, SIGTERM fallback) |
|
| Restart the app |
|
| Check status, port, PID, health endpoint |
|
| View recent log lines |
|
Code Quality (SonarQube)
Tool | Description | Key Parameters |
| Run |
|
Zero LLM token waste: the analysis runs locally via Maven. The MCP server only fetches structured JSON results from the SonarQube API.
Project Info
Tool | Description | Key Parameters |
| Detect project structure, modules, Java version |
|
| Detect JDK version and vendor |
|
| Get Maven version and home | — |
| Health check | — |
projectPath: all build/test/project tools accept an optionalprojectPathparameter. Use it to target a specific module without changing Claude Code's working directory. Example:runTests({ projectPath: "C:/Java/BancomatPay/be-bancomatpay" })
Configuration
All settings are optional and configured via environment variables (set in the MCP server env block):
Variable | Default | Description |
| 300000 | Build timeout in milliseconds |
| 500 | Max stdout lines to keep |
| 500 | Spring Boot log ring buffer size |
| 120000 | Max wait for Spring Boot startup |
| true | Enable/disable build caching |
| — | Default Maven profile |
| — | Override JDK path |
|
| Full path to |
|
| Enable/disable build cache |
|
| SonarQube server URL |
| — | SonarQube authentication token (user token, not project-scoped) |
| — | Default SonarQube project key (e.g. |
Project Structure
src/
├── index.ts # Entry point
├── core/ # Server setup, types, config
│ ├── server.ts # MCP server init, tool registration
│ ├── config.ts # Environment variable loader
│ └── types.ts # Shared TypeScript interfaces
├── project/ # Project discovery
│ ├── discovery.ts # pom.xml upward scan, module resolution
│ ├── pom-parser.ts # XML parser for pom.xml
│ └── java-env.ts # JDK version detection (all sources)
├── maven/ # Maven execution
│ ├── runner.ts # mvn process spawn with execa
│ ├── parser.ts # Javac error parser (JDK 8–21)
│ ├── reports.ts # Surefire/Failsafe XML reader
│ └── process-manager.ts # Process queue, cancel, timeout
├── tools/ # MCP tool implementations
│ ├── index.ts # Tool registry
│ ├── compile.ts # compileProject, getCompilationErrors
│ ├── test.ts # runTests, runSingleTest, getFailedTests
│ ├── build.ts # verifyProject, packageProject, cleanProject
│ ├── project.ts # getProjectInfo, getJavaInfo, getMavenInfo, ping
│ └── spring-boot.ts # Spring Boot lifecycle tools
└── utils/
└── spring-boot-manager.ts # Long-running process managementLicense
MIT
Available Tools
20 toolscleanProjectC
Clean the project (mvn clean)
Inputs: module.
compileProjectB
Compile the Maven project and return structured compilation errors
Inputs: module, profile.
executeMavenCommandB
Execute an arbitrary Maven command with custom arguments. Output is parsed for errors.
Inputs: args (required), module.
getCompilationErrorsC
Run compile and return only the structured error list (no success noise)
Inputs: module, profile.
getFailedTestsA
Read test reports and return only failed/errored tests without re-running
Inputs: module.
getJavaInfoA
Detect which JDK is being used — from JAVA_HOME, mvn --version, or PATH
Inputs: no named parameters.
getMavenInfoA
Get Maven version and path from mvn --version
Inputs: no named parameters.
getProjectInfoA
Detect the current Maven project structure: root, modules, Java version
Inputs: no named parameters.
getTestReportsA
Read test reports from disk without running tests again
Inputs: module.
packageProjectC
Package the project as JAR/WAR (skip tests by default)
Inputs: module, profile, skipTests.
pingA
Health check — verify the MCP server is alive and responding
Inputs: no named parameters.
runSingleMethodB
Run a single test method and return structured results
Inputs: className (required), methodName (required), module.
runSingleTestB
Run a single test class and return structured results
Inputs: className (required), module.
runTestsA
Run all tests (mvn test) and return structured results
Inputs: module, profile.
springBootLogsC
Get the most recent log lines from the running Spring Boot application
Inputs: lines, module.
springBootRestartC
Restart the Spring Boot application (stop then start)
Inputs: module, profile.
springBootRunB
Start the Spring Boot application. Captures logs and detects port/startup.
Inputs: module, profile, waitForStartup.
springBootStatusB
Get the current status of the Spring Boot application (port, PID, uptime, health)
Inputs: module.
springBootStopA
Stop the Spring Boot application gracefully (actuator shutdown first, SIGTERM fallback)
Inputs: module.
verifyProjectB
Run mvn verify — compile, test, and integration-check the project
Inputs: module, profile.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 20 tools
Each tool targets a specific task without overlap. Maven build, test, and Spring Boot operations are clearly separated, and tools like getCompilationErrors and getFailedTests have distinct purposes from their run counterparts.
Most tools follow a verb+noun pattern (e.g., cleanProject, compileProject), but springBootLogs, springBootStatus, and springBootStop lack verbs, deviating slightly. Overall, the pattern is predictable and readable.
20 tools cover Maven build lifecycle, test reporting, project info, and Spring Boot management. While slightly numerous, each tool serves a distinct purpose and the scope is well-defined.
The tool set provides comprehensive coverage for Maven development workflows: clean, compile, test (single/class/all), package, verify, plus error retrieval and test report reading. Spring Boot lifecycle (start, stop, restart, status, logs) is fully covered. Missing deploy or install, but these are less common in typical development cycles.
Maintenance
Related MCP Connectors
Source-checked CLI guides and model-aware planning for Claude Code, Codex, and Grok Build.
Build Spring Boot applications, ready for coding agents, including best practices.
Build, test and cache insights for Xcode, Gradle and Bazel projects, for coding agents.
Build Laravel apps through conversation. Code stored as structured JSON for surgical AI edits.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA utility toolkit that enhances Claude's code interaction capabilities by providing seamless tools for Java code analysis, manipulation, and testing workflows.3ISC
- AlicenseAqualityDmaintenanceProvides structured build, compile, and test operations with parsed output to reduce token usage and improve readability.91MIT
- AlicenseNot gradedqualityDmaintenanceProvides MCP tools for common developer operations like file outlining, git commit context, test summary, process management, and waiting for conditions, returning structured JSON to reduce token usage.MIT
- AlicenseNot gradedqualityAmaintenanceWraps developer tools like git, npm, Docker, and test runners to return clean, schema-validated JSON instead of raw terminal text. This lets agents use typed, token-efficient results directly without brittle string parsing.4 npmMIT