Skip to main content
Glama

load_data

Load data from files in formats like CSV, JSON, or XLSX to enable analysis and visualization within the VisiData environment.

Instructions

Load data from a file using VisiData.

Args: file_path: Path to the data file file_type: Optional file type hint (csv, json, xlsx, etc.)

Returns: String representation of the loaded data structure

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
file_typeNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The load_data tool handler that loads data from files (CSV, JSON, Excel, TSV) using pandas and returns basic dataset information including filename, row count, column count, column names, column types, and file size.
    @mcp.tool()
    def load_data(file_path: str, file_type: Optional[str] = None) -> str:
        """
        Load data from a file using VisiData.
        
        Args:
            file_path: Path to the data file
            file_type: Optional file type hint (csv, json, xlsx, etc.)
        
        Returns:
            String representation of the loaded data structure
        """
        try:
            # Use pandas as a reliable fallback for common formats
            import pandas as pd
            from pathlib import Path
            
            file_extension = Path(file_path).suffix.lower()
            
            # Load with pandas first for reliability
            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:
                # Try CSV as default
                df = pd.read_csv(file_path)
            
            # Get basic information about the dataset
            info = {
                "filename": Path(file_path).name,
                "rows": len(df),
                "columns": len(df.columns),
                "column_names": list(df.columns)[:10],  # First 10 columns
                "column_types": [str(df[col].dtype) for col in df.columns[:10]],
                "file_size": Path(file_path).stat().st_size if Path(file_path).exists() else 0
            }
            
            return json.dumps(info, indent=2)
            
        except Exception as e:
            return f"Error loading data: {str(e)}\n{traceback.format_exc()}"
  • The @mcp.tool() decorator registers the load_data function as an MCP tool with the server.
    @mcp.tool()
    def load_data(file_path: str, file_type: Optional[str] = None) -> str:
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 states the tool loads data and returns a string representation, but lacks details on permissions, error handling, rate limits, or what happens if the file is invalid. For a tool with no annotations, this is insufficient, leaving the agent uncertain about operational risks.

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 sized and front-loaded: the first sentence states the purpose clearly, followed by structured 'Args' and 'Returns' sections. There's no wasted text, and the formatting aids readability. It could be slightly more concise by integrating the sections into a single paragraph, but it's efficient overall.

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 has an output schema (implied by 'Has output schema: true'), the description doesn't need to detail return values. However, with no annotations, 2 parameters, and 0% schema coverage, it should provide more context on usage and behavior. The description covers basics but leaves gaps in guidelines and transparency, making it minimally adequate but incomplete.

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?

Schema description coverage is 0%, so the description must compensate. It adds meaning by explaining 'file_path' as 'Path to the data file' and 'file_type' as 'Optional file type hint (csv, json, xlsx, etc.)', which clarifies beyond the schema's basic types. However, it doesn't cover all nuances (e.g., file path formats, default behaviors for null file_type), so it only partially addresses the coverage gap.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Load data from a file using VisiData.' It specifies the verb ('Load') and resource ('data from a file'), and mentions the tool/context ('using VisiData'). However, it doesn't explicitly differentiate from siblings like 'convert_data' or 'get_data_sample', which might also involve file operations, so it doesn't reach the highest score.

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 alternatives. It doesn't mention siblings like 'convert_data' (which might transform data) or 'get_data_sample' (which might retrieve subsets), nor does it specify prerequisites or exclusions. The only implied usage is loading data from files, but this is too vague for effective tool selection.

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