Skip to main content
Glama

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
input_data_file_pathNoPath 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)
  • 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(), ),
  • Maps the 'data_product' tool name to its handler function in the tool_to_handler dictionary.
    MCPServerDataWrangler.data_product.value[0]: handle_data_product,
  • Defines the tool name and description in the MCPServerDataWrangler enum.
    data_product = ("data_product", "Product values for each column")

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/shibuiwilliam/mcp-server-data-wrangler'

If you have feedback or need assistance with the MCP directory API, please join our Discord server