|
1 | 1 | # Kubeflow MCP Server |
2 | 2 |
|
3 | | -AI-powered interface for Kubeflow Training via [Model Context Protocol](https://modelcontextprotocol.io/). |
| 3 | +[](LICENSE) [](https://www.python.org) [](https://www.kubeflow.org/docs/about/community/#kubeflow-slack-channels) |
4 | 4 |
|
5 | | -Proposal: https://github.com/kubeflow/community/tree/master/proposals/936-kubeflow-mcp-server |
6 | | - |
7 | | -> ⚠️ **Note:** This project is in early development. We currently accept PRs only after prior discussion on Slack — join `#kubeflow-ml-experience` on the [CNCF Slack](https://www.kubeflow.org/docs/about/community/). For more discussion, join on bi-weekly ML Experience WG call on Wednesdays. |
| 5 | +Proposal: [KEP-936](https://github.com/kubeflow/community/tree/master/proposals/936-kubeflow-mcp-server) · [ROADMAP](ROADMAP.md) · [SECURITY](SECURITY.md) · [CONTRIBUTING](CONTRIBUTING.md) |
8 | 6 |
|
9 | 7 | ## Overview |
10 | 8 |
|
11 | | -This MCP server enables LLM agents (Claude, Cursor, etc.) to interact with Kubeflow Training through natural language. It wraps the [Kubeflow SDK](https://github.com/kubeflow/sdk) with MCP tools for fine-tuning, training job management, and monitoring. |
| 9 | +The Kubeflow MCP Server exposes Kubeflow Training operations as [Model Context Protocol](https://modelcontextprotocol.io/) tools, enabling AI agents (Claude, Cursor, Claude Code, or any custom agents etc.) to plan, submit, monitor, and manage training jobs through natural language — without users needing to learn Kubernetes or the Kubeflow SDK directly. |
| 10 | + |
| 11 | +### Benefits |
12 | 12 |
|
13 | | -## Compatibility |
| 13 | +- **Agent-Native**: Tools auto-discovered via MCP — no manual API wiring |
| 14 | +- **Guided Workflow**: Phase ordering with next-step hints (Plan → Discover → Train → Monitor) |
| 15 | +- **Preview-Before-Submit**: Every mutating operation requires explicit confirmation |
| 16 | +- **Security-First**: Persona gating, namespace enforcement, input validation, bearer/JWT auth |
| 17 | +- **Multi-Platform**: Auto-detects OpenShift, EKS, GKE with platform-specific guidance |
| 18 | +- **Token-Efficient**: Progressive/semantic modes compress 23 tools into 2-3 meta-tools |
| 19 | +- **Extensible**: Plugin architecture for additional Kubeflow clients (TODO: optimizer, hub) |
14 | 20 |
|
15 | | -| MCP Server | Kubeflow SDK | Python | Kubernetes | |
16 | | -|------------|-------------|-------------|------------| |
17 | | -| 0.1.x | ≥ 0.4.0 | 3.10 – 3.12 | ≥ 1.27 | |
| 21 | +## Get Started |
18 | 22 |
|
19 | | -## Status |
| 23 | +### Install from source |
20 | 24 |
|
21 | | -| Component | Status | |
22 | | -|-----------|--------| |
23 | | -| Core Infrastructure | 🚧 In Progress | |
24 | | -| TrainerClient Tools | 🚧 In Progress | |
25 | | -| OptimizerClient Tools | ⬜ Planned (Contributors Welcome) | |
26 | | -| ModelRegistryClient Tools | ⬜ Planned (Contributors Welcome) | |
27 | | -| PipelinesClient Tools | ⬜ Planned (Contributors Welcome) | |
28 | | -| SparkClient Tools | ⬜ Planned (Contributors Welcome) | |
29 | | -| FeastClient Tools | ⬜ Planned (Contributors Welcome) | |
| 25 | +```bash |
| 26 | +git clone https://github.com/kubeflow/mcp-server.git |
| 27 | +cd mcp-server |
| 28 | +pip install . |
| 29 | +``` |
30 | 30 |
|
31 | | -## Quick Start |
| 31 | +### Run the server |
32 | 32 |
|
33 | 33 | ```bash |
34 | | -# Install (trainer + optimizer included by default) |
35 | | -pip install kubeflow-mcp |
| 34 | +kubeflow-mcp serve |
| 35 | +``` |
| 36 | + |
| 37 | +> Once published to PyPI, install with `pip install kubeflow-mcp`. |
36 | 38 |
|
37 | | -# Install with hub or spark extras |
38 | | -pip install kubeflow-mcp[hub] |
39 | | -pip install kubeflow-mcp[spark] |
| 39 | +### Example: Fine-tune a model via AI agent |
40 | 40 |
|
41 | | -# Run |
42 | | -kubeflow-mcp serve --clients trainer |
| 41 | +Once connected, your AI agent can run a complete training workflow through natural language: |
| 42 | + |
| 43 | +``` |
| 44 | +User: "Fine-tune gemma-2b on the alpaca dataset" |
| 45 | +
|
| 46 | +Agent calls: check_compatibility() → ✅ K8s 1.29, Trainer CRD installed |
| 47 | +Agent calls: get_cluster_resources() → 4x A100 GPUs available |
| 48 | +Agent calls: estimate_resources("google/gemma-2b") → needs ~16GB GPU, 1x A100 |
| 49 | +Agent calls: list_runtimes() → torchtune-llama, torchtune-gemma, ... |
| 50 | +Agent calls: fine_tune( → preview config (confirmed=False) |
| 51 | + model="hf://google/gemma-2b", |
| 52 | + dataset="hf://tatsu-lab/alpaca", |
| 53 | + runtime="torchtune-gemma-2b" |
| 54 | +) |
| 55 | +Agent calls: fine_tune(..., confirmed=True) → TrainJob "train-gemma-abc" created |
| 56 | +Agent calls: get_training_logs("train-gemma-abc") → training progress... |
43 | 57 | ``` |
44 | 58 |
|
45 | | -## Development |
| 59 | +Every mutating tool requires `confirmed=True` — agents always preview before submitting. |
| 60 | + |
| 61 | +### MCP Client Config |
| 62 | + |
| 63 | + |
| 64 | +<details> |
| 65 | +<summary>Cursor</summary> |
46 | 66 |
|
47 | | -The project uses `uv` and a `Makefile` to manage the development environment. |
| 67 | +Add to `.cursor/mcp.json` (or use the `.mcp.json` at the repo root for local dev): |
| 68 | + |
| 69 | +```json |
| 70 | +{ |
| 71 | + "mcpServers": { |
| 72 | + "kubeflow": { |
| 73 | + "command": "uv", |
| 74 | + "args": ["run", "kubeflow-mcp", "serve"] |
| 75 | + } |
| 76 | + } |
| 77 | +} |
| 78 | +``` |
| 79 | + |
| 80 | +</details> |
| 81 | + |
| 82 | +<details> |
| 83 | +<summary>Claude Code</summary> |
48 | 84 |
|
49 | 85 | ```bash |
50 | | -# Setup development environment |
51 | | -make install-dev |
| 86 | +claude mcp add kubeflow -- kubeflow-mcp serve |
| 87 | +``` |
| 88 | + |
| 89 | +</details> |
| 90 | + |
| 91 | +## Tools |
| 92 | + |
| 93 | +23 tools organized by workflow phase: |
| 94 | + |
| 95 | +| Phase | Tools | Description | |
| 96 | +|-------|-------|-------------| |
| 97 | +| Planning | `pre_flight`, `check_compatibility`, `get_cluster_resources`, `estimate_resources` | Environment validation and resource estimation | |
| 98 | +| Discovery | `list_training_jobs`, `get_training_job`, `list_runtimes`, `get_runtime` | Browse jobs and available runtimes | |
| 99 | +| Training | `fine_tune`, `run_custom_training`, `run_container_training` | Submit LoRA/QLoRA fine-tuning, custom scripts, or container jobs | |
| 100 | +| Monitoring | `get_training_logs`, `get_training_events`, `wait_for_training` | Track progress, debug failures | |
| 101 | +| Lifecycle | `delete_training_job`, `update_training_job` | Manage existing jobs (ownership-guarded) | |
| 102 | +| Platform | `inspect_crd`, `inspect_controller`, `patch_runtime`, `create_runtime`, `delete_runtime` | Cluster inspection and runtime management | |
| 103 | +| Health | `health_check`, `get_server_logs` | Server diagnostics | |
| 104 | + |
| 105 | + |
| 106 | +### Requirements |
| 107 | + |
| 108 | +| MCP Server | Kubeflow Trainer | Kubeflow SDK | Python | Kubernetes | |
| 109 | +|------------|------------------|--------------|-------------|------------| |
| 110 | +| 0.1.x | >= 2.2.0 | >= 0.4.0 | 3.10 - 3.12 | >= 1.27 | |
52 | 111 |
|
53 | | -# Run verification (lint, format) |
54 | | -make verify |
| 112 | +## CLI Reference |
55 | 113 |
|
56 | | -# Run unit tests |
57 | | -make test-python |
| 114 | +### `kubeflow-mcp serve` |
| 115 | + |
| 116 | +```bash |
| 117 | +kubeflow-mcp serve \ |
| 118 | + --clients trainer \ # modules: trainer, optimizer (stub), hub (stub) |
| 119 | + --persona ml-engineer \ # readonly | data-scientist | ml-engineer | platform-admin |
| 120 | + --mode full \ # full | progressive | semantic |
| 121 | + --instruction-tier full \ # full | compact | minimal |
| 122 | + --transport stdio \ # stdio | http | sse |
| 123 | + --auth-token SECRET \ # bearer token for HTTP auth (dev/staging) |
| 124 | + --log-level INFO \ # DEBUG | INFO | WARNING | ERROR |
| 125 | + --log-format console \ # console | json (auto-detected if omitted) |
| 126 | + --no-banner # suppress startup banner |
| 127 | +``` |
| 128 | + |
| 129 | +`--mode progressive` exposes 3 meta-tools (~85 tokens) for hierarchical discovery. `--mode semantic` exposes 2 meta-tools (~69 tokens) using embedding search. Both reduce token consumption significantly for agent workflows. |
| 130 | + |
| 131 | +<details> |
| 132 | +<summary> HTTP Authentication</summary> |
| 133 | + |
| 134 | +When using `--transport http`, configure auth to secure the endpoint: |
| 135 | + |
| 136 | +```bash |
| 137 | +# Simple API key (dev/staging) |
| 138 | +kubeflow-mcp serve --transport http --auth-token my-secret-token |
| 139 | + |
| 140 | +# Or via env var |
| 141 | +export KUBEFLOW_MCP_AUTH_TOKEN=my-secret-token |
| 142 | +kubeflow-mcp serve --transport http |
| 143 | + |
| 144 | +# JWT verification (production) |
| 145 | +export KUBEFLOW_MCP_JWKS_URI=https://auth.example.com/.well-known/jwks.json |
| 146 | +export KUBEFLOW_MCP_JWT_ISSUER=https://auth.example.com |
| 147 | +export KUBEFLOW_MCP_JWT_AUDIENCE=kubeflow-mcp |
| 148 | +kubeflow-mcp serve --transport http |
58 | 149 | ``` |
59 | 150 |
|
60 | | -## Contributing |
| 151 | +Without auth configured, the server logs a warning that the HTTP endpoint is open. |
| 152 | + |
| 153 | +</details> |
| 154 | + |
| 155 | +<details> |
| 156 | +<summary>Agent Subcommand</summary> |
| 157 | + |
| 158 | +```bash |
| 159 | +kubeflow-mcp agent \ |
| 160 | + --backend ollama \ # ollama (default; more backends planned) |
| 161 | + --model qwen3:8b \ # model name for the backend |
| 162 | + --mode full \ # full | progressive | semantic |
| 163 | + --thinking # enable thinking output (supported models) |
| 164 | +``` |
| 165 | + |
| 166 | +</details> |
| 167 | + |
| 168 | +## Development |
| 169 | + |
| 170 | +```bash |
| 171 | +make install-dev # setup environment |
| 172 | +make verify # lint + format check |
| 173 | +make test-python # run tests |
| 174 | +make inspector # launch MCP Inspector (stdio) |
| 175 | +make inspector TRANSPORT=http # Inspector + Streamable HTTP (start server separately) |
| 176 | +make inspector TRANSPORT=sse # Inspector + SSE (start server separately) |
| 177 | +``` |
| 178 | + |
| 179 | +## Community |
| 180 | + |
| 181 | +- **Slack**: Join [#kubeflow-ml-experience](https://www.kubeflow.org/docs/about/community/#kubeflow-slack-channels) on CNCF Slack |
| 182 | +- **Meetings**: Attend the [Kubeflow SDK and ML Experience](https://bit.ly/kf-ml-experience) bi-weekly call |
| 183 | +- **GitHub**: Issues and contributions at [kubeflow/mcp-server](https://github.com/kubeflow/mcp-server) |
| 184 | + |
| 185 | +## Documentation |
| 186 | + |
61 | 187 |
|
62 | | -See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines. |
| 188 | +- **[CONTRIBUTING](CONTRIBUTING.md)**: Development workflow and PR guidelines |
| 189 | +- **[KEP-936](https://github.com/kubeflow/community/tree/master/proposals/936-kubeflow-mcp-server)**: Design proposal |
63 | 190 |
|
64 | 191 | ## License |
65 | 192 |
|
66 | | -Apache License 2.0 - See [LICENSE](LICENSE) |
| 193 | +Apache License 2.0 — see [LICENSE](LICENSE). |
0 commit comments