Skip to content

Tools reference

Every tool the Legion MCP server offers, what it changes, which ones ask before they act, and how arguments, errors and limits work.

On this page

Each tool runs one operation of the Legion API as you, with your permissions in the organization, whether Claude is connected by signing in or the client uses an API key. The tool list is generated from the API's description, so the tools, their summaries and which ones ask first always match it. The For column says who a tool is for: Renting tools are on every key an agent uses, and Hosting tools are for providers (audience: provider in the API's description) and are offered only to a key made with provider tools, or a connection approved as Agent + hosts. For any other Agent key or connection the server does not list them, and calling one is refused as an unknown tool.

The tools

The tools
ToolForWhat it doesEffectAsks you firstReference
estimate_backupRentingWhat a backup of this rental would costRead onlyNoGET /v1/rentals/{rental_id}/backup-estimate
estimate_workspace_exportRentingWhat downloading a rental's workspace export will costRead onlyNoGET /v1/rentals/{rental_id}/workspace-exports/estimate
get_backupRentingGet a backupRead onlyNoGET /v1/backups/{backup_id}
get_billing_accountRentingGet the organization's balanceRead onlyNoGET /v1/billing/account
get_meRentingGet the callerRead onlyNoGET /v1/me
get_offerRentingGet one offer with its score breakdown and uptime historyRead onlyNoGET /v1/offers/{host_id}
get_rentalRentingGet a rentalRead onlyNoGET /v1/rentals/{rental_id}
get_rental_chargesRentingGet what a rental has costRead onlyNoGET /v1/rentals/{rental_id}/charges
get_rental_hostRentingThe host a rental runs on, its health and its GPUs' live telemetryRead onlyNoGET /v1/rentals/{rental_id}/host
get_rental_logsRentingRead a rental's logsRead onlyNoGET /v1/rentals/{rental_id}/logs
get_rental_networkRentingThe rental's effective network policy and whether its host applied itRead onlyNoGET /v1/rentals/{rental_id}/network
get_serviceRentingGet a serviceRead onlyNoGET /v1/services/{service_id}
get_service_logsRentingRead a service's logs, every replicaRead onlyNoGET /v1/services/{service_id}/logs
get_service_metricsRentingA service's inference metricsRead onlyNoGET /v1/services/{service_id}/metrics
get_spend_breakdownRentingThe organization's spend by one dimensionRead onlyNoGET /v1/renter/spend/breakdown
get_spend_overviewRentingThe organization's spend over a period, with the previous periodRead onlyNoGET /v1/renter/spend/overview
get_storage_policyRentingHow long a stopped rental's files are kept, and what backups costRead onlyNoGET /v1/storage-policy
get_workspace_exportRentingGet a workspace exportRead onlyNoGET /v1/rentals/{rental_id}/workspace-exports/{export_id}
inspect_imageRentingInspect a container image before renting itRead onlyNoPOST /v1/images/inspect
list_backupsRentingThe organization's backups, newest firstRead onlyNoGET /v1/backups
list_billing_activityRentingList what happened to the organization's balance or earningsRead onlyNoGET /v1/billing/activity
list_catalogRentingList Legion's starter images and premade models, and which a host can runRead onlyNoGET /v1/catalog
list_offer_alertsRentingList the caller's offer alertsRead onlyNoGET /v1/offer-alerts
list_offersRentingSearch GPU offersRead onlyNoGET /v1/offers
list_registry_credentialsRentingThe organization's registry credentialsRead onlyNoGET /v1/registry-credentials
list_rental_backupsRentingA rental's backups, newest firstRead onlyNoGET /v1/rentals/{rental_id}/backups
list_rental_chargesRentingList what the organization's rentals have costRead onlyNoGET /v1/billing/charges
list_rentalsRentingList the organization's rentalsRead onlyNoGET /v1/rentals
list_service_eventsRentingA service's activityRead onlyNoGET /v1/services/{service_id}/events
list_servicesRentingList the organization's servicesRead onlyNoGET /v1/services
list_spend_by_rentalRentingThe organization's rentals that were charged in a periodRead onlyNoGET /v1/renter/spend/rentals
list_ssh_keysRentingList the caller's saved SSH public keysRead onlyNoGET /v1/ssh-keys
add_registry_credentialRentingSave a registry credentialChanges dataYesPOST /v1/registry-credentials
add_ssh_keyRentingSave an SSH public keyChanges dataYesPOST /v1/ssh-keys
cancel_backupRentingCancel a queued or uploading backupChanges dataNoPOST /v1/backups/{backup_id}/cancel
cancel_workspace_exportRentingCancel a pending workspace exportChanges dataYesPOST /v1/rentals/{rental_id}/workspace-exports/{export_id}/cancel
create_offer_alertRentingBe emailed once when a matching machine is availableChanges dataNoPOST /v1/offer-alerts
create_service_keyRentingCreate a service keyChanges dataYesPOST /v1/services/{service_id}/keys
delete_offer_alertRentingDelete an offer alertChanges dataNoDELETE /v1/offer-alerts/{alert_id}
export_workspaceRentingExport a stopped rental's workspaceChanges dataNoPOST /v1/rentals/{rental_id}/workspace-exports
rotate_service_keyRentingRotate a service keyChanges dataYesPOST /v1/services/{service_id}/keys/{key_id}/rotate
update_rentalRentingChange a rental's settingsChanges dataYesPATCH /v1/rentals/{rental_id}
backup_rentalRentingBack up a stopped or failed rental's workspaceSpends creditYesPOST /v1/rentals/{rental_id}/backups
create_backup_download_linkRentingMint a download link for a ready backupSpends creditYesPOST /v1/backups/{backup_id}/download-links
create_rentalRentingRent GPUs on a hostSpends creditYesPOST /v1/rentals
create_serviceRentingCreate a serviceSpends creditYesPOST /v1/services
create_workspace_export_download_linkRentingMake a single-use download link for a ready workspace exportSpends creditYesPOST /v1/rentals/{rental_id}/workspace-exports/{export_id}/download-links
start_rentalRentingRestart a stopped rentalSpends creditYesPOST /v1/rentals/{rental_id}/start
update_serviceRentingChange a service's model, hardware, scaling or budget, or switch autoscaling on or offSpends creditYesPATCH /v1/services/{service_id}
delete_backupRentingDelete a ready backup earlyDeletes or stopsYesDELETE /v1/backups/{backup_id}
delete_rentalRentingDelete a rental and its workspaceDeletes or stopsYesDELETE /v1/rentals/{rental_id}
delete_serviceRentingDelete a serviceDeletes or stopsYesDELETE /v1/services/{service_id}
remove_registry_credentialRentingRemove a registry credentialDeletes or stopsYesDELETE /v1/registry-credentials/{credential_id}
revoke_service_keyRentingRevoke a service keyDeletes or stopsYesDELETE /v1/services/{service_id}/keys/{key_id}
stop_rentalRentingStop a rentalDeletes or stopsYesPOST /v1/rentals/{rental_id}/stop
get_earnings_overviewHostingThe organization's earnings over a period, with the previous periodRead onlyNoGET /v1/provider/earnings/overview
get_hostHostingGet a hostRead onlyNoGET /v1/hosts/{host_id}
get_host_networkHostingA host's network state and the abuse flags raised on its rentalsRead onlyNoGET /v1/hosts/{host_id}/network
get_host_removal_previewHostingPreview what is on a host before removing itRead onlyNoGET /v1/hosts/{host_id}/removal-preview
get_price_recommendationHostingWhat Legion recommends the host charge per GPU-hourRead onlyNoGET /v1/hosts/{host_id}/price-recommendation
get_provider_earningsHostingGet the organization's provider earningsRead onlyNoGET /v1/billing/earnings
get_rental_earningsHostingGet what a rental on one of the organization's hosts has earnedRead onlyNoGET /v1/billing/earnings/rentals/{rental_id}
list_earnings_attentionHostingHosts that are earning less than they could, with what to doRead onlyNoGET /v1/provider/earnings/attention
list_earnings_by_hostHostingWhat each of the organization's hosts earned and how it performedRead onlyNoGET /v1/provider/earnings/hosts
list_host_benchmarksHostingA host's benchmark runs, newest firstRead onlyNoGET /v1/hosts/{host_id}/benchmarks
list_host_gpu_benchmarksHostingA host's GPU benchmark runs, newest firstRead onlyNoGET /v1/hosts/{host_id}/gpu-benchmarks
list_hostsHostingList the organization's hostsRead onlyNoGET /v1/hosts
list_maintenance_windowsHostingThe organization's maintenance windowsRead onlyNoGET /v1/maintenance-windows
preview_maintenanceHostingWhat scheduling maintenance would doRead onlyNoGET /v1/maintenance-windows/preview
cancel_maintenanceHostingCancel scheduled maintenance windowsChanges dataYesPOST /v1/maintenance-windows/cancel
end_maintenanceHostingEnd active maintenance windows now ("done with maintenance")Changes dataYesPOST /v1/maintenance-windows/end
rename_hostHostingRename a hostChanges dataYesPUT /v1/hosts/{host_id}/name
reschedule_maintenanceHostingMove or change scheduled maintenance windowsChanges dataYesPOST /v1/maintenance-windows/reschedule
schedule_maintenanceHostingSchedule maintenance on one or many hostsChanges dataYesPOST /v1/maintenance-windows
update_host_listingHostingSet a host's price and availabilityChanges dataYesPUT /v1/hosts/{host_id}/listing
remove_hostHostingRemove a hostDeletes or stopsYesPOST /v1/hosts/{host_id}/remove

