Skip to main content
Glama
vastai-mcp

vastai-mcp

by dam2452

vastai-mcp

Polski

Vast.ai GPU cloud marketplace and instance management MCP server.

Wraps the Vast.ai REST API (https://console.vast.ai/api/v0) so an LLM agent can search the GPU marketplace, rent machines, manage lifecycle, run commands, and inspect billing.

Table of contents

Related MCP server: quads-mcp

Tools

Tool

Parameters

Description

search_offers

query: Dict[str, Any]

Search the GPU marketplace (POST /bundles/)

search_benchmarks

gpu_name: Optional[str] = None

GPU benchmark data (GET /benchmarks/)

search_templates

select_filters: Optional[Dict] = None

Search user and public templates (GET /template/)

get_gpu_metrics

gpu_name, verified, datacenter

Current supply/demand/pricing snapshot

get_gpu_trends

gpu_names, window_hours=24, step

Historical price/supply time-series

list_instances

label: Optional[str] = None

List user's instances (GET /instances/)

get_instance

instance_id: int

Instance details (GET /instances/{id}/)

create_instance

offer_id, image/template_hash_id, disk, runtype, env, onstart, price, ...

Rent a GPU (PUT /asks/{offer_id}/)

manage_instance

instance_id, action: Literal[...], label?

start/stop/label/reboot/recycle

destroy_instance

instance_id: int

Permanently destroy (DELETE /instances/{id}/)

change_bid

instance_id, price: float

Change spot bid price

show_instance_logs

instance_id, tail=1000

Request instance logs

execute_command

instance_id, command: str

Run a remote command

get_current_user

none

Current account + credit balance

raw_request

method, path, params?, body?

Escape hatch for any other endpoint

register_ssh_key

name, public_key_path

Register a local public key on the Vast.ai account (POST /ssh/)

list_ssh_keys

none

List registered SSH keys (GET /ssh/)

get_instance_ssh_info

instance_id

Resolve ssh_host/ssh_port + ready-to-run ssh command

ssh_exec

instance_id, command, key_path?, user="root", timeout=30

Run a command over SSH (paramiko)

ssh_transfer

direction: Literal["upload","download"], instance_id, local_path, remote_path, key_path?, user="root"

SFTP upload/download between local disk and instance

The query body for search_offers follows the Vast.ai filter operator convention: each field maps to {eq, neq, gt, lt, gte, lte, in, notin}. Example:

{
  "gpu_name": {"in": ["RTX 4090"]},
  "num_gpus": {"gte": 1},
  "reliability": {"gte": 0.99},
  "verified": {"eq": true},
  "rentable": {"eq": true},
  "type": "ondemand",
  "limit": 5
}

Environment variables

Variable

Required

Description

VASTAI_MCP_API_KEY

yes

Vast.ai API key (https://cloud.vast.ai/manage-keys/)

VASTAI_MCP_SSH_KEY_PATH

no

Default path to your SSH private key, used by ssh_exec and ssh_transfer when key_path is not passed per-call

Wiring it up

Only requirement: uv (https://docs.astral.sh/uv/). Nothing else to install.

Claude Code

claude mcp add vastai-mcp -e VASTAI_MCP_API_KEY=<value> -- uvx --from git+https://github.com/dam2452/vastai-mcp.git vastai-mcp

Claude Desktop / other MCP client

{
  "mcpServers": {
    "vastai-mcp": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/dam2452/vastai-mcp.git", "vastai-mcp"],
      "env": { "VASTAI_MCP_API_KEY": "<value>" }
    }
  }
}

After pushing a new version: uv cache clean and restart the client.

Local run

uv run --directory . vastai-mcp

Tests (manual):

uv run --directory . --with pytest pytest test/

Available Tools

20 tools
change_bidA

Change the bid price of an interruptible instance (PUT /instances/bid_price/{id}/).

Examples: change_bid(instance_id=12345, price=0.25)

Inputs: price (required), instance_id (required). Returns: object

create_instanceA

Rent a GPU by accepting offer_id (PUT /asks/{offer_id}/).

Either image or template_hash_id must be provided. Use price to create an interruptible (spot) instance; omit it for on-demand.

env is a flat dict: regular vars as key/value pairs, port mappings as {"-p 8000:8000": "1"}. Use onstart to launch your app on SSH/Jupyter runtypes (their entrypoint is replaced by Vast's).

Examples: create_instance(offer_id=12345678, image="ubuntu:22.04", disk=16, runtype="ssh_direct") create_instance(offer_id=12345678, image="vllm/vllm-openai:latest", disk=50, runtype="ssh_direct", env={"MODEL_ID": "deepseek-ai/DeepSeek-R1-Distill-Llama-8B", "-p 8000:8000": "1"}, onstart="vllm serve $MODEL_ID --port 8000") create_instance(offer_id=12345678, template_hash_id="4e17788f74f075dd9aab7d0d4427968f", disk=100) create_instance(offer_id=12345678, image="ubuntu:22.04", disk=16, runtype="ssh_direct", price=0.20)

Inputs: offer_id (required), env, disk, image, +10 more. Returns: object

destroy_instanceA

Permanently destroy an instance and all its data (DELETE /instances/{id}/).

Irreversible. Call carefully.

Examples: destroy_instance(instance_id=12345)

Inputs: instance_id (required). Returns: object

execute_commandA

Execute a constrained remote command on a STOPPED instance (PUT /instances/command/{id}/).

Only works on instances whose actual_status is stopped (transient launch commands like downloading an image on first start). For running instances, the API rejects this with: "Execute command only avail on stopped instances. Use ssh to run commands on running instances." — use ssh_exec instead.

The API additionally enforces a command whitelist — unknown commands return 400 "Invalid command given". ls-style inspection commands are accepted; nvidia-smi, whoami, arbitrary binaries are not. For arbitrary commands on a running instance, use ssh_exec.

Examples: execute_command(instance_id=12345, command="ls /workspace")

Inputs: command (required), instance_id (required). Returns: object

get_current_userA

Retrieve the authenticated user's account info and credit balance (GET /users/current/).

Examples: get_current_user()

Inputs: no named parameters. Returns: object

get_gpu_metricsB

Current snapshot of supply, demand, and pricing across GPU types (GET /metrics/gpu/current/).

Examples: get_gpu_metrics() get_gpu_metrics(gpu_name=["RTX 4090", "A100"], verified=True)

Inputs: gpu_name, verified, datacenter. Returns: object

get_instanceA

Retrieve details of a specific instance (GET /instances/{id}/).

Examples: get_instance(instance_id=12345)

Inputs: instance_id (required). Returns: object

get_instance_ssh_infoA

Resolve an instance's direct SSH endpoint (host, port) and return a ready-to-run ssh command. Requires actual_status == "running" and a ssh_direct or jupyter_direct runtype.

Examples: get_instance_ssh_info(instance_id=12345)

Inputs: instance_id (required). Returns: object

list_instancesA

List the authenticated user's instances (GET /instances/).

Examples: list_instances() list_instances(label="vllm-inference")

Inputs: label. Returns: object

list_ssh_keysA

List SSH keys registered on the Vast.ai account (GET /ssh/).

Examples: list_ssh_keys()

Inputs: no named parameters. Returns: object

manage_instanceA

Control instance state: start/stop/label/reboot/recycle.

  • start/stop/label: PUT /instances/{id}/ with state or label.

  • reboot: PUT /instances/reboot/{id}/ (stops and starts, preserves GPU priority).

  • recycle: PUT /instances/recycle/{id}/ (destroys and recreates from fresh image pull).

For action="label", the label argument is required.

Examples: manage_instance(instance_id=12345, action="stop") manage_instance(instance_id=12345, action="start") manage_instance(instance_id=12345, action="label", label="my-server") manage_instance(instance_id=12345, action="reboot")

Inputs: action (required), instance_id (required), label. Returns: object

raw_requestA

Escape hatch for any Vast.ai REST endpoint not covered by other tools.

path is appended to https://console.vast.ai/api/v0 (include the leading slash, e.g. "/volumes/").

Examples: raw_request(method="GET", path="/volumes/") raw_request(method="POST", path="/ssh/", body={"ssh_key": "ssh-rsa AAA..."})

Inputs: path (required), method (required), body, params. Returns: object

register_ssh_keyA

Register a local SSH public key on the Vast.ai account (POST /ssh/).

The key is applied automatically to all current instances and any new instances created afterwards. Reads the .pub file from disk — never uploads your private key.

Examples: register_ssh_key(name="laptop", public_key_path="C:/Users/me/.ssh/id_ed25519.pub") register_ssh_key(name="ci", public_key_path="/home/runner/.ssh/id_ed25519.pub")

Inputs: name (required), public_key_path (required). Returns: object

search_benchmarksA

Retrieve all GPU benchmark records (GET /benchmarks/).

Returns a list of benchmark entries with gpu_name, value, type, etc.

Examples: search_benchmarks()

Inputs: no named parameters. Returns: object

search_offersA

Search the Vast.ai GPU marketplace for rentable machine offers.

The body is sent as-is to POST /bundles/. Top-level keys commonly include type ("ondemand" | "bid"), limit, and filter objects. Each filter maps a field name to an operator object: {eq, neq, gt, lt, gte, lte, in, notin}.

Examples: search_offers({"gpu_name": {"in": ["RTX 4090"]}, "num_gpus": {"gte": 1}, "reliability": {"gte": 0.99}, "verified": {"eq": True}, "rentable": {"eq": True}, "type": "ondemand", "limit": 5}) search_offers({"type": "bid", "gpu_ram": {"gte": 24000}, "order": [["dph_total", "asc"]], "limit": 10})

Inputs: query (required). Returns: object

search_templatesA

Search user and public templates (GET /template/).

The endpoint always requires a select_filters body (pass {} for "all"). This tool defaults to {} when called without arguments.

Examples: search_templates() search_templates(select_filters={"tag": {"eq": "pytorch"}})

Inputs: select_filters. Returns: object

show_instance_logsA

Request instance logs (PUT /instances/request_logs/{id}). Logs are uploaded to S3; the response contains a URL to fetch them.

Examples: show_instance_logs(instance_id=12345) show_instance_logs(instance_id=12345, tail=5000)

Inputs: instance_id (required), tail. Returns: object

ssh_execA

Execute a command on a running instance over SSH (paramiko).

Resolves the instance's ssh_host/ssh_port automatically. The private key stays local — never sent to the Vast.ai API.

key_path defaults to the VASTAI_MCP_SSH_KEY_PATH env var if set.

Examples: ssh_exec(instance_id=12345, command="nvidia-smi") ssh_exec(instance_id=12345, command="ls /workspace", key_path="/home/me/.ssh/id_ed25519") ssh_exec(instance_id=12345, command="python train.py", user="root", timeout=300)

Inputs: command (required), instance_id (required), user, timeout, +1 more. Returns: object

ssh_transferA

Transfer a single file between the local machine and an instance over SFTP.

  • upload: local file -> instance path

  • download: instance path -> local file

Directories are not supported — call once per file. Resolves the instance's ssh_host/ssh_port automatically. The private key stays local.

key_path defaults to the VASTAI_MCP_SSH_KEY_PATH env var if set.

Examples: ssh_transfer(direction="upload", instance_id=12345, local_path="./train.py", remote_path="/workspace/train.py") ssh_transfer(direction="download", instance_id=12345, local_path="./results.tar", remote_path="/workspace/results.tar")

Inputs: direction (required), local_path (required), instance_id (required), remote_path (required), +3 more. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 20 tools

    Disambiguation5/5

    Each tool targets a distinct resource and action: search_offers/search_benchmarks/search_templates operate on different datasets, get_gpu_metrics vs get_gpu_trends differ by snapshot vs history, and instance tools are clearly separated (list/get/create/manage/destroy). Even potentially similar tools like execute_command and ssh_exec are explicitly differentiated by stopped vs running instance state.

    Naming Consistency5/5

    All tools follow a consistent verb_noun snake_case pattern (search_offers, list_instances, create_instance, destroy_instance, ssh_exec, ssh_transfer). The naming is predictable and consistent, with no camelCase or mixed conventions.

    Tool Count4/5

    20 tools is at the upper end of 'well-scoped' but appropriate for a full Vast.ai API surface covering marketplace search, instance CRUD, SSH operations, metrics, and user info. The count feels justified given the breadth of features, though slightly heavy compared to a typical 3-15 tool server.

    Completeness4/5

    The surface covers the main GPU rental workflow: search offers, create/read/delete instances, manage state, run commands, transfer files, and fetch metrics. Minor gaps like volume management exist, but the raw_request escape hatch covers any missing endpoint, preventing dead ends.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      MCP server that exposes 300+ AI agents as tools via a single API key. Supports listing agents, invoking any agent with chat-completion style messages, checking agent health, and retrieving platform statistics.
      5
      4
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP server for interacting with QUADS infrastructure systems via API, enabling resource management and automation through LLM applications.
      MIT
    • F
      license
      Not graded
      quality
      C
      maintenance
      MCP server for renting real GPUs from the terminal. Enables browsing, renting, chatting, managing, and pooling GPU instances with per-second billing, designed for AI agents.
      82 npm
      1
      -
    • A
      license
      A
      quality
      B
      maintenance
      Enables managing Vast.ai cloud operations, including listing GPUs, searching offers, creating volumes and instances, and viewing billing, through MCP tools.
      6
      MIT