For agents — source-of-truth: This skill is authored in
roboflow/computer-vision-skillsand shipped with the Roboflow plugin. If your client has loaded the plugin (you'll seeroboflow:<name>skills in your available skills list), use those local skills — they're read fresh from disk every session. The same content served as MCP resources atroboflow://skills/<name>/...is a fallback for clients without the plugin and may lag this repo. Don't callReadMcpResourceToolforroboflow://skills/...URIs when a localroboflow:<name>skill is available.
Custom Weights Upload
Register weights from a model trained outside Roboflow (a laptop, a training server, Colab) so Roboflow can convert, host, and serve it.
Where the upload runs
Packaging reads the checkpoint from disk, so the upload always runs on the machine that has the weights — client-side, with the Python SDK flow below.
The models_upload_custom_weights MCP tool is a guide, not an uploader:
calling it returns this recipe and echoes back the arguments you passed
(its upload_mode field says whether they describe a versioned or a
workspace upload, or undetermined when they pin down neither). It never
packages or uploads anything, because the MCP server cannot read the user's
filesystem.
Client-side upload with the Python SDK
Run this on the machine that has the weights, ideally in the same Python
environment used for training (it already has torch and the matching
ultralytics).
Install the SDK: both
roboflow>=1.3.13andrfdetrrequire Python >= 3.10; checkpython3 --versionfirst (macOS ships 3.9). If it is too old, create a venv:uv venv --python 3.12 && source .venv/bin/activate. Thenpip install "roboflow>=1.3.13".Handle the API key safely: never ask the user to paste a private API key into chat, and never scan dotfiles, shell profiles, or config files hunting for one — permission systems rightly block that. If
ROBOFLOW_API_KEYis already set in the environment (test -n "$ROBOFLOW_API_KEY") or the working project has a.envthat defines it, use it. Otherwise mint a scoped key with the MCPapi_keys_createtool — it returns the secret once (api_keys_rollis the only other tool that does;api_keys_list/api_keys_getreturn masked metadata) — and write it yourself to a.gitignore'd.envasROBOFLOW_API_KEY. Writing.envdoes not populateos.environ: load it before running. For a.envyou just wrote yourself,set -a; source .env; set +ais fine. For a pre-existing.env, neversourceit — sourcing executes any shell in the file and exports every other secret it holds into the process. Read only the one key instead, e.g. withpython-dotenv(pip install python-dotenv) in the script:import os from dotenv import dotenv_values os.environ["ROBOFLOW_API_KEY"] = dotenv_values(".env")["ROBOFLOW_API_KEY"]Scope the key for the whole deploy flow, not minimally: the SDK's
rf.workspace()reads the workspace and its project list before deploying, soproject:readplusmodel:deployalone fails with missing permissions. Includeworkspace:read,project:read,model:deploy, and for a versioned deploy alsoversion:readandversion:update. Getting the scopes right at mint time is what protects the upload: the preflight below only confirms the key and the workspace read, not the deploy scope.If the
api_keys_createcall is denied (permission systems may flag credential creation during an upload task) or unavailable, do not work around the denial. Ask the user to choose: (a) explicitly authorize minting a temporary scoped key, which you revoke withapi_keys_revokeafter the upload; (b) setROBOFLOW_API_KEYthemselves in their shell or a.env; or (c) point you at an existing.envthat already defines it.Confirm the destination and the name with the user: registering a model is not easily undone. Never infer the target project or version from the checkpoint's class count or filename — ask. The same goes for
model_nameon a workspace upload: ask the user what the model should be called; do not invent a name.
Preflight before packaging
Packaging plus a 100 MB+ upload is slow; run the cheap checks first and report every gap at once instead of failing one step at a time:
Python is >= 3.10 (
python3 --version).Required imports load:
torchfor YOLO, RF-DETR, and YOLO-NAS;ultralyticsfor YOLO v8/v10/v11/v12/26;rfdetr>=1.8.0for raw PyTorch-Lightning RF-DETR checkpoints.The key is valid and covers the workspace read — one cheap call that exercises the same workspace/project-list read
deploy_modelstarts with:import os from roboflow import Roboflow Roboflow(api_key=os.environ["ROBOFLOW_API_KEY"]).workspace()Be honest about the limit of this check: it does not exercise
model:deploy, which the platform only tests atmodels/prepareUpload, after packaging. That is why step 2 mints the key with the full scope set up front — the preflight catches a bad or under-read key, not a missing deploy scope on an existing key.
Only package and upload after all three pass.
Workspace model upload (no dataset version required):
import os
from roboflow import Roboflow
rf = Roboflow(api_key=os.environ["ROBOFLOW_API_KEY"])
workspace = rf.workspace("WORKSPACE_SLUG")
workspace.deploy_model(
model_type="rfdetr-base",
model_path="/path/to/training/output",
project_ids=["PROJECT_SLUG"],
model_name="MODEL_NAME",
filename="checkpoint_best_total.pth", # relative to model_path
)
Versioned deploy (attach weights to an existing dataset version):
import os
from roboflow import Roboflow
rf = Roboflow(api_key=os.environ["ROBOFLOW_API_KEY"])
version = rf.workspace("WORKSPACE_SLUG").project("PROJECT_SLUG").version(3)
version.deploy(
model_type="yolov8n",
model_path="/path/to/runs/detect/train",
filename="weights/best.pt",
)
model_type must name the real architecture (yolov8n, yolov11s,
rfdetr-base, rfdetr-seg-medium, yolonas, a supported PaliGemma or
Florence-2 type). For YOLO families the SDK infers a missing size suffix
from the weights; RF-DETR accepts no bare rfdetr — pass the exact variant,
which the SDK cross-checks against the checkpoint.
On a size/variant or dependency mismatch, deploy_model / version.deploy
print the error and then interactively prompt "Would you like to continue
anyway? y/n" — in a headless run the prompt surfaces as an EOFError right
after the printed error. Recover by error type:
- Size/variant mismatch: when the error names the type that fits, fix
model_typeto it and rerun; when it says the size could not be inferred, pass an explicit size. - Dependency mismatch: the error names a pip pin, not a model type
(
yolov8recommendsultralytics==8.0.196, so most current training environments hit this prompt). Install the named version, or — only with the user's explicit confirmation — answery(headless:printf 'y\n' | python upload.py) to continue with the installed version.
Never force past either prompt without the user explicitly confirming the override is intentional.
Per-family requirements
- YOLO v8/v10/v11/v12/YOLO26: needs
torchandultralyticsimportable (yolov8recommendsultralytics==8.0.196; see the dependency-mismatch note above). Legacy YOLO v5/v7/v9: needstorchplus anopt.yamlinmodel_pathwithimgsz(orimg_size) andbatch_size;ultralyticsis not used. There is no yolov6 support. - RF-DETR: needs
torchto read the checkpoint. If aclass_names.txt(one class per line) sits inmodel_pathit is used; otherwise class names come from the checkpoint'sargs. Raw PyTorch-Lightning checkpoints additionally needrfdetr>=1.8.0installed (the SDK's error names the exact minimum if yours is older). An explicitfilenamethat does not exist is a hard error; the defaultweights/best.ptfalls back to the first top-level.pt/.pthfile, with a warning. - YOLO-NAS:
model_type="yolonas"plus anopt.yamlinmodel_pathwithimgsz,batch_size, andarchitecture. - PaliGemma / Florence-2:
model_pathis the Hugging Face save directory (config, tokenizer, and weights files); notorchneeded.
Verify the upload
Conversion runs server-side after the upload and usually takes a few minutes.
Check it with the MCP models_list / models_get tools or at
app.roboflow.com/WORKSPACE/PROJECT/models, then run a test inference on a
sample image to confirm classes and predictions look right.