MCP Data Analyst Server

MCP Data Analyst Server

Transforms AI assistants into data analysts by enabling CSV and Google Sheets import, SQL querying, and instant insights through natural language.

Category
Visit Server

README

MCP Data Analyst Server

Transform Claude (or ChatGPT) into a powerful data analyst with SQL capabilities. Import CSVs or Google Sheets, run complex queries, and get instant insights - all through natural language.

🎯 What This Does

This MCP server lets AI assistants analyze your data by:

  • Importing CSV files and Google Sheets
  • Querying data with full SQL (JOINs, aggregations, window functions)
  • Analyzing datasets from 100 rows to billions
  • Exporting results to CSV

Simple Example:

You: "Load sales_2024.csv as sales and show me the top 10 products by revenue"

Claude/ChatGPT:
1. Imports your CSV into a DuckDB database
2. Writes SQL: SELECT product, SUM(revenue) FROM sales GROUP BY product ORDER BY revenue DESC LIMIT 10
3. Executes the query
4. Shows results with insights: "Your top product is Widget A with $50K revenue..."

πŸš€ Quick Start

Prerequisites

  • Python 3.8+ (or Docker Desktop)
  • Claude Desktop or ChatGPT Desktop
  • 2GB+ RAM

Installation

Option 1: Docker (Recommended)

# Clone or download this repo
cd mcp-data-analyst

# Start the container
./docker-start.sh

# Falls das File nicht ausfΓΌhrbar ist. fΓΌhre im Terminal folgenden Befehl aus:

chmod +x docker-start.sh

# Danach starte es erneut:

./docker-start.sh 


# Follow the instructions to configure Claude/ChatGPT

Option 2: Direct Python Install

# Clone or download this repo
cd mcp-data-analyst

# Install dependencies
pip install -r requirements.txt

# Run the server
python server.py

πŸ“‹ Configuration

Step 1: Configure Your AI Assistant

For Claude Desktop

Edit the config file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

If using Docker:

{
  "mcpServers": {
    "mcp-data-analyst": {
      "command": "docker",
      "args": ["exec", "-i", "data-analyst-mcp", "python3", "server.py"]
    }
  }
}

If using direct install:

{
  "mcpServers": {
    "mcp-data-analyst": {
      "command": "python3",
      "args": ["/absolute/path/to/mcp-data-analyst/server.py"]
    }
  }
}

For ChatGPT Desktop

Edit the config file:

  • macOS: ~/Library/Application Support/ChatGPT/config.json
  • Windows: %APPDATA%\ChatGPT\config.json

Use the same JSON format as Claude Desktop above.

Step 2: Configure Environment (Optional)

For cloud storage with MotherDuck (handles billions of rows):

# Copy the example
cp .env.example .env

# Edit .env and add your token
nano .env

Add your MotherDuck token:

MOTHERDUCK_TOKEN=your_token_here
MEMORY_LIMIT=4G
CPU_LIMIT=2.0

Get a free token at motherduck.com (10GB free tier).

Without MotherDuck: Data is stored in-memory (fast, but session-only).

Step 3: Restart Your AI Assistant

Completely quit and restart Claude Desktop or ChatGPT Desktop.

Step 4: Test It!

You: "Load example_data.csv as customers and show me the data"

The AI will import the file and show you the results!

πŸ“Š Features

6 Powerful Tools

  1. import_csv - Load CSV files, Google Sheets, or URLs
  2. query_data - Execute SQL queries with full DuckDB support
  3. list_tables - Show all available tables
  4. describe_table - Get schema and sample data
  5. export_query_results - Save query results to CSV
  6. get_table_stats - Get statistical summaries

Supported Data Sources

  • Local CSV files - Any CSV on your computer
  • CSV URLs - Direct HTTP/HTTPS links
  • Google Sheets - Automatically converts share links to CSV
  • Multiple files - Load multiple CSVs as separate tables

SQL Capabilities

Full SQL support including:

  • SELECT, WHERE, GROUP BY, ORDER BY, LIMIT
  • JOINs (INNER, LEFT, RIGHT, FULL OUTER)
  • Aggregate functions (SUM, AVG, COUNT, MIN, MAX)
  • Window functions (ROW_NUMBER, RANK, LAG, LEAD)
  • CTEs (WITH clauses)
  • Subqueries
  • Date/time functions

Data Size Limits

Rows CSV Size Mode Performance
< 1M ~100MB In-memory ⚑ Instant
1-10M ~1GB In-memory βœ… Fast (seconds)
10M+ 1GB+ MotherDuck ☁️ Optimized (cloud)

Recommendation: Use in-memory for < 10M rows, MotherDuck for larger datasets.

πŸ’‘ Usage Examples

Example 1: Basic Analysis

You: "Load my sales data from https://example.com/sales.csv as sales"
AI: βœ“ Imported 50,000 rows into 'sales' table

You: "What are the top 5 products by revenue?"
AI: [Writes and executes SQL, shows results with insights]

