Skip to main content
Glama
jermeyyy
by jermeyyy

list_projects

Lists all Gradle projects in the workspace to help developers identify available projects and manage their build environment.

Instructions

List all Gradle projects in the workspace.

Returns: List of Gradle projects.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The primary handler function for the 'list_projects' MCP tool. It is registered via the @mcp.tool() decorator, fetches projects using GradleWrapper, and returns a list of ProjectInfo objects.
    @mcp.tool()
    async def list_projects(ctx: Context) -> list[ProjectInfo]:
        """List all Gradle projects in the workspace.
    
        Returns:
            List of Gradle projects.
        """
        try:
            await ctx.info("Listing all Gradle projects")
            gradle = _get_gradle_wrapper(ctx)
            projects = gradle.list_projects()
            await ctx.info(f"Found {len(projects)} projects: {', '.join(p.name for p in projects)}")
            return [
                ProjectInfo(
                    name=p.name,
                    path=p.path,
                    description=p.description,
                )
                for p in projects
            ]
        except Exception as e:
            raise ValueError(f"Failed to list projects: {str(e)}") from e
  • Pydantic BaseModel defining the output schema for the list_projects tool, specifying fields for project name, path, and optional description.
    class ProjectInfo(BaseModel):
        """Information about a Gradle project."""
    
        name: str
        path: str
        description: str | None = None
  • Core helper method in GradleWrapper class that executes 'gradlew projects -q', parses the output, and constructs GradleProject objects used by the tool handler.
    def list_projects(self) -> list[GradleProject]:
        """List all Gradle projects in the workspace.
    
        Returns:
            List of GradleProject objects.
    
        Raises:
            subprocess.CalledProcessError: If Gradle command fails.
        """
        try:
            result = subprocess.run(
                [str(self.wrapper_script), "projects", "-q"],
                cwd=str(self.project_root),
                capture_output=True,
                text=True,
                check=True,
                env=self._build_execution_environment(),
            )
    
            projects = []
            root_added = False
    
            for line in result.stdout.split("\n"):
                line = line.strip()
    
                # Add root project (only once)
                if "Root project" in line and not root_added:
                    projects.append(
                        GradleProject(
                            name=":", path=str(self.project_root), description="Root project"
                        )
                    )
                    root_added = True
                    continue
    
                # Look for subproject lines like "+--- Project ':app'" or "Project ':app'"
                # But skip if it's the root project line we already handled
                if "Project '" in line and "Root project" not in line:
                    # Extract project name from various formats
                    match = re.search(r"Project '([^']+)'", line)
                    if match:
                        project_name = match.group(1)
                        # Skip root project if it appears again
                        if project_name != ":":
                            projects.append(
                                GradleProject(
                                    name=project_name,
                                    path=str(self.project_root),
                                )
                            )
    
            return projects
        except subprocess.CalledProcessError as e:
            raise RuntimeError(f"Failed to list projects: {e.stderr}") from e
  • Dataclass defining the internal structure for Gradle projects, mirrored by the ProjectInfo schema in server.py.
    @dataclass
    class GradleProject:
        """Represents a Gradle project."""
    
        name: str
        path: str
        description: str | None = None
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool returns a list of projects, which is helpful, but doesn't cover important aspects like whether this is a read-only operation, potential performance impacts, error conditions, or pagination behavior. The description adds minimal behavioral context beyond the basic return statement.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise with two clear sentences. The first states the purpose, and the second describes the return value. There's no wasted language, though it could be slightly more structured by combining both pieces of information into a single flowing sentence.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given that the tool has no parameters, an output schema exists, and it's a relatively simple list operation, the description provides adequate basic information. However, for a tool with no annotations, it should ideally include more behavioral context about what 'list all' means in practice (e.g., completeness guarantees, ordering, or limitations).

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters with 100% schema description coverage, so the schema already fully documents the parameter situation. The description doesn't need to add parameter information, and it correctly doesn't attempt to describe non-existent parameters. This meets the baseline expectation for tools with no parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('List') and resource ('Gradle projects in the workspace'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'list_project_tasks', which could cause confusion about when to use each tool.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'list_project_tasks' or 'get_gradle_config'. It doesn't mention prerequisites, context, or exclusions, leaving the agent to infer usage from tool names alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/jermeyyy/gradle-mcp'

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