get_gradle_config
Retrieve current Gradle configuration including JVM arguments, daemon settings, and version information to diagnose memory issues and understand project setup.
Instructions
Get current Gradle configuration including memory settings.
Returns configuration from gradle.properties and gradle-wrapper.properties including JVM args, daemon settings, and Gradle version info. Useful for diagnosing memory issues or understanding project configuration.
Returns: GradleConfigResult with JVM args, daemon/parallel/caching settings, max workers, distribution URL, and Gradle version.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/gradle_mcp/server.py:530-575 (handler)MCP tool handler for get_gradle_config. Creates GradleWrapper instance, calls its get_config() method, and returns structured GradleConfigResult or empty on error.@mcp.tool() async def get_gradle_config(ctx: Context | None = None) -> GradleConfigResult: """Get current Gradle configuration including memory settings. Returns configuration from gradle.properties and gradle-wrapper.properties including JVM args, daemon settings, and Gradle version info. Useful for diagnosing memory issues or understanding project configuration. Returns: GradleConfigResult with JVM args, daemon/parallel/caching settings, max workers, distribution URL, and Gradle version. """ try: if ctx: await ctx.info("Getting Gradle configuration") gradle = _get_gradle_wrapper(ctx) config = gradle.get_config() if ctx: await ctx.info("Retrieved Gradle configuration successfully") return GradleConfigResult( jvm_args=config["jvm_args"], daemon_enabled=config["daemon_enabled"], parallel_enabled=config["parallel_enabled"], caching_enabled=config["caching_enabled"], max_workers=config["max_workers"], distribution_url=config["distribution_url"], gradle_version=config["gradle_version"], ) except Exception as e: # Return a result with None values and could log the error if ctx: await ctx.error("Failed to get Gradle configuration", extra={"error": str(e)}) # Return empty config - all fields are optional (None) return GradleConfigResult( jvm_args=None, daemon_enabled=None, parallel_enabled=None, caching_enabled=None, max_workers=None, distribution_url=None, gradle_version=None, )
- src/gradle_mcp/server.py:132-142 (schema)Pydantic model defining the output schema for the get_gradle_config tool response.class GradleConfigResult(BaseModel): """Result of Gradle configuration query.""" jvm_args: str | None daemon_enabled: bool | None parallel_enabled: bool | None caching_enabled: bool | None max_workers: int | None distribution_url: str | None gradle_version: str | None
- src/gradle_mcp/gradle.py:1315-1373 (helper)Core helper method in GradleWrapper class that reads and parses gradle.properties and gradle-wrapper.properties to extract configuration values like JVM args, daemon/parallel/caching settings, max workers, distribution URL, and Gradle version.def get_config(self) -> dict: """Get current Gradle configuration including memory settings. Returns: dict with: - jvm_args: str | None (from gradle.properties org.gradle.jvmargs) - daemon_enabled: bool | None (from org.gradle.daemon) - parallel_enabled: bool | None (from org.gradle.parallel) - caching_enabled: bool | None (from org.gradle.caching) - max_workers: int | None (from org.gradle.workers.max) - distribution_url: str | None (from wrapper properties) - gradle_version: str | None (extracted from distribution URL) """ def parse_bool(value: str | None) -> bool | None: """Parse a boolean string value.""" if value is None: return None return value.lower() == "true" def parse_int(value: str | None) -> int | None: """Parse an integer string value.""" if value is None: return None try: return int(value) except ValueError: return None def extract_gradle_version(distribution_url: str | None) -> str | None: """Extract Gradle version from distribution URL. Examples: - https://services.gradle.org/distributions/gradle-8.5-bin.zip -> 8.5 - https://services.gradle.org/distributions/gradle-8.5-all.zip -> 8.5 """ if distribution_url is None: return None # Match patterns like gradle-8.5-bin.zip or gradle-8.5-all.zip match = re.search(r"gradle-([\d.]+(?:-\w+)?)-(?:bin|all)\.zip", distribution_url) if match: return match.group(1) return None gradle_props = self.gradle_properties wrapper_props = self.wrapper_properties distribution_url = wrapper_props.get("distributionUrl") return { "jvm_args": gradle_props.get("org.gradle.jvmargs"), "daemon_enabled": parse_bool(gradle_props.get("org.gradle.daemon")), "parallel_enabled": parse_bool(gradle_props.get("org.gradle.parallel")), "caching_enabled": parse_bool(gradle_props.get("org.gradle.caching")), "max_workers": parse_int(gradle_props.get("org.gradle.workers.max")), "distribution_url": distribution_url, "gradle_version": extract_gradle_version(distribution_url), }