Skip to content

Maven Central Version Maven snapshots GitHub Repo GitHub License

Gradle MCP server

A MCP server for Gradle. Tools include introspecting projects, running tasks, and running tests. Also supports publishing Develocity Build Scans.

Installation

JDK Requirement

JDK 17 or higher is required to run gradle-mcp. You can use JBang to install JDKs too: docs.

Use jbang:

jbang run --fresh dev.rnett.gradle-mcp:gradle-mcp:+ stdio

For snapshots:

jbang run --fresh \
  --repos snapshots=https://central.sonatype.com/repository/maven-snapshots/ \
  dev.rnett.gradle-mcp:gradle-mcp:+ stdio

You can add an alias to make invoking it easier:

jbang alias add dev.rnett.gradle-mcp:gradle-mcp:+

Then run it with jbang gradle-mcp stdio.

Or even install it as a command (gradle-mcp):

jbang app setup
jbang app install --name gradle-mcp dev.rnett.gradle-mcp:gradle-mcp:+

See jbang documentation for more details.

Example MCP configuration

{
  "mcpServers": {
    "gradle": {
      "command": "jbang",
      "args": [
        "run",
        "--fresh",
        "dev.rnett.gradle-mcp:gradle-mcp:+",
        "stdio"
      ]
    }
  }
}

Environment Variables

The server forwards its environment variables to Gradle. If your Gradle build relies on environment variables, e.g. for JDK detection, you may want to run the server in a shell rather than using jbang directly in your MCP configuration. While MCP hosts should pass their environment to the server, this isn't always the case.

{
  "mcpServers": {
    "gradle": {
      "command": "bash -c",
      "args": [
        "jbang run --fresh dev.rnett.gradle-mcp:gradle-mcp:+ stdio"
      ]
    }
  }
}

Usage

Run the server. It accepts a single argument, stdio, to run in STDIO mode. By default it runs as a server on port 47813.

Danger

DO NOT EVER EXPOSE THIS SERVER TO THE INTERNET.

Publishing Build Scans

Even if you don't have your build configured to publish build scans automatically, you can still publish build scans - just ask your agent to publish a scan when invoking Gradle. These will publish to the public https://scans.gradle.com instance unless you have a Develocity instance configured in your build. You will be prompted by your agent to accept the terms of service for publishing scans. If your agent does not support elicitation, you will not be able to publish scans.