Skip to main content
Glama

analyze_data

Analyze datasets to extract statistics and identify data types, enabling data exploration and insight generation from files.

Instructions

Perform basic analysis on a dataset.

Args: file_path: Path to the data file

Returns: Analysis results including statistics and data types

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The analyze_data tool handler that performs basic analysis on datasets. It loads data from a file (CSV, JSON, Excel, TSV) using pandas, analyzes each column for data type, null counts, sample values, and basic statistics (min/max/mean for numeric columns, most common values for text columns), and returns the analysis as JSON.
    @mcp.tool()
    def analyze_data(file_path: str) -> str:
        """
        Perform basic analysis on a dataset.
        
        Args:
            file_path: Path to the data file
        
        Returns:
            Analysis results including statistics and data types
        """
        try:
            import pandas as pd
            from pathlib import Path
            
            file_extension = Path(file_path).suffix.lower()
            
            # Load with pandas
            if file_extension == '.csv':
                df = pd.read_csv(file_path)
            elif file_extension == '.json':
                df = pd.read_json(file_path)
            elif file_extension in ['.xlsx', '.xls']:
                df = pd.read_excel(file_path)
            elif file_extension == '.tsv':
                df = pd.read_csv(file_path, sep='\t')
            else:
                df = pd.read_csv(file_path)
            
            analysis = {
                "filename": Path(file_path).name,
                "total_rows": len(df),
                "total_columns": len(df.columns),
                "columns": []
            }
            
            # Analyze each column
            for col_name in df.columns:
                col_data = df[col_name]
                
                col_info = {
                    "name": col_name,
                    "type": str(col_data.dtype),
                    "null_count": int(col_data.isna().sum()),
                    "non_null_count": int(col_data.notna().sum()),
                }
                
                # Get some sample values
                sample_values = []
                valid_values = col_data.dropna().head(5)
                for value in valid_values:
                    if hasattr(value, 'item'):  # numpy types
                        sample_values.append(value.item())
                    else:
                        sample_values.append(str(value) if value is not None else None)
                
                col_info["sample_values"] = sample_values
                
                # Add basic statistics for numeric columns
                if pd.api.types.is_numeric_dtype(col_data):
                    col_info["min"] = float(col_data.min()) if not col_data.empty else None
                    col_info["max"] = float(col_data.max()) if not col_data.empty else None
                    col_info["mean"] = float(col_data.mean()) if not col_data.empty else None
                    col_info["unique_count"] = int(col_data.nunique())
                else:
                    col_info["unique_count"] = int(col_data.nunique())
                    col_info["most_common"] = list(col_data.value_counts().head(3).index)
                
                analysis["columns"].append(col_info)
            
            return json.dumps(analysis, indent=2)
            
        except Exception as e:
            return f"Error analyzing data: {str(e)}\n{traceback.format_exc()}"
  • The @mcp.tool() decorator registers the analyze_data function as an MCP tool with the FastMCP server.
    @mcp.tool()
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions that the tool 'Perform[s] basic analysis' and returns 'Analysis results including statistics and data types', but fails to specify what 'basic analysis' includes (e.g., summary statistics, data profiling), any constraints (e.g., file size limits, supported formats), or side effects. For a tool with no annotation coverage, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise and structured with clear sections for 'Args' and 'Returns'. It uses three sentences efficiently, though the first sentence 'Perform basic analysis on a dataset' could be more specific. There is no redundant information, and the structure aids readability, but it lacks depth that might justify additional content.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (basic analysis with one parameter), no annotations, and the presence of an output schema (which handles return values), the description is minimally complete. However, it fails to address key contextual aspects like what 'basic analysis' entails compared to siblings, supported data formats, or limitations. The output schema mitigates some gaps, but the description remains inadequate for fully informed tool selection.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds minimal semantics beyond the input schema. It states 'file_path: Path to the data file', which echoes the schema's title 'File Path' without providing additional context (e.g., supported file formats, path requirements). With 0% schema description coverage and only one parameter, the baseline is 4, but the description does little to compensate, offering only basic clarification rather than meaningful elaboration.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool 'Perform[s] basic analysis on a dataset', which provides a vague but understandable purpose. It specifies the verb ('analyze') and resource ('dataset'), but lacks specificity about what 'basic analysis' entails compared to more specialized sibling tools like 'get_column_stats' or 'create_distribution_plots'. The purpose is not tautological but remains broad without distinguishing from alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus its many siblings. With tools like 'get_column_stats', 'create_distribution_plots', 'filter_data', and 'load_data' available, there is no indication of what makes 'analyze_data' distinct or when it should be preferred over more specific analysis tools. The description implies usage but offers no explicit context or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/moeloubani/visidata-mcp'

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