vastai-host-mcp
Enables Vast.ai providers to manage hosted machines, update pricing, run self-tests, and automate host operations through natural language.
README
vastai-host-mcp
Production-ready Model Context Protocol (MCP) server for Vast.ai host/provider operations using FastMCP and TypeScript.
This project is the host/provider counterpart to renter-focused tools. For renting GPUs as a customer, use CryDevOk/vastai-mcp.
Table of contents
<!-- TOC -->
- What this server is for
- Feature summary
- Getting started
- Environment variables
- Development workflow
- Connect from MCP clients
- Use with GitHub Copilot
- Where to check Vast API
- Run on Vast.ai machines
- Project layout
- Contributing
- License
<!-- /TOC -->
What this server is for
This MCP server is purpose-built for Vast.ai providers (hosts who own and operate machines). It focuses on host-side workflows including:
- Viewing and managing hosted machines.
- Updating default jobs, pricing, and offer settings.
- Running verification and self-test operations.
- Inspecting reliability, uptime, and host operational signals.
- Managing host scripts and daemon restart workflows.
Feature summary
- TypeScript-first server implementation with strict compiler settings.
- FastMCP tool definitions with rich tool metadata and strict Zod schemas.
- Singleton Vast.ai host client with:
- Bearer token API auth
/api/v0/...endpoint targeting- robust error handling
- timestamped logging via Pino
- API-first execution with optional Vast CLI fallback for host commands.
- stdio and httpStream transport support.
- Host automation helper rules for pricing and reliability recommendations.
Getting started
Prerequisites
- Node.js 20+
- pnpm 9+
- Vast.ai API key with host/provider permissions
Install and run
- Install dependencies:
pnpm install
- Copy environment file and edit values:
cp .env.example .env
-
Set at least
VAST_API_KEYin.env. -
Start development server (FastMCP dev mode):
pnpm dev
- Inspect tools interactively:
pnpm inspect
- Build and run production bundle:
pnpm build
pnpm start
Environment variables
| Variable | Required | Default | Purpose |
|---|---|---|---|
VAST_API_KEY |
Yes | none | Vast.ai API token for host/provider operations |
VAST_SERVER_URL |
No | https://console.vast.ai |
Vast.ai API base URL |
MCP_TRANSPORT |
No | stdio |
Transport mode: stdio or httpStream |
MCP_HTTP_HOST |
No | 0.0.0.0 |
Host bind for httpStream transport |
MCP_HTTP_PORT |
No | 8080 |
Port for httpStream transport |
VAST_REQUEST_TIMEOUT_MS |
No | 30000 |
API and CLI timeout in milliseconds |
VAST_USE_CLI_FALLBACK |
No | true |
Enable CLI fallback for host operations |
VAST_CLI_PATH |
No | vastai |
Vast CLI executable path |
VAST_AUTO_PRICING_ENABLED |
No | false |
Toggle automation hints for price workflows |
VAST_AUTO_RELIABILITY_GUARD |
No | false |
Toggle automation hints for reliability workflows |
LOG_LEVEL |
No | info |
Pino log level |
Development workflow
Default local development workflow (warning-free in pnpm-managed environments):
pnpm dev
FastMCP terminal harness workflow (optional):
pnpm dev:fastmcp
pnpm inspect
Codespaces inspector workflow:
# If you had a prior inspector run, free default ports first
pkill -f mcp-inspector || true
# Start inspector with Codespaces-safe host and origin settings
pnpm inspect:codespaces
# If token/auth forwarding is problematic, use no-auth mode in dev only
pnpm inspect:codespaces:noauth
If the browser opens but cannot connect, ensure both forwarded ports are active:
- 6274 (Inspector UI)
- 6277 (Inspector proxy)
If the UI still shows Disconnected, use these manual values in Inspector:
- Transport Type:
STDIO - Command:
pnpm - Arguments:
exec tsx src/index.ts - Then click
Connect
If auth is enabled, open Auth Settings and paste the MCP_PROXY_AUTH_TOKEN printed in terminal.
Production build workflow:
pnpm build
pnpm start
Key host tools currently implemented:
vastai_host_show_machinesvastai_host_set_defjobvastai_host_upsert_offervastai_host_set_min_bidvastai_host_verification_statusvastai_host_self_test_machinevastai_host_get_statsvastai_host_recommend_pricingvastai_host_update_scriptvastai_host_restart_daemonvastai_host_search_offersvastai_host_show_logsvastai_host_network_statusvastai_host_reliability_actions
Connect from MCP clients
Use stdio transport for desktop tools unless you specifically need network transport.
Claude Desktop example
{
"mcpServers": {
"vastai-host": {
"command": "pnpm",
"args": ["start"],
"cwd": "/absolute/path/to/vastai-host-mcp",
"env": {
"VAST_API_KEY": "YOUR_VAST_API_KEY",
"VAST_SERVER_URL": "https://console.vast.ai",
"MCP_TRANSPORT": "stdio"
}
}
}
}
Cursor example
{
"mcpServers": {
"vastai-host": {
"command": "pnpm",
"args": ["start"],
"cwd": "/absolute/path/to/vastai-host-mcp",
"env": {
"VAST_API_KEY": "YOUR_VAST_API_KEY",
"MCP_TRANSPORT": "stdio"
}
}
}
}
VS Code MCP example
{
"servers": {
"vastai-host": {
"type": "stdio",
"command": "pnpm",
"args": ["start"],
"cwd": "/absolute/path/to/vastai-host-mcp",
"env": {
"VAST_API_KEY": "YOUR_VAST_API_KEY"
}
}
}
}
Use with GitHub Copilot
For GitHub Copilot Chat in VS Code, this repository already includes a workspace MCP config at .vscode/mcp.json.
Recommended flow:
- Set your real
VAST_API_KEYin.vscode/mcp.json. - Stop any manually running local server process (
pnpm dev) so VS Code can own the MCP process lifecycle. - In VS Code, reload MCP servers from the Command Palette.
- In Copilot Chat, test a tool call such as
vastai_host_show_machines.
Note: For VS Code MCP usage, you usually do not need to run pnpm dev manually.
Where to check Vast API
Use these sources to validate endpoint existence and request format:
- API docs index: llms.txt
- API intro: Vast API Reference
- Machines: show machines
- Machines: set min-bid
- Machines: set defjob
- Machines: list machine
- Search: search offers
The current endpoint mapping used by this MCP server is implemented in src/client/VastAIHostClient.ts.
Quick local checks:
pnpm build
pnpm inspect
When using the Inspector, a command returning HTTP 404 is usually a route mismatch, while HTTP 400/403/500 generally means the route exists and your payload, permissions, or backend state should be checked.
Run on Vast.ai machines
When deploying this MCP server inside a Vast.ai instance:
- Keep API keys in environment variables only. Never hardcode secrets.
- Use
stdiomode for local desktop tunneling workflows. - Use
httpStreamonly behind trusted network boundaries or a reverse proxy. - Install Vast CLI in the runtime if you want CLI fallback behavior.
- Monitor logs with your preferred process manager (systemd, pm2, supervisord).
For onboarding guidance, see Building your first MCP server on Vast.ai.
Project layout
.
├── src/
│ ├── client/
│ │ └── VastAIHostClient.ts
│ ├── rules/
│ │ └── MCPRules.ts
│ ├── tools/
│ │ └── hostTools.ts
│ ├── config.ts
│ ├── index.ts
│ └── logger.ts
├── .env.example
├── package.json
├── tsconfig.json
└── README.md
Contributing
- Open an issue describing the host/provider workflow or API gap.
- Keep additions host-focused (not renter workflow features).
- Add or update tool descriptions so they remain LLM-friendly and explicit.
- Run local checks before opening a PR.
Repository-wide conventions and agent behavior are documented in AGENTS.md.
License
This project is licensed under the MIT License. See LICENSE.
<!-- Named links -->
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.