data_shape
Analyze and extract the structure and format of input data files to understand key characteristics for preprocessing and transformation tasks.
Instructions
Data shape of the input data
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input_data_file_path | No | Path to the input data file |
Implementation Reference
- The async handler function for the 'data_shape' tool. Parses input arguments, loads the DataFrame from the specified file, computes its shape (rows and columns), and returns a JSON-formatted text content with the results.async def handle_data_shape( arguments: dict[str, Any], ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]: data_shape_input = DataShapeInputSchema.from_args(arguments) data_shape = data_shape_input.df.shape num_rows = data_shape[0] num_cols = data_shape[1] return [ types.TextContent( type="text", text=json.dumps( { "description": "Data shape of the input data", "rows": num_rows, "cols": num_cols, } ), ) ]
- Pydantic model defining the input schema for the 'data_shape' tool. Subclass of Data, provides input_schema() method returning the JSON schema for MCP Tool inputSchema, and factory methods to construct from file path or arguments by loading the DataFrame.class DataShapeInputSchema(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(inuput_data_file_path: str) -> "DataShapeInputSchema": data = Data.from_file(inuput_data_file_path) return DataShapeInputSchema(df=data.df) @staticmethod def from_args(arguments: dict[str, Any]) -> "DataShapeInputSchema": input_data_file_path = arguments["input_data_file_path"] return DataShapeInputSchema.from_schema(inuput_data_file_path=input_data_file_path)
- src/mcp_server_data_wrangler/tools/tools.py:67-71 (registration)Registration of the 'data_shape' tool in the MCPServerDataWrangler.tools() static method, creating the MCP types.Tool object with name, description from enum, and inputSchema from DataShapeInputSchema.input_schema().types.Tool( name=MCPServerDataWrangler.data_shape.value[0], description=MCPServerDataWrangler.data_shape.value[1], inputSchema=DataShapeInputSchema.input_schema(), ),
- src/mcp_server_data_wrangler/tools/tools.py:152-152 (registration)Handler registration for 'data_shape' tool in the MCPServerDataWrangler.tool_to_handler() dict, mapping the tool name to the handle_data_shape function.MCPServerDataWrangler.data_shape.value[0]: handle_data_shape,
- src/mcp_server_data_wrangler/tools/tools.py:40-40 (registration)Enum definition for 'data_shape' in MCPServerDataWrangler, providing the tool name and description used in tool registration.data_shape = ("data_shape", "Data shape of the input data")