Skip to main content
Glama

load_file

Load CSV or XLSX files into DataFrames for data analysis. Specify sheet names for XLSX files and customize DataFrame names as needed.

Instructions

Load Data File Tool

Purpose: Load a local CSV or XLSX file into a DataFrame.

Usage Notes: • If a df_name is not provided, the tool will automatically assign names sequentially as df_1, df_2, and so on. • For XLSX files, you can specify the sheet_name. If not provided, the first sheet will be loaded.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
df_nameNo
sheet_nameNo

Implementation Reference

  • The core handler function in ScriptRunner class that implements the load_file tool logic: loads CSV or XLSX files into a pandas DataFrame, stores it in self.data with a given or auto-generated name, logs notes, and returns success or error TextContent.
    def load_file(self, file_path: str, df_name:str = None, sheet_name: Optional[str] = None):
        self.df_count += 1
        if not df_name:
            df_name = f"df_{self.df_count}"
        try:
            file_extension = os.path.splitext(file_path)[1].lower()
            if file_extension == ".csv":
                self.data[df_name] = pd.read_csv(file_path)
                self.notes.append(f"Successfully loaded CSV into dataframe '{df_name}' from '{file_path}'")
            elif file_extension == ".xlsx":
                self.data[df_name] = pd.read_excel(file_path, sheet_name=sheet_name)
                self.notes.append(f"Successfully loaded XLSX into dataframe '{df_name}' from '{file_path}' (sheet: {sheet_name or 'first'})")
            else:
                raise ValueError(f"Unsupported file type: {file_extension}. Only .csv and .xlsx are supported.")
            
            return [
                TextContent(type="text", text=f"Successfully loaded data into dataframe '{df_name}'")
            ]
        except Exception as e:
            error_message = f"Error loading file: {str(e)}"
            self.notes.append(f"ERROR: {error_message}")
            return [
                TextContent(type="text", text=f"Error: {error_message}")
            ]
  • Pydantic schema (BaseModel) defining the input parameters for the load_file tool: file_path (required), optional df_name and sheet_name.
    class LoadFile(BaseModel):
        file_path: str
        df_name: Optional[str] = None
        sheet_name: Optional[str] = None
  • Registration of the load_file tool in the MCP server's list_tools handler, providing name, description, and input schema.
    Tool(name=DataExplorationTools.LOAD_FILE, description=LOAD_FILE_TOOL_DESCRIPTION, inputSchema=LoadFile.model_json_schema()),
  • Dispatch logic in the MCP server's call_tool handler that routes calls to the load_file tool to the ScriptRunner instance's load_file method.
    if name == DataExplorationTools.LOAD_FILE:
        return script_runner.load_file(arguments.get("file_path"), arguments.get("df_name"), arguments.get("sheet_name"))
  • Enum defining the tool names, including LOAD_FILE = 'load_file' used in registration and dispatch.
    class DataExplorationTools(str, Enum):
        LOAD_FILE = "load_file"
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It explains default naming behavior for df_name and sheet selection for XLSX files, which are useful behavioral traits. However, it doesn't address important aspects like error handling, file size limits, memory implications, or what the output looks like (though there's no output schema).

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

Conciseness5/5

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

The description is efficiently structured with clear sections (Purpose, Usage Notes), uses bullet points for readability, and contains no redundant information. Every sentence adds value, and the information is appropriately front-loaded with the core purpose stated first.

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?

For a data loading tool with 3 parameters, 0% schema coverage, no annotations, and no output schema, the description provides adequate basic information but lacks important context. It doesn't explain what a DataFrame is in this context, doesn't mention supported file encodings or formats beyond CSV/XLSX, and doesn't describe error conditions or the structure of returned data.

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

Parameters4/5

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

With 0% schema description coverage, the description must compensate. It provides meaningful context for all three parameters: file_path is implied as the data source, df_name gets default naming behavior explained, and sheet_name gets XLSX-specific guidance. The description adds substantial value beyond the bare schema, though it doesn't explain parameter formats or constraints.

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

Purpose5/5

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

The description clearly states the specific action ('Load a local CSV or XLSX file into a DataFrame'), identifies the resource (data files), and distinguishes this from its only sibling 'run_script' by focusing on data loading rather than script execution. The purpose is concrete and unambiguous.

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

Usage Guidelines3/5

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

The description provides implied usage guidance through the 'Usage Notes' section, which explains default behaviors for optional parameters. However, it doesn't explicitly state when to use this tool versus alternatives (like 'run_script') or mention any prerequisites or exclusions. The guidance is helpful but incomplete.

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/OuchiniKaeru/mcp-data-analyzer'

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