dataprep-mcp 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dataprep_mcp-0.1.0/LICENSE +21 -0
- dataprep_mcp-0.1.0/PKG-INFO +158 -0
- dataprep_mcp-0.1.0/README.md +124 -0
- dataprep_mcp-0.1.0/pyproject.toml +59 -0
- dataprep_mcp-0.1.0/setup.cfg +4 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/__init__.py +0 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/__main__.py +76 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/auth_cli.py +96 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/cli.py +0 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/client/__init__.py +0 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/client/agent.py +144 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/client/cli.py +210 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/client/config.py +48 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/client/forms.py +94 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/client/hub.py +158 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/engine/__init__.py +0 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/engine/distributions.py +64 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/engine/loading.py +70 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/engine/ml_recommend.py +301 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/engine/outliers.py +96 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/engine/preprocessing.py +240 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/engine/profiling.py +204 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/engine/quality.py +198 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/engine/relationships.py +114 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/engine/target.py +93 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/engine/versioning.py +0 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/schemas/__init__.py +0 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/schemas/dashboard.py +84 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/schemas/dataset.py +34 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/schemas/ml.py +66 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/schemas/preprocessing.py +84 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/schemas/profile.py +117 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/server/__init__.py +0 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/server/app.py +45 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/server/approval.py +103 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/server/auth.py +70 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/server/completions.py +57 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/server/dashboard.py +147 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/server/ml_tools.py +50 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/server/preprocessing_tools.py +213 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/server/progress.py +111 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/server/prompts.py +101 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/server/resources.py +103 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/server/security.py +53 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/server/session.py +115 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/server/tools.py +175 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/server/views.py +202 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp/ui/dashboard.html +549 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp.egg-info/PKG-INFO +158 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp.egg-info/SOURCES.txt +52 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp.egg-info/dependency_links.txt +1 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp.egg-info/entry_points.txt +4 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp.egg-info/requires.txt +12 -0
- dataprep_mcp-0.1.0/src/dataprep_mcp.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nadun Sooriyaarchchi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dataprep-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MCP server for agent-driven dataset analysis with human-in-the-loop preprocessing
|
|
5
|
+
Author-email: Nadun Sooriyaarachchi <nadunbiz27@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/NadunAtGit/DataPrep-AI
|
|
8
|
+
Project-URL: Issues, https://github.com/NadunAtGit/DataPrep-AI/issues
|
|
9
|
+
Keywords: mcp,model-context-protocol,fastmcp,data-quality,eda,llm
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: fastmcp<5,>=4.2
|
|
23
|
+
Requires-Dist: pandas>=2.2
|
|
24
|
+
Requires-Dist: numpy>=1.26
|
|
25
|
+
Requires-Dist: duckdb>=1.1
|
|
26
|
+
Requires-Dist: pyarrow>=16.0
|
|
27
|
+
Requires-Dist: openpyxl>=3.1
|
|
28
|
+
Requires-Dist: scipy>=1.13
|
|
29
|
+
Requires-Dist: pydantic>=2.7
|
|
30
|
+
Requires-Dist: cryptography>=42
|
|
31
|
+
Provides-Extra: agent
|
|
32
|
+
Requires-Dist: anthropic>=0.40; extra == "agent"
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
|
|
35
|
+
# DataPrep MCP
|
|
36
|
+
|
|
37
|
+
An [MCP](https://modelcontextprotocol.io) server that lets an AI assistant load a
|
|
38
|
+
tabular dataset, check its quality, explain what it finds, propose preprocessing
|
|
39
|
+
that **you approve step by step**, and show the results in an interactive dashboard.
|
|
40
|
+
|
|
41
|
+
It's a learning project that exercises most of the protocol: tools with structured
|
|
42
|
+
output, resources and resource templates, prompts, completions, progress and
|
|
43
|
+
cancellation, approval requests (elicitation / multi-round-trip input), an MCP App
|
|
44
|
+
(interactive UI), and a remote Streamable HTTP transport with token authentication.
|
|
45
|
+
|
|
46
|
+
## Install
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install dataprep-mcp # server
|
|
50
|
+
pip install "dataprep-mcp[agent]" # plus the example agent client
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Python 3.11 or newer.
|
|
54
|
+
|
|
55
|
+
## Use it locally (stdio)
|
|
56
|
+
|
|
57
|
+
Add it to an MCP client such as Claude Desktop (`claude_desktop_config.json`):
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"mcpServers": {
|
|
62
|
+
"dataprep": {
|
|
63
|
+
"command": "dataprep-mcp",
|
|
64
|
+
"env": { "DATAPREP_ALLOWED_DIRS": "/path/to/your/data" }
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Or explore it with the MCP Inspector:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
npx @modelcontextprotocol/inspector dataprep-mcp
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The server only reads files inside `DATAPREP_ALLOWED_DIRS` (several folders are
|
|
77
|
+
separated by `;` on Windows and `:` elsewhere).
|
|
78
|
+
|
|
79
|
+
## What it offers
|
|
80
|
+
|
|
81
|
+
| Kind | Names |
|
|
82
|
+
|---|---|
|
|
83
|
+
| 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` |
|
|
84
|
+
| Resources | `datasets://list`, `dataset://{id}/overview`, `/profile`, `/quality`, `/history`, `/sample{?rows}`, `/columns/{column}` |
|
|
85
|
+
| Prompts | `analyze_new_dataset`, `explain_quality_issues`, `investigate_column`, `prepare_for_modeling`, `explain_ml_recommendation` |
|
|
86
|
+
| App | `ui://dataprep/dashboard.html` – interactive dashboard in clients that support MCP Apps |
|
|
87
|
+
|
|
88
|
+
Changes to data always need your approval, and each approved change creates a new
|
|
89
|
+
dataset version, so the original is never modified.
|
|
90
|
+
|
|
91
|
+
## Run it as a remote server (HTTP)
|
|
92
|
+
|
|
93
|
+
Remote mode requires token authentication. Every dataset belongs to the user named
|
|
94
|
+
in the token, so users can't see each other's data.
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# 1. Create a signing key pair (keys/private.pem stays secret; never commit it)
|
|
98
|
+
dataprep-mcp-auth keys --out keys
|
|
99
|
+
|
|
100
|
+
# 2. Start the server; it only needs the public key
|
|
101
|
+
export DATAPREP_AUTH_PUBLIC_KEY_FILE=keys/public.pem # Windows: $env:DATAPREP_AUTH_PUBLIC_KEY_FILE="keys\public.pem"
|
|
102
|
+
export DATAPREP_ALLOWED_DIRS=examples
|
|
103
|
+
dataprep-mcp --transport http --port 8000 # endpoint: http://127.0.0.1:8000/mcp
|
|
104
|
+
|
|
105
|
+
# 3. Issue a token for a user (for testing)
|
|
106
|
+
dataprep-mcp-auth token --subject alice
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
With an identity provider (Auth0, Keycloak, Entra ID …) set `DATAPREP_AUTH_JWKS_URI`,
|
|
110
|
+
`DATAPREP_AUTH_ISSUER` and `DATAPREP_AUTH_AUDIENCE` instead of a key file.
|
|
111
|
+
`GET /health` needs no token. For quick local experiments only,
|
|
112
|
+
`--allow-no-auth` works when the host is `127.0.0.1`.
|
|
113
|
+
|
|
114
|
+
### Docker
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
dataprep-mcp-auth keys --out keys
|
|
118
|
+
docker compose up --build
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
`compose.yaml` mounts `./examples` and `./data` under `/data` and passes only the
|
|
122
|
+
public key into the container.
|
|
123
|
+
|
|
124
|
+
## Configuration
|
|
125
|
+
|
|
126
|
+
| Variable | Meaning | Default |
|
|
127
|
+
|---|---|---|
|
|
128
|
+
| `DATAPREP_ALLOWED_DIRS` | folders the server may read | none (nothing is readable) |
|
|
129
|
+
| `DATAPREP_MAX_FILE_MB` | largest file it will load | 100 |
|
|
130
|
+
| `DATAPREP_REPORTS_DIR` | where `export_dashboard` writes | `reports` |
|
|
131
|
+
| `DATAPREP_MAX_DATASETS` | datasets kept per user | 20 |
|
|
132
|
+
| `DATAPREP_AUTH_PUBLIC_KEY_FILE` / `_PUBLIC_KEY` | verify tokens with this key | – |
|
|
133
|
+
| `DATAPREP_AUTH_JWKS_URI` | verify tokens with a provider's keys | – |
|
|
134
|
+
| `DATAPREP_AUTH_ISSUER` / `_AUDIENCE` | expected token claims | `dataprep-mcp` |
|
|
135
|
+
| `DATAPREP_AUTH_REQUIRED_SCOPES` | comma-separated scopes | – |
|
|
136
|
+
|
|
137
|
+
## Example client
|
|
138
|
+
|
|
139
|
+
`dataprep-client` connects to every server in `mcp_servers.json` (same format as
|
|
140
|
+
Claude Desktop) and gives you a shell to call tools, read resources and run an
|
|
141
|
+
agent (`ask …`, needs `ANTHROPIC_API_KEY`). Remote servers look like:
|
|
142
|
+
|
|
143
|
+
```json
|
|
144
|
+
{ "mcpServers": { "remote": { "url": "http://127.0.0.1:8000/mcp", "token_env": "DATAPREP_TOKEN" } } }
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Development
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
python -m venv .venv && . .venv/bin/activate # Windows: .venv\Scripts\activate
|
|
151
|
+
python -m pip install -e . -r requirements-dev.txt
|
|
152
|
+
python -m pytest
|
|
153
|
+
python -m ruff check src tests
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## License
|
|
157
|
+
|
|
158
|
+
MIT
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# DataPrep MCP
|
|
2
|
+
|
|
3
|
+
An [MCP](https://modelcontextprotocol.io) server that lets an AI assistant load a
|
|
4
|
+
tabular dataset, check its quality, explain what it finds, propose preprocessing
|
|
5
|
+
that **you approve step by step**, and show the results in an interactive dashboard.
|
|
6
|
+
|
|
7
|
+
It's a learning project that exercises most of the protocol: tools with structured
|
|
8
|
+
output, resources and resource templates, prompts, completions, progress and
|
|
9
|
+
cancellation, approval requests (elicitation / multi-round-trip input), an MCP App
|
|
10
|
+
(interactive UI), and a remote Streamable HTTP transport with token authentication.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pip install dataprep-mcp # server
|
|
16
|
+
pip install "dataprep-mcp[agent]" # plus the example agent client
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Python 3.11 or newer.
|
|
20
|
+
|
|
21
|
+
## Use it locally (stdio)
|
|
22
|
+
|
|
23
|
+
Add it to an MCP client such as Claude Desktop (`claude_desktop_config.json`):
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"mcpServers": {
|
|
28
|
+
"dataprep": {
|
|
29
|
+
"command": "dataprep-mcp",
|
|
30
|
+
"env": { "DATAPREP_ALLOWED_DIRS": "/path/to/your/data" }
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Or explore it with the MCP Inspector:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npx @modelcontextprotocol/inspector dataprep-mcp
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The server only reads files inside `DATAPREP_ALLOWED_DIRS` (several folders are
|
|
43
|
+
separated by `;` on Windows and `:` elsewhere).
|
|
44
|
+
|
|
45
|
+
## What it offers
|
|
46
|
+
|
|
47
|
+
| Kind | Names |
|
|
48
|
+
|---|---|
|
|
49
|
+
| 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` |
|
|
50
|
+
| Resources | `datasets://list`, `dataset://{id}/overview`, `/profile`, `/quality`, `/history`, `/sample{?rows}`, `/columns/{column}` |
|
|
51
|
+
| Prompts | `analyze_new_dataset`, `explain_quality_issues`, `investigate_column`, `prepare_for_modeling`, `explain_ml_recommendation` |
|
|
52
|
+
| App | `ui://dataprep/dashboard.html` – interactive dashboard in clients that support MCP Apps |
|
|
53
|
+
|
|
54
|
+
Changes to data always need your approval, and each approved change creates a new
|
|
55
|
+
dataset version, so the original is never modified.
|
|
56
|
+
|
|
57
|
+
## Run it as a remote server (HTTP)
|
|
58
|
+
|
|
59
|
+
Remote mode requires token authentication. Every dataset belongs to the user named
|
|
60
|
+
in the token, so users can't see each other's data.
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# 1. Create a signing key pair (keys/private.pem stays secret; never commit it)
|
|
64
|
+
dataprep-mcp-auth keys --out keys
|
|
65
|
+
|
|
66
|
+
# 2. Start the server; it only needs the public key
|
|
67
|
+
export DATAPREP_AUTH_PUBLIC_KEY_FILE=keys/public.pem # Windows: $env:DATAPREP_AUTH_PUBLIC_KEY_FILE="keys\public.pem"
|
|
68
|
+
export DATAPREP_ALLOWED_DIRS=examples
|
|
69
|
+
dataprep-mcp --transport http --port 8000 # endpoint: http://127.0.0.1:8000/mcp
|
|
70
|
+
|
|
71
|
+
# 3. Issue a token for a user (for testing)
|
|
72
|
+
dataprep-mcp-auth token --subject alice
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
With an identity provider (Auth0, Keycloak, Entra ID …) set `DATAPREP_AUTH_JWKS_URI`,
|
|
76
|
+
`DATAPREP_AUTH_ISSUER` and `DATAPREP_AUTH_AUDIENCE` instead of a key file.
|
|
77
|
+
`GET /health` needs no token. For quick local experiments only,
|
|
78
|
+
`--allow-no-auth` works when the host is `127.0.0.1`.
|
|
79
|
+
|
|
80
|
+
### Docker
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
dataprep-mcp-auth keys --out keys
|
|
84
|
+
docker compose up --build
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`compose.yaml` mounts `./examples` and `./data` under `/data` and passes only the
|
|
88
|
+
public key into the container.
|
|
89
|
+
|
|
90
|
+
## Configuration
|
|
91
|
+
|
|
92
|
+
| Variable | Meaning | Default |
|
|
93
|
+
|---|---|---|
|
|
94
|
+
| `DATAPREP_ALLOWED_DIRS` | folders the server may read | none (nothing is readable) |
|
|
95
|
+
| `DATAPREP_MAX_FILE_MB` | largest file it will load | 100 |
|
|
96
|
+
| `DATAPREP_REPORTS_DIR` | where `export_dashboard` writes | `reports` |
|
|
97
|
+
| `DATAPREP_MAX_DATASETS` | datasets kept per user | 20 |
|
|
98
|
+
| `DATAPREP_AUTH_PUBLIC_KEY_FILE` / `_PUBLIC_KEY` | verify tokens with this key | – |
|
|
99
|
+
| `DATAPREP_AUTH_JWKS_URI` | verify tokens with a provider's keys | – |
|
|
100
|
+
| `DATAPREP_AUTH_ISSUER` / `_AUDIENCE` | expected token claims | `dataprep-mcp` |
|
|
101
|
+
| `DATAPREP_AUTH_REQUIRED_SCOPES` | comma-separated scopes | – |
|
|
102
|
+
|
|
103
|
+
## Example client
|
|
104
|
+
|
|
105
|
+
`dataprep-client` connects to every server in `mcp_servers.json` (same format as
|
|
106
|
+
Claude Desktop) and gives you a shell to call tools, read resources and run an
|
|
107
|
+
agent (`ask …`, needs `ANTHROPIC_API_KEY`). Remote servers look like:
|
|
108
|
+
|
|
109
|
+
```json
|
|
110
|
+
{ "mcpServers": { "remote": { "url": "http://127.0.0.1:8000/mcp", "token_env": "DATAPREP_TOKEN" } } }
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Development
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
python -m venv .venv && . .venv/bin/activate # Windows: .venv\Scripts\activate
|
|
117
|
+
python -m pip install -e . -r requirements-dev.txt
|
|
118
|
+
python -m pytest
|
|
119
|
+
python -m ruff check src tests
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
|
|
124
|
+
MIT
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "dataprep-mcp"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "MCP server for agent-driven dataset analysis with human-in-the-loop preprocessing"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
authors = [{ name = "Nadun Sooriyaarachchi", email = "nadunbiz27@gmail.com" }]
|
|
13
|
+
requires-python = ">=3.11"
|
|
14
|
+
keywords = ["mcp", "model-context-protocol", "fastmcp", "data-quality", "eda", "llm"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Intended Audience :: Science/Research",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Topic :: Scientific/Engineering :: Information Analysis",
|
|
25
|
+
]
|
|
26
|
+
dependencies = [
|
|
27
|
+
"fastmcp>=4.2,<5",
|
|
28
|
+
"pandas>=2.2",
|
|
29
|
+
"numpy>=1.26",
|
|
30
|
+
"duckdb>=1.1",
|
|
31
|
+
"pyarrow>=16.0",
|
|
32
|
+
"openpyxl>=3.1",
|
|
33
|
+
"scipy>=1.13",
|
|
34
|
+
"pydantic>=2.7",
|
|
35
|
+
"cryptography>=42",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.optional-dependencies]
|
|
39
|
+
agent = ["anthropic>=0.40"]
|
|
40
|
+
|
|
41
|
+
[project.urls]
|
|
42
|
+
Homepage = "https://github.com/NadunAtGit/DataPrep-AI"
|
|
43
|
+
Issues = "https://github.com/NadunAtGit/DataPrep-AI/issues"
|
|
44
|
+
|
|
45
|
+
[project.scripts]
|
|
46
|
+
dataprep-mcp = "dataprep_mcp.__main__:main"
|
|
47
|
+
dataprep-mcp-auth = "dataprep_mcp.auth_cli:main"
|
|
48
|
+
dataprep-client = "dataprep_mcp.client.cli:main"
|
|
49
|
+
|
|
50
|
+
[tool.setuptools.packages.find]
|
|
51
|
+
where = ["src"]
|
|
52
|
+
|
|
53
|
+
[tool.setuptools.package-data]
|
|
54
|
+
dataprep_mcp = ["ui/*.html"]
|
|
55
|
+
|
|
56
|
+
[tool.pytest.ini_options]
|
|
57
|
+
testpaths = ["tests"]
|
|
58
|
+
asyncio_mode = "auto"
|
|
59
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
File without changes
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""Start the DataPrep MCP server.
|
|
2
|
+
|
|
3
|
+
dataprep-mcp # stdio (Claude Desktop, MCP Inspector)
|
|
4
|
+
dataprep-mcp --transport http --port 8000 # remote: Streamable HTTP at /mcp
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import argparse
|
|
8
|
+
import ipaddress
|
|
9
|
+
import logging
|
|
10
|
+
import sys
|
|
11
|
+
|
|
12
|
+
from dataprep_mcp.server.app import mcp
|
|
13
|
+
from dataprep_mcp.server.auth import AuthConfigError, verifier_from_env
|
|
14
|
+
|
|
15
|
+
log = logging.getLogger("dataprep_mcp")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def is_loopback(host: str) -> bool:
|
|
19
|
+
if host == "localhost":
|
|
20
|
+
return True
|
|
21
|
+
try:
|
|
22
|
+
return ipaddress.ip_address(host).is_loopback
|
|
23
|
+
except ValueError:
|
|
24
|
+
return False
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def parse_args(argv: list[str] | None = None) -> argparse.Namespace:
|
|
28
|
+
parser = argparse.ArgumentParser(prog="dataprep-mcp", description="DataPrep MCP server")
|
|
29
|
+
parser.add_argument("--transport", choices=["stdio", "http"], default="stdio")
|
|
30
|
+
parser.add_argument("--host", default="127.0.0.1", help="HTTP only (default 127.0.0.1)")
|
|
31
|
+
parser.add_argument("--port", type=int, default=8000, help="HTTP only (default 8000)")
|
|
32
|
+
parser.add_argument("--path", default="/mcp", help="HTTP endpoint path (default /mcp)")
|
|
33
|
+
parser.add_argument(
|
|
34
|
+
"--allow-no-auth",
|
|
35
|
+
action="store_true",
|
|
36
|
+
help="HTTP without tokens; only allowed on a loopback host such as 127.0.0.1",
|
|
37
|
+
)
|
|
38
|
+
return parser.parse_args(argv)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def main(argv: list[str] | None = None) -> None:
|
|
42
|
+
logging.basicConfig(
|
|
43
|
+
level=logging.INFO,
|
|
44
|
+
stream=sys.stderr, # stdout carries the protocol in stdio mode
|
|
45
|
+
format="%(asctime)s %(levelname)s %(name)s: %(message)s",
|
|
46
|
+
)
|
|
47
|
+
args = parse_args(argv)
|
|
48
|
+
|
|
49
|
+
if args.transport == "stdio":
|
|
50
|
+
mcp.run()
|
|
51
|
+
return
|
|
52
|
+
|
|
53
|
+
try:
|
|
54
|
+
verifier = verifier_from_env()
|
|
55
|
+
except AuthConfigError as exc:
|
|
56
|
+
sys.exit(f"Auth configuration error: {exc}")
|
|
57
|
+
|
|
58
|
+
if verifier is not None:
|
|
59
|
+
mcp.auth = verifier
|
|
60
|
+
log.info("Token authentication on")
|
|
61
|
+
elif args.allow_no_auth and is_loopback(args.host):
|
|
62
|
+
log.warning("No authentication: only programs on this computer can connect")
|
|
63
|
+
elif args.allow_no_auth:
|
|
64
|
+
sys.exit("--allow-no-auth only works with a loopback --host such as 127.0.0.1.")
|
|
65
|
+
else:
|
|
66
|
+
sys.exit(
|
|
67
|
+
"HTTP needs authentication. Set DATAPREP_AUTH_PUBLIC_KEY_FILE (see "
|
|
68
|
+
"`dataprep-mcp-auth keys`) or DATAPREP_AUTH_JWKS_URI, or add --allow-no-auth "
|
|
69
|
+
"for local testing."
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
mcp.run(transport="http", host=args.host, port=args.port, path=args.path)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
if __name__ == "__main__":
|
|
76
|
+
main()
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"""Development helper: create a signing key pair and issue tokens for testing.
|
|
2
|
+
|
|
3
|
+
dataprep-mcp-auth keys --out keys
|
|
4
|
+
dataprep-mcp-auth token --key keys/private.pem --subject alice
|
|
5
|
+
|
|
6
|
+
In production an identity provider issues tokens; the server only needs the
|
|
7
|
+
public key (or the provider's JWKS URL). Never commit the private key.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import argparse
|
|
11
|
+
import sys
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
from cryptography.hazmat.primitives import serialization
|
|
15
|
+
from cryptography.hazmat.primitives.asymmetric import rsa
|
|
16
|
+
from fastmcp.server.auth.providers.jwt import RSAKeyPair
|
|
17
|
+
from pydantic import SecretStr
|
|
18
|
+
|
|
19
|
+
from dataprep_mcp.server.auth import DEFAULT_AUDIENCE, DEFAULT_ISSUER
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def write_keys(out: Path) -> tuple[Path, Path]:
|
|
23
|
+
out.mkdir(parents=True, exist_ok=True)
|
|
24
|
+
private = rsa.generate_private_key(public_exponent=65537, key_size=2048)
|
|
25
|
+
private_pem = private.private_bytes(
|
|
26
|
+
serialization.Encoding.PEM,
|
|
27
|
+
serialization.PrivateFormat.PKCS8,
|
|
28
|
+
serialization.NoEncryption(),
|
|
29
|
+
)
|
|
30
|
+
public_pem = private.public_key().public_bytes(
|
|
31
|
+
serialization.Encoding.PEM, serialization.PublicFormat.SubjectPublicKeyInfo
|
|
32
|
+
)
|
|
33
|
+
private_path, public_path = out / "private.pem", out / "public.pem"
|
|
34
|
+
private_path.write_bytes(private_pem)
|
|
35
|
+
public_path.write_bytes(public_pem)
|
|
36
|
+
return private_path, public_path
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def make_token(
|
|
40
|
+
key_file: Path,
|
|
41
|
+
subject: str,
|
|
42
|
+
*,
|
|
43
|
+
issuer: str = DEFAULT_ISSUER,
|
|
44
|
+
audience: str = DEFAULT_AUDIENCE,
|
|
45
|
+
scopes: list[str] | None = None,
|
|
46
|
+
hours: float = 8,
|
|
47
|
+
) -> str:
|
|
48
|
+
private_pem = key_file.read_bytes()
|
|
49
|
+
private = serialization.load_pem_private_key(private_pem, password=None)
|
|
50
|
+
public_pem = private.public_key().public_bytes(
|
|
51
|
+
serialization.Encoding.PEM, serialization.PublicFormat.SubjectPublicKeyInfo
|
|
52
|
+
)
|
|
53
|
+
pair = RSAKeyPair(private_key=SecretStr(private_pem.decode()), public_key=public_pem.decode())
|
|
54
|
+
return pair.create_token(
|
|
55
|
+
subject=subject,
|
|
56
|
+
issuer=issuer,
|
|
57
|
+
audience=audience,
|
|
58
|
+
scopes=scopes or [],
|
|
59
|
+
expires_in_seconds=int(hours * 3600),
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def main(argv: list[str] | None = None) -> None:
|
|
64
|
+
parser = argparse.ArgumentParser(prog="dataprep-mcp-auth", description=__doc__.split("\n")[0])
|
|
65
|
+
sub = parser.add_subparsers(dest="command", required=True)
|
|
66
|
+
|
|
67
|
+
keys = sub.add_parser("keys", help="create private.pem and public.pem")
|
|
68
|
+
keys.add_argument("--out", type=Path, default=Path("keys"))
|
|
69
|
+
|
|
70
|
+
token = sub.add_parser("token", help="print a signed token for a user")
|
|
71
|
+
token.add_argument("--key", type=Path, default=Path("keys/private.pem"))
|
|
72
|
+
token.add_argument("--subject", required=True, help="user name the server will see")
|
|
73
|
+
token.add_argument("--issuer", default=DEFAULT_ISSUER)
|
|
74
|
+
token.add_argument("--audience", default=DEFAULT_AUDIENCE)
|
|
75
|
+
token.add_argument("--scope", action="append", default=[], help="repeatable")
|
|
76
|
+
token.add_argument("--hours", type=float, default=8)
|
|
77
|
+
|
|
78
|
+
args = parser.parse_args(argv)
|
|
79
|
+
if args.command == "keys":
|
|
80
|
+
private_path, public_path = write_keys(args.out)
|
|
81
|
+
print(f"Wrote {private_path} (keep secret) and {public_path}", file=sys.stderr)
|
|
82
|
+
else:
|
|
83
|
+
print(
|
|
84
|
+
make_token(
|
|
85
|
+
args.key,
|
|
86
|
+
args.subject,
|
|
87
|
+
issuer=args.issuer,
|
|
88
|
+
audience=args.audience,
|
|
89
|
+
scopes=args.scope,
|
|
90
|
+
hours=args.hours,
|
|
91
|
+
)
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
if __name__ == "__main__":
|
|
96
|
+
main()
|
|
File without changes
|
|
File without changes
|