You: "Show me monthly revenue trends"
AI: [Creates time-series analysis with DATE_TRUNC]

Example 2: Multi-Table Analysis

You: "Load sales.csv as sales and products.csv as products"
AI: βœ“ Imported both tables

You: "Join these tables and show me which product categories generate the most revenue"
AI: [Automatically identifies the relationship (product_id), performs JOIN, provides analysis]

Example 3: Advanced Analytics

You: "Analyze customer behavior and create segments based on purchase patterns"
AI: [Performs multi-step analysis with CTEs, window functions, and provides business insights]

Example 4: Google Sheets

You: "Load this Google Sheet: https://docs.google.com/spreadsheets/d/abc123/edit"
AI: βœ“ Converted to CSV and imported

You: "Calculate the correlation between marketing spend and sales"
AI: [Performs statistical analysis]

🐳 Docker Commands

# Start server
./docker-start.sh

# Stop server
./docker-stop.sh

# View logs
docker-compose logs -f

# Restart
docker-compose restart

# Stop and remove
docker-compose down

# Rebuild
docker-compose down && docker-compose up -d --build

πŸ”§ Troubleshooting

MCP Server Not Appearing

  1. Verify config file path is correct
  2. Use absolute paths (not ~ or relative)
  3. Ensure container is running: docker ps
  4. Check logs: docker-compose logs
  5. Restart AI assistant completely (quit, not just close)

Permission Denied on Scripts

chmod +x docker-start.sh docker-stop.sh setup.sh

Import Errors

  • Local files: Use absolute paths
  • Google Sheets: Share with "Anyone with link"
  • URLs: Verify URL is publicly accessible

Out of Memory

For large datasets (> 10M rows):

Option 1: Increase Docker memory in docker-compose.yml:

memory: 8G  # or 16G
cpus: '4.0'

Option 2: Use MotherDuck (recommended for > 10M rows):

  1. Get token from motherduck.com
  2. Add to .env: MOTHERDUCK_TOKEN=your_token
  3. Restart: docker-compose restart

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Claude Desktop / ChatGPT Desktop  β”‚
β”‚   (Natural Language Interface)      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚ MCP Protocol
                  β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   MCP Data Analyst Server (Python) β”‚
β”‚   - 6 Tools (FastMCP)               β”‚
β”‚   - CSV Import & SQL Query          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚
                  β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   DuckDB Database                   β”‚
β”‚   - In-Memory (< 10M rows)          β”‚
β”‚   - MotherDuck Cloud (billions)     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”’ Security & Privacy

  • In-memory mode: All data stays on your computer, never leaves your machine
  • MotherDuck mode: Data stored in your private cloud account
  • No external sharing: Your data is never sent to third parties
  • Read-only SQL: Only SELECT queries, no data modification
  • Container isolation: Docker provides additional security layer

πŸ“š Advanced Configuration

Custom Memory Limits

Edit docker-compose.yml:

deploy:
  resources:
    limits:
      memory: 8G      # Increase for large datasets
      cpus: '4.0'     # More CPU for faster processing

Multiple Tables

Load multiple CSVs:

You: "Load sales.csv, products.csv, and customers.csv"
AI: [Imports all three as separate tables]

You: "Show me how these tables relate to each other"
AI: [Analyzes schemas, identifies foreign keys, suggests JOINs]

Export Results

You: "Export the top 100 customers to a CSV file"
AI: [Executes query and saves to /data/top_customers.csv]

πŸ› οΈ Development

Adding Custom Tools

The FastMCP framework makes it easy to add new tools:

@mcp.tool()
def my_custom_tool(param: str, count: int = 10) -> dict:
    """Description that appears to the AI"""
    # Your logic here
    return {"result": "..."}

That's it! FastMCP handles validation, errors, and protocol details.

Project Structure

mcp-data-analyst/
β”œβ”€β”€ server.py              # Main MCP server (FastMCP)
β”œβ”€β”€ requirements.txt       # Python dependencies
β”œβ”€β”€ Dockerfile            # Container definition
β”œβ”€β”€ docker-compose.yml    # Docker orchestration
β”œβ”€β”€ docker-start.sh       # Easy start script
β”œβ”€β”€ docker-stop.sh        # Easy stop script
β”œβ”€β”€ setup.sh              # Direct install script
β”œβ”€β”€ .env.example          # Environment template
β”œβ”€β”€ .gitignore            # Git ignore rules
└── example_data.csv      # Sample data for testing

🀝 Contributing

Contributions welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

πŸ“„ License

MIT License - Free to use, modify, and distribute.

πŸ™ Credits

Built with:

  • FastMCP - Modern MCP framework
  • DuckDB - Fast analytical database
  • MotherDuck - Cloud data warehouse
  • MCP Protocol by Anthropic

πŸ“ž Support

  • Issues: Open a GitHub issue
  • Questions: Start a discussion
  • Documentation: Check this README

🌟 Star This Repo

If you find this useful, please star the repo! ⭐


Transform your AI assistant into a data analyst in 5 minutes! πŸ“Šβœ¨

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured