Skip to main content
Glama
K02D

MCP Tabular Data Analysis Server

by K02D

export_data

Export filtered, sorted, and transformed tabular data from CSV or SQLite files to new CSV files for analysis and sharing.

Instructions

Export filtered/transformed data to a new CSV file.

Args:
    file_path: Path to source CSV or SQLite file
    output_name: Name for output file (without extension, saved to data/ folder)
    filter_column: Optional column to filter on
    filter_operator: Filter operator - 'eq', 'ne', 'gt', 'gte', 'lt', 'lte', 'contains'
    filter_value: Value to filter by
    columns: List of columns to include (default: all)
    sort_by: Column to sort by
    sort_ascending: Sort direction (default: ascending)
    limit: Maximum rows to export

Returns:
    Dictionary containing export details and file path

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
output_nameYes
filter_columnNo
filter_operatorNo
filter_valueNo
columnsNo
sort_byNo
sort_ascendingNo
limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The primary handler function for the 'export_data' tool. It loads data from a file, optionally applies filters, column selection, sorting, and row limits, then exports the processed data to a timestamped CSV file in the data/ directory. Returns details about the export operation.
    def export_data(
        file_path: str,
        output_name: str,
        filter_column: str | None = None,
        filter_operator: str | None = None,
        filter_value: str | float | None = None,
        columns: list[str] | None = None,
        sort_by: str | None = None,
        sort_ascending: bool = True,
        limit: int | None = None,
    ) -> dict[str, Any]:
        """
        Export filtered/transformed data to a new CSV file.
        
        Args:
            file_path: Path to source CSV or SQLite file
            output_name: Name for output file (without extension, saved to data/ folder)
            filter_column: Optional column to filter on
            filter_operator: Filter operator - 'eq', 'ne', 'gt', 'gte', 'lt', 'lte', 'contains'
            filter_value: Value to filter by
            columns: List of columns to include (default: all)
            sort_by: Column to sort by
            sort_ascending: Sort direction (default: ascending)
            limit: Maximum rows to export
        
        Returns:
            Dictionary containing export details and file path
        """
        df = _load_data(file_path)
        original_count = len(df)
        
        # Apply filter if specified
        if filter_column and filter_operator and filter_value is not None:
            if filter_column not in df.columns:
                raise ValueError(f"Filter column '{filter_column}' not found")
            
            if filter_operator == "eq":
                df = df[df[filter_column] == filter_value]
            elif filter_operator == "ne":
                df = df[df[filter_column] != filter_value]
            elif filter_operator == "gt":
                df = df[df[filter_column] > float(filter_value)]
            elif filter_operator == "gte":
                df = df[df[filter_column] >= float(filter_value)]
            elif filter_operator == "lt":
                df = df[df[filter_column] < float(filter_value)]
            elif filter_operator == "lte":
                df = df[df[filter_column] <= float(filter_value)]
            elif filter_operator == "contains":
                df = df[df[filter_column].astype(str).str.contains(str(filter_value), case=False, na=False)]
            else:
                raise ValueError(f"Unknown operator: {filter_operator}")
        
        # Select columns
        if columns:
            invalid = [c for c in columns if c not in df.columns]
            if invalid:
                raise ValueError(f"Columns not found: {invalid}")
            df = df[columns]
        
        # Sort
        if sort_by:
            if sort_by not in df.columns:
                raise ValueError(f"Sort column '{sort_by}' not found")
            df = df.sort_values(sort_by, ascending=sort_ascending)
        
        # Limit rows
        if limit:
            df = df.head(limit)
        
        # Save file
        output_dir = _PROJECT_ROOT / 'data'
        output_dir.mkdir(parents=True, exist_ok=True)
        
        # Clean output name and add timestamp
        clean_name = "".join(c for c in output_name if c.isalnum() or c in ('-', '_'))
        timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')
        output_file = output_dir / f"{clean_name}_{timestamp}.csv"
        
        df.to_csv(output_file, index=False)
        
        return {
            "success": True,
            "source_file": file_path,
            "output_file": str(output_file.relative_to(_PROJECT_ROOT)),
            "absolute_path": str(output_file),
            "original_rows": original_count,
            "exported_rows": len(df),
            "exported_columns": df.columns.tolist(),
            "filter_applied": f"{filter_column} {filter_operator} {filter_value}" if filter_column else None,
        }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden for behavioral disclosure. While it mentions the tool creates a new CSV file and returns a dictionary with export details, it lacks critical behavioral information: whether this operation modifies source files, what permissions are required, where exactly files are saved (beyond 'data/ folder'), error handling, or performance characteristics. The description is insufficient for a mutation tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections (purpose, args, returns) and uses bullet-like formatting for parameters. Every sentence adds value, though the parameter explanations could be slightly more concise. The front-loaded purpose statement is effective, and there's no redundant information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (9 parameters, mutation operation) and lack of annotations, the description does well but has gaps. It thoroughly documents parameters and mentions the return format, but lacks behavioral context about file operations, permissions, or error conditions. The presence of an output schema helps, but for a data export tool that creates files, more operational context would be beneficial.

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

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description compensates excellently by providing detailed parameter documentation. It explains all 9 parameters with clear semantics: what each parameter controls, optional vs. required status, default values, and even enumerates the filter_operator options. This goes far beyond what the bare schema provides and makes the parameters fully understandable.

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 tool's purpose: 'Export filtered/transformed data to a new CSV file.' It specifies the verb (export), resource (data), and output format (CSV file). However, it doesn't explicitly differentiate from sibling tools like 'filter_rows' or 'merge_datasets' which might have overlapping functionality, preventing 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. With sibling tools like 'filter_rows', 'merge_datasets', and 'query_sqlite' available, there's no indication of when this export tool is preferred over those for data manipulation tasks. The description only states what it does, not when it should be used.

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/K02D/mcp-tabular'

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