Skip to main content
Glama

exec_make_target

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

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"

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