The last column links to the API operation the tool runs. Its page has every parameter and response.

What the columns mean

  • Read only tools change nothing. They are safe to let an agent call freely.

  • Changes data tools create or change something. They are add_registry_credential, which saves a registry credential for private images, add_ssh_key, which saves an SSH key that later rentals can use, export_workspace, which packs a stopped rental's /workspace into a file kept for 24 hours (making it is free; each download link is charged, see below), cancel_workspace_export, which stops a pending export and discards its upload, cancel_backup, which cancels a queued or uploading backup, discards its upload and refunds it, update_rental, which changes an interruptible rental's max price per GPU-hour, whether it resumes by itself, whether it backs up automatically or which SSH key opens it (the old key stops working within about a minute), and the Service tools create_service_key, which makes a service key, and rotate_service_key, which replaces one, and the Hosting tools update_host_listing, which sets a host's price and whether it is offered, rename_host, and the maintenance tools schedule_maintenance, reschedule_maintenance, cancel_maintenance and end_maintenance, which announce, move, call off or end a maintenance window and email the renters on the host, and the Renting tools create_offer_alert, which asks Legion to email you once when a machine matching a search becomes available (an offer alert), and delete_offer_alert, which takes one back.

  • Spends credit tools charge your credit. They are create_rental, which starts billing and can turn on the automatic backup of an interruptible rental, start_rental, which starts billing, backup_rental, which makes a backup of a stopped or failed rental, kept for 7 or 30 days, create_backup_download_link, which makes a download link for a backup: the first is included in its price, and each further one is charged, and create_workspace_export_download_link, which makes a download link for a ready workspace export: $0.15 per GiB of the file, every link. A download link works once. The Service tools create_service and update_service expose a port of a rental or start replicas that spend credit, up to the service's monthly cap.

  • Deletes or stops tools end something. They are stop_rental, delete_rental, remove_registry_credential, which removes a registry credential, delete_backup, which deletes a backup early with no refund, and the Hosting tool remove_host, which cannot be undone. The Service tools delete_service and revoke_service_key end a service and cut off a key.

  • Back up and stop, or back up then delete: stop_rental and delete_rental with backup_retention_days also make a backup and charge its price, so the agent states that price, from estimate_backup, and asks first. The preview of stop_rental and delete_rental presents both choices side by side: stop or delete without a backup (the default, unless the rental backs up automatically) and back up first with its price, and the agent asks which one the user wants.

  • Hosting tools are list_hosts, get_host, list_host_benchmarks, list_host_gpu_benchmarks, get_host_network, get_price_recommendation, get_provider_earnings, get_earnings_overview, list_earnings_by_host, list_earnings_attention, get_rental_earnings, update_host_listing, rename_host, get_host_removal_preview, remove_host, list_maintenance_windows, preview_maintenance, schedule_maintenance, reschedule_maintenance, cancel_maintenance and end_maintenance. They read your hosts, their benchmarks and network state, what a removal would meet (the renters' files stored on the host), the price Legion recommends, your earnings and how your hosts are performing, and change a host's price, listing and name, or remove it. The maintenance tools read a host's windows and what a new window would do (preview_maintenance, which writes nothing), and schedule, move, cancel or end one: the preview before a yes names the hosts, the start and planned end, whether each is penalty-free, and how many renter organizations and rentals are emailed. A host change also needs an organization owner's key.

  • Asks you first is Yes for a tool that does nothing until the agent passes confirm: true, and the agent should only do that after you said yes. It is No for a tool that only reads.

Arguments

Arguments
ArgumentType, and the tools that take itWhat it does
Path and query parametersEvery tool whose operation has themThe operation's own parameters are top-level arguments with the same names. For example list_offers takes gpu_models, min_gpus, sort, limit and cursor. The API's own pages list them.
bodyEvery tool whose operation has a request bodyThe request body goes in this one argument.
idempotency_keyRequired string, on create_rental, create_service and create_service_keyThe operation takes an Idempotency-Key. The key is at most 255 characters. The agent makes a new one for each thing it means to do and reuses it when it retries that same thing, so a retry never rents twice. See Idempotency.
confirmBoolean, on every tool that asks firsttrue once you have said yes. Without it the tool only returns a preview.
expected_price_per_gpu_hour_minorInteger, on create_rental and start_rentalThe price per GPU-hour, in cents, that you agreed to. Required when confirm is true. If the price has changed, the call is refused and you are shown the current price.
expected_hourly_total_minorInteger, on create_rentalThe hourly total, in cents, from the preview (the price per GPU-hour times the number of GPUs). Required when confirm is true. It ties your yes to the GPU count as well as the price.
confirm_rental_nameString, on delete_rentalRequired when confirm is true. It must equal the rental's name, so a mistaken ID can't delete the wrong rental.
confirm_host_nameString, on update_host_listing, rename_host and remove_hostRequired when confirm is true. It must equal the host's current name, so a mistaken ID can't change or remove the wrong host.
confirm_large_price_cutBoolean, on update_host_listingRequired (true) when the new price is under half the current one, after you said yes to that cut. Without it the call is refused with price_cut_unconfirmed.
stored_dataString in body, on remove_hostwhen_empty ("Remove when empty") or delete_now ("Delete renters' files and remove now"). Required when the host holds renters' files, else the call is refused with host_has_stored_data. Read get_host_removal_preview first and offer both. delete_now also needs body.reason and body.confirm_host_name (the host's name, as the user typed it, besides the top-level confirm_host_name), after the user said yes to deleting the files.
confirm_forceBoolean, on remove_hostRequired with body.force true, after you said yes to forcing: rentals stranded on the offline host end as failed. Without it the call is refused with invalid_params.
expected_listing_price_per_gpu_hour_minorInteger, on update_host_listingThe new price per GPU-hour, in cents, equal to body.price_per_gpu_hour.amount_minor in USD. Required when confirm is true. A mismatch is refused, so a price typed in dollars where cents belong is caught.

