MCP Data Analysis Agent
An MCP server that answers natural-language questions over CSV, Excel, and SQL data by providing deterministic tools for loading, profiling, querying, cleaning, statistical analysis, visualization, and reporting. It enables LLMs to plan and interpret while all computation is done exactly through MCP tools.
README
π Autonomous Data Analysis System (MCP)
An AI data analyst that answers natural-language questions over CSV / Excel / SQL data. The language model plans and interprets β all computation (SQL, stats, cleaning, charts) runs in deterministic MCP tools, so results are exact, reproducible, and auditable.
Core principle: the LLM never does arithmetic. It reads schemas, chooses which tool to call with which arguments, and turns the returned numbers into business insight.
Architecture
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Streamlit UI (upload Β· chat Β· charts Β· report Β· switch) β
βββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββ
β Agent host β
β β’ Provider switch (LiteLLM): Ollama Β· Groq Β· Gemini β
β β’ MCP client: MCP tool schemas β OpenAI function calls β
β β’ Loop: plan β call tool β observe β answer β
βββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββ
β MCP protocol (stdio)
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββ
β MCP analysis server β
β load Β· profile Β· sql Β· eda Β· clean Β· stats Β· viz Β· reportβ
β Dataset registry Β· Pandas Β· DuckDB Β· SciPy Β· matplotlib β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
See DESIGN.md for the full design and milestone tracker.
Features
- Upload CSV / Excel; DuckDB SQL over your files with no database server.
- Automated profiling & EDA β schema, nulls, cardinality, correlations, group aggregates.
- Non-destructive cleaning β missing values, duplicates, type casts, outliers (each returns a new versioned dataset).
- Statistics β t-test / ANOVA / chi-square, correlation tests, trend analysis, distribution/normality.
- Charts β bar, line, scatter, histogram, box, correlation heatmap (PNG).
- Self-contained HTML reports with embedded charts.
- Pluggable LLM β local Ollama by default, switch to Groq or Gemini free tiers.
Setup
python3 -m venv .venv
source .venv/bin/activate # fish: source .venv/bin/activate.fish
pip install -r requirements.txt
cp .env.example .env # then fill in the provider you want
Choosing a provider (edit .env)
| Provider | Setup | Notes |
|---|---|---|
| Ollama (default, local) | ollama pull qwen2.5:3b and run the Ollama daemon |
Free & private; smaller models plan tools less reliably |
| Groq (free tier) | GROQ_API_KEY=... from https://console.groq.com/keys |
Fast, strong tool-calling β best for reliable planning |
| Gemini (free tier) | GEMINI_API_KEY=... from https://aistudio.google.com/app/apikey |
Large context, strong function-calling |
You can also switch provider live from the sidebar dropdown in the UI.
Run the app
streamlit run ui/streamlit_app.py
Then upload one of the samples in data/ (e.g. sample_sales.csv) and ask
things like "Which region sells the most units, and is the trend rising?" or
"Which plan has the highest churn β build me a report."
Use the MCP server directly (e.g. Claude Desktop)
The server speaks stdio and works with any MCP client:
python -m mcp_server.server
Claude Desktop config:
{ "mcpServers": {
"data-analysis": { "command": "python", "args": ["-m", "mcp_server.server"] }
} }
MCP tool catalog
| Group | Tools |
|---|---|
| Load | load_csv, load_excel, list_datasets |
| Profile | profile_dataset |
| SQL | run_sql (DuckDB) |
| EDA | value_counts, correlations, groupby_aggregate |
| Clean | drop_duplicates, handle_missing, cast_types, handle_outliers, rename_columns |
| Stats | hypothesis_test, correlation_test, trend_analysis, distribution_fit |
| Viz | make_chart |
| Report | export_report |
Testing
PYTHONPATH="$PWD" pytest -q
15 tests spawn the real MCP server over stdio and exercise every tool group; the agent loop is tested with a scripted fake LLM (deterministic, no network).
Project structure
mcp_server/ FastMCP server + registry + tools/
agent/ provider switch (config, providers) + mcp_client + agent loop
ui/ streamlit_app.py
data/ sample datasets + uploads/
reports/ generated charts and HTML reports
tests/ per-milestone test suites
Recommended Servers
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.
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.
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.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
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.
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.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
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.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.