mcp-proxyml 0.1.2__tar.gz → 0.1.3__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.
- {mcp_proxyml-0.1.2 → mcp_proxyml-0.1.3}/PKG-INFO +48 -1
- {mcp_proxyml-0.1.2 → mcp_proxyml-0.1.3}/README.md +47 -0
- {mcp_proxyml-0.1.2 → mcp_proxyml-0.1.3}/mcp_proxyml/schema.py +9 -0
- {mcp_proxyml-0.1.2 → mcp_proxyml-0.1.3}/mcp_proxyml/server.py +157 -27
- {mcp_proxyml-0.1.2 → mcp_proxyml-0.1.3}/mcp_proxyml.egg-info/PKG-INFO +48 -1
- {mcp_proxyml-0.1.2 → mcp_proxyml-0.1.3}/pyproject.toml +1 -1
- {mcp_proxyml-0.1.2 → mcp_proxyml-0.1.3}/LICENSE +0 -0
- {mcp_proxyml-0.1.2 → mcp_proxyml-0.1.3}/mcp_proxyml/__init__.py +0 -0
- {mcp_proxyml-0.1.2 → mcp_proxyml-0.1.3}/mcp_proxyml/drift.py +0 -0
- {mcp_proxyml-0.1.2 → mcp_proxyml-0.1.3}/mcp_proxyml.egg-info/SOURCES.txt +0 -0
- {mcp_proxyml-0.1.2 → mcp_proxyml-0.1.3}/mcp_proxyml.egg-info/dependency_links.txt +0 -0
- {mcp_proxyml-0.1.2 → mcp_proxyml-0.1.3}/mcp_proxyml.egg-info/entry_points.txt +0 -0
- {mcp_proxyml-0.1.2 → mcp_proxyml-0.1.3}/mcp_proxyml.egg-info/requires.txt +0 -0
- {mcp_proxyml-0.1.2 → mcp_proxyml-0.1.3}/mcp_proxyml.egg-info/top_level.txt +0 -0
- {mcp_proxyml-0.1.2 → mcp_proxyml-0.1.3}/setup.cfg +0 -0
- {mcp_proxyml-0.1.2 → mcp_proxyml-0.1.3}/tests/test_drift.py +0 -0
- {mcp_proxyml-0.1.2 → mcp_proxyml-0.1.3}/tests/test_schema.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mcp-proxyml
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: MCP server for the ProxyML API
|
|
5
5
|
Author-email: ProxyML <contact@proxyml.ai>
|
|
6
6
|
License: Apache License
|
|
@@ -262,6 +262,53 @@ PROXYML_API_KEY=your-key mcp-proxyml
|
|
|
262
262
|
|---|---|---|
|
|
263
263
|
| `PROXYML_API_KEY` | Yes | Your ProxyML API key |
|
|
264
264
|
|
|
265
|
+
## Security & permissions
|
|
266
|
+
|
|
267
|
+
### What this server can access
|
|
268
|
+
|
|
269
|
+
**Filesystem** — `proxyml_infer_schema` reads one CSV file at the path you
|
|
270
|
+
provide. No other tool reads or writes local files.
|
|
271
|
+
|
|
272
|
+
**Network** — outbound HTTPS only, to `https://api.proxyml.ai` (or the URL
|
|
273
|
+
set in `PROXYML_BASE_URL`). No other hosts are contacted.
|
|
274
|
+
|
|
275
|
+
**Environment** — only `PROXYML_API_KEY` and `PROXYML_BASE_URL` are read.
|
|
276
|
+
No other environment variables are accessed.
|
|
277
|
+
|
|
278
|
+
**No shell execution, no local ports, no other system resources.**
|
|
279
|
+
|
|
280
|
+
### What is sent to ProxyML's servers
|
|
281
|
+
|
|
282
|
+
| Tool | What is transmitted |
|
|
283
|
+
|---|---|
|
|
284
|
+
| `proxyml_infer_schema` | Nothing — CSV is read and processed locally only |
|
|
285
|
+
| `proxyml_put_schema` | Feature schema: column names, types, and constraints |
|
|
286
|
+
| `proxyml_get_schema` | Schema name (string) |
|
|
287
|
+
| `proxyml_synthesize_data` | Schema name, sample count, and optionally one feature vector |
|
|
288
|
+
| `proxyml_train_surrogate` | Synthetic feature vectors + your model's predictions for those vectors |
|
|
289
|
+
| `proxyml_predict_batch` | Feature vectors you pass explicitly |
|
|
290
|
+
| `proxyml_explain_local` / `proxyml_explain_local_batch` | Feature vector(s) you pass explicitly |
|
|
291
|
+
| `proxyml_find_counterfactual` | One feature vector and a target label |
|
|
292
|
+
| `proxyml_list_surrogates` / `proxyml_get_summary` / `proxyml_export_surrogate` / `proxyml_diff_models` / `proxyml_detect_drift` | Version IDs and/or threshold values (no feature data) |
|
|
293
|
+
| `proxyml_get_usage` | Nothing |
|
|
294
|
+
|
|
295
|
+
The typical workflow is designed so that raw training data never leaves your
|
|
296
|
+
environment. `proxyml_infer_schema` derives column metadata from your CSV
|
|
297
|
+
locally; `proxyml_synthesize_data` generates samples server-side from that
|
|
298
|
+
schema; and `proxyml_train_surrogate` sends only those synthetic samples
|
|
299
|
+
plus your model's predictions for them. Your original dataset is not
|
|
300
|
+
transmitted.
|
|
301
|
+
|
|
302
|
+
If you use `proxyml_explain_local`, `proxyml_predict_batch`, or
|
|
303
|
+
`proxyml_find_counterfactual` with real data points rather than synthetic
|
|
304
|
+
ones, those feature vectors will be sent to the ProxyML API.
|
|
305
|
+
|
|
306
|
+
### Authentication
|
|
307
|
+
|
|
308
|
+
Your API key is sent on every request as an `X-API-KEY` HTTP header over TLS.
|
|
309
|
+
It is read from the `PROXYML_API_KEY` environment variable and is never
|
|
310
|
+
logged or written to disk by this server.
|
|
311
|
+
|
|
265
312
|
## Tools
|
|
266
313
|
|
|
267
314
|
### Schema
|
|
@@ -51,6 +51,53 @@ PROXYML_API_KEY=your-key mcp-proxyml
|
|
|
51
51
|
|---|---|---|
|
|
52
52
|
| `PROXYML_API_KEY` | Yes | Your ProxyML API key |
|
|
53
53
|
|
|
54
|
+
## Security & permissions
|
|
55
|
+
|
|
56
|
+
### What this server can access
|
|
57
|
+
|
|
58
|
+
**Filesystem** — `proxyml_infer_schema` reads one CSV file at the path you
|
|
59
|
+
provide. No other tool reads or writes local files.
|
|
60
|
+
|
|
61
|
+
**Network** — outbound HTTPS only, to `https://api.proxyml.ai` (or the URL
|
|
62
|
+
set in `PROXYML_BASE_URL`). No other hosts are contacted.
|
|
63
|
+
|
|
64
|
+
**Environment** — only `PROXYML_API_KEY` and `PROXYML_BASE_URL` are read.
|
|
65
|
+
No other environment variables are accessed.
|
|
66
|
+
|
|
67
|
+
**No shell execution, no local ports, no other system resources.**
|
|
68
|
+
|
|
69
|
+
### What is sent to ProxyML's servers
|
|
70
|
+
|
|
71
|
+
| Tool | What is transmitted |
|
|
72
|
+
|---|---|
|
|
73
|
+
| `proxyml_infer_schema` | Nothing — CSV is read and processed locally only |
|
|
74
|
+
| `proxyml_put_schema` | Feature schema: column names, types, and constraints |
|
|
75
|
+
| `proxyml_get_schema` | Schema name (string) |
|
|
76
|
+
| `proxyml_synthesize_data` | Schema name, sample count, and optionally one feature vector |
|
|
77
|
+
| `proxyml_train_surrogate` | Synthetic feature vectors + your model's predictions for those vectors |
|
|
78
|
+
| `proxyml_predict_batch` | Feature vectors you pass explicitly |
|
|
79
|
+
| `proxyml_explain_local` / `proxyml_explain_local_batch` | Feature vector(s) you pass explicitly |
|
|
80
|
+
| `proxyml_find_counterfactual` | One feature vector and a target label |
|
|
81
|
+
| `proxyml_list_surrogates` / `proxyml_get_summary` / `proxyml_export_surrogate` / `proxyml_diff_models` / `proxyml_detect_drift` | Version IDs and/or threshold values (no feature data) |
|
|
82
|
+
| `proxyml_get_usage` | Nothing |
|
|
83
|
+
|
|
84
|
+
The typical workflow is designed so that raw training data never leaves your
|
|
85
|
+
environment. `proxyml_infer_schema` derives column metadata from your CSV
|
|
86
|
+
locally; `proxyml_synthesize_data` generates samples server-side from that
|
|
87
|
+
schema; and `proxyml_train_surrogate` sends only those synthetic samples
|
|
88
|
+
plus your model's predictions for them. Your original dataset is not
|
|
89
|
+
transmitted.
|
|
90
|
+
|
|
91
|
+
If you use `proxyml_explain_local`, `proxyml_predict_batch`, or
|
|
92
|
+
`proxyml_find_counterfactual` with real data points rather than synthetic
|
|
93
|
+
ones, those feature vectors will be sent to the ProxyML API.
|
|
94
|
+
|
|
95
|
+
### Authentication
|
|
96
|
+
|
|
97
|
+
Your API key is sent on every request as an `X-API-KEY` HTTP header over TLS.
|
|
98
|
+
It is read from the `PROXYML_API_KEY` environment variable and is never
|
|
99
|
+
logged or written to disk by this server.
|
|
100
|
+
|
|
54
101
|
## Tools
|
|
55
102
|
|
|
56
103
|
### Schema
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
1
3
|
import numpy as np
|
|
2
4
|
import pandas as pd
|
|
3
5
|
from pandas.api.types import is_float_dtype, is_integer_dtype
|
|
4
6
|
|
|
7
|
+
logger = logging.getLogger(__name__)
|
|
8
|
+
|
|
5
9
|
|
|
6
10
|
def infer_schema(df: pd.DataFrame, immutable_cols: list[str] | None = None) -> dict:
|
|
7
11
|
"""Infer a ProxyML feature schema from a DataFrame.
|
|
@@ -9,6 +13,11 @@ def infer_schema(df: pd.DataFrame, immutable_cols: list[str] | None = None) -> d
|
|
|
9
13
|
Integer columns default to 'count'. Consider switching to 'categorical_ordinal'
|
|
10
14
|
for ordered categories like ratings or education level.
|
|
11
15
|
"""
|
|
16
|
+
if immutable_cols:
|
|
17
|
+
unknown = set(immutable_cols) - set(df.columns)
|
|
18
|
+
if unknown:
|
|
19
|
+
logger.warning("immutable_cols not found in DataFrame and will be ignored: %s", sorted(unknown))
|
|
20
|
+
|
|
12
21
|
features = []
|
|
13
22
|
for col in df.columns:
|
|
14
23
|
immutable = immutable_cols is not None and col in immutable_cols
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import json
|
|
2
|
+
import logging
|
|
2
3
|
import os
|
|
3
4
|
|
|
4
5
|
import httpx
|
|
@@ -8,9 +9,12 @@ from mcp.server.fastmcp import FastMCP
|
|
|
8
9
|
from mcp_proxyml.drift import interpret_diff
|
|
9
10
|
from mcp_proxyml.schema import infer_schema
|
|
10
11
|
|
|
12
|
+
logger = logging.getLogger(__name__)
|
|
13
|
+
|
|
11
14
|
mcp = FastMCP("ProxyML")
|
|
12
15
|
|
|
13
16
|
_DEFAULT_BASE_URL = "https://api.proxyml.ai/api/v1"
|
|
17
|
+
_TIMEOUT = 120.0
|
|
14
18
|
|
|
15
19
|
|
|
16
20
|
def _client() -> httpx.AsyncClient:
|
|
@@ -23,10 +27,21 @@ def _client() -> httpx.AsyncClient:
|
|
|
23
27
|
return httpx.AsyncClient(
|
|
24
28
|
base_url=os.environ.get("PROXYML_BASE_URL", _DEFAULT_BASE_URL),
|
|
25
29
|
headers={"X-API-KEY": api_key, "Content-Type": "application/json"},
|
|
26
|
-
timeout=
|
|
30
|
+
timeout=_TIMEOUT,
|
|
27
31
|
)
|
|
28
32
|
|
|
29
33
|
|
|
34
|
+
def _result(r: httpx.Response) -> dict:
|
|
35
|
+
"""Return the JSON body on success, or a structured error dict on failure."""
|
|
36
|
+
if r.is_success:
|
|
37
|
+
return r.json()
|
|
38
|
+
try:
|
|
39
|
+
detail = r.json().get("detail", r.text)
|
|
40
|
+
except Exception:
|
|
41
|
+
detail = r.text
|
|
42
|
+
return {"error": True, "status_code": r.status_code, "detail": detail}
|
|
43
|
+
|
|
44
|
+
|
|
30
45
|
# ---------------------------------------------------------------------------
|
|
31
46
|
# Local tools (no API call)
|
|
32
47
|
# ---------------------------------------------------------------------------
|
|
@@ -43,6 +58,8 @@ async def proxyml_infer_schema(
|
|
|
43
58
|
Integer columns default to 'count'; consider 'categorical_ordinal' for
|
|
44
59
|
ordered categories like ratings or education level.
|
|
45
60
|
"""
|
|
61
|
+
if not os.path.isfile(csv_path):
|
|
62
|
+
return {"error": True, "detail": f"File not found or not a file: {csv_path}"}
|
|
46
63
|
df = pd.read_csv(csv_path)
|
|
47
64
|
return infer_schema(df, immutable_cols)
|
|
48
65
|
|
|
@@ -56,8 +73,7 @@ async def proxyml_get_schema(schema_name: str = "default") -> dict:
|
|
|
56
73
|
"""Retrieve a stored feature schema by name."""
|
|
57
74
|
async with _client() as c:
|
|
58
75
|
r = await c.get(f"/schema/{schema_name}")
|
|
59
|
-
r
|
|
60
|
-
return r.json()
|
|
76
|
+
return _result(r)
|
|
61
77
|
|
|
62
78
|
|
|
63
79
|
@mcp.tool()
|
|
@@ -65,8 +81,7 @@ async def proxyml_put_schema(schema: dict, schema_name: str = "default") -> dict
|
|
|
65
81
|
"""Upload or replace a feature schema."""
|
|
66
82
|
async with _client() as c:
|
|
67
83
|
r = await c.put(f"/schema/{schema_name}", content=json.dumps(schema))
|
|
68
|
-
r
|
|
69
|
-
return r.json()
|
|
84
|
+
return _result(r)
|
|
70
85
|
|
|
71
86
|
|
|
72
87
|
# ---------------------------------------------------------------------------
|
|
@@ -92,8 +107,7 @@ async def proxyml_synthesize_data(
|
|
|
92
107
|
else:
|
|
93
108
|
payload = {"n": num_points, "instance": instance, "schema_name": schema_name}
|
|
94
109
|
r = await c.post("/synthesize/blended", content=json.dumps(payload))
|
|
95
|
-
r
|
|
96
|
-
return r.json()
|
|
110
|
+
return _result(r)
|
|
97
111
|
|
|
98
112
|
|
|
99
113
|
# ---------------------------------------------------------------------------
|
|
@@ -133,8 +147,7 @@ async def proxyml_train_surrogate(
|
|
|
133
147
|
payload["comments"] = comments
|
|
134
148
|
async with _client() as c:
|
|
135
149
|
r = await c.post("/surrogate/train", content=json.dumps(payload))
|
|
136
|
-
r
|
|
137
|
-
return r.json()
|
|
150
|
+
return _result(r)
|
|
138
151
|
|
|
139
152
|
|
|
140
153
|
@mcp.tool()
|
|
@@ -146,8 +159,7 @@ async def proxyml_list_surrogates(limit: int = 50, offset: int = 0) -> dict:
|
|
|
146
159
|
"""
|
|
147
160
|
async with _client() as c:
|
|
148
161
|
r = await c.get("/surrogate/models", params={"limit": limit, "offset": offset})
|
|
149
|
-
r
|
|
150
|
-
return r.json()
|
|
162
|
+
return _result(r)
|
|
151
163
|
|
|
152
164
|
|
|
153
165
|
# ---------------------------------------------------------------------------
|
|
@@ -163,8 +175,7 @@ async def proxyml_get_summary(version: str | None = None) -> dict:
|
|
|
163
175
|
async with _client() as c:
|
|
164
176
|
params = {"version": version} if version is not None else {}
|
|
165
177
|
r = await c.get("/explain/summary", params=params)
|
|
166
|
-
r
|
|
167
|
-
return r.json()
|
|
178
|
+
return _result(r)
|
|
168
179
|
|
|
169
180
|
|
|
170
181
|
@mcp.tool()
|
|
@@ -182,8 +193,7 @@ async def proxyml_explain_local(
|
|
|
182
193
|
payload["version"] = version
|
|
183
194
|
async with _client() as c:
|
|
184
195
|
r = await c.post("/explain/local", content=json.dumps(payload))
|
|
185
|
-
r
|
|
186
|
-
return r.json()
|
|
196
|
+
return _result(r)
|
|
187
197
|
|
|
188
198
|
|
|
189
199
|
@mcp.tool()
|
|
@@ -209,8 +219,7 @@ async def proxyml_find_counterfactual(
|
|
|
209
219
|
payload["version"] = version
|
|
210
220
|
async with _client() as c:
|
|
211
221
|
r = await c.post("/explain/counterfactual", content=json.dumps(payload))
|
|
212
|
-
r
|
|
213
|
-
return r.json()
|
|
222
|
+
return _result(r)
|
|
214
223
|
|
|
215
224
|
|
|
216
225
|
@mcp.tool()
|
|
@@ -221,8 +230,7 @@ async def proxyml_diff_models(version_a: str, version_b: str) -> dict:
|
|
|
221
230
|
"""
|
|
222
231
|
async with _client() as c:
|
|
223
232
|
r = await c.get("/explain/diff", params={"version_a": version_a, "version_b": version_b})
|
|
224
|
-
r
|
|
225
|
-
return r.json()
|
|
233
|
+
return _result(r)
|
|
226
234
|
|
|
227
235
|
|
|
228
236
|
@mcp.tool()
|
|
@@ -275,8 +283,7 @@ async def proxyml_predict_batch(
|
|
|
275
283
|
payload["version"] = version
|
|
276
284
|
async with _client() as c:
|
|
277
285
|
r = await c.post("/surrogate/predict/batch", content=json.dumps(payload))
|
|
278
|
-
r
|
|
279
|
-
return r.json()
|
|
286
|
+
return _result(r)
|
|
280
287
|
|
|
281
288
|
|
|
282
289
|
# ---------------------------------------------------------------------------
|
|
@@ -292,8 +299,7 @@ async def proxyml_get_usage() -> dict:
|
|
|
292
299
|
"""
|
|
293
300
|
async with _client() as c:
|
|
294
301
|
r = await c.get("/account/usage")
|
|
295
|
-
r
|
|
296
|
-
return r.json()
|
|
302
|
+
return _result(r)
|
|
297
303
|
|
|
298
304
|
|
|
299
305
|
# ---------------------------------------------------------------------------
|
|
@@ -309,8 +315,7 @@ async def proxyml_export_surrogate(version: str) -> dict:
|
|
|
309
315
|
"""
|
|
310
316
|
async with _client() as c:
|
|
311
317
|
r = await c.get(f"/surrogate/models/{version}/export")
|
|
312
|
-
r
|
|
313
|
-
return r.json()
|
|
318
|
+
return _result(r)
|
|
314
319
|
|
|
315
320
|
|
|
316
321
|
@mcp.tool()
|
|
@@ -328,8 +333,133 @@ async def proxyml_explain_local_batch(
|
|
|
328
333
|
payload["version"] = version
|
|
329
334
|
async with _client() as c:
|
|
330
335
|
r = await c.post("/explain/local/batch", content=json.dumps(payload))
|
|
331
|
-
r
|
|
332
|
-
|
|
336
|
+
return _result(r)
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
# ---------------------------------------------------------------------------
|
|
340
|
+
# Additional schema and model management tools
|
|
341
|
+
# ---------------------------------------------------------------------------
|
|
342
|
+
|
|
343
|
+
@mcp.tool()
|
|
344
|
+
async def proxyml_list_schemas() -> dict:
|
|
345
|
+
"""List all named feature schemas for the authenticated account."""
|
|
346
|
+
async with _client() as c:
|
|
347
|
+
r = await c.get("/schemas")
|
|
348
|
+
return _result(r)
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
@mcp.tool()
|
|
352
|
+
async def proxyml_delete_schema(schema_name: str) -> dict:
|
|
353
|
+
"""Delete a named feature schema. Returns success or a structured error."""
|
|
354
|
+
async with _client() as c:
|
|
355
|
+
r = await c.delete(f"/schema/{schema_name}")
|
|
356
|
+
if r.status_code == 204:
|
|
357
|
+
return {"deleted": True, "schema_name": schema_name}
|
|
358
|
+
return _result(r)
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
@mcp.tool()
|
|
362
|
+
async def proxyml_get_model_schema(version: str) -> dict:
|
|
363
|
+
"""Retrieve the feature schema that was snapshotted when a surrogate was trained.
|
|
364
|
+
|
|
365
|
+
Useful for auditing which schema version a model was trained against.
|
|
366
|
+
"""
|
|
367
|
+
async with _client() as c:
|
|
368
|
+
r = await c.get(f"/surrogate/models/{version}/schema")
|
|
369
|
+
return _result(r)
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
@mcp.tool()
|
|
373
|
+
async def proxyml_update_surrogate(
|
|
374
|
+
version: str,
|
|
375
|
+
name: str | None = None,
|
|
376
|
+
comments: str | None = None,
|
|
377
|
+
) -> dict:
|
|
378
|
+
"""Update the name or comments of a surrogate without retraining.
|
|
379
|
+
|
|
380
|
+
Omit a parameter to leave that field unchanged.
|
|
381
|
+
Pass null/None to clear a field.
|
|
382
|
+
"""
|
|
383
|
+
payload: dict = {}
|
|
384
|
+
if name is not None:
|
|
385
|
+
payload["name"] = name
|
|
386
|
+
if comments is not None:
|
|
387
|
+
payload["comments"] = comments
|
|
388
|
+
if not payload:
|
|
389
|
+
return {"error": True, "detail": "Provide at least one of: name, comments"}
|
|
390
|
+
async with _client() as c:
|
|
391
|
+
r = await c.patch(f"/surrogate/models/{version}", content=json.dumps(payload))
|
|
392
|
+
return _result(r)
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
@mcp.tool()
|
|
396
|
+
async def proxyml_delete_surrogate(model_id: str) -> dict:
|
|
397
|
+
"""Delete a surrogate model by its UUID. Returns success or a structured error."""
|
|
398
|
+
async with _client() as c:
|
|
399
|
+
r = await c.delete(f"/surrogate/models/{model_id}")
|
|
400
|
+
if r.status_code == 204:
|
|
401
|
+
return {"deleted": True, "model_id": model_id}
|
|
402
|
+
return _result(r)
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
@mcp.tool()
|
|
406
|
+
async def proxyml_predict(
|
|
407
|
+
instance: list,
|
|
408
|
+
version: str | None = None,
|
|
409
|
+
) -> dict:
|
|
410
|
+
"""Get a surrogate model prediction for a single instance.
|
|
411
|
+
|
|
412
|
+
Returns prediction, and optionally probability (classification) or
|
|
413
|
+
a regression value. Use proxyml_predict_batch for multiple instances.
|
|
414
|
+
"""
|
|
415
|
+
payload: dict = {"inputs": instance}
|
|
416
|
+
if version is not None:
|
|
417
|
+
payload["version"] = version
|
|
418
|
+
async with _client() as c:
|
|
419
|
+
r = await c.post("/surrogate/predict", content=json.dumps(payload))
|
|
420
|
+
return _result(r)
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
@mcp.tool()
|
|
424
|
+
async def proxyml_find_counterfactuals(
|
|
425
|
+
instances: list[list],
|
|
426
|
+
target_label: float | str,
|
|
427
|
+
n_neighbors: int = 10000,
|
|
428
|
+
perturbation_scale: float = 0.1,
|
|
429
|
+
version: str | None = None,
|
|
430
|
+
) -> dict:
|
|
431
|
+
"""Find counterfactuals for multiple instances in one call.
|
|
432
|
+
|
|
433
|
+
Equivalent to calling proxyml_find_counterfactual for each instance.
|
|
434
|
+
Each result has a 'counterfactual' field (None if none was found).
|
|
435
|
+
"""
|
|
436
|
+
payload: dict = {
|
|
437
|
+
"instances": instances,
|
|
438
|
+
"target_label": target_label,
|
|
439
|
+
"n_neighbors": n_neighbors,
|
|
440
|
+
"perturbation_scale": perturbation_scale,
|
|
441
|
+
}
|
|
442
|
+
if version is not None:
|
|
443
|
+
payload["version"] = version
|
|
444
|
+
async with _client() as c:
|
|
445
|
+
r = await c.post("/explain/counterfactual/batch", content=json.dumps(payload))
|
|
446
|
+
return _result(r)
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
@mcp.tool()
|
|
450
|
+
async def proxyml_health_check() -> dict:
|
|
451
|
+
"""Check API connectivity. Does not require authentication and does not count against usage quota.
|
|
452
|
+
|
|
453
|
+
Returns status, model_loaded, and API version. Useful as a pre-flight
|
|
454
|
+
check before training or synthesis operations.
|
|
455
|
+
"""
|
|
456
|
+
base_url = os.environ.get("PROXYML_BASE_URL", _DEFAULT_BASE_URL)
|
|
457
|
+
try:
|
|
458
|
+
async with httpx.AsyncClient(timeout=_TIMEOUT) as c:
|
|
459
|
+
r = await c.get(f"{base_url}/health")
|
|
460
|
+
return _result(r)
|
|
461
|
+
except httpx.RequestError as exc:
|
|
462
|
+
return {"error": True, "detail": f"Network error: {exc}"}
|
|
333
463
|
|
|
334
464
|
|
|
335
465
|
# ---------------------------------------------------------------------------
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mcp-proxyml
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: MCP server for the ProxyML API
|
|
5
5
|
Author-email: ProxyML <contact@proxyml.ai>
|
|
6
6
|
License: Apache License
|
|
@@ -262,6 +262,53 @@ PROXYML_API_KEY=your-key mcp-proxyml
|
|
|
262
262
|
|---|---|---|
|
|
263
263
|
| `PROXYML_API_KEY` | Yes | Your ProxyML API key |
|
|
264
264
|
|
|
265
|
+
## Security & permissions
|
|
266
|
+
|
|
267
|
+
### What this server can access
|
|
268
|
+
|
|
269
|
+
**Filesystem** — `proxyml_infer_schema` reads one CSV file at the path you
|
|
270
|
+
provide. No other tool reads or writes local files.
|
|
271
|
+
|
|
272
|
+
**Network** — outbound HTTPS only, to `https://api.proxyml.ai` (or the URL
|
|
273
|
+
set in `PROXYML_BASE_URL`). No other hosts are contacted.
|
|
274
|
+
|
|
275
|
+
**Environment** — only `PROXYML_API_KEY` and `PROXYML_BASE_URL` are read.
|
|
276
|
+
No other environment variables are accessed.
|
|
277
|
+
|
|
278
|
+
**No shell execution, no local ports, no other system resources.**
|
|
279
|
+
|
|
280
|
+
### What is sent to ProxyML's servers
|
|
281
|
+
|
|
282
|
+
| Tool | What is transmitted |
|
|
283
|
+
|---|---|
|
|
284
|
+
| `proxyml_infer_schema` | Nothing — CSV is read and processed locally only |
|
|
285
|
+
| `proxyml_put_schema` | Feature schema: column names, types, and constraints |
|
|
286
|
+
| `proxyml_get_schema` | Schema name (string) |
|
|
287
|
+
| `proxyml_synthesize_data` | Schema name, sample count, and optionally one feature vector |
|
|
288
|
+
| `proxyml_train_surrogate` | Synthetic feature vectors + your model's predictions for those vectors |
|
|
289
|
+
| `proxyml_predict_batch` | Feature vectors you pass explicitly |
|
|
290
|
+
| `proxyml_explain_local` / `proxyml_explain_local_batch` | Feature vector(s) you pass explicitly |
|
|
291
|
+
| `proxyml_find_counterfactual` | One feature vector and a target label |
|
|
292
|
+
| `proxyml_list_surrogates` / `proxyml_get_summary` / `proxyml_export_surrogate` / `proxyml_diff_models` / `proxyml_detect_drift` | Version IDs and/or threshold values (no feature data) |
|
|
293
|
+
| `proxyml_get_usage` | Nothing |
|
|
294
|
+
|
|
295
|
+
The typical workflow is designed so that raw training data never leaves your
|
|
296
|
+
environment. `proxyml_infer_schema` derives column metadata from your CSV
|
|
297
|
+
locally; `proxyml_synthesize_data` generates samples server-side from that
|
|
298
|
+
schema; and `proxyml_train_surrogate` sends only those synthetic samples
|
|
299
|
+
plus your model's predictions for them. Your original dataset is not
|
|
300
|
+
transmitted.
|
|
301
|
+
|
|
302
|
+
If you use `proxyml_explain_local`, `proxyml_predict_batch`, or
|
|
303
|
+
`proxyml_find_counterfactual` with real data points rather than synthetic
|
|
304
|
+
ones, those feature vectors will be sent to the ProxyML API.
|
|
305
|
+
|
|
306
|
+
### Authentication
|
|
307
|
+
|
|
308
|
+
Your API key is sent on every request as an `X-API-KEY` HTTP header over TLS.
|
|
309
|
+
It is read from the `PROXYML_API_KEY` environment variable and is never
|
|
310
|
+
logged or written to disk by this server.
|
|
311
|
+
|
|
265
312
|
## Tools
|
|
266
313
|
|
|
267
314
|
### Schema
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|