How asking first works

A tool that asks first does nothing when confirm is missing. Instead it returns a preview with the code confirmation_required. For create_rental, the preview shows the price, your balance, the SSH key and the image. For a host tool it shows the host's name and state and what the change does: the old and new price and what a new rental earns you, that the old name is never assigned again, or that removing the host revokes its credentials and that the machine comes back only by enrolling again as a new host. The agent shows you the preview, and calls again with confirm: true only if you say yes.

JSON
{
  "name": "create_rental",
  "arguments": {
    "idempotency_key": "6f1c2b8e-3d4a-4f5e-9b7c-2a1d0e8f9c3b",
    "body": {
      "host_id": "8c0e2f4a-1b3d-4e5f-9a7b-6c5d4e3f2a1b",
      "gpu_count": 1,
      "image": "pytorch/pytorch:2.4.0-cuda12.4-cudnn9-runtime",
      "ssh_public_key": "ssh-ed25519 AAAA… you@laptop"
    }
  }
}

This call has no confirm, so it creates nothing. It returns the preview. After your yes, the agent sends the same call with confirm: true and expected_price_per_gpu_hour_minor and expected_hourly_total_minor set to the values in the preview.

confirm is a safeguard against mistakes. It can't stop an agent that has been manipulated into passing it. Your client's own approval prompt can. See Safety.

