Skip to main content
Glama

load_csv_from_content

Parse and load CSV data directly from string content into a structured format for manipulation and analysis within the CSV Editor MCP server. Specify delimiter, header presence, and session ID for customization.

Instructions

Load CSV data from string content.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYes
delimiterNo,
has_headerNo
session_idNo

Implementation Reference

  • Core handler function that loads CSV from string content using pandas.read_csv on StringIO, creates or loads session, and returns 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. This wrapper delegates to the core handler 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)

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