Skip to main content
Glama
santoshray02

CSV Editor

by santoshray02

load_csv_from_content

Load CSV data directly from string content to process and manipulate tabular information within the CSV Editor MCP server.

Instructions

Load CSV data from string content.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYes
delimiterNo,
session_idNo
has_headerNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function that implements the tool logic: parses CSV content from string using pandas.read_csv with StringIO, loads DataFrame into a session, and returns detailed OperationResult.
    async def load_csv_from_content(
        content: str,
        delimiter: str = ",",
        session_id: Optional[str] = None,
        has_header: bool = True,
        ctx: Context = None
    ) -> Dict[str, Any]:
        """Load CSV data from a string content.
        
        Args:
            content: CSV content as string
            delimiter: Column delimiter
            session_id: Optional existing session ID
            has_header: Whether first row is header
            ctx: FastMCP context
        
        Returns:
            Operation result with session ID and data info
        """
        try:
            if ctx:
                await ctx.info("Loading CSV from content string")
            
            # Parse CSV from string
            from io import StringIO
            df = pd.read_csv(
                StringIO(content),
                delimiter=delimiter,
                header=0 if has_header else None
            )
            
            # Get or create session
            session_manager = get_session_manager()
            session = session_manager.get_or_create_session(session_id)
            session.load_data(df, None)
            
            if ctx:
                await ctx.info(f"Loaded {len(df)} rows and {len(df.columns)} columns")
            
            return OperationResult(
                success=True,
                message=f"Successfully loaded CSV from content",
                session_id=session.session_id,
                rows_affected=len(df),
                columns_affected=df.columns.tolist(),
                data={
                    "shape": df.shape,
                    "preview": df.head(5).to_dict('records')
                }
            ).model_dump()
            
        except Exception as e:
            if ctx:
                await ctx.error(f"Failed to parse CSV content: {str(e)}")
            return OperationResult(
                success=False,
                message="Failed to parse CSV content",
                error=str(e)
            ).model_dump()
  • MCP tool registration using @mcp.tool decorator. Thin wrapper that imports and delegates to the core implementation in io_operations.py.
    @mcp.tool
    async def load_csv_from_content(
        content: str,
        delimiter: str = ",",
        session_id: Optional[str] = None,
        has_header: bool = True,
        ctx: Context = None
    ) -> Dict[str, Any]:
        """Load CSV data from string content."""
        return await _load_csv_from_content(content, delimiter, session_id, has_header, ctx)
  • Import of the core load_csv_from_content function (aliased as _load_csv_from_content) used by the registered tool wrapper.
    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
    )
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. 'Load CSV data' implies a read operation, but it doesn't specify whether this creates a new dataset, modifies an existing one, requires authentication, has rate limits, or what the output entails. For a tool with 4 parameters and no annotation coverage, this leaves critical behavioral aspects unexplained.

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 that front-loads the core purpose without unnecessary words. Every part of the sentence ('Load CSV data from string content') directly contributes to understanding the tool's function, making it highly concise and well-structured.

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, but with an output schema), the description is incomplete. It covers the basic purpose but lacks usage guidelines, behavioral details, and parameter explanations. The presence of an output schema means return values don't need description, but other gaps prevent a higher score.

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 for undocumented parameters. It only mentions 'string content', which corresponds to the 'content' parameter, but ignores 'delimiter', 'session_id', and 'has_header'. This adds minimal value beyond the schema, resulting in a baseline score of 3 due to the partial 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 verb ('Load') and resource ('CSV data from string content'), making the purpose immediately understandable. It distinguishes this from sibling tools like 'load_csv' (which presumably loads from a file) and 'load_csv_from_url' (which loads from a URL). However, it doesn't specify what happens after loading (e.g., into memory, a session, or a 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. It doesn't mention prerequisites (e.g., whether a session must be active), compare it to 'load_csv' or 'load_csv_from_url', or indicate typical use cases. The agent must infer usage from the tool name alone, which is insufficient.

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