Results

A successful call returns the API's JSON, as structured content and as text.

Errors

When the API refuses a call, the result is marked as an error and carries the problem: code, title, detail, status and request_id. The agent should branch on code, as with the API. Every API code is in Errors. Quote the request_id when you contact support.

The server adds a few codes of its own:

Errors
CodeWhat it means
confirmation_requiredThe tool asks first and confirm was missing. Nothing was done. The result is the preview.
price_mismatchexpected_price_per_gpu_hour_minor or expected_hourly_total_minor does not match the current price, or expected_listing_price_per_gpu_hour_minor does not equal the new listing price. Nothing was created or changed.
price_changedFrom create_rental: the host's price changed after the check, before the GPUs were reserved. Nothing was created. current_price_per_gpu_hour is the new price.
name_mismatchconfirm_rental_name is not the rental's name, or confirm_host_name is not the host's current name. Nothing was deleted or changed.
price_cut_unconfirmedFrom update_host_listing: the new price is under half the current one and confirm_large_price_cut was missing. Nothing was changed. Show the cut and ask again.
invalid_paramsAn argument is missing or wrong, for example confirm: true without expected_price_per_gpu_hour_minor. detail says which. Nothing was done.
secret_withheldThe answer contained a credential, so the server withheld it. The agent should not try to get the value another way. Use the Legion app.
response_too_largeThe answer is too large for an agent. The agent narrows the request with filters, limit and cursor.
rate_limitedThe key made too many calls. Wait, then try again.

