Skip to main content
Glama
santoshray02

CSV Editor

by santoshray02

load_csv_from_url

Import CSV data directly from web URLs into the CSV Editor for processing, enabling remote file access without local downloads.

Instructions

Load a CSV file from a URL.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes
encodingNoutf-8
delimiterNo,
session_idNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function that downloads CSV from URL using pandas.read_csv, validates URL, loads into session manager, and returns operation result with data preview.
    async def load_csv_from_url(
        url: str,
        encoding: str = "utf-8",
        delimiter: str = ",",
        session_id: Optional[str] = None,
        ctx: Context = None
    ) -> Dict[str, Any]:
        """Load a CSV file from a URL.
        
        Args:
            url: URL of the CSV file
            encoding: File encoding
            delimiter: Column delimiter
            session_id: Optional existing session ID
            ctx: FastMCP context
        
        Returns:
            Operation result with session ID and data info
        """
        try:
            # Validate URL
            is_valid, validated_url = validate_url(url)
            if not is_valid:
                return OperationResult(
                    success=False,
                    message=f"Invalid URL: {validated_url}",
                    error=validated_url
                ).model_dump()
            
            if ctx:
                await ctx.info(f"Loading CSV from URL: {url}")
                await ctx.report_progress(0.1, "Downloading file...")
            
            # Download CSV using pandas (it handles URLs directly)
            df = pd.read_csv(url, encoding=encoding, delimiter=delimiter)
            
            if ctx:
                await ctx.report_progress(0.8, "Processing data...")
            
            # Get or create session
            session_manager = get_session_manager()
            session = session_manager.get_or_create_session(session_id)
            session.load_data(df, url)
            
            if ctx:
                await ctx.report_progress(1.0, "Complete!")
                await ctx.info(f"Loaded {len(df)} rows and {len(df.columns)} columns")
            
            return OperationResult(
                success=True,
                message=f"Successfully loaded CSV from URL",
                session_id=session.session_id,
                rows_affected=len(df),
                columns_affected=df.columns.tolist(),
                data={
                    "shape": df.shape,
                    "source_url": url,
                    "preview": df.head(5).to_dict('records')
                }
            ).model_dump()
            
        except Exception as e:
            if ctx:
                await ctx.error(f"Failed to load CSV from URL: {str(e)}")
            return OperationResult(
                success=False,
                message="Failed to load CSV from URL",
                error=str(e)
            ).model_dump()
  • MCP tool registration with @mcp.tool decorator, which delegates to the imported handler _load_csv_from_url from io_operations.
    @mcp.tool
    async def load_csv_from_url(
        url: str,
        encoding: str = "utf-8",
        delimiter: str = ",",
        session_id: Optional[str] = None,
        ctx: Context = None
    ) -> Dict[str, Any]:
        """Load a CSV file from a URL."""
        return await _load_csv_from_url(url, encoding, delimiter, session_id, ctx)
  • Import of the actual handler function aliased as _load_csv_from_url for use in the registered tool stub.
    from .tools.io_operations import (
        load_csv as _load_csv,
        load_csv_from_url as _load_csv_from_url,
        load_csv_from_content as _load_csv_from_content,
        export_csv as _export_csv,
        get_session_info as _get_session_info,
        list_sessions as _list_sessions,
        close_session as _close_session
    )
  • Re-export of load_csv_from_url from io_operations for compatibility in data_operations module.
    load_csv_from_url,
Behavior2/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 states the basic action but omits critical details: whether this creates a new session or uses an existing one, how large files are handled, error conditions (e.g., invalid URLs or malformed CSV), authentication requirements, or rate limits. For a tool with 4 parameters and no annotation coverage, this leaves significant behavioral gaps.

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 a single, efficient sentence with zero wasted words. It's front-loaded with the core action and resource, making it immediately scannable. Every word earns its place, achieving ideal conciseness for such a straightforward tool name.

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 moderate complexity (4 parameters, no annotations) and the presence of an output schema (which reduces the need to describe return values), the description is minimally adequate. However, it lacks details on parameter usage, behavioral traits, and sibling differentiation, leaving gaps that could hinder effective tool invocation. It meets the baseline but doesn't excel.

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

Parameters2/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 by explaining parameters. It mentions 'URL' implicitly but provides no context for the other 3 parameters (encoding, delimiter, session_id). The description doesn't clarify what 'Load' entails in terms of these parameters, leaving their purposes undocumented. This fails to add meaningful semantics beyond the bare schema.

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 action ('Load') and resource ('CSV file from a URL'), making the purpose immediately understandable. It distinguishes from sibling tools like 'load_csv' (which presumably loads from local content) and 'load_csv_from_content' (which loads from provided content rather than a URL). However, it doesn't specify what happens after loading (e.g., into memory, a session, or dataset), which prevents a perfect 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 like 'load_csv' or 'load_csv_from_content'. There's no mention of prerequisites, limitations, or typical use cases. The agent must infer usage from the tool name alone, which is insufficient for optimal 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/santoshray02/csv-editor'

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