data_product
Extract product values for each column in a dataset. Uses the MCP Data Wrangler server to process and analyze data, enabling structured data transformation and preprocessing tasks.
Instructions
Product values for each column
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "data_product"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input_data_file_path | No | Path to the input data file |
Implementation Reference
- The handler function for the 'data_product' tool. It loads data from the input file path, computes the product for each column, formats it as a dictionary, and returns it as JSON text content.
async def handle_data_product( arguments: dict[str, Any], ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]: data_product_input = DataProductInputSchema.from_args(arguments) product_df = data_product_input.df.product() # Convert the DataFrame to a dictionary format product_dict = { "description": "Product values for each column", "product_values": { col: str(val) if val is not None else None for col, val in zip(product_df.columns, product_df.row(0)) }, } return [ types.TextContent( type="text", text=json.dumps(product_dict), ) ] - Pydantic model and methods defining the input schema and parsing for the data_product tool.
class DataProductInputSchema(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) -> "DataProductInputSchema": data = Data.from_file(input_data_file_path) return DataProductInputSchema(df=data.df) @staticmethod def from_args(arguments: dict[str, Any]) -> "DataProductInputSchema": input_data_file_path = arguments["input_data_file_path"] return DataProductInputSchema.from_schema(input_data_file_path=input_data_file_path) - src/mcp_server_data_wrangler/tools/tools.py:127-131 (registration)Creates and registers the 'data_product' Tool object with MCP types.Tool, specifying name, description, and inputSchema.
types.Tool( name=MCPServerDataWrangler.data_product.value[0], description=MCPServerDataWrangler.data_product.value[1], inputSchema=DataProductInputSchema.input_schema(), ), - src/mcp_server_data_wrangler/tools/tools.py:164-164 (registration)Maps the 'data_product' tool name to its handler function in the tool_to_handler dictionary.
MCPServerDataWrangler.data_product.value[0]: handle_data_product, - src/mcp_server_data_wrangler/tools/tools.py:52-52 (registration)Defines the tool name and description in the MCPServerDataWrangler enum.
data_product = ("data_product", "Product values for each column")