Skip to main content
Glama

data_var

Calculate variance values for each column in a dataset using MCP Data Wrangler. Specify the input file path and adjust Delta Degrees of Freedom for precise statistical analysis.

Instructions

Variance values for each column

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ddofNoDelta Degrees of Freedom: the divisor used in the calculation is N - ddof
input_data_file_pathYesPath to the input data file

Implementation Reference

  • The async handler function for the 'data_var' tool. It parses input arguments into DataVarInputSchema, computes variance for each column of the dataframe using pandas .var(ddof=...), formats results as a dictionary, and returns it as JSON text content.
    async def handle_data_var( arguments: dict[str, Any], ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]: data_var_input = DataVarInputSchema.from_args(arguments) var_df = data_var_input.df.var(ddof=data_var_input.ddof) # Convert the DataFrame to a dictionary format var_dict = { "description": f"Variance values for each column with ddof={data_var_input.ddof}", "var_values": {col: str(val) if val is not None else None for col, val in zip(var_df.columns, var_df.row(0))}, } return [ types.TextContent( type="text", text=json.dumps(var_dict), ) ]
  • Pydantic schema class DataVarInputSchema extending Data, including input_schema() for MCP tool schema, and factory methods from_schema() and from_args() to load dataframe from file and validate inputs.
    class DataVarInputSchema(Data): model_config = ConfigDict( validate_assignment=True, frozen=True, extra="forbid", arbitrary_types_allowed=True, ) ddof: int = Field( default=1, description="Delta Degrees of Freedom: the divisor used in the calculation is N - ddof", ge=0 ) @staticmethod def input_schema() -> dict: return { "type": "object", "properties": { "input_data_file_path": { "type": "string", "description": "Path to the input data file", }, "ddof": { "type": "integer", "description": "Delta Degrees of Freedom: the divisor used in the calculation is N - ddof", "minimum": 0, "default": 1, }, }, "required": ["input_data_file_path"], } @staticmethod def from_schema(input_data_file_path: str, ddof: int = 1) -> "DataVarInputSchema": data = Data.from_file(input_data_file_path) return DataVarInputSchema( df=data.df, ddof=ddof, ) @staticmethod def from_args(arguments: dict[str, Any]) -> "DataVarInputSchema": input_data_file_path = arguments["input_data_file_path"] ddof = arguments.get("ddof", 1) return DataVarInputSchema.from_schema( input_data_file_path=input_data_file_path, ddof=ddof, )
  • MCP Tool object registration for 'data_var', using enum value for name and description, and DataVarInputSchema.input_schema() for input validation.
    types.Tool( name=MCPServerDataWrangler.data_var.value[0], description=MCPServerDataWrangler.data_var.value[1], inputSchema=DataVarInputSchema.input_schema(), ),
  • Handler function mapping for 'data_var' tool to handle_data_var in the tool_to_handler() dictionary.
    MCPServerDataWrangler.data_var.value[0]: handle_data_var,

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