Metadata-Version: 2.4
Name: simplismart-mcp
Version: 0.1.0
Summary: Official MCP server for the Simplismart MLOps platform
Author: Simplismart
License: Proprietary
Project-URL: Homepage, https://simplismart.ai
Project-URL: Repository, https://github.com/simpli-smart/simplismart-mcp-server
Keywords: mcp,model-context-protocol,simplismart,mlops
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: mcp<2,>=1.10.0
Requires-Dist: simplismart-sdk>=0.1.15
Dynamic: license-file

# Simplismart MCP Server

[![PyPI version](https://img.shields.io/pypi/v/simplismart-mcp.svg)](https://pypi.org/project/simplismart-mcp/)
[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)

Official **Model Context Protocol (MCP)** server for the [Simplismart](https://simplismart.ai) MLOps platform.

Exposes Simplismart operations as MCP tools so clients like Claude Code, Claude Desktop and Cursor can manage Simplismart resources.

## Features

- **Model repos**: list, get, create (Bring Your Own Container), create private compile jobs, profiles lookup, delete
- **Deployments**: create/list/get/update/start/stop/restart/delete, autoscaling, health and status variants (including paginated list)
- **Accounts / Alerting / Observability / Usage**: workspaces, members, alert channels/rules/presets, metrics scrape, usage stats, API tokens
- **Tracing**: optional per-tool-call `trace_id` forwarded as `X-Trace-Id` (UUID auto-generated if omitted)

## Requirements

- [`uv`](https://docs.astral.sh/uv/getting-started/installation/) (provides `uvx`), or Python 3.10+ for `pip`
- A Simplismart **Playground token**: create one in [Settings → API Key](https://app.simplismart.ai/settings?tab=2)

## Set up your client

```bash
uvx simplismart-mcp install                         # asks for the token, then which clients
uvx simplismart-mcp install --all                   # every detected client, skip the client question
uvx simplismart-mcp install --client claude-code    # only these (repeat --client)
uvx simplismart-mcp install --access write         # skip the access question (read-only, write, destructive)
```

`install` adds the server to Claude Code, Claude Desktop and Cursor, whichever are installed. It lists the clients it found: press Enter for all, or type numbers like `1,3`. `--base-url` sets a non-default API and `--dry-run` prints the config with the token masked, without writing anything. It prints which API it will use. It then asks what your assistant may do: **read-only** (the default: only tools that look things up), **write** (also create, update, start and autoscaling) or **destructive** (also stop, restart and delete). Tools above the level you pick aren't available, and every change still needs your approval in the client. `--access` answers the question up front; it is set again on every install. For Claude Code it also adds deny rules to `~/.claude/settings.json` so Claude Code's own Read and Edit tools can't open the MCP config files (they hold your token and access level); other rules in that file are kept. Rerunning it replaces the existing `simplismart` entry, keeps its API URL unless you pass `--base-url`, and leaves other MCP servers untouched. Afterwards, restart Claude Desktop or Cursor, or start a new Claude Code session.

**Expired token:** create a new Playground token in **Settings → API Key**, then run

```bash
uvx simplismart-mcp update-token                  # every client that has the server
uvx simplismart-mcp update-token --client cursor  # only these (repeat --client)
```

`update-token` asks for the new token, replaces it in every client that already has the server, and keeps the rest of its config. Afterwards, restart Claude Desktop or Cursor, or start a new Claude Code session. When the API rejects a token, tool errors say so and point here.

Both `install` and `update-token` always ask for the token with hidden input. Pass `--token` to skip the prompt; it is required when not running in a terminal. They never read `SIMPLISMART_PG_TOKEN` from your shell, so an old exported token can't end up in your config.

### Manual setup

**Claude Code:**

```bash
claude mcp add simplismart --scope user \
  -e SIMPLISMART_PG_TOKEN=YOUR_PG_TOKEN \
  -- uvx simplismart-mcp
```

**Claude Desktop, Cursor and other stdio clients:** add this to the client's config file:

```json
{
  "mcpServers": {
    "simplismart": {
      "command": "uvx",
      "args": ["simplismart-mcp"],
      "env": {
        "SIMPLISMART_PG_TOKEN": "YOUR_PG_TOKEN"
      }
    }
  }
}
```

| Client | Config file |
|---|---|
| Claude Desktop (macOS) | `~/Library/Application Support/Claude/claude_desktop_config.json` |
| Claude Desktop (Windows) | `%APPDATA%\Claude\claude_desktop_config.json` |
| Cursor | `~/.cursor/mcp.json` (all projects) or `.cursor/mcp.json` (one project) |
| VS Code | `.vscode/mcp.json`, with a top-level `servers` key instead of `mcpServers` |

Desktop apps don't see your shell `PATH`, so use the full path from `which uvx` as `command`. With `pip install simplismart-mcp`, use `simplismart-mcp` as the command and drop `args`. Copy-ready file: [`examples/claude_desktop_config.json`](examples/claude_desktop_config.json). Step-by-step guide: [docs.simplismart.ai/sdk/mcp/overview](https://docs.simplismart.ai/sdk/mcp/overview).

### Environment variables

| Variable | Required | Default | Description |
|---|---:|---|---|
| `SIMPLISMART_PG_TOKEN` | yes | (none) | Simplismart Playground token |
| `SIMPLISMART_BASE_URL` | no | `https://api.app.simplismart.ai` | API base URL (no trailing slash) |
| `SIMPLISMART_TIMEOUT` | no | (SDK default) | Request timeout (seconds) |
| `SIMPLISMART_ACCESS` | no | `read-only` | `read-only`: only tools that look things up. `write`: also create, update, start and autoscaling. `destructive`: also stop, restart and delete. Any other value means read-only. |
| `SIMPLISMART_TRACE_ID` | no | (none) | Default trace id if a tool call does not provide one |

Sample env file: [`.env.example`](.env.example).

## Local development

### Run your checkout in Claude Code, Claude Desktop or Cursor

```bash
git clone https://github.com/simpli-smart/simplismart-mcp-server && cd simplismart-mcp-server
python -m venv .venv && . .venv/bin/activate
pip install -e . pytest          # editable: your code changes apply on the next client restart
# Optional, to work on the SDK too: pip install -e ../simplismart-python && pip install -e . --no-deps

pytest                           # unit tests, no network

# Point your clients at this checkout (staging API; pick an access level when asked)
.venv/bin/simplismart-mcp install --base-url https://api.staging.aws.model-suite.simplismart.ai
```

- Run it from an editable install and `install` writes the checkout's `.venv/bin/simplismart-mcp` into the client config (not `uvx simplismart-mcp`), so the client runs your code. Check with `--dry-run`.
- Restart the client after each code change. The MCP server is started once per client session.
- `install` asks for the Playground token in a hidden prompt and prints where to get it (staging: Settings → API Key on the staging app). Never paste a token in the chat.
- Change the access level by rerunning `install` with `--access read-only|write|destructive`. Replace an expired token with `.venv/bin/simplismart-mcp update-token`.
- Check what's connected: `claude mcp list` (Claude Code), Settings → MCP (Cursor), Settings → Developer (Claude Desktop). Server logs show `client <name> <version>: confirmation dialog|two-step`, which tells you whether the client shows dialogs.
- Go back to the released package: `uvx simplismart-mcp install`.

Run the server by hand (stdio), for example with the MCP Inspector: `SIMPLISMART_PG_TOKEN=... SIMPLISMART_BASE_URL=... simplismart-mcp`. This repo's [`.mcp.json`](.mcp.json) points Claude Code at the local install when you open the repo in it. See [`CONTRIBUTING.md`](CONTRIBUTING.md).

### Try a dev build (TestPyPI)

Pre-release builds go to TestPyPI as `simplismart-mcp-dev`. [`scripts/smcp`](scripts/smcp) runs the newest one against staging (needs [`uv`](https://docs.astral.sh/uv/)):

```bash
scripts/smcp install            # pick clients and access level; asks for a staging token
```

It writes a `uvx ... simplismart-mcp-dev` entry (TestPyPI, staging API), so each client restart picks up the newest dev build. If TestPyPI's index lags right after an upload, `smcp` runs the newest version uv can see; pin one with `SMCP_VERSION=0.1.13 scripts/smcp`. Change the access level by rerunning it with `--access`. Replace an expired token with `scripts/smcp update-token`. Go back to the released package with `uvx simplismart-mcp install --base-url https://api.app.simplismart.ai`.

## Tools

Tool names and payload shapes follow the Simplismart Python SDK (`simplismart-sdk`). Clients read each tool's description and argument schema from the server itself.

All tools accept an optional `trace_id`. If omitted, the server generates a UUID and forwards it as `X-Trace-Id`.

### Accounts

- `accounts_list_workspaces(org_id, ...)`
- `accounts_list_workspace_members(workspace_id, ...)`

### Model Repos

- `model_repos_list(...)`
- `model_repos_get(model_repo_id, ...)`
- `model_repos_create_container(model_repo, ...)` (`model_repo`: SDK `ModelRepoCreate`)
- `model_repos_create_private_compile(model_repo, ...)` (`model_repo`: SDK `ModelRepoCompileCreate`)
- `model_repos_profiles(type, path, ...)`
- `model_repos_delete(model_repo_id, ...)`

### Deployments

- `deployments_list(...)`
- `deployments_list_paginated(org_id, ...)`
- `deployments_list_by_cluster(cluster_id, org_id?, offset?, count?)` (returns `count` items, default 20, plus `total`)
- `deployments_get_config(model_id, ...)`
- `deployments_create_private(deployment, ...)` (`deployment`: SDK `DeploymentCreate`)
- `deployments_create(deployment, ...)` (alias)
- `deployments_create_byoc(deployment, ...)` (`deployment`: SDK `BYOCDeploymentCreate`)
- `deployments_get(deployment_id, ...)`
- `deployments_get_model_deployment(deployment_id, ...)` (alias)
- `deployments_update(deployment_id, changes, ...)` (`changes`: SDK `DeploymentUpdate`; only set fields change)
- `deployments_start(deployment_id, ...)`
- `deployments_stop(deployment_id, ...)`
- `deployments_restart(deployment_id, org_id, namespace, ...)`
- `deployments_health(deployment_id, ...)`
- `deployments_detailed_status(model_deployment_id, ...)`
- `deployments_lite_status(deployment_id, ...)`
- `deployments_cloud_status(deployment_id, ...)`
- `deployments_update_autoscaling(deployment_id, min_replicas, max_replicas, ...)` (also `scale_to_zero`, `cron_scaling`, `cooldown_period`, `initial_cooldown_period`, `targets`, `scale_down_behavior`, `scale_up_behavior`)
- `deployments_delete(deployment_id, ...)`
- `deployments_delete_model_deployment(deployment_id, ...)` (alias)

### Observability

- `observability_federate_metrics(bundle, namespace, ...)` (Prometheus text, capped at 20,000 chars)

### Alerting

- `alerting_list_channels(...)` / `alerting_get_channel(channel_id, ...)`
- `alerting_list_rules(...)` / `alerting_get_rule(alert_id, ...)`
- `alerting_list_presets(...)`
- `alerting_list_deployments(...)`
- `alerting_list_rules_by_deployment(deployment_id, ...)`

### Usage

- `usage_stats(plan_type, start_time, end_time, ...)` (the only usage/cost tool; asks for the period and plan type if missing, picks `window_size` from the range, use `private` for reserved GPUs; filters, `statuses`, `group_by`, `include_points`, `max_items`; returns the 100 highest-cost items by default, without per-window points)
- `api_tokens_list(...)` (API tokens only; no usage or cost data)

## Prompts

Ready-made requests (slash commands in Claude Code): `monthly_totals`, `cost_by_gpu_type`, `top_deployments`. Each asks for the period if you leave it blank.

## Not available yet

- Storage / volume usage (coming soon)
- Training job management (list, create, cancel); training usage works through `usage_stats`
- Invoices and payments

## Results

Write tools (create, update, start, stop, restart, delete, autoscaling) only run once the user approves. In clients that support MCP elicitation (Claude Code, Cursor), the server shows a confirmation dialog the model can't answer; stop, restart and delete need the deployment or model repo name typed. Other clients get two steps: the first call sends nothing and returns `confirmation_required`, a summary and a single-use `confirmation_id` (expires in 10 minutes); the change is sent only when the tool is called again with the same arguments and that id, after the user confirms. Scaling to 0 replicas gets its own "Are you sure?" dialog. Change tools are off by default: the server is read-only and doesn't list them unless `SIMPLISMART_ACCESS` is `write` or `destructive`. Don't set up client hooks or auto-approve rules that answer these dialogs for you; they exist so a person approves each change.

Every tool returns `{"ok": true, "data": ...}` on success. Failures come back as MCP tool errors
(`isError: true`) whose text is `<Type> (HTTP <status>): <message>` plus the API error payload,
capped at 2,000 characters.

See [`examples/`](examples/) for a runnable stdio client and [`examples/tool_calls.md`](examples/tool_calls.md) for sample tool JSON.

## Notes

- The MCP server does not print or log your token.
- Every create and update input is validated with the `simplismart-sdk` model for that endpoint before any request is sent.

## Troubleshooting

- **Missing, invalid or expired token**: tool errors start with "Your Simplismart Playground token is missing, invalid or expired". Create a new token in **Settings → API Key**, run `uvx simplismart-mcp update-token` (or `install` if the server isn't set up yet), then restart the client.
- **`uvx: command not found` / server fails to start**: install `uv`. Desktop apps may not see your shell `PATH`; `install` writes the full `uvx` path, or set it by hand from `which uvx`.
- **"MCP access is turned off for this organisation"**: a Simplismart admin has switched off MCP access (for every org or yours). Nothing in the client can override it, and plain SDK and UI use are unaffected; ask your admin.
- **Tools not showing**: restart the client after changing its config; in Claude Code run `/mcp`.
- **Wrong base URL**: set `SIMPLISMART_BASE_URL` (no trailing slash).
- **Debugging a single request**: pass `trace_id` on the tool call (or set `SIMPLISMART_TRACE_ID`).

## Publishing (maintainers)

Package name: [`simplismart-mcp`](https://pypi.org/project/simplismart-mcp/) (`0.1.0`).

**PyPI (`uvx` / `pip`):** merge to `main`, tag it `v<version>` (must match `pyproject.toml`), then Actions → **Publish to PyPI** (`workflow_dispatch`) on that tag. Tests run before the build; other refs are skipped. Needs a PyPI project + Trusted Publishing (OIDC) for this repo (same pattern as `simplismart-python`).

Publish [`simplismart-sdk` `0.1.15`](https://pypi.org/project/simplismart-sdk/) first: this package requires `simplismart-sdk>=0.1.15`.

**DockerHub:** set `DOCKER_USERNAME` / `DOCKER_PASSWORD` secrets. Workflow `.github/workflows/dockerhub-publish.yml` pushes on `main` and `feat/**` (also `workflow_dispatch`).
