|
| 1 | +# Install & set up P2Predict |
| 2 | + |
| 3 | +P2Predict runs locally and connects to your AI agent over the Model Context Protocol (MCP). Below is the fast path to a working setup; for the full CLI, Python API, and data-format reference see **[TECHNICAL.md](TECHNICAL.md)**. |
| 4 | + |
| 5 | +## 1. Install |
| 6 | + |
| 7 | +```bash |
| 8 | +pip install p2predict[mcp] |
| 9 | +``` |
| 10 | + |
| 11 | +This installs the engine, the command-line tools (`p2predict`, `p2predict-train`), and the MCP server (`p2predict-mcp`). |
| 12 | + |
| 13 | +## 2. Connect your AI agent |
| 14 | + |
| 15 | +Add P2Predict to your MCP client (Claude Desktop, Claude Code, Cursor, or any MCP-capable assistant): |
| 16 | + |
| 17 | +```json |
| 18 | +{ |
| 19 | + "mcpServers": { |
| 20 | + "p2predict": { |
| 21 | + "command": "p2predict-mcp", |
| 22 | + "args": ["--models-dir", "/path/to/your/models"] |
| 23 | + } |
| 24 | + } |
| 25 | +} |
| 26 | +``` |
| 27 | + |
| 28 | +Point `--models-dir` at the folder where your trained models live (or will live). The agent discovers models and tools from there automatically. |
| 29 | + |
| 30 | +## 3. Talk to it |
| 31 | + |
| 32 | +Once connected, just ask: |
| 33 | + |
| 34 | +> *"Train a model on my purchasing data at ~/data/parts.csv, predicting Price."* |
| 35 | +> |
| 36 | +> *"What would a 25 kg EU part from Supplier A cost?"* |
| 37 | +> |
| 38 | +> *"What happens to the price if we switch to Supplier B?"* |
| 39 | +> |
| 40 | +> *"Benchmark these 200 RFQ line items against the model."* |
| 41 | +
|
| 42 | +## What the agent can do (MCP tools) |
| 43 | + |
| 44 | +The agent has the full surface available and picks the right tool for the question: |
| 45 | + |
| 46 | +| Tool | What it does | |
| 47 | +|---|---| |
| 48 | +| `list_models` | Discover trained models | |
| 49 | +| `get_model_info` | Features, types, categories, calibration status | |
| 50 | +| `get_model_quality` | Trust verdict: is the model reliable, where, and by how much | |
| 51 | +| `predict` | Point estimate for a single part | |
| 52 | +| `predict_batch` | Predict multiple parts in one call | |
| 53 | +| `predict_from_csv` | Batch-predict a CSV file | |
| 54 | +| `predict_interval` | The likely range (e.g. 9-in-10 coverage) | |
| 55 | +| `explain` | Per-feature attribution — what drives this price | |
| 56 | +| `what_if` | What changes if I switch supplier / material / spec? | |
| 57 | +| `propose_training_plan` | Review the data and propose how to train, before training | |
| 58 | +| `train` | Train a new model from a CSV | |
| 59 | +| `generate_report` | Model-quality PDF report | |
| 60 | + |
| 61 | +## Other surfaces |
| 62 | + |
| 63 | +The same engine is available three ways, all calling the same math: |
| 64 | + |
| 65 | +- **AI agent (MCP)** — the primary interface, described above. |
| 66 | +- **Command line** — `p2predict` and `p2predict-train` for scripted or interactive use. |
| 67 | +- **Python API** — `from p2predict import auto_train, explain, predict_interval, what_if` for embedding in a notebook or pipeline. |
| 68 | + |
| 69 | +Full reference for the CLI, Python API, JSON output schema, and CSV data format: **[TECHNICAL.md](TECHNICAL.md)**. |
| 70 | + |
| 71 | +## Keeping your data safe |
| 72 | + |
| 73 | +- P2Predict reads your CSV, trains, and predicts entirely on your machine over local (stdio) transport. Nothing is uploaded. |
| 74 | +- Don't commit raw vendor data or credentials to a shared repo — keep raw pulls and API keys outside version control. |
| 75 | +- Respect the terms of service of any catalog or data source you pull from. |
| 76 | + |
| 77 | +## Contributing |
| 78 | + |
| 79 | +Bug reports, feature requests, and dataset suggestions — [open an issue](https://github.com/ahmed-khalil-hafsi/P2Predict/issues). |
| 80 | + |
| 81 | +Open procurement datasets are especially welcome: ICs, passive components, plastic parts, mechanical parts. If you know of one, or your organization would share, [reach out](https://ahmedhafsi.com/contact/). |
| 82 | + |
| 83 | +Code contributions require a CLA (P2Predict is dual-licensed). [Reach out](https://ahmedhafsi.com/contact/) before investing time in a large patch. |
0 commit comments