Skip to main content
Glama
HeetVekariya

Linear Regression MCP

by HeetVekariya

upload_file

Upload CSV data to prepare for linear regression analysis, reading file content and returning dataset shape information.

Instructions

This function read the csv data and stores it in the class variable.

Args: Absolute path to the .csv file.

Returns: String which shows the shape of the data.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes

Implementation Reference

  • server.py:36-68 (handler)
    The main handler function for the 'upload_file' tool. It loads a CSV file using pandas, stores the DataFrame in a global DataContext instance, and returns the shape of the data or an error message.
    @mcp.tool()
    def upload_file(path: str) -> str:
        """
        This function read the csv data and stores it in the class variable.
    
        Args:
            Absolute path to the .csv file.
    
        Returns:
            String which shows the shape of the data.
        """
    
        if not os.path.exists(path):
            return f"Error: The file at '{path}' does not exist."
    
        # Check if file has a .csv extension
        if not path.lower().endswith('.csv'):
            return "Error: The file must be a CSV file."
    
        try:
            # Try to read the CSV file using pandas
            data = pd.read_csv(path)
            
            # Store the data in the DataContext class
            context.set_data(data)
    
            # Store the shape of the data (rows, columns)
            data_shape = context.get_data().shape
    
            return f"Data successfully loaded. Shape: {data_shape}"
        except Exception as e:
            return f"An unexpected error occured: {str(e)}"
  • Helper class DataContext used by upload_file to store and retrieve the loaded DataFrame globally.
    @dataclass
    class DataContext():
        """
        A class that stores the DataFrame in the context.
        """
        _data: pd.DataFrame = None
    
        def set_data(self, new_data: pd.DataFrame):
            """
            Method to set or update the data.
            """
            self._data = new_data
    
        def get_data(self) -> pd.DataFrame:
            """
            Method to get the data from the context.
            """
            return self._data
    
    # Initialize the DataContext instance globally
    context = DataContext()
  • server.py:36-36 (registration)
    Decorator that registers the upload_file function as an MCP tool.
    @mcp.tool()
Behavior2/5

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

With no annotations, the description carries the full burden of behavioral disclosure. It states the tool reads and stores data, implying a mutation operation, but doesn't cover critical aspects like side effects (e.g., overwriting existing data), error handling, or performance considerations. This is a significant gap for a tool with no annotation support.

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 concise and front-loaded, with the core purpose stated first. It uses two sentences to explain the function and return value efficiently, with no wasted words. However, it could be slightly improved by integrating usage context more seamlessly.

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

Completeness2/5

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

Given the complexity of a data upload tool with no annotations, no output schema, and low schema coverage, the description is incomplete. It lacks details on error cases, data format requirements, and how the stored data interacts with other tools. This makes it inadequate for safe and effective use by an AI agent.

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 schema description coverage is 0%, so the description must compensate. It specifies that the parameter is an 'Absolute path to the .csv file,' which adds meaning beyond the schema's generic 'Path' title. However, it doesn't detail format constraints or validation rules, leaving some ambiguity. Baseline 3 is appropriate as it partially compensates for the low coverage.

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 reads CSV data and stores it in a class variable, which is a specific action. However, it doesn't clearly distinguish from sibling tools like 'get_columns_info' or 'check_category_columns' that might also involve data operations. The purpose is understandable but lacks sibling differentiation.

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?

No guidance is provided on when to use this tool versus alternatives. The description mentions storing data in a class variable, but it doesn't specify prerequisites, such as needing a CSV file, or when to use it over other data-handling tools. This leaves the agent without context for 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/HeetVekariya/Linear-Regression-MCP'

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