data_min_horizontal
Calculate minimum values across columns for each row in a dataset. Specify the input file path to process data and generate row-wise minimums using MCP Data Wrangler.
Instructions
Minimum values across columns for each row
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input_data_file_path | No | Path to the input data file |
Implementation Reference
- The main handler function for the 'data_min_horizontal' tool. It parses input using DataMinInputSchema, computes df.min_horizontal(), formats results as JSON, and returns as TextContent. Handles exceptions.async def handle_data_min_horizontal( arguments: dict[str, Any], ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]: data_min_input = DataMinInputSchema.from_args(arguments) try: min_horizontal_df = data_min_input.df.min_horizontal() # Convert the DataFrame to a dictionary format min_horizontal_dict = { "description": "Minimum values across columns for each row", "min_values": {str(i): str(val) if val is not None else None for i, val in enumerate(min_horizontal_df)}, } return [ types.TextContent( type="text", text=json.dumps(min_horizontal_dict), ) ] except Exception as e: logger.error(f"Error calculating min: {e}") return [ types.TextContent( type="text", text=json.dumps( { "error": "Failed to calculate min values.", "message": str(e), } ), ) ]
- Pydantic schema for input validation. Defines input_schema() for the tool's inputSchema, loads Data from file, provides from_args/from_schema factory methods.class DataMinInputSchema(Data): model_config = ConfigDict( validate_assignment=True, frozen=True, extra="forbid", arbitrary_types_allowed=True, ) @staticmethod def input_schema() -> dict: return { "type": "object", "properties": { "input_data_file_path": { "type": "string", "description": "Path to the input data file", }, }, } @staticmethod def from_schema(input_data_file_path: str) -> "DataMinInputSchema": data = Data.from_file(input_data_file_path) return DataMinInputSchema(df=data.df) @staticmethod def from_args(arguments: dict[str, Any]) -> "DataMinInputSchema": input_data_file_path = arguments["input_data_file_path"] return DataMinInputSchema.from_schema(input_data_file_path=input_data_file_path)
- src/mcp_server_data_wrangler/tools/tools.py:107-111 (registration)Tool registration in MCPServerDataWrangler.tools(): creates types.Tool object with name, description from enum, and inputSchema from DataMinInputSchema.types.Tool( name=MCPServerDataWrangler.data_min_horizontal.value[0], description=MCPServerDataWrangler.data_min_horizontal.value[1], inputSchema=DataMinInputSchema.input_schema(), ),
- src/mcp_server_data_wrangler/tools/tools.py:160-160 (registration)Handler mapping in MCPServerDataWrangler.tool_to_handler(): maps tool name to handle_data_min_horizontal function.MCPServerDataWrangler.data_min_horizontal.value[0]: handle_data_min_horizontal,
- src/mcp_server_data_wrangler/tools/tools.py:48-48 (registration)Enum definition in MCPServerDataWrangler providing the tool name and description used in registration.data_min_horizontal = ("data_min_horizontal", "Minimum values across columns for each row")