Skip to main content
Glama

read_csv

Read CSV file contents and return data with metadata for analysis and processing. Supports optional row limits to manage data size.

Instructions

Read and return CSV file contents. Args: filename: Name of the CSV file to read limit: Optional limit on number of rows to return Returns: Dictionary with file contents and metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameYes
limitNo

Implementation Reference

  • MCP tool handler and registration for 'read_csv'. Thin wrapper that delegates to CSVManager.read_csv and handles exceptions. Function signature defines the input schema.
    @mcp.tool() def read_csv(filename: str, limit: Optional[int] = None) -> Dict[str, Any]: """ Read and return CSV file contents. Args: filename: Name of the CSV file to read limit: Optional limit on number of rows to return Returns: Dictionary with file contents and metadata """ try: return csv_manager.read_csv(filename, limit) except Exception as e: return {"success": False, "error": str(e)}
  • Core handler logic for reading CSV files. Resolves filepath, loads with pandas.read_csv, applies row limit if specified, and returns structured data.
    def read_csv(self, filename: str, limit: Optional[int] = None) -> Dict[str, Any]: """Read CSV file contents.""" filepath = self._get_file_path(filename) if not filepath.exists(): raise FileNotFoundError(f"CSV file '{filename}' not found") try: df = pd.read_csv(filepath) # Apply limit if specified if limit and limit > 0: df = df.head(limit) return { "success": True, "filename": filename, "data": df.to_dict('records'), "columns": list(df.columns), "total_rows": len(df), "shape": df.shape } except Exception as e: logger.error(f"Failed to read CSV: {e}") raise

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/NovaAI-innovation/csv-mcp-server'

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