Image tools of the MCP server
The 11 tools that work on single images or on lists of images. How to connect, and how results and errors come back, is in Connecting a client. To query the images of a dataset, use dataset_images in Dataset tools.
Reading
image_get
Returns one image: its dataset, division, class, labeled flag, groups, annotations (tags), comments and file locations.
| Parameter | Type | Required | Meaning |
|---|---|---|---|
imageId | string | yes | |
urls | boolean | no | Add originalUrl, a URL to download the original file (null if it cannot be worked out), next to the preview URLs |
fields | array of strings | no | Return these stored fields instead of the summary |
The strokes of the masks are left out unless fields includes masks.
image_get_by_name
Finds an image of a dataset by its file name; the extension is optional. Returns the same as image_get.
| Parameter | Type | Required |
|---|---|---|
datasetId | string | yes |
name | string | yes |
urls | boolean | no |
fields | array of strings | no |
image_comments
The free-text comment and the point comments of an image.
| Parameter | Type | Required |
|---|---|---|
imageId | string | yes |
Editing
image_set_division
Moves images to a division.
| Parameter | Type | Required | Meaning |
|---|---|---|---|
imageIds | array of strings | yes | At least one |
set | train, test, validation, predetermined or review | yes |
image_set_tag
Sets the class of one or more images. For datasets with one class per image: MULTICLASS and ANOMALY. Answers tag <id> not found in <dataset> if the tag does not exist.
| Parameter | Type | Required |
|---|---|---|
imageIds | array of strings | yes |
datasetId | string | yes |
tagId | string | yes |
image_set_labeled
Marks images as labeled or not labeled.
| Parameter | Type | Required | Meaning |
|---|---|---|---|
imageIds | array of strings | yes | |
labeled | boolean | yes | |
clearAnnotations | boolean | no | Only with labeled: false: also removes the boxes and tags of the images |
image_groups_update
Adds images to groups, removes them from groups, or takes them out of all their groups.
| Parameter | Type | Required | Meaning |
|---|---|---|---|
imageIds | array of strings | yes | |
action | add, remove or clear | yes | |
groupIds | array of strings | for add and remove |
image_set_comments
Writes the free-text comment of an image, its point comments, or both. At least one of the two is required.
| Parameter | Type | Required |
|---|---|---|
imageId | string | yes |
comments | string | no |
pointComments | array of objects | no |
Uploading
image_upload
Uploads one image into a dataset and creates its previews. Returns imageId.
| Parameter | Type | Required | Meaning |
|---|---|---|---|
datasetId | string | yes | |
fileName | string | yes | File name with extension, such as part_001.jpg |
source | object | yes | Where the image comes from: one of url, gsUri or base64 |
tagId | string | no | Class of the image |
source | Meaning |
|---|---|
{ "url": "https://…" } | The server downloads the image from this URL |
{ "gsUri": "gs://…" } | A file in cloud storage that the project can read |
{ "base64": "…" } | The content of the file in base64, with or without a data: prefix |
The new image starts in the PREDETERMINED division, not labeled. The call fails if the dataset already has an image with that name; the extension is not compared, so part_001.png is refused when part_001.jpg exists. With tagId, a MULTICLASS dataset creates the tag when it is missing; in the other types the tag has to exist, and if it does not the image stays uploaded without class and the answer says so.
image_upload_annotations
Imports box annotations for images that are already in the dataset, for detection, oriented-box and OCR datasets. The annotations of each image named in the file are replaced, tags that do not exist yet are created, and the images that receive annotations are marked as labeled.
| Parameter | Type | Required | Meaning |
|---|---|---|---|
datasetId | string | yes | |
fileName | string | yes | Name with extension. For a .txt file it must be the name of the image |
content | string | yes | Content of the file as text |
Coordinates are fractions of the image width and height, from 0 to 1, given as two opposite corners of the box. Values outside that range, such as pixel coordinates, are rejected. The YOLO form (center, width, height) is not supported and is not always detected, so convert it first.
| File | One line per box |
|---|---|
.txt, detection | <tag> <x1> <y1> <x2> <y2>, with x2 > x1 and y2 > y1 |
.csv, detection | [SET,]<image name>,<tag>,<x1>,<y1>,,,<x2>,<y2> |
.csv, oriented boxes | [SET,]<image name>,<tag> followed by the 8 corner values |
.csv, OCR | As detection, with the text in the tag column |
Oriented boxes can only be imported from a .csv file. Their corners may leave the 0 to 1 range when the object is cut by the border of the image, as long as the center of the box is inside the image and the box is not larger than it.
The result has images, successful and failed, and the status success, or partial when some image failed. failed lists each image with the reason: an image that is not in the dataset, or one with a box that is not valid, in which case none of its boxes is written. Segmentation masks cannot be imported with this tool: use the uploader of the application.
Deleting
image_delete
Destructive. Cloud only. Deletes up to 100 images with their files.
| Parameter | Type | Required |
|---|---|---|
imageIds | array of strings, 1 to 100 | yes |
confirm | boolean | yes, true |
Returns deleted, the ids deleted, and failed, each id that could not be deleted with the reason. The status is partial when some failed.