data_schema
Analyze and validate the structure of input data files to ensure compatibility with data wrangling processes in the MCP Data Wrangler server.
Instructions
Data schema 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 main handler function for the 'data_schema' tool. It processes input arguments, loads the data using DataSchemaInputSchema, extracts the schema from the dataframe, converts it to a dictionary, and returns it as JSON text content.async def handle_data_schema( arguments: dict[str, Any], ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]: data_schema_input = DataSchemaInputSchema.from_args(arguments) schema = data_schema_input.df.schema schema_dict = {col: str(dtype) for col, dtype in schema.items()} return [ types.TextContent( type="text", text=json.dumps( { "description": "Data schema of the input data", "schema": schema_dict, } ), ) ]
- Pydantic model defining the input schema for the 'data_schema' tool, including the JSON schema definition via input_schema(), and factory methods to load data from file or arguments.class DataSchemaInputSchema(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) -> "DataSchemaInputSchema": data = Data.from_file(input_data_file_path) return DataSchemaInputSchema(df=data.df) @staticmethod def from_args(arguments: dict[str, Any]) -> "DataSchemaInputSchema": input_data_file_path = arguments["input_data_file_path"] return DataSchemaInputSchema.from_schema(input_data_file_path=input_data_file_path)
- src/mcp_server_data_wrangler/tools/tools.py:72-76 (registration)Registration of the 'data_schema' tool in the list of MCP tools returned by MCPServerDataWrangler.tools(), specifying name, description, and input schema.types.Tool( name=MCPServerDataWrangler.data_schema.value[0], description=MCPServerDataWrangler.data_schema.value[1], inputSchema=DataSchemaInputSchema.input_schema(), ),
- src/mcp_server_data_wrangler/tools/tools.py:153-153 (registration)Mapping of the 'data_schema' tool name to its handler function in the tool_to_handler dictionary.MCPServerDataWrangler.data_schema.value[0]: handle_data_schema,
- src/mcp_server_data_wrangler/tools/tools.py:41-41 (registration)Enum definition providing the name and description for the 'data_schema' tool.data_schema = ("data_schema", "Data schema of the input data")