preview_csv
Preview the first few rows of a CSV file to understand its structure, column names, and data types before performing batch tagging.
Instructions
Preview the first few rows of a CSV file to understand its structure.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| csv_path | Yes | Path to the CSV file | |
| rows | No | Number of rows to preview (default: 5) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- tagging.py:162-186 (handler)The main handler for the 'preview_csv' tool. Decorated with @mcp.tool(), it reads a CSV file using polars, returns column names, row count, and a preview of the first N rows.
@mcp.tool() def preview_csv(csv_path: str, rows: int = 5) -> dict: """ Preview the first few rows of a CSV file to understand its structure. Args: csv_path: Path to the CSV file rows: Number of rows to preview (default: 5) Returns: Dictionary with column names and preview data """ try: df = pl.read_csv(csv_path) return { "status": "success", "columns": df.columns, "rows": len(df), "preview": df.head(rows).to_dicts() } except Exception as e: return { "status": "error", "message": str(e) } - tagging.py:162-163 (registration)The tool is registered via the @mcp.tool() decorator on line 162, using FastMCP's decorator pattern to register 'preview_csv' as an MCP tool.
@mcp.tool() def preview_csv(csv_path: str, rows: int = 5) -> dict: - tagging.py:13-20 (helper)Helper constant PROVIDER_MAP used across other tools (but not directly used by preview_csv). Included for complete context.
PROVIDER_MAP = { "claude": Provider.ANTHROPIC, "anthropic": Provider.ANTHROPIC, "openai": Provider.OPENAI, "gemini": Provider.GEMINI, "groq": Provider.GROQ, "bedrock": Provider.BEDROCK }