Limits

  • Each API key or connected app can make 120 MCP requests a minute. Each API key can make 20 rental creations or restarts an hour. Each organization can make 60 rental creations or restarts an hour, over all its keys.

  • The API's own limits apply to the tools too: for example, checking images is limited per organization. Over a limit the result has the code rate_limited. See Rate limits.

  • Lists return a page at a time. The agent passes next_cursor back as cursor. See Pagination.

Hints for clients

Every tool carries hints that clients can use: read tools are marked read only, and tools that remove or widen access are marked destructive. A client may ask for your approval before a tool call. Leave that on for any tool that isn't read only.

Service tools

A service is a public URL for something you run on Legion: a port on one of your rentals, or a model that Legion runs on rented GPUs and scales with traffic. The tools that manage services are in the table above (list_services, get_service, create_service, update_service, delete_service, create_service_key, rotate_service_key, revoke_service_key, get_service_metrics and list_service_events). They run the service operations of the Legion API as you, with the same permissions (services.read and services.manage). What each does:

  • get_service shows the Service URL, access, mode, status, scaling, cap, replicas, a usage summary and the keys (masked).

  • create_service works in either mode: on a rental (a port of one of your rentals) or autoscaled (a model or image). Without confirm it returns a preview with the estimate: the likely hardware, its price, the range, the cost per hour idle, at the minimum and at the maximum, and the cap.

  • update_service changes scaling, the price ceiling or cap, the access (public or API key required, and the allowed addresses) and the mode (turn autoscaling on or off), or pauses and resumes with paused: true or false.

  • delete_service deletes the service and its keys. For a service on a rental the rental is untouched. Deleting an autoscaled service needs a fresh sign-in, so it is refused with step_up_required: use the app.

Things to know:

  • Configuration. create_rental, create_service and update_service take env, model_settings, and, for your own image, command and args. Previews and events show variable names and whether each is secret, never a secret's value, and the preview says when a change restarts the container or rolls the replicas. An agent never asks you to type a secret into the chat: save it in the app or with legion --secret-env. See Configuration.

  • create_rental with serve also returns the service_id of the service it creates.

  • Making a service public removes the key check. For an autoscaled service it also lets anyone with the Service URL drive scale-up, up to its maximum replicas and cap. The preview says so, and the agent asks you first. The preview of create_service for an autoscaled model carries the estimate: the likely hardware, its price and the range.

  • A key's secret is a credential. create_service (with an API key required), create_service_key and rotate_service_key return the new key's secret once, in the answer. The agent gives it to you to store, and doesn't print it again, write it to a file or put it in a URL. Legion keeps only a fingerprint, so it can't be shown again.

  • Changes need a Full access key. An Agent key, and an app connected by signing in, can only read services (list_services, get_service, get_service_metrics, list_service_events). A change answers 403 api_key_scope: make it in the app, or use a Full access API key with the MCP server.

  • Asks first works as for every other tool: without confirm: true the tool returns a preview and changes nothing. The agent passes confirm: true only after your yes, in your latest message.

Registry credentials

list_registry_credentials lists the organization's saved credentials for private images (name, host, path prefix, username, last used), never a token. add_registry_credential and remove_registry_credential ask first, like every tool that changes things, and need the registry.manage permission, which owners have. Don't paste a token into the chat: save it in Settings, Registry credentials, or with legion registry add. See Private images.

What isn't a tool

Adding credit, payouts, API keys, invitations and enrollment tokens are not tools. Enrolling a host needs an enrollment token, which is a secret that adds a machine to your organization, so you run the installer on the machine yourself from Add a host in the app. A host's blocked networks are a provider security control and stay in the app, and so do egress requests and the web terminal. Use the Legion app for them. Managing existing hosts is possible only with the Hosting tools, on a key made with provider tools. Connecting to a rental is ssh, which the agent runs in a shell, not an MCP tool: see Connecting.