Gradle MCP
STDIOMCP server enabling AI tools to interact with Gradle projects programmatically.
MCP server enabling AI tools to interact with Gradle projects programmatically.
A Model Context Protocol (MCP) server that enables AI tools to interact with Gradle projects programmatically. It uses the Gradle Tooling API to query project information and execute tasks.
Provides tools for:
clean
, build
, assemble
) with custom arguments, JVM arguments, and environment variables. Returns formatted text output including stdout/stderr and status.test
) and receive detailed, structured results in a hierarchical JSON format (Suite -> Class -> Method). Includes:
--tests
).curl
This method downloads the server JAR to a standard location in your home directory.
Linux / macOS (requires curl
):
# Downloads gradle-mcp-server-all.jar to ~/mcp-servers/gradle-mcp-server/ TARGET_DIR="$HOME/mcp-servers/gradle-mcp-server" && mkdir -p "$TARGET_DIR" && curl -fSL -o "$TARGET_DIR/gradle-mcp-server-all.jar" "https://github.com/IlyaGulya/gradle-mcp-server/releases/latest/download/gradle-mcp-server-all.jar" && echo "Downloaded to '$TARGET_DIR'." || echo "Download failed."
Windows (PowerShell 5+):
# Downloads gradle-mcp-server-all.jar to %USERPROFILE%\mcp-servers\gradle-mcp-server\ $targetDir = Join-Path $env:USERPROFILE "mcp-servers\gradle-mcp-server"; if (-not (Test-Path $targetDir)) { New-Item -ItemType Directory -Path $targetDir -Force | Out-Null }; $outFile = Join-Path $targetDir "gradle-mcp-server-all.jar"; Write-Host "Downloading..."; Invoke-WebRequest -Uri "https://github.com/IlyaGulya/gradle-mcp-server/releases/latest/download/gradle-mcp-server-all.jar" -OutFile $outFile -ErrorAction Stop; Write-Host "Downloaded to '$targetDir'."
gradle-mcp-server-all.jar
asset from the latest release.~/mcp-servers/gradle-mcp-server/
%USERPROFILE%\mcp-servers\gradle-mcp-server\
(Create the directory if it doesn't exist).To use this server with an MCP client (like the VSCode extension or Claude Desktop app), you need to add its configuration to the client's settings file.
Locate the settings file:
/Users/<YourUsername>/Library/Application Support/VSCodium/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
(Adjust path for standard VSCode or other OS).~/Library/Application Support/Claude/claude_desktop_config.json
(Adjust path for other OS).Add the server configuration: Edit the JSON file and add the following entry inside the mcpServers
object. Replace <absolute_path_to_home>
with the actual absolute path to your home directory.
{ "mcpServers": { "gradle-mcp-server": { "command": "java", "args": [ "-jar", "<absolute_path_to_home>/mcp-servers/gradle-mcp-server/gradle-mcp-server-all.jar" ], "env": {}, "disabled": false, "autoApprove": [] } } }
The server exposes the following tools via the Model Context Protocol:
Get Gradle Project Info
buildStructure
, tasks
, environment
, projectDetails
). If requestedInfo
is omitted, all categories are fetched.projectPath
(string, required): Absolute path to the Gradle project root.requestedInfo
(array of strings, optional): List of categories to retrieve (e.g., ["tasks", "environment"]
).GradleProjectInfoResponse
) containing the requested data fields and potential errors.Execute Gradle Task
build
, clean
). Not recommended for running tests if detailed results are needed (use the test tool instead). Returns formatted text output summarizing execution and including captured stdout/stderr.projectPath
(string, required): Absolute path to the Gradle project root.tasks
(array of strings, required): List of task names to execute (e.g., ["clean", "assemble"]
).arguments
(array of strings, optional): Gradle command-line arguments (e.g., ["--info", "-PmyProp=value"]
).jvmArguments
(array of strings, optional): JVM arguments for Gradle (e.g., ["-Xmx4g"]
).environmentVariables
(object, optional): Environment variables for the build (e.g., {"CI": "true"}
).Success
/Failure
), and combined stdout/stderr.Run Gradle Tests
projectPath
(string, required): Absolute path to the Gradle project root.gradleTasks
(array of strings, optional): Test tasks to run (defaults to ["test"]
).arguments
(array of strings, optional): Additional Gradle arguments (verbose flags like --info
/--debug
are filtered out).environmentVariables
(object, optional): Environment variables for the test execution.testPatterns
(array of strings, optional): Test filter patterns passed via --tests
(e.g., ["*.MyTestClass"]
).includeOutputForPassed
(boolean, optional): Set to true
to include output for passed tests (default false
).maxLogLines
(integer, optional): Override the default limit on output lines per test (0 for unlimited).defaultMaxLogLines
(integer, optional): Set the default output line limit (defaults internally to 100).GradleHierarchicalTestResponse
) containing execution details, overall build success status, informative notes, and the test_hierarchy
tree. Each node includes display name, type, outcome, failure message (if any), filtered/truncated output lines, and children.If you want to build the server yourself:
./gradlew shadowJar
gradle-mcp-server-<version>-all.jar
) will be created in the build/libs/
directory. You can then configure your MCP client to use this JAR (remember to use the correct absolute path and version in the configuration).You can run the built JAR directly from the command line for testing purposes. The server communicates over stdio by default.
# Run the packaged JAR in stdio mode java -jar build/libs/gradle-mcp-server-<version>-all.jar # Run with specific arguments (see Configuration section) java -jar build/libs/gradle-mcp-server-<version>-all.jar --sse 8080 --debug
When running the server JAR directly (primarily for testing/development), its behavior can be controlled via command-line arguments:
--stdio
: (Default) Use standard input/output for MCP communication.--sse [port]
: Run as an SSE server on the specified port
(defaults to 3001 if port is omitted). Connect MCP clients (like the Anthropic Console Inspector) to http://localhost:<port>/sse
.--debug
: Enable verbose logging on the server console.build.gradle.kts
)