data_estimated_size
Calculate the estimated size of an input data file in specified units (b, kb, mb, gb, tb) using this tool for efficient data management and preprocessing.
Instructions
Estimated size of the input data
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input_data_file_path | No | Path to the input data file | |
| unit | No | Unit for the estimated size | b |
Implementation Reference
- The main handler function that executes the tool: parses input arguments, loads the dataframe, computes the estimated size in specified unit, formats result as JSON, and returns as TextContent.async def handle_data_estimated_size( arguments: dict[str, Any], ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]: data_estimated_size_input = DataEstimatedSizeInputSchema.from_args(arguments) estimated_size = data_estimated_size_input.df.estimated_size(unit=data_estimated_size_input.unit) result_dict = { "description": "Estimated size of the input data", "size": estimated_size, "unit": data_estimated_size_input.unit, } return [ types.TextContent( type="text", text=json.dumps(result_dict), ) ]
- Pydantic model defining input schema, including static methods for MCP inputSchema, from_schema (loads Data from file), and from_args (parses tool arguments).class DataEstimatedSizeInputSchema(Data): model_config = ConfigDict( validate_assignment=True, frozen=True, extra="forbid", arbitrary_types_allowed=True, ) unit: str = Field( default="b", description="Unit for the estimated size. One of: 'b' (bytes), 'kb', 'mb', 'gb', 'tb'", ) @staticmethod def input_schema() -> dict: return { "type": "object", "properties": { "input_data_file_path": { "type": "string", "description": "Path to the input data file", }, "unit": { "type": "string", "enum": ["b", "kb", "mb", "gb", "tb"], "description": "Unit for the estimated size", "default": "b", }, }, } @staticmethod def from_schema( input_data_file_path: str, unit: str = "b", ) -> "DataEstimatedSizeInputSchema": data = Data.from_file(input_data_file_path) return DataEstimatedSizeInputSchema( df=data.df, unit=unit, ) @staticmethod def from_args(arguments: dict[str, Any]) -> "DataEstimatedSizeInputSchema": input_data_file_path = arguments["input_data_file_path"] unit = arguments.get("unit", "b") return DataEstimatedSizeInputSchema.from_schema( input_data_file_path=input_data_file_path, unit=unit, )
- src/mcp_server_data_wrangler/tools/tools.py:82-86 (registration)Registers the tool schema (name, description, inputSchema) in the MCPServerDataWrangler.tools() method which returns the list of all tools.types.Tool( name=MCPServerDataWrangler.data_estimated_size.value[0], description=MCPServerDataWrangler.data_estimated_size.value[1], inputSchema=DataEstimatedSizeInputSchema.input_schema(), ),
- src/mcp_server_data_wrangler/tools/tools.py:155-155 (registration)Maps the tool name to its handler function in the tool_to_handler() dictionary used for dispatching.MCPServerDataWrangler.data_estimated_size.value[0]: handle_data_estimated_size,
- src/mcp_server_data_wrangler/tools/tools.py:43-43 (registration)Enum member in MCPServerDataWrangler defining the canonical tool name and description.data_estimated_size = ("data_estimated_size", "Estimated size of the input data")