High-performance Model Context Protocol (MCP) server for CSV analysis and SQL execution using Polars
The MCP Polars SQL Analyst Server enables AI agents and developers to interact with CSV datasets through natural language or SQL queries.
It leverages the Polars DataFrame engine (Rust-powered, multi-threaded, lazy evaluation) for lightning-fast analytics on large files.
With this server, you can:
- โ Discover CSV files available in a directory
- โ Inspect schemas, datatypes, and stats
- โ Run SQL queries directly on your CSVs using Polars SQL
- โ Easily integrate with AI agents and dashboards for interactive CSV insights
-
High-Performance Data Processing
- Rust-based Polars engine (faster than pandas)
- Multi-threaded execution across CPUs
- Lazy evaluation for optimized queries
- Memory-efficient for large datasets
-
MCP Tools Available
-
get_files_list
- ๐ Retrieve all available CSV files in the configured directory
- Returns: List of file names and paths
-
get_schema
- ๐ Extract schema: column names, datatypes, and basic stats
- Params: file_path (CSV file path)
- Returns: JSON with field info
-
execute_polars_sql
- ๐ Run SQL queries on CSV data via Polars SQL engine
- Params: sql_query, file_path
- Returns: Structured query results
-
- MCP Framework: FastMCP โ rapid protocol server creation
- Data Engine: Polars โ fast, Rust-native DataFrame library
- Query Language: SQL (via Polars SQL context)
- File Support: CSV datasets
๐ฆ Installation bash
git clone https://github.com/yourusername/mcp-polars-analyst.git cd mcp-polars-analyst
pip install -e .
bash
FILE_LOCATION="/mnt/c/workspaces/mcpserver/temp/*.csv"
python server/analyst.py
The server will:
Scan the specified location for CSVs
Initialize Polars SQL context
Expose MCP tools (get_files_list, get_schema, execute_polars_sql)
Start SSE (Server-Sent Events) for agent communication