make
Execute Makefile targets to run tests, format code, and automate development tasks through natural language commands.
Instructions
Run a make target from the Makefile
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target | Yes | Make target to run |
Implementation Reference
- src/mcp_server_make/server.py:69-135 (handler)The call_tool decorator and function that serves as the handler for the 'make' tool. It validates arguments using the Make schema, executes the 'make' subprocess with the specified target and Makefile path, captures stdout/stderr, and returns the results or error messages.@server.call_tool() async def call_tool(name: str, arguments: Dict[str, Any]) -> List[TextContent]: """Execute a tool. Args: name: Name of the tool to execute arguments: Arguments for the tool Returns: List of text content with tool execution results """ if name != "make": return [TextContent(type="text", text=f"Unknown tool: {name}")] try: args = Make(**arguments) except Exception as e: return [TextContent(type="text", text=f"Invalid arguments: {str(e)}")] try: # Run make command proc = await asyncio.create_subprocess_exec( "make", "-f", make_path, args.target, stdout=PIPE, stderr=PIPE, # Ensure proper error propagation from child process start_new_session=True, ) except Exception as e: return [ TextContent(type="text", text=f"Failed to start make process: {str(e)}") ] try: stdout, stderr = await proc.communicate() except asyncio.CancelledError: # Handle task cancellation if proc.returncode is None: try: proc.terminate() await asyncio.sleep(0.1) if proc.returncode is None: proc.kill() except Exception: pass raise except Exception as e: return [ TextContent(type="text", text=f"Error during make execution: {str(e)}") ] stderr_text = stderr.decode() if stderr else "" stdout_text = stdout.decode() if stdout else "" if proc.returncode != 0: return [ TextContent( type="text", text=f"Make failed with exit code {proc.returncode}:\n{stderr_text}\n{stdout_text}", ) ] return [TextContent(type="text", text=stdout_text)]
- src/mcp_server_make/server.py:22-26 (schema)Pydantic BaseModel defining the input schema for the 'make' tool, which requires a 'target' string field describing the make target to run.class Make(BaseModel): """Parameters for running make.""" target: str = Field(description="Make target to run")
- src/mcp_server_make/server.py:54-68 (registration)The list_tools handler that registers the single 'make' tool, providing its name, description, and input schema derived from the Make model.@server.list_tools() async def list_tools() -> List[Tool]: """List available tools. Returns: List of available tools, currently only the make tool. """ return [ Tool( name="make", description="Run a make target from the Makefile", inputSchema=Make.model_json_schema(), ) ]