Skip to main content
Glama

exec_make_target

Destructive

Execute Makefile targets directly without terminal usage. Pass a list of targets to process and receive structured execution results for each. Simplifies build automation and task management.

Instructions

Use instead of terminal: Execute Makefile targets.

    Args:
        commands: List of Makefile targets to execute

    Returns:
        A dictionary containing the execution results for each target

    Raises:
        ValueError: If commands is not a list

    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function (__call__) that implements the tool logic for 'exec_make_target'. It validates input as a list of targets, executes each via _exec_commands, and returns a dict of results.
    async def __call__(
        self,
        commands: List[str],
    ) -> Dict[str, Any]:
        """Execute Makefile targets.
    
        Args:
            commands: List of Makefile targets to execute
    
        Returns:
            A dictionary containing the execution results for each target
    
        Raises:
            ValueError: If commands is not a list
    
        """
        # Handle both model and direct list input for backward compatibility
        if not isinstance(commands, list):
            raise ValueError("Expected a list of commands as the argument")
    
        result: Dict[str, Any] = {}
    
        for cmd in commands:
            await self._exec_commands(cmd, result)
        return result
  • Tool registration point in server initialization. Uses ToolFactory to dynamically import and register all tools exported from dev_kit_mcp_server.tools.__all__, including ExecMakeTarget with name 'exec_make_target'.
    # Register all tools
    tool_factory = ToolFactory(fastmcp)
    tool_factory(["dev_kit_mcp_server.tools"], root_dir=root_dir, commands_toml=commands_toml)
    return fastmcp
  • Supporting helper that performs the actual 'make' execution for a single target, including Makefile existence check, target validation, subprocess execution, and error raising on failure.
    async def _exec_commands(self, target: str, result: Dict[str, Any]) -> None:
        """Execute a Makefile target and store the result.
    
        Args:
            target: The Makefile target to execute
            commands: The list of all targets being executed
            result: Dictionary to store the execution results
    
        Raises:
            RuntimeError: If the make command returns a non-zero exit code
    
        """
        if not self._make_file_exists:
            result[target] = {
                "error": "'Makefile' not found",
                "directory": self._root_path.as_posix(),
            }
            return
        valid_cmd_regex = r"^[a-zA-Z0-9_-]+$"
    
        if not re.match(valid_cmd_regex, target):
            result[target] = {
                "error": f"Target '{target}' is invalid.",
            }
            return
    
        line = ["make", target, "--quiet"]
        process = await self.create_sub_proccess(line)
    
        stdout, stderr = await process.communicate()
    
        res = {
            "target": target,
            "stdout": stdout.decode(errors="replace"),
            "stderr": stderr.decode(errors="replace"),
            "exitcode": process.returncode,
            "cwd": self._root_path.as_posix(),
        }
        if process.returncode != 0:
            raise RuntimeError(f"non-zero exitcode: {process.returncode}. details: {res}")
    
        result[target] = res
  • Utility helper to create and configure subprocess for running shell commands (used for 'make' invocations).
    async def create_sub_proccess(self, cmd: List[str]) -> asyncio.subprocess.Process:
        """Create a subprocess to execute a shell command.
    
        Args:
            cmd: The shell command to execute as a list of strings
    
        Returns:
            A subprocess object with stdout and stderr pipes
    
        """
        process_get = await asyncio.create_subprocess_exec(
            *cmd,
            cwd=self._root_path.as_posix(),
            stdin=asyncio.subprocess.DEVNULL,
            stdout=asyncio.subprocess.PIPE,
            stderr=asyncio.subprocess.PIPE,
        )
        return process_get
  • Tool name definition, used for MCP registration and identification.
    name = "exec_make_target"
Behavior3/5

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

The annotations include 'destructiveHint: true,' indicating potential destructive behavior. The description adds context by mentioning it returns execution results and raises a ValueError for invalid input, which goes beyond the annotations. However, it doesn't detail what 'destructive' entails (e.g., file modifications, side effects) or other traits like rate limits or auth needs, limiting transparency.

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 sized and front-loaded with the core purpose. It uses a structured format with Args, Returns, and Raises sections, making it easy to scan. However, the initial phrase 'Use instead of terminal' is somewhat redundant and could be integrated more smoothly.

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

Completeness4/5

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

Given the tool's complexity (destructive hint, one parameter), the description is fairly complete. It explains the parameter, return values, and error handling, and with an output schema present, it doesn't need to detail return structure. However, it could better address the destructive nature and sibling tool differentiation.

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?

With 0% schema description coverage, the description compensates by explaining the 'commands' parameter as 'List of Makefile targets to execute' and noting it raises a ValueError if not a list. This adds meaningful semantics beyond the bare schema, though it could elaborate on target format or examples.

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 tool's purpose: 'Execute Makefile targets.' It specifies the verb ('Execute') and resource ('Makefile targets'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'predefined_commands' or terminal usage beyond the initial phrase 'Use instead of terminal,' which is somewhat vague.

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

Usage Guidelines3/5

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

The description provides implied usage guidance with 'Use instead of terminal,' suggesting this tool is preferred over direct terminal commands for executing Makefile targets. However, it lacks explicit when-to-use rules, alternatives (e.g., when to use 'predefined_commands' instead), or exclusions, leaving some ambiguity in context.

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

Related 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/DanielAvdar/dev-kit-mcp-server'

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