Metadata-Version: 2.4
Name: dataprep-mcp
Version: 0.1.0
Summary: MCP server for agent-driven dataset analysis with human-in-the-loop preprocessing
Author-email: Nadun Sooriyaarachchi <nadunbiz27@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/NadunAtGit/DataPrep-AI
Project-URL: Issues, https://github.com/NadunAtGit/DataPrep-AI/issues
Keywords: mcp,model-context-protocol,fastmcp,data-quality,eda,llm
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fastmcp<5,>=4.2
Requires-Dist: pandas>=2.2
Requires-Dist: numpy>=1.26
Requires-Dist: duckdb>=1.1
Requires-Dist: pyarrow>=16.0
Requires-Dist: openpyxl>=3.1
Requires-Dist: scipy>=1.13
Requires-Dist: pydantic>=2.7
Requires-Dist: cryptography>=42
Provides-Extra: agent
Requires-Dist: anthropic>=0.40; extra == "agent"
Dynamic: license-file

# DataPrep MCP

An [MCP](https://modelcontextprotocol.io) server that lets an AI assistant load a
tabular dataset, check its quality, explain what it finds, propose preprocessing
that **you approve step by step**, and show the results in an interactive dashboard.

It's a learning project that exercises most of the protocol: tools with structured
output, resources and resource templates, prompts, completions, progress and
cancellation, approval requests (elicitation / multi-round-trip input), an MCP App
(interactive UI), and a remote Streamable HTTP transport with token authentication.

## Install

```bash
pip install dataprep-mcp            # server
pip install "dataprep-mcp[agent]"   # plus the example agent client
```

Python 3.11 or newer.

## Use it locally (stdio)

Add it to an MCP client such as Claude Desktop (`claude_desktop_config.json`):

```json
{
  "mcpServers": {
    "dataprep": {
      "command": "dataprep-mcp",
      "env": { "DATAPREP_ALLOWED_DIRS": "/path/to/your/data" }
    }
  }
}
```

Or explore it with the MCP Inspector:

```bash
npx @modelcontextprotocol/inspector dataprep-mcp
```

The server only reads files inside `DATAPREP_ALLOWED_DIRS` (several folders are
separated by `;` on Windows and `:` elsewhere).

## What it offers

| Kind | Names |
|---|---|
| Tools | `load_dataset`, `get_overview`, `assess_quality`, `profile_dataset`, `detect_outliers`, `analyze_target`, `set_target`, `recommend_preprocessing`, `apply_preprocessing`, `recommend_ml_approach`, `show_dashboard`, `export_dashboard` |
| Resources | `datasets://list`, `dataset://{id}/overview`, `/profile`, `/quality`, `/history`, `/sample{?rows}`, `/columns/{column}` |
| Prompts | `analyze_new_dataset`, `explain_quality_issues`, `investigate_column`, `prepare_for_modeling`, `explain_ml_recommendation` |
| App | `ui://dataprep/dashboard.html` – interactive dashboard in clients that support MCP Apps |

Changes to data always need your approval, and each approved change creates a new
dataset version, so the original is never modified.

## Run it as a remote server (HTTP)

Remote mode requires token authentication. Every dataset belongs to the user named
in the token, so users can't see each other's data.

```bash
# 1. Create a signing key pair (keys/private.pem stays secret; never commit it)
dataprep-mcp-auth keys --out keys

# 2. Start the server; it only needs the public key
export DATAPREP_AUTH_PUBLIC_KEY_FILE=keys/public.pem   # Windows: $env:DATAPREP_AUTH_PUBLIC_KEY_FILE="keys\public.pem"
export DATAPREP_ALLOWED_DIRS=examples
dataprep-mcp --transport http --port 8000             # endpoint: http://127.0.0.1:8000/mcp

# 3. Issue a token for a user (for testing)
dataprep-mcp-auth token --subject alice
```

With an identity provider (Auth0, Keycloak, Entra ID …) set `DATAPREP_AUTH_JWKS_URI`,
`DATAPREP_AUTH_ISSUER` and `DATAPREP_AUTH_AUDIENCE` instead of a key file.
`GET /health` needs no token. For quick local experiments only,
`--allow-no-auth` works when the host is `127.0.0.1`.

### Docker

```bash
dataprep-mcp-auth keys --out keys
docker compose up --build
```

`compose.yaml` mounts `./examples` and `./data` under `/data` and passes only the
public key into the container.

## Configuration

| Variable | Meaning | Default |
|---|---|---|
| `DATAPREP_ALLOWED_DIRS` | folders the server may read | none (nothing is readable) |
| `DATAPREP_MAX_FILE_MB` | largest file it will load | 100 |
| `DATAPREP_REPORTS_DIR` | where `export_dashboard` writes | `reports` |
| `DATAPREP_MAX_DATASETS` | datasets kept per user | 20 |
| `DATAPREP_AUTH_PUBLIC_KEY_FILE` / `_PUBLIC_KEY` | verify tokens with this key | – |
| `DATAPREP_AUTH_JWKS_URI` | verify tokens with a provider's keys | – |
| `DATAPREP_AUTH_ISSUER` / `_AUDIENCE` | expected token claims | `dataprep-mcp` |
| `DATAPREP_AUTH_REQUIRED_SCOPES` | comma-separated scopes | – |

## Example client

`dataprep-client` connects to every server in `mcp_servers.json` (same format as
Claude Desktop) and gives you a shell to call tools, read resources and run an
agent (`ask …`, needs `ANTHROPIC_API_KEY`). Remote servers look like:

```json
{ "mcpServers": { "remote": { "url": "http://127.0.0.1:8000/mcp", "token_env": "DATAPREP_TOKEN" } } }
```

## Development

```bash
python -m venv .venv && . .venv/bin/activate      # Windows: .venv\Scripts\activate
python -m pip install -e . -r requirements-dev.txt
python -m pytest
python -m ruff check src tests
```

## License